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

Function getProject

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

Source from the content-addressed store, hash-verified

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