Open WebUI fails when running without --port flag (uses unresolvable opencode.internal URL)
Bug Description
When running OpenCode without the --port flag (default mode), the "Open WebUI" command (accessible via Cmd+P menu) attempts to open http://opencode.internal in the browser, which fails because this domain doesn't resolve.
Steps to Reproduce
- Run
opencodewithout any flags (default mode) - Press Cmd+P to open the command palette
- Select "Open WebUI"
- Browser opens with
http://opencode.internalwhich fails to load
Expected Behavior
Either:
- Show a warning that WebUI requires server mode and explain how to enable it
- Or hide the "Open WebUI" option when server is not running
Root Cause
In packages/opencode/src/cli/cmd/tui/thread.ts, when shouldStartServer is false (default behavior), the URL is set to http://opencode.internal which is only used for internal RPC communication:
```typescript if (shouldStartServer) { const server = await client.call("server", networkOpts) url = server.url // Real localhost URL } else { url = "http://opencode.internal" // Virtual URL for internal RPC customFetch = createWorkerFetch(client) } ```
The "Open WebUI" command in app.tsx then uses this URL directly without checking if it's resolvable:
```typescript { title: "Open WebUI", value: "webui.open", onSelect: () => { open(sdk.url).catch(() => {}) // sdk.url might be "http://opencode.internal" dialog.clear() }, } ```
Workaround
Run OpenCode with the --port flag to start the HTTP server:
```bash
opencode --port 4096
```
Environment
- OpenCode version: 1.1.23
- OS: macOS