Skip to content

VS Code Beta extension (opencode-v2) hardcodes --port=4096 — panel fails to open whenever port 4096 is in use #49006

Closed

Description

@leorochael

Summary

The OpenCode Beta VS Code extension (sst-dev.opencode-v2, v0.1.1) spawns its
backend with a hardcoded port:

opencode serve --hostname=127.0.0.1 --port=4096

(ServerManager.startServer calls createOpencodeServer({ port: 4096, ... }), and
the SDK default client is baseUrl: "http://localhost:4096".)

Because the port is explicit, Server.listen takes the no-fallback path
(startWithPortFallback: if (opts.port !== 0) return startListener(opts, opts.port)),
so if 4096 is already bound, the server exits with code 1 and the panel fails with:

Failed to open OpenCode panel: Server exited with code 1
Server output: Warning: OPENCODE_SERVER_PASSWORD is not set; server is unsecured.
Error: Unexpected error
ServeError

(The useless last line is a separate, already-reported bug: #38738, #46263.)

Steps to reproduce

  1. Occupy port 4096 with anything:
    • nc -l 4096, or
    • an opencode acp session (e.g. Zed's opencode agent integration), or
    • opencode web / opencode serve, or
    • the OpenCode panel in another VS Code window
  2. In VS Code, click the OpenCode activity-bar icon (or run "Open OpenCode Assistant").
  3. Panel fails with the error above.

Expected behavior

The extension should let the opencode process select the port itself instead of
pinning 4096. The CLI already implements the ideal behavior for a default port:
startWithPortFallback tries 4096 and falls back to any free port
(startListener(opts, 4096) |> Effect.catch(() => startListener(opts, 0)))
— this is why multiple opencode acp sessions coexist fine. Passing --port=0
would give the extension that behavior for free, the port is bound atomically by
the server process (no scan-then-bind race on the extension side), and
createOpencodeServer already parses the actual server URL back from stdout, so
the extension machinery for a dynamic port is already in place.

Alternatively, attach to an already-running compatible server (see #7629) instead of
spawning a new one.

Impact

  • Only one VS Code window can ever use the panel at a time (each window's
    extension host spawns its own server on the same fixed port).
  • The panel cannot coexist with Zed's opencode ACP agent, the desktop app, or a
    manual opencode serve/web — whoever starts first wins, everyone else gets an
    opaque ServeError.
  • Closing the panel tab doesn't even free the port; the server outlives the webview
    (onDidDispose only clears the panel reference), so a window reload is required.

Environment

  • Extension: sst-dev.opencode-v2 v0.1.1
  • opencode CLI: 1.18.30 (homebrew, macOS arm64)
  • VS Code: 1.137.0

Related

Activity

  1. rekram1-node commented on Oct 14, 2026

    @rekram1-node
    Contributor

    The "OpenCode Beta" extension (sst-dev.opencode-v2) is no longer maintained and won't be updated for V2. Please use the main opencode extension (sst-dev.opencode) v1.0.0 instead, which works with the V2 CLI. Closing.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions