Skip to content

Annotate: a Windows OpenCode registration wins over WSL even with the lab on #2110

Closed

Description

@giovannijoao

Version checked: Hex 3.4.0 (v3.4.0, 8766d09, 2026-11-11), Windows 10 Pro 26H2.
labs.opencode_in_wsl = true, capture.enabled = true,
capture.routing.sendCaptures = true, capture.routing.autoSend = rules.

Configuration

  • OpenCode Desktop 2.3.2 on Windows, with its local Windows service registered at
    %USERPROFILE%\.local\state\opencode\service.json (http://127.0.0.1:28894, 0 sessions).
  • OpenCode 2.3.0 in WSL, with its CLI service registered at
    ~/.local/state/opencode/service.json (http://127.0.0.1:4097, 81 root sessions).
  • labs.opencode_in_wsl = true.

What happens

In this configuration, every Annotate capture routes to the Windows service, not the WSL
service:

routing time: look local_ms=0 lookup_ms=15 page_ms=0 candidates=0

page_ms=0 and candidates=0, with no a capture's look couldn't read all of OpenCode's sessions warning: the read succeeded against a real service and returned no sessions. The
capsule's "Send to" list is empty ("No sessions match"), and the capture remains in the
clipboard. The WSL service's 81 sessions are never listed.

Both registrations confirmed at the time:

File Version URL Sessions
%USERPROFILE%\.local\state\opencode\service.json 2.3.2 http://127.0.0.1:28894 0
WSL ~/.local/state/opencode/service.json 2.3.0 http://127.0.0.1:4097 81

GET /api/session?parentID=null&limit=5 with each registration's Basic password returns []
for 28894 and sessions for 4097.

Why the lab does not engage

src/desktop/opencode_service.rs::with_wsl only looks at WSL when the Windows lookup failed:

if crate::labs::opencode_in_wsl() {
    if found.is_err() {
        return prefer_wsl(found, wsl::discover(budget, cancelled));
    }
}

The desktop app's registration confirms, so found is Ok and the WSL fallback is never
reached. In src/capture_host/routing/opencode.rs, Wsl::request then returns None because
the discovered service is not WSL, so the lab's transport does not engage either.

This precedence is documented, not accidental: docs/opencode-compatibility.md says the WSL
registration is read "when no Windows registration answers". The report is about the dead end
that rule creates, not about the rule being unknown.

The mechanism above is verified from the source and the two registrations. The assumption is
the expected precedence: the lab is intended to select WSL even when a Windows registration
also confirms. If the fallback rule is intentional, the remaining bug is the empty-state
signal (expected #3): neither process.log nor the capsule says which service was read.

Why the Windows registration cannot be removed in-app

The desktop app starts its local Windows server on launch and re-ensures it. The Servers page
has no Stop or Remove action for the builtin "This computer" entry; hiding it does not stop
the process. opencode-cli.exe service stop is undone while the app runs. The Windows
registration is therefore present whenever the desktop app is running. Removing it requires
quitting or uninstalling the app.

That is the technical reason the lab's fallback rule produces a dead end in this
configuration: the fallback cannot be reached while the desktop app is installed and running.

Expected (any one would resolve it)

  1. When Labs › OpenCode in WSL is on and the WSL service answers, prefer it — even when a
    Windows registration also confirms. The lab is the explicit opt-in to the WSL service.
  2. Or let the user choose the OpenCode instance (Windows / WSL) and remember it.
  3. Or, at minimum, name the service that was read (url, pid, version, session count) in
    process.log and in the capsule's empty state, so "No sessions match" is not the only
    signal.

Workaround

  1. In WSL: opencode service start (writes ~/.local/state/opencode/service.json, the file
    Hex's WSL lookup reads).
  2. Quit the Windows desktop app, then stop its bundled service if needed:
    opencode-cli.exe service stop (from
    %LOCALAPPDATA%\Programs\ai.opencode.desktop\resources). Uninstalling the desktop app also
    removes the registration.
  3. hex capture route latest --explain should now report the WSL session count.

The WSL CLI service remains at 127.0.0.1:4097 and serves the web UI at
http://localhost:4097/; that client is available after the Windows desktop app is stopped.

Validated on 2026-11-20 19:43 (-03): after closing the app and running service stop
(status → stopped), the Windows registration was gone and the next Annotate capture was
routed into the WSL session. The fallback works as soon as the Windows registration is absent;
the bug is that the registration cannot be removed while the desktop app runs.

Related

No existing issue describes two live registrations and the empty-list outcome.

Activity

  1. thdxr commented on Nov 21, 2026

    @thdxr
    Member

    with opencode in wsl on, hex only looked in wsl when no windows opencode answered. the desktop app always keeps its own empty one running, so wsl never got a chance and the send list came up empty.

    now with the lab on, a wsl opencode that answers is used first, and the windows one is only the fallback. you can keep the desktop app open.

    fixed in #2112, it'll be in the next dev build

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions