fix(tui): preserve ExitPlanMode plan path after mode cycling (#1329)

Co-authored-by: Letta Code <noreply@letta.com>
This commit is contained in:
jnjpng
2026-03-10 13:26:29 -06:00
committed by GitHub
parent 4fda294a99
commit 58633e9557
2 changed files with 24 additions and 12 deletions

View File

@@ -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;
}

View File

@@ -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;");
});
});