Skip to content

feat(opencode): TUI half reports blocked state from permissions and forms (#310) - #314

Merged
amirlehmam merged 1 commit into
amirlehmam:masterfrom
Mattheinrichs:feat/opencode-tui-blocked
Oct 20, 2026
Merged

amirlehmam merged 1 commit into
amirlehmam:masterfrom
Mattheinrichs:feat/opencode-tui-blocked

Conversation

@Mattheinrichs

Copy link
Copy Markdown
Contributor

Phase 3a of the CLI-side (TUI) half, following the plan in #310. The server half cannot see a pane whose TUI is a client of a remote or shared server, so until now nothing could mark such a pane "Needs you".

Events (verified against packages/schema/src/permission.ts and the bundled TUI notifications plugin):

Event Report
permission.asked {id, sessionID, action, resources, message?} report-agent --blocked "<message ?? action ?? generic>"
permission.replied {sessionID, requestID, reply} --unblocked
form.created {form:{id, sessionID, title}} --blocked "<form.title>"
form.replied / form.cancelled --unblocked
session.execution.interrupted / .failed --unblocked (mirrors the server half's error/interrupt)

Verification

  • New/changed suites: opencode-tui-core (8 blocked cases), entry-shape assertions, and the dedupe pin — 57 tests in the three TUI-related files, watched red first (the dedupe pin passes by design; it characterizes existing behaviour).
  • Full suite: only the pre-existing Windows/path.join failures that also fail on untouched master in this container.
  • npm run typecheck, entry syntax check, node --check on the core pass. No CLI changes, so no resources/cli rebuild.

Live check after merge (same setup as #311/#312): wmux opencode-tui (v2 → v3), trigger a permission-requiring action → sidebar shows "Needs you" with the reason; reply → clears. A form (form.created) behaves the same.

3b (working/idle via absolute report-agent --run-depth) follows in its own PR.

Part of #310

…orms (amirlehmam#310)

Phase 3a of the CLI-side (TUI) half: a pane whose TUI is a client of a
remote or shared server now shows "Needs you" — the server half cannot see
those processes, so nothing could mark them blocked before.

v2 announces the asks as `permission.asked` (id, sessionID, action,
resources, optional message) and `form.created` (form.id/sessionID/title).
Both report through the existing `report-agent --blocked`: reason from the
permission's message, else its action, else a generic; the form's title.
Cleared only by an explicit `permission.replied`, `form.replied`/
`form.cancelled`, or a turn-ending `session.execution.interrupted|failed` —
tool and streaming events never unblock, because the ask's own tool part
transitions within a frame of the ask (amirlehmam#189), and a block that clears
itself is worse than one that lingers. Replays dedupe by request/form id;
reasons cap at 200 chars like the server half. Same hosted-session scoping
as prompts: the event stream is the whole server's.

Also pins the two-producer prompt dedupe that was asked for: both halves
reporting one submission inside the renderer's 1500 ms window still
produces a single log entry, and a deliberate repeat later produces two.

Plugin marker 2 → 3 so installed halves update.

Part of amirlehmam#310
@amirlehmam
amirlehmam merged commit a5406a3 into amirlehmam:master Oct 20, 2026
amirlehmam added a commit that referenced this pull request Oct 20, 2026
Follow-up to #314. One reply cleared every pending ask, a reply that arrived
after the session left the pane's tabs was dropped (stranding "Needs you"),
and a replay of an answered ask raised it again. Asks are now tracked by id
with their session: the pane unblocks when the last one is answered, a reply
to a known ask always counts, and a turn failure clears only its session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@amirlehmam

Copy link
Copy Markdown
Owner

Thanks @Mattheinrichs — 3a is merged and ships in v2.33.0, together with the two-producer prompt pin.

During review I changed one thing in createBlockedReporter (01df550). With a single boolean plus id sets, three cases went wrong:

  • Overlapping asks: a permission and a form open together, and the first reply cleared "Needs you" while the second was still waiting.
  • Reply after the session left the screen: observe returned early on hosted === false, so a reply to an ask this pane raised was dropped once the user switched tabs, and the pane stayed blocked.
  • Replay of an answered ask: replying removed the id from the set, so a replayed permission.asked raised "Needs you" again.

Each open ask is now tracked by id together with its session. The pane unblocks when the last one is answered. A reply to a known ask counts whatever is on screen. An answered id is remembered (bounded) so a replay of it is ignored. session.execution.interrupted|failed clears only that session's asks. An ask with no id is released by any hosted reply of its kind, so it can't strand the pane. Four tests cover these cases, and docs/opencode-plugin.md is updated. The marker stays at 3 because v3 had not shipped yet.

3b (absolute --run-depth) is welcome whenever you're ready. #310 stays open for it.

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