From d11e886733b53bd3bcbb15d59bf020695f8f756a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 23 Jun 2026 00:12:59 +0000 Subject: [PATCH] feat: add --no-open flag to opencode web command This introduces a new optional flag --no-open to the opencode web command that prevents the automatic browser launch when running in headless environments (e.g., Docker containers without XDG-open). By default, the behavior remains unchanged (browser opens) for backward compatibility. The flag is useful for CI/CD pipelines, remote terminals, and any scenario where a graphical browser is not available or desired. --- packages/opencode/src/cli/cmd/web.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/opencode/src/cli/cmd/web.ts b/packages/opencode/src/cli/cmd/web.ts index 69a981aada49..990b7ca88136 100644 --- a/packages/opencode/src/cli/cmd/web.ts +++ b/packages/opencode/src/cli/cmd/web.ts @@ -30,7 +30,10 @@ function getNetworkIPs() { export const WebCommand = effectCmd({ command: "web", - builder: (yargs) => withNetworkOptions(yargs), + builder: (yargs) => + withNetworkOptions(yargs) + .boolean('no-open') + .describe('no-open', 'Do not automatically open the web interface in a browser'), describe: "start opencode server and open web interface", // Server loads instances per-request via x-opencode-directory header — no // ambient project InstanceContext needed at startup. @@ -71,12 +74,17 @@ export const WebCommand = effectCmd({ ) } - // Open localhost in browser - open(localhostUrl).catch(() => {}) + // Open localhost in browser unless --no-open is set + if (!args['no-open']) { + open(localhostUrl).catch(() => {}) + } } else { const displayUrl = server.url.toString() UI.println(UI.Style.TEXT_INFO_BOLD + " Web interface: ", UI.Style.TEXT_NORMAL, displayUrl) - open(displayUrl).catch(() => {}) + // Open display URL in browser unless --no-open is set + if (!args['no-open']) { + open(displayUrl).catch(() => {}) + } } yield* Effect.never