Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/opencode/src/cli/cmd/tui/thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ export const TuiThreadCommand = cmd({
return piped ? piped + "\n" + args.prompt : args.prompt
})

// Check if server should be started (port or hostname explicitly set in CLI or config)
// Check if server should be started (explicitly enabled or network options set)
const networkOpts = await resolveNetworkOptions(args)
const shouldStartServer =
networkOpts.enabled ||
process.argv.includes("--port") ||
process.argv.includes("--hostname") ||
process.argv.includes("--mdns") ||
Expand Down
3 changes: 2 additions & 1 deletion packages/opencode/src/cli/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export async function resolveNetworkOptions(args: NetworkOptions) {
const configCors = config?.server?.cors ?? []
const argsCors = Array.isArray(args.cors) ? args.cors : args.cors ? [args.cors] : []
const cors = [...configCors, ...argsCors]
const enabled = config?.server?.enabled ?? false

return { hostname, port, mdns, cors }
return { hostname, port, mdns, cors, enabled }
}
1 change: 1 addition & 0 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ export namespace Config {

export const Server = z
.object({
enabled: z.boolean().optional().describe("Enable HTTP server for TUI (allows external connections)"),
port: z.number().int().positive().optional().describe("Port to listen on"),
hostname: z.string().optional().describe("Hostname to listen on"),
mdns: z.boolean().optional().describe("Enable mDNS service discovery"),
Expand Down