Repository navigation
Description
Problem
The blocked-state feature added in #188 is defeated by the plugin's own message.part.updated handler. When OpenCode fires question.asked or permission.asked, the plugin correctly calls report-agent --blocked. But within ~17 ms OpenCode also fires message.part.updated for the same tool (status transitioning to running), and the plugin's handler for that event calls pingActive() → clearBlocked() → report-agent --unblocked.
The sidebar flashes "Needs you" for one frame and reverts before the user can see it.
Timeline from debug log
08:55:02.188 question.asked → report-agent --blocked "Waiting for your answer"
08:55:02.205 message.part.updated → pingActive() → clearBlocked() → report-agent --unblocked
(tool=question, status=running)
^^^ 17 ms later, blocked state is gone
08:55:12.519 question.replied → user answers 10 seconds later, but pane was already unblocked
Root cause
In the event handler (wmux.js, event hook), message.part.updated unconditionally calls pingActive(), which calls clearBlocked():
} else if (type === "message.part.updated") {
pingActive(); // → clearBlocked() → report-agent --unblocked
}The self-heal logic (any activity proves the agent is not waiting on a human) is correct in general, but message.part.updated fires for tool status transitions that are part of the ask/reply lifecycle itself. The tool going to running is not evidence that the agent resumed work — it is the question being presented.
The same race applies to permission.asked: the permission prompt's own tool-part update immediately clears the block.
Fix
Stop calling clearBlocked() from message.part.updated. The activity ping is still useful (it tells wmux the pane is alive), but it should not clear the blocked flag:
} else if (type === "message.part.updated") {
// Activity ping only — do not clear blocked state.
// This event fires for tool status transitions (e.g. question tool
// going to "running"), which would immediately undo a block set
// milliseconds earlier.
const now = Date.now();
if (now - lastActivePing < 1000) return;
lastActivePing = now;
wmux(["agent-activity", "--surface", surface, "--active"]);
}The blocked state is still cleared by:
- explicit
*.replied/*.answeredevents tool.execute.before/tool.execute.after(real tool work)session.error
These are all genuine indicators that the agent is no longer waiting on the user.
Verified timeline after fix
08:57:33.675 question.asked → report-agent --blocked "Waiting for your answer"
08:57:33.702 message.part.updated → activity ping only, blocked state preserved
08:57:42.895 question.replied → report-agent --unblocked (9 seconds later, when user actually answers)
Environment
- wmux: v1.9.0 (plugin version 3)
- OpenCode: latest (
opencode.execompiled binary) - OS: Windows 11
Activity
fix(opencode): keep the block through the ask's own part update, log …
amirlehmam commentedon Aug 23, 2026
Fixed in v1.10.0 (9164e07), plugin version 4.
message.part.updatedno longer clears the blocked flag — it pings activity only. Your diagnosis was exact: the part update is the ask's own tool going torunning, so it is the question being presented, not the question being answered.The self-heal the old
clearBlocked()was there for still holds, throughtool.execute.before/.after, the*.replied/*.answeredevents, andsession.error— all of which mean the agent genuinely moved on. That is now written down in docs/opencode-plugin.md, with the 17 ms timeline, so nobody re-adds the clear as an obvious missing safety net.Test
keeps the block when the ask's own tool part goes to "running" (#189)loads the shippedwmux.jsitself and asserts the block survives that exact event. The old test asserting the opposite is gone.Thanks for the log — the timeline is what made this a five-minute fix instead of a guess.
feat(pi): teach pi about wmux, and let it declare its own state (#231)
feat(opencode): TUI half reports blocked state from permissions and f…