Skip to content

fix(plugin): leave serverUrl undefined without an HTTP listener - #63063

Open
Nowaker wants to merge 1 commit into
anomalyco:v1from
Nowaker:serverurl-honest
Open

Nowaker wants to merge 1 commit into
anomalyco:v1from
Nowaker:serverurl-honest

Conversation

@Nowaker

@Nowaker Nowaker commented Nov 10, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #39561

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

PluginInput.serverUrl no longer invents http://localhost:4096 when the process has no HTTP listener. It mirrors Server.url and is undefined in that case. The PluginInput type marks the field optional and documents that client is the in-process route when it is absent.

A TUI started without --port has no listener, yet every plugin was told the server is at localhost:4096. Plugins that make raw HTTP calls to serverUrl (wake-ups, status probes, session prompts) then reach whatever else holds port 4096: another opencode instance, a leftover opencode serve, or an unrelated service. We hit this in practice: a plugin probed a stranger on 4096 (/global/health 200), posted a prompt_async there (204), and the wake meant for the local session was silently lost.

The SDK client handed to plugins was already correct: with no listener it fetches the in-process app directly. Only serverUrl misreported the situation.

Compatibility: serverUrl: URL becomes serverUrl?: URL. Plugins that read it unconditionally get a type error pointing at the case they were already mishandling; at runtime they see undefined instead of a URL that may belong to another process. Plugins that need to talk to this process should use client.

How did you verify your code works?

packages/opencode/test/plugin/server-url.test.ts loads a real plugin through Plugin.Service:

  • with no listener, serverUrl is undefined and client.project.current() still resolves the instance in-process;
  • with Server.listen({ port: 0 }), serverUrl equals the listener URL and the client works over HTTP.

The first test fails on the previous code with http://localhost:4096/. bun test test/plugin 212 pass; bun typecheck clean in opencode, plugin, sdk/js, tui.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

This PR is AI generated, but under direct supervision and on request of @Nowaker.

PluginInput.serverUrl returned http://localhost:4096 whenever the
process had no HTTP listener, which is every TUI started without
--port. Plugins that call that URL then reach whatever else holds 4096:
another opencode instance, a leftover `serve`, or an unrelated service.
Requests meant for this process (session prompts, status probes) land
on the stranger and are lost.

The SDK client passed to plugins was already correct: without a
listener it fetches the in-process app directly. Only serverUrl lied.

serverUrl now mirrors Server.url and is undefined when nothing listens.
The PluginInput type marks it optional and documents that `client` is
the in-process route in that case.
@Nowaker

Nowaker commented Nov 17, 2026

Copy link
Copy Markdown
Author

Friendly ping: this one has been quiet for a week. CI is green and it is a small, self-contained fix - happy to adjust anything if a maintainer has a moment to take a look. Thanks!

Nowaker added a commit to Nowaker/opencode that referenced this pull request Nov 17, 2026
Add pr-queue/00-open-slots.md as the daily drain's record of the three
open author PRs (anomalyco#63062, anomalyco#63063, anomalyco#63897), their checks, next nudges and
a log of every nudge, starting with the 2026-11-17 pings on anomalyco#63062 and
anomalyco#63063. Mark entry 06 filed as anomalyco#63897; it still read "not filed" after
anomalyco#54578 closed and freed its slot. The cap stays full and entry 10 is
next in line.

AI-Model: anthropic/claude-opus-5-5
AI-Variant: high
AI-Tool: opencode 1.18.34-vt-101-907b3bc518
AI-Platform: linux
AI-Harness: Vibeterm 3c3f1fadd21
AI-Session-ID: ses_eeda1d251ffel81U5Y42j4kb33

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant