8000 fix(opencode): harden the server-half session reporter by Mattheinrichs · Pull Request #444 · amirlehmam/wmux · GitHub
[go: up one dir, main page]

Skip to content

fix(opencode): harden the server-half session reporter - #444

Merged
amirlehmam merged 1 commit into
amirlehmam:masterfrom
Mattheinrichs:fix/opencode-server-half-hardening
Nov 7, 2026
Merged

amirlehmam merged 1 commit into
amirlehmam:masterfrom
Mattheinrichs:fix/opencode-server-half-hardening

Conversation

@Mattheinrichs
Copy link
Copy Markdown
Contributor

Problem

The server-side OpenCode plugin (~/.config/opencode/plugin/wmux.js) had the same fire-and-forget session report as the TUI half, plus two attribution bugs:

  • It only skipped --service when deciding a server was shared. A plain opencode serve --port … also hosts many panes, while WMUX_SURFACE_ID names only the pane that started it — so activity, blocked state, prompts and shell env from every pane landed on one pane.
  • It reported v2 session handles from the server process, where it cannot tell a background session from the one on screen. That raced the TUI half's viewed-session report.

It also released the handle on v2 dispose, which runs on plugin reload as well as shutdown.

Fix

  • Shared server = no pane-specific signals. --service, and any serve without --stdio, returns a no-op. A standalone TUI's private serve --stdio still reports.
  • v2 session handles are TUI-half-only. The server half keeps v2 activity/blocked/prompt for private servers, and keeps session reporting for v1.
  • Reliable reports: 1 s / 3 s / 10 s retries, accepted: false treated as permanent, an increasing --seq so a late report for an old session cannot win, a 30 s reassert on later turns, and a 10 s CLI timeout.
  • Lifecycle: dispose/reload schedules a 1.5 s release that a replacement instance cancels; a real process exit still releases synchronously.
  • Marker 9 → 10 so wmux reinstalls it; docs and tests updated.

Verification

  • Live isolated opencode --standalone: the plugin loaded as private, logged session: handles are reported by the TUI half, and its real agent-activity / hook calls reached wmux. A private serve --stdio is not mistaken for shared.
  • Targeted suite: 73 passed (2 known Windows-path failures in resolveNodeRuntime on Linux).
  • npm run typecheck: clean.
  • Full WSL suite: 6292 passed, 42 known Windows-path/platform failures — same baseline as before, none in the changed suite.

Scope

This is PR A of two. PR B will add a bounded transport retry for idempotent report commands in the CLI, so a busy named pipe is handled for every producer, not only OpenCode.

A shared server cannot attribute any pane-specific signal: WMUX_SURFACE_ID names only the pane that started it. The server half now returns a no-op for --service and any serve without --stdio; a standalone TUI's private serve --stdio still reports. v2 session handles move to the TUI half, which knows the viewed session, so the two halves can no longer race over the same handle.

report-session is success-aware: 1s/3s/10s retries, accepted:false as a permanent rejection, an increasing --seq so a late report cannot overwrite a newer one, a 30s reassert on later turns, and a 10s CLI timeout. A dispose/reload waits 1.5s for a replacement instance to cancel the release; a real exit still releases synchronously. Marker 9 -> 10, docs and tests.

Verified live with an isolated standalone server: the plugin loaded as private, left v2 handles to the TUI half, and its activity/prompt calls reached wmux. Targeted suite 73 passed; full WSL suite 6292 passed, 42 known Windows-path/platform failures (none in the changed suite).
@amirlehmam
Copy link
Copy Markdown
Owner

Merged, thank you! The shared-server detection (any serve without --stdio) and keeping v2 session handles in the TUI half are the right split. The delayed release on dispose also fixes the upgrade case cleanly. This ships in 2.59.0.

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.

2 participants

0