MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / exitRestoredWorktree

Function exitRestoredWorktree

src/utils/sessionRestore.ts:381–401  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

379 * worktree that should take precedence, handled by the re-assert above).
380 */
381export 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.

Callers 1

REPLFunction · 0.85

Calls 8

restoreWorktreeSessionFunction · 0.85
clearMemoryFileCachesFunction · 0.85
setCwdFunction · 0.85
setOriginalCwdFunction · 0.85
getCwdFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected