mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 12:40:44 +00:00
feat(core): add prePlanMode tracking to restore previous approval mode
When entering plan mode, Config now saves the previous approval mode (e.g. AUTO_EDIT, YOLO) so it can be restored when exiting. Previously, /plan execute and ExitPlanModeTool both hardcoded a return to DEFAULT, losing the user's prior mode. Changes: - Config: add prePlanMode field, getPrePlanMode(), auto-track in setApprovalMode() - planCommand: /plan execute restores prePlanMode instead of DEFAULT - ExitPlanModeTool: ProceedOnce restores prePlanMode instead of DEFAULT - Tests: 4 new Config tests, 1 new planCommand test, 1 new ExitPlanModeTool test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
09ccc1b896
commit
c597847bc3
6 changed files with 105 additions and 2 deletions
|
|
@ -529,6 +529,7 @@ export class Config {
|
|||
private sdkMode: boolean;
|
||||
private geminiMdFileCount: number;
|
||||
private approvalMode: ApprovalMode;
|
||||
private prePlanMode: ApprovalMode | undefined;
|
||||
private readonly accessibility: AccessibilitySettings;
|
||||
private readonly telemetrySettings: TelemetrySettings;
|
||||
private readonly gitCoAuthor: GitCoAuthorSettings;
|
||||
|
|
@ -1634,6 +1635,14 @@ export class Config {
|
|||
return this.approvalMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the approval mode that was active before entering plan mode.
|
||||
* Falls back to DEFAULT if no pre-plan mode was recorded.
|
||||
*/
|
||||
getPrePlanMode(): ApprovalMode {
|
||||
return this.prePlanMode ?? ApprovalMode.DEFAULT;
|
||||
}
|
||||
|
||||
setApprovalMode(mode: ApprovalMode): void {
|
||||
if (
|
||||
!this.isTrustedFolder() &&
|
||||
|
|
@ -1644,6 +1653,15 @@ export class Config {
|
|||
'Cannot enable privileged approval modes in an untrusted folder.',
|
||||
);
|
||||
}
|
||||
// Track the mode before entering plan mode so it can be restored later
|
||||
if (mode === ApprovalMode.PLAN && this.approvalMode !== ApprovalMode.PLAN) {
|
||||
this.prePlanMode = this.approvalMode;
|
||||
} else if (
|
||||
mode !== ApprovalMode.PLAN &&
|
||||
this.approvalMode === ApprovalMode.PLAN
|
||||
) {
|
||||
this.prePlanMode = undefined;
|
||||
}
|
||||
this.approvalMode = mode;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue