MCPcopy Index your code
hub / github.com/Noumena-Network/code / getProject

Function getProject

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

Source from the content-addressed store, hash-verified

477let cleanupRegistered = false
478
479function getProject(): Project {
480 if (!project) {
481 project = new Project()
482
483 // Register flush as a cleanup handler (only once)
484 if (!cleanupRegistered) {
485 registerCleanup(async () => {
486 // Flush queued writes first, then re-append session metadata
487 // (customTitle, tag) so they always appear in the last 64KB tail
488 // window. readLiteMetadata only reads the tail to extract these
489 // fields — if enough messages are appended after a /rename, the
490 // custom-title entry gets pushed outside the window and --resume
491 // shows the auto-generated firstPrompt instead.
492 await project?.flush()
493 try {
494 project?.reAppendSessionMetadata()
495 } catch {
496 // Best-effort — don't let metadata re-append crash the cleanup
497 }
498 })
499 cleanupRegistered = true
500 }
501 }
502 return project
503}
504
505/**
506 * Reset the Project singleton's flush state for testing.

Callers 15

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

Calls 3

registerCleanupFunction · 0.85
flushMethod · 0.45

Tested by

no test coverage detected