Keep Claude context when switching permission mode

This commit is contained in:
cc-dan
2026-03-16 15:37:26 +00:00
parent 29bb938385
commit 7c993f1c4a
2 changed files with 34 additions and 6 deletions

View File

@@ -2066,9 +2066,7 @@ function handleSlashCommand(ws, text, sessionId, fallbackAgent) {
const mode = modeInput.toLowerCase();
if (session) {
session.permissionMode = mode;
// Claude CLI permission mode changes should reset runtime resume id.
// For Codex, keep thread id so mode switching does not drop context.
if (isClaudeSession(session)) clearRuntimeSessionId(session);
// Mode switching should not reset runtime context (Claude/Codex both resume).
session.updated = new Date().toISOString();
saveSession(session);
}
@@ -2339,8 +2337,7 @@ function handleRenameSession(ws, sessionId, title) {
const session = loadSession(sessionId);
if (session) {
session.permissionMode = mode;
// Same rule as /mode: don't clear Codex thread id on mode changes.
if (isClaudeSession(session)) clearRuntimeSessionId(session);
// Same rule as /mode: don't clear runtime context on mode changes.
session.updated = new Date().toISOString();
saveSession(session);
}