Agent Host: bring back granular "sticky" terminal auto-approve controls (allow for session / always allow exact command line)
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
Building on the recent work to have `chat.tools.terminal.autoApprove` and `chat.tools.terminal.enableAutoApprove` respected for Agent Host Copilot (#322633, #322774), I'd like to bring back the more granular, "sticky" approval controls we used to have so users aren't re-prompted for commands they've already OK'd.
Issue:
Today the AH terminal auto-approver (`src/vs/platform/agentHost/node/commandAutoApprover.ts`) only compiles the forwarded `chat.tools.terminal.autoApprove` rules and checks each command against them. Unlike the workbench auto-approver (`.../chatAgentTools/browser/tools/commandLineAnalyzer/autoApprove/commandLineAutoApprover.ts`, which has `_getSessionRules` and shows "Auto approved for this session"), the AH side has **no concept of session-scoped approvals**. So once I approve something, there's no way to make it stick for the rest of the session, and I keep getting re-prompted.
This shows up a lot because terminal auto-approve is deliberately picky about sub-commands: a compound command only auto-approves if *every* parsed segment matches a rule, and things like nested `$(...)` substitutions, added write redirects, or combos the tree-sitter parser can't decompose will still prompt.
Potential thoughts/plan forward:
- **Allow `` for this session**
- **Always allow exact command line ``** (persists to the `chat.tools.terminal.autoApprove` setting)
- **Allow all commands in this session** — would want to align with the permissions / risk-assessment folks on how this interacts with the session permission model before wiring it up
Pointers for agent:
- AH: `src/vs/platform/agentHost/node/commandAutoApprover.ts`, and `sessionPermissions.ts` (`getAutoApproval`, `permissionKind === 'shell'` path)
- Workbench reference for session-scoped rules: `_getSessionRules` in `.../chatAgentTools/browser/tools/commandLineAnalyzer/autoApprove/commandLineAutoApprover.ts`
Contributor guide
Assessment
This issue has not been assessed yet.