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