fix(tui): allow Alt+P permission cycle while busy - #360
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) emitEventTurnDone, 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
Quietflag to permission intents (protocol.Intent/service.Intent, JSONquiet,omitempty— backward compatible).Quietis set, the service applies the state change and emitsEventInfo(AutoAcceptKnown), but skipsEventTurnDone— mirroring the approval modal's existing quietIntentEnableAutoAcceptpath.ask -> auto-review -> auto-accept -> askmid-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— addQuietfieldinternal/app/service/service.go/protocol_dispatch.go/dispatch.go— wire through and honorQuietinternal/tui/model_keys_chat.go— allow Alt+P while busy; dispatch quiet intents mid-turninternal/tui/model_permission_cycle_test.go,internal/app/service/events_test.goTested
go test ./internal/tui/... ./internal/app/service/... ./internal/runtime/...— passgo test ./...— only pre-existinginternal/toolsPTY-environment failures (reproduced on base without these changes)