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

Function getProject

src/utils/sessionStorage.ts:443–467  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

441let cleanupRegistered = false
442
443function getProject(): Project {
444 if (!project) {
445 project = new Project()
446
447 // Register flush as a cleanup handler (only once)
448 if (!cleanupRegistered) {
449 registerCleanup(async () => {
450 // Flush queued writes first, then re-append session metadata
451 // (customTitle, tag) so they always appear in the last 64KB tail
452 // window. readLiteMetadata only reads the tail to extract these
453 // fields — if enough messages are appended after a /rename, the
454 // custom-title entry gets pushed outside the window and --resume
455 // shows the auto-generated firstPrompt instead.
456 await project?.flush()
457 try {
458 project?.reAppendSessionMetadata()
459 } catch {
460 // Best-effort — don't let metadata re-append crash the cleanup
461 }
462 })
463 cleanupRegistered = true
464 }
465 }
466 return project
467}
468
469/**
470 * Reset the Project singleton's flush state for testing.

Callers 15

setSessionFileForTestingFunction · 0.85
setInternalEventWriterFunction · 0.85
setInternalEventReaderFunction · 0.85
recordTranscriptFunction · 0.85
recordQueueOperationFunction · 0.85
removeTranscriptMessageFunction · 0.85
recordContentReplacementFunction · 0.85
resetSessionFilePointerFunction · 0.85

Calls 3

registerCleanupFunction · 0.85
flushMethod · 0.45

Tested by

no test coverage detected