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