Repository navigation
feat(opencode): CLI-side (TUI) half — session handles from inside the pane (#310) - #311
Merged
amirlehmam merged 1 commit intoOct 20, 2026
Merged
Conversation
… pane (amirlehmam#310) The server-side plugin cannot attribute anything when the TUI is a client of a remote OpenCode server, or of v2's shared `opencode serve --service`: the server process has no pane environment, and on a shared server it has exactly one pane's. The documented consequence is that "Resume OpenCode sessions on restore" never captures a handle on those setups. This adds the half that runs in the TUI process, against a remote server, with the pane's WMUX_*: `wmux opencode-tui` installs `tui.js` + `core.js` to <config>/plugins/wmux-cli/ from inside the environment that will host the TUI (WSL distro, devcontainer, native Windows), honouring an absolute XDG_CONFIG_HOME; `--remove` is guarded by the version marker. The Windows side never writes WSL homes — that would need distro/user discovery, would write into arbitrary homes, and cannot serve containers. It reports the viewed session (`report-session`, subagents resolved to their root, release on quit) by following `ui.router.current()` reactively. The core is a plain ESM module importing node builtins only, so the wmux suite can load it; the entry is the reactive glue OpenCode's host resolves. Unique event types are logged once under WMUX_PLUGIN_DEBUG — the one-pass diagnostic the prompt-log phase needs. Part of amirlehmam#310
Contributor
Author
|
Live verification of this half on Windows wmux 2.30.0 + a WSL pane whose TUI is a client of a remote OpenCode server (
One environment finding worth recording: OpenCode loads every directory directly under Phase 2 (prompt log, #312) was verified on top of this branch and is marked draft until this merges. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The server-side plugin cannot attribute anything when the TUI is a client of a remote OpenCode server, or of v2's shared
opencode serve --servicefor another pane: the server process has no pane's environment, and on a shared server it has exactly one pane's. The docs already record that for session handles, and #304's prompt hook inherits it. The missing half was proposed in #290 and verified live on Windows wmux + a WSL pane against a remote server: a CLI-side (TUI) plugin, loaded once per TUI process, with the pane'sWMUX_*.What this PR adds (phase 1 of #310)
wmux opencode-tui [--remove]— a local file operation, deliberately not a pipe command. It runs from the pane that will host the TUI, so the config directory it resolves is the distro/container/native home the TUI actually reads. It honours an absolute$XDG_CONFIG_HOME, else~/.config/opencode, and writes<config>/plugins/wmux-cli/{tui,core}.js— the directory form OpenCode's CLI resolves without apackage.json, live-verified in Resume OpenCode sessions on restore, alongside Claude Code and Codex #290.resources/opencode-plugin/wmux-tui.js— the entry, the shape verified in Resume OpenCode sessions on restore, alongside Claude Code and Codex #290 (Plugin.define,ui.router.current()followed withcreateRoot/createEffect, no polling). Reports the viewed session viawmux report-session <id> --provider opencode, resolves a viewed subagent to its root (the server half'sparentIDskip), dedupes per session, and releases the handle on dispose/exit. Marker1;--removerefuses atui.jswithout it.resources/opencode-plugin/wmux-tui-core.js— runtime resolution (WSL has no usableWMUX_NODE, so PATH falls back like the server half), the file logger (OpenCode plugin: log to file instead of console.error so agents can self-diagnose #190), the CLI caller, and the route→report rules. Node builtins only, so wmux's suite can load it; the entry carries just the two host-provided imports (@opencode/plugin/tui,solid-js).WMUX_PLUGIN_DEBUG— the one-pass diagnostic that will pick the client-side signal for phase 2 (the prompt log). Until then prompts and blocked/activity remain server-half features and are unchanged.opencode-tui-install.jsadded toresources/cli/andextraResources(the packaging test derives it from the new relative import);resources/opencode-plugin/already ships as a directory.Verification
opencode-tui-core(13) andopencode-tui-install(22, incl. marker parity withagent-plugin-file.ts, XDG resolution, install/current/reinstall/remove/foreign-file guards, and the entry file's shape). 35 pass, watched red first.npm test: only the pre-existing Windows/path.joinfailures and the known flakygrok-contextmtime assertion (both reproduce on untouched master in this container).npm run typecheck, eslint on the touched files,npm run build:main,npm run verify:resources, andpackaging.test.tspass.XDG_CONFIG_HOME: install →current→ remove →absent.wmux opencode-tuiin a WSL pane,WMUX_PLUGIN_DEBUG=1, and a check thatwmux agent-statelists the surface would settle it.Open question for the maintainer
The half-split policy once both halves exist: keep the server half for v1 and non-pane-attributed signals and let this one add pane-attributed reporting (phase 2/3), or move attribution over wholesale? This PR is additive only — nothing the server half reports today changes.
Part of #310