feat(plan): support Plan mode in untrusted folders (#17586)

This commit is contained in:
Adib234
2026-03-30 23:33:55 -04:00
committed by GitHub
parent 2f7f967189
commit d0d3639e16
2 changed files with 11 additions and 1 deletions
+6
View File
@@ -1682,6 +1682,12 @@ describe('setApprovalMode with folder trust', () => {
expect(() => config.setApprovalMode(ApprovalMode.DEFAULT)).not.toThrow();
});
it('should NOT throw an error when setting PLAN mode in an untrusted folder', () => {
const config = new Config(baseParams);
vi.spyOn(config, 'isTrustedFolder').mockReturnValue(false);
expect(() => config.setApprovalMode(ApprovalMode.PLAN)).not.toThrow();
});
it('should NOT throw an error when setting any mode in a trusted folder', () => {
const config = new Config(baseParams);
vi.spyOn(config, 'isTrustedFolder').mockReturnValue(true);
+5 -1
View File
@@ -2517,7 +2517,11 @@ export class Config implements McpContext, AgentLoopContext {
}
setApprovalMode(mode: ApprovalMode): void {
if (!this.isTrustedFolder() && mode !== ApprovalMode.DEFAULT) {
if (
!this.isTrustedFolder() &&
mode !== ApprovalMode.DEFAULT &&
mode !== ApprovalMode.PLAN
) {
throw new Error(
'Cannot enable privileged approval modes in an untrusted folder.',
);