fix(tui): start server on-demand when opening WebUI from command palette
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:
- Calls the worker RPC to start a real server on localhost
- Returns the actual URL (e.g.,
http://127.0.0.1:4096/) - 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-providererror is pre-existing in upstream/dev)
🤖 Generated with Claude Code