Repository navigation
feat(opencode): TUI half reports user prompts via session.inbox.enqueued (#310) - #312
Conversation
|
Live verification on Windows wmux 2.30.0 + a WSL pane whose TUI is a client of a remote OpenCode server ( Load + session handle
Prompt log (this PR)
Loader finding — fixed in docs Still marked draft until #311 lands; then this is ready. |
…ued (amirlehmam#310) Phase 2 of the CLI-side (TUI) half: prompts typed in a pane now reach the prompt log even when the TUI is a client of a remote or shared OpenCode server, where the server-side plugin (amirlehmam#304) can never run with a pane's environment. The client-side source is v2's `session.inbox.enqueued` — a public durable event carrying `{ sessionID, inboxID, item }`. Only `item.type === "user"` counts, which is the same exclusion set the server-side `session.prompt` hook gets for free (synthetic messages, compaction controls and moves are never something a human typed). `inboxID` dedupes admission; the text is trimmed and capped at 4000 chars, the number every producer uses. The event stream is the connected server's, so with several panes on one server a prompt is attributed only when its session is the one being viewed or open in a tab — pane B's prompt must not land in pane A's outline. The report rides the same `wmux hook --event UserPromptSubmit --prompt` path amirlehmam#305 wired end to end; `caller` carries the pane, and the renderer resolves it for the prompt log only. Plugin marker 1 → 2 so installed copies pick it up. Part of amirlehmam#310
…mirlehmam#310) OpenCode loads every directory under <config>/plugins/ as a plugin, so a `plugins/wmux-cli.bak` copy registers the same `wmux.cli` id and the live copy silently loses its load — no init line, no reports. Found in live testing: the obvious backup spot made the new v2 plugin invisible until the copy was moved out. Say where a backup belongs instead. Part of amirlehmam#310
b9526cd to
8db42d2
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Stacked on #311 — phase 2 of #310. Review after #311 merges; this diff will shrink to the phase-2 commits alone once master carries them.
Why
The server-side prompt hook (#304) needs the pane's environment, which a remote or shared server process does not have. The TUI half from #311 runs where the prompt is actually typed; this PR teaches it to report the prompt itself.
Signal, from the v2 schema (
packages/schema/src/session-event.ts+session-inbox.ts):It is a public durable event, so
data.onsees it against a remote server. Onlyitem.type === "user"is reported — the same exclusions the server-sidesession.prompthook gets for free.inboxIDdedupes admission (v2 documents admission as retry-safe, not exactly-once); the text is trimmed and capped at 4000 chars, the numberwmux-hook.jsand the server half use.Attribution
data.listen/data.onis the whole connected server's stream: with several panes on one remote server, pane B's session events arrive in pane A's TUI too. The reporter therefore only attributes prompts for sessions this TUI hosts — the one being viewed, or one open in a tab (ui.tabs.list(), read defensively for the host's field name). A tab-less TUI falls back to the current route.Path
wmux hook --event UserPromptSubmit --prompt …— exactly what #305 wired end to end.calleris stamped by the CLI transport,hookEventSurfaceresolves it, and the prompt log renders it. No main, renderer, or CLI changes in this PR.Tests
11 new cases in
opencode-tui-core(user vs synthetic/compaction/move, empty payloads, validator, tab extraction, hosted vs foreign sessions,inboxIDreplay dedupe, 4000-char cap) and the entry-shape test now asserts the subscription and marker2. Full suite: only the pre-existing Windows/path.joinfailures that also fail on untouched master in this container.Live check (after #311 + this): in the WSL pane,
node "$WMUX_CLI" opencode-tui(rewrites v1 → v2), restart OpenCode withWMUX_PLUGIN_DEBUG=1, submit a prompt — the debug log should showprompt {"chars":…}andcli ["hook","--event","UserPromptSubmit","--prompt",…], and the entry should land in the Prompts pane /wmux prompts. Two panes on the same remote server is the attribution check: prompt in B must not appear in A.Part of #310