()
| 378 | * worktree that should take precedence, handled by the re-assert above). |
| 379 | */ |
| 380 | export function exitRestoredWorktree(): void { |
| 381 | const current = getCurrentWorktreeSession() |
| 382 | if (!current) return |
| 383 | |
| 384 | restoreWorktreeSession(null) |
| 385 | // Worktree state changed, so cached prompt sections that reference it are |
| 386 | // stale whether or not chdir succeeds below. |
| 387 | clearMemoryFileCaches() |
| 388 | clearSystemPromptSections() |
| 389 | getPlansDirectory.cache.clear?.() |
| 390 | |
| 391 | try { |
| 392 | process.chdir(current.originalCwd) |
| 393 | } catch { |
| 394 | // Original dir is gone (rare). Stay put — restoreWorktreeForResume |
| 395 | // will cd into the target worktree next if there is one. |
| 396 | return |
| 397 | } |
| 398 | setCwd(current.originalCwd) |
| 399 | setOriginalCwd(getCwd()) |
| 400 | } |
| 401 | |
| 402 | /** |
| 403 | * Process a loaded conversation for resume/continue. |
no test coverage detected