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