Repository navigation
feat(tui): allow binding a key to permission.mode - #42057
thepigdestroyer wants to merge 1 commit into
Conversation
Auto-approve permission mode is reachable by CLI flag (--auto, --yolo, --dangerously-skip-permissions) and by the permission.mode command in the palette, and context/permission.tsx already exposes toggle(). There is no keybind definition for it, so it cannot be bound from config and the only in-session route is the palette. Add a permission_mode definition (default "none", so no behaviour change unless a user opts in) mapped to the existing permission.mode command, and list the command in appBindingCommands so a layer gathers the binding.
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Found a potential duplicate: PR #40334: feat(tui): make permission mode keybind configurable This PR appears to address the exact same feature as the current PR #42057. Both are about making permission mode bindable via keybinds in the TUI configuration. You should check if #40334 has already been merged or if this is a re-implementation of the same feature. |
|
Closing this in favour of #40334, which is the same change and 9 days older. I searched open issues before starting but not open PRs, so I missed it. For anyone comparing the two: #40334 is functionally identical, including the I have been running this change locally and can confirm it works: bound to a key, the toggle flips |
Problem
Auto-approve permission mode can be reached three ways today:
--auto,--yolo,--dangerously-skip-permissionspermission.modecommand in the command palettetoggle()on the permission contextWhat is missing is a keybind.
Definitionsinpackages/tui/src/config/keybind.tshas nopermission_modeentry, so the command cannot be bound from config, and the only in-session route is opening the palette and picking the entry.The machinery is already there.
context/permission.tsxexposesset()andtoggle(), andapp.tsxregisters apermission.modepalette command with a state-dependent title. This just makes it bindable.Change
permission_mode: keybind("none", "Toggle auto-approve permissions")toDefinitionspermission.modecommand inCommandMappermission.modeinappBindingCommandsso a layer actually gathers the bindingDefault is
"none", so nothing changes for anyone who does not opt in.Three lines, and the third is the one that is easy to miss: a definition plus a
CommandMapentry resolves correctly but stays inert unless the command is also in a gathered list. I had this wrong at first and the key silently did nothing.Verification
bun run typecheckinpackages/tui— cleanbun test test/keymap.test.tsx test/config.test.tsx— 11 passWith
{"keybinds": {"permission_mode": "ctrl+alt+n"}}intui.json, resolving throughTuiConfig.get()gives:I also confirmed end to end that toggling this way suppresses prompts, using a permission that evaluates to
ask. From the log:asking id=per_…at.714, then the action proceeding at.744with no prompt rendered.Notes
Deliberately no default key. Auto-approving permissions is dangerous enough that it should stay opt-in, and I did not want to claim a chord on anyone's behalf.
If you would prefer a keybind naming other than
permission_mode, say the word and I will rename.