diff --git a/src/cli/App.tsx b/src/cli/App.tsx index 8436e7e..6d89adc 100644 --- a/src/cli/App.tsx +++ b/src/cli/App.tsx @@ -12372,8 +12372,11 @@ ${SYSTEM_REMINDER_CLOSE} const isLast = currentIndex + 1 >= pendingApprovals.length; // Capture plan file path BEFORE exiting plan mode (for post-approval rendering) - const planFilePath = permissionMode.getPlanFilePath(); - lastPlanFilePathRef.current = planFilePath; + const planFilePath = + permissionMode.getPlanFilePath() ?? lastPlanFilePathRef.current; + if (planFilePath) { + lastPlanFilePathRef.current = planFilePath; + } // Exit plan mode const restoreMode = acceptEdits @@ -12484,16 +12487,6 @@ ${SYSTEM_REMINDER_CLOSE} if (hasUsablePlan) { // User likely cycled out of plan mode (e.g., Shift+Tab to acceptEdits/yolo) // Keep approval flow alive and let ExitPlanMode proceed using fallback plan path. - const statusId = uid("status"); - buffersRef.current.byId.set(statusId, { - kind: "status", - id: statusId, - lines: [ - "ℹ️ Plan mode switched, continuing ExitPlanMode with saved plan file", - ], - }); - buffersRef.current.order.push(statusId); - refreshDerived(); return; } diff --git a/src/tests/cli/permission-mode-retry-wiring.test.ts b/src/tests/cli/permission-mode-retry-wiring.test.ts index 7eb8ad3..eb0aa83 100644 --- a/src/tests/cli/permission-mode-retry-wiring.test.ts +++ b/src/tests/cli/permission-mode-retry-wiring.test.ts @@ -89,4 +89,23 @@ describe("permission mode retry wiring", () => { expect(segment).toContain("conversationBusyRetriesRef.current = 0;"); expect(segment).toContain("continue;"); }); + + test("preserves saved plan path when approving ExitPlanMode after mode cycling", () => { + const source = readAppSource(); + + const start = source.indexOf("const handlePlanApprove = useCallback("); + const end = source.indexOf( + "useEffect(() => {\n const currentIndex = approvalResults.length;", + start, + ); + expect(start).toBeGreaterThan(-1); + expect(end).toBeGreaterThan(start); + + const segment = source.slice(start, end); + expect(segment).toContain( + "permissionMode.getPlanFilePath() ?? lastPlanFilePathRef.current", + ); + expect(segment).toContain("if (planFilePath) {"); + expect(segment).toContain("lastPlanFilePathRef.current = planFilePath;"); + }); });