Repository navigation
feat(tui): require consent before enabling auto-approve permissions - #133
Merged
Merged
Conversation
Launching with --auto (or its hidden aliases) no longer enables auto-approve silently: a confirm dialog explains the risk and the mode turns on only after the user confirms, followed by a warning toast reusing the same message. Enabling auto mode via shift+tab goes through the same one-time gate; consent is remembered for the rest of the run, so later toggles are silent. Declining or dismissing stays in manual mode. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The consent dialog inherited DialogConfirm's confirm-first default, so a stray return granted auto-approve. Add an opt-in `defaultChoice` prop and start this dialog on cancel, name the risk as "dangerous" in the shared message that both the dialog and the warning toast render, and cover the gate with a view test: the prompt on `--auto`, return declining, and consent being remembered for the rest of the run. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The consent dialog and its toast now render the risk word in theme.error, the same red as the `auto` badge, so the warning reads as a danger signal. The message is passed as an accessor because renderables can only be created during render and the gate runs outside it, which widens DialogConfirm's and Toast's `message` to accept one. The toast no longer replays the dialog: it restates the mode in a single line, since it is only on screen for a few seconds. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Summary
Auto-approve (
--auto) previously turned on silently — the only signal was the redautobadge in the prompt footer. This PR adds an explicit consent gate, shared by both entry points:--auto(or the hidden--yolo/--dangerously-skip-permissionsaliases) no longer enables auto-approve directly. On startup aDialogConfirmexplains that permission requests not explicitly denied will be approved automatically and that this is dangerous (the word rendered intheme.errorred, like theautobadge); the mode turns on only after the user confirms, followed by a warning toast. Declining or dismissing (esc) stays in manual mode.shift+tab(or the palette command) goes through the same dialog and toast the first time. Consent is remembered for the rest of the run, so later toggles are silent; disabling is always instant.The toast does not replay the dialog — it only has a few seconds on screen, so it restates the mode in one line: "Auto-approve is on — a dangerous mode where commands run and files change without asking."
Changes
packages/tui/src/context/permission.tsx: mode always starts"normal"; added a per-runconsentedflag +consent(); replacedtoggle()with explicitset(mode)so there is no ungated path into auto mode.packages/tui/src/app.tsx: sharedenableAutoApprove()consent gate, anonMounthook forargs.auto, and thepermission.modecommand now enables via the gate. The dialog and toast bodies areautoApproveMessage/autoApproveToastaccessors that redden the risk word — passed unevaluated, since renderables can only be created during a render pass and the gate runs outside one.packages/tui/src/ui/dialog-confirm.tsx: optionaldefaultChoiceprop (+ 5thDialogConfirm.showarg) selecting the initially-active button; omitting it keeps the existing confirm-first default, so other callers are unaffected.messagewidened to accept an accessor and resolved at the render site.packages/tui/src/ui/toast.tsx: samemessagewidening, resolved by amessage()helper inToast(). Existing string callers still typecheck.packages/tui/test/auto-approve-consent.view.test.tsx(new): boots the real app withargs.autoagainst the fetch fixture and covers the prompt on startup, a bare return declining, confirming enabling auto mode with the warning toast, and consent being remembered across later toggles. The red word is asserted viacaptureSpans()— char frames carry no color.DIVERGENCES.mdrow +CHANGELOG.mdUnreleased entry per fork policy.Headless
codev run --autois deliberately untouched — a consent prompt there would break scripted usage.Testing
bun typecheckpasses inpackages/tui.bun test test/auto-approve-consent.view.test.tsx— 3/3; also green alongside the neighboring view suites (configure-gate,custom-provider,interrupt).defaultChoice: "cancel", and the color assertion fails when the word is nottheme.error.🤖 Generated with Claude Code