MCPcopy
hub / github.com/codeaashu/claude-code / exitRestoredWorktree

Function exitRestoredWorktree

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

Source from the content-addressed store, hash-verified

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

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