fix: resolve 3 remaining PR #1819 review issues

- Preserve 'exited' status in setClaudeMode(false) instead of overwriting to 'running'
- Add isResumingPhase guard to SWAP_RESUME_COMPLETE for consistency with other swap events
- Clean up stale migratedSessionFlags when resumeClaudeAsync finds no terminal

Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
AndyMik90
2026-02-18 09:49:35 +01:00
co-authored by Claude Opus 4.6
parent faf6148f82
commit 7f7e845cd5
3 changed files with 7 additions and 1 deletions
@@ -229,6 +229,10 @@ export class TerminalManager {
async resumeClaudeAsync(id: string, sessionId?: string, options?: { migratedSession?: boolean }): Promise<void> {
const terminal = this.terminals.get(id);
if (!terminal) {
// Clean up stale migratedSessionFlags if terminal no longer exists
if (options?.migratedSession && sessionId) {
this.migratedSessionFlags.delete(sessionId);
}
return;
}
@@ -417,7 +417,7 @@ export const useTerminalStore = create<TerminalState>((set, get) => ({
? {
...t,
isClaudeMode,
status: isClaudeMode ? 'claude-active' : 'running',
status: isClaudeMode ? 'claude-active' : (t.status === 'exited' ? 'exited' : 'running'),
// Reset busy state and naming flag when leaving Claude mode
isClaudeBusy: isClaudeMode ? t.isClaudeBusy : undefined,
claudeNamedOnce: isClaudeMode ? t.claudeNamedOnce : undefined
@@ -108,6 +108,7 @@ export const terminalMachine = createMachine(
},
SWAP_RESUME_COMPLETE: {
target: 'claude_active',
guard: 'isResumingPhase',
actions: 'applySwapComplete',
},
SWAP_FAILED: {
@@ -142,6 +143,7 @@ export const terminalMachine = createMachine(
isCapturingPhase: ({ context }) => context.swapPhase === 'capturing',
isMigratingPhase: ({ context }) => context.swapPhase === 'migrating',
isRecreatingPhase: ({ context }) => context.swapPhase === 'recreating',
isResumingPhase: ({ context }) => context.swapPhase === 'resuming',
},
actions: {
setProfileId: assign({