MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / exitRestoredWorktree

Function exitRestoredWorktree

source code/utils/sessionRestore.ts:382–402  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

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