[PR #8409] fix(tui): start server on-demand when opening WebUI from command palette #12730

Open
opened 2026-02-16 18:17:37 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8409

State: open
Merged: No


What does this PR do?

Fixes #8407
Fixes #7549

When using direct RPC communication (the default mode), the "Open WebUI" command in the command palette was trying to open http://opencode.internal/ - a placeholder URL that doesn't resolve on any system. This caused DNS errors like:

This site can't be reached
opencode.internal's DNS address could not be found.

The root cause is that when OpenCode starts without explicit --port or network options, it uses direct RPC communication via Worker threads instead of starting an HTTP server. The sdk.url in this case is set to the non-routable placeholder.

The fix

This PR adds an onStartServer callback that lazily starts an HTTP server when the user selects "Open WebUI" from the command palette and no server is already running. The callback:

  1. Calls the worker RPC to start a real server on localhost
  2. Returns the actual URL (e.g., http://127.0.0.1:4096/)
  3. Opens that URL in the browser

This matches the behavior of opencode web which correctly opens localhost.

How did you verify your code works?

  • Code review of the fix logic
  • Verified the pattern matches existing RPC calls in thread.ts
  • Confirmed typecheck passes (the @gitlab/gitlab-ai-provider error is pre-existing in upstream/dev)

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8409 **State:** open **Merged:** No --- ### What does this PR do? Fixes #8407 Fixes #7549 When using direct RPC communication (the default mode), the "Open WebUI" command in the command palette was trying to open `http://opencode.internal/` - a placeholder URL that doesn't resolve on any system. This caused DNS errors like: ``` This site can't be reached opencode.internal's DNS address could not be found. ``` The root cause is that when OpenCode starts without explicit `--port` or network options, it uses direct RPC communication via Worker threads instead of starting an HTTP server. The `sdk.url` in this case is set to the non-routable placeholder. ### The fix This PR adds an `onStartServer` callback that lazily starts an HTTP server when the user selects "Open WebUI" from the command palette and no server is already running. The callback: 1. Calls the worker RPC to start a real server on localhost 2. Returns the actual URL (e.g., `http://127.0.0.1:4096/`) 3. Opens that URL in the browser This matches the behavior of `opencode web` which correctly opens localhost. ### How did you verify your code works? - Code review of the fix logic - Verified the pattern matches existing RPC calls in thread.ts - Confirmed typecheck passes (the `@gitlab/gitlab-ai-provider` error is pre-existing in upstream/dev) --- 🤖 Generated with Claude Code
yindo added the pull-request label 2026-02-16 18:17:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12730