Skip to content

fix(tui): allow Alt+P permission cycle while busy - #360

Merged
shayne-snap merged 2 commits into
mainfrom
worktree-fix-option-p
Aug 6, 2026
Merged

fix(tui): allow Alt+P permission cycle while busy#360
shayne-snap merged 2 commits into
mainfrom
worktree-fix-option-p

Conversation

@shayne-snap

Copy link
Copy Markdown
Contributor

What changed

Option+P (Alt+P) was silently ignored while a turn was running — the permission cycle only worked when the agent was idle. This made the shortcut's behavior inconsistent between working and non-working states.

Root cause

The permission intents (IntentSetApprovalMode, IntentSetAutoReview) emit EventTurnDone, which the TUI treats as turn completion. Dispatching them mid-turn committed the live transcript and cleared busy state while the backend kept streaming, so a previous fix (f5bcca4) simply gated Alt+P on !m.busy.

Fix

  • Add a Quiet flag to permission intents (protocol.Intent / service.Intent, JSON quiet,omitempty — backward compatible).
  • When Quiet is set, the service applies the state change and emits EventInfo (AutoAcceptKnown), but skips EventTurnDone — mirroring the approval modal's existing quiet IntentEnableAutoAccept path.
  • Alt+P now cycles ask -> auto-review -> auto-accept -> ask mid-turn with no TUI/backend desync; the permission change takes effect immediately for subsequent tool calls of the running turn (the approval callback reads it dynamically). Idle behavior is unchanged.

Files

  • internal/runtime/protocol/intents.go — add Quiet field
  • internal/app/service/service.go / protocol_dispatch.go / dispatch.go — wire through and honor Quiet
  • internal/tui/model_keys_chat.go — allow Alt+P while busy; dispatch quiet intents mid-turn
  • Tests: internal/tui/model_permission_cycle_test.go, internal/app/service/events_test.go

Tested

  • go test ./internal/tui/... ./internal/app/service/... ./internal/runtime/... — pass
  • go test ./... — only pre-existing internal/tools PTY-environment failures (reproduced on base without these changes)

Option+P was silently ignored while a turn was running, so the
permission cycle only worked when idle. The old busy gate existed
because the permission intents emit EventTurnDone, which the TUI
treats as turn completion and would commit the live transcript and
clear busy while the backend kept streaming.

Add a Quiet flag to permission intents: when set, the service applies
the state change and emits EventInfo (AutoAcceptKnown) but skips
EventTurnDone, mirroring the approval modal's quiet
IntentEnableAutoAccept path. Alt+P now cycles ask -> auto-review ->
auto-accept mid-turn with no TUI/backend desync; idle behavior is
unchanged.
@shayne-snap
shayne-snap merged commit 3a78d44 into main Aug 6, 2026
2 checks passed
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.

1 participant