Skip to content

OpenCode v2: user prompts never reach the prompt log — the plugin registers no prompt hook #304

Closed

Description

@Mattheinrichs

What happens

The prompt outline / Prompts pane / wmux prompts is always empty for an OpenCode pane. Not "missing some" — nothing ever lands, for any pane, on any OpenCode version.

Why: it is never collected

The prompt log (src/renderer/utils/prompt-log.ts) has exactly two producers, and neither can see a prompt typed inside an agent TUI:

  1. OSC 133 shell marks — the shell integration's A/B/C sequence. Once opencode owns the screen there are no shell prompts to mark.
  2. UserPromptSubmit hook events — App.tsx turns {event: 'UserPromptSubmit', prompt} into a recordAgentPrompt call. The only thing that ever sends that event is resources/cli/wmux-hook.js, which is registered in Claude Code's settings.json (claude-context.ts) and Grok's hooks (grok-context.ts). git grep UserPromptSubmit on master shows no other producer.

The OpenCode integration is a different mechanism entirely — resources/opencode-plugin/wmux.js, installed to ~/.config/opencode/plugin/. It sends PostToolUse, report-agent --blocked/--unblocked, agent-activity, and the session handle; it has no handler for user-message submission at all. In the v1 half, WmuxPlugin's returned hooks object has no chat.message entry; in setupV2, register(...) is called for tool.execute.before/after and shell.create.before only; the string prompt appears in the file once, in a comment about permission prompts.

So this is not a regression and not a broken wire: the prompt-log feature (issue #207) was built for hook-driven agents and OpenCode's plugin half was never taught to report prompts. Everything downstream already works — main fans hook.event params out to every window verbatim, and the renderer consumes UserPromptSubmit today (it is also what ends a "Needs you" the moment a user replies, via agent-hook-bridge.ts).

Fix direction

OpenCode v2's plugin API has a prompt-admission hook made for exactly this — ctx.session.hook("prompt", (event) => …) runs for incoming user prompts (docs: "Intercept incoming user prompts before attachment and skill resolution and durable inbox admission"; synthetic messages, shell messages, compaction and move controls are excluded).

  • Plugin: register session.prompt in setupV2 (guarded like the existing registrations), read event.prompt.text, cap it at the same 4000 chars wmux-hook.js uses (MAX_PROMPT), dedupe by message id — the docs note prompt hooks are retry-safe but not exactly-once — and call wmux(["hook", "--event", "UserPromptSubmit", "--prompt", text]).
  • CLI: cmdHook accepts --prompt and rides it through hook.event; COMMAND_SPECS.hook grows the flag. The renderer side needs nothing.
  • Bump the plugin version marker so installed copies update.
  • v1 chat.message could feed the same event later; scoping this to v2 only.

Known limitation, same as the session handle (docs "Session handle for restore"): on v2's shared opencode serve --service, the plugin's WMUX_SURFACE_ID names only the pane that started the server, so prompts from other panes on that server would be attributed to it. That is the existing behaviour of every server-side signal, and the documented reason a CLI-side half (the #290 follow-up) is the eventual answer for remote/shared setups.

Environment

wmux 2.28.1 (master 3d59aef), OpenCode v2.

Activity

  1. amirlehmam commented on Oct 19, 2026

    @amirlehmam
    Owner

    Fixed by #305, released in v2.29.0. The OpenCode v2 plugin (marker 8, reinstalled automatically) registers the prompt-admission hook, so submitted prompts now fill the outline, the Prompts pane and wmux prompts. v1 is unchanged, and the shared serve --service caveat still applies.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions