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

Function loadTranscriptFile

src/utils/sessionStorage.ts:3654–4015  ·  view source on GitHub ↗
(
  filePath: string,
  opts?: { keepAllLeaves?: boolean },
)

Source from the content-addressed store, hash-verified

3652 * Returns the messages, summaries, custom titles, tags, file history snapshots, and attribution snapshots.
3653 */
3654export async function loadTranscriptFile(
3655 filePath: string,
3656 opts?: { keepAllLeaves?: boolean },
3657): Promise<{
3658 messages: Map<UUID, TranscriptMessage>
3659 summaries: Map<UUID, string>
3660 customTitles: Map<UUID, string>
3661 tags: Map<UUID, string>
3662 agentNames: Map<UUID, string>
3663 agentColors: Map<UUID, string>
3664 agentSettings: Map<UUID, string>
3665 prNumbers: Map<UUID, number>
3666 prUrls: Map<UUID, string>
3667 prRepositories: Map<UUID, string>
3668 modes: Map<UUID, string>
3669 worktreeStates: Map<UUID, PersistedWorktreeSession | null>
3670 fileHistorySnapshots: Map<UUID, FileHistorySnapshotMessage>
3671 attributionSnapshots: Map<UUID, AttributionSnapshotMessage>
3672 contentReplacements: Map<UUID, ContentReplacementRecord[]>
3673 agentContentReplacements: Map<AgentId, ContentReplacementRecord[]>
3674 contextCollapseCommits: ContextCollapseCommitEntry[]
3675 contextCollapseSnapshot: ContextCollapseSnapshotEntry | undefined
3676 leafUuids: Set<UUID>
3677}> {
3678 const messages = new Map<UUID, TranscriptMessage>()
3679 const summaries = new Map<UUID, string>()
3680 const customTitles = new Map<UUID, string>()
3681 const tags = new Map<UUID, string>()
3682 const agentNames = new Map<UUID, string>()
3683 const agentColors = new Map<UUID, string>()
3684 const agentSettings = new Map<UUID, string>()
3685 const prNumbers = new Map<UUID, number>()
3686 const prUrls = new Map<UUID, string>()
3687 const prRepositories = new Map<UUID, string>()
3688 const modes = new Map<UUID, string>()
3689 const worktreeStates = new Map<UUID, PersistedWorktreeSession | null>()
3690 const fileHistorySnapshots = new Map<UUID, FileHistorySnapshotMessage>()
3691 const attributionSnapshots = new Map<UUID, AttributionSnapshotMessage>()
3692 const contentReplacements = new Map<UUID, ContentReplacementRecord[]>()
3693 const agentContentReplacements = new Map<
3694 AgentId,
3695 ContentReplacementRecord[]
3696 >()
3697 // Array, not Map — commit order matters (nested collapses).
3698 const contextCollapseCommits: ContextCollapseCommitEntry[] = []
3699 // Last-wins — later entries supersede.
3700 let contextCollapseSnapshot: ContextCollapseSnapshotEntry | undefined
3701
3702 try {
3703 // For large transcripts, avoid materializing megabytes of stale content.
3704 // Single forward chunked read: attribution-snapshot lines are skipped at
3705 // the fd level (never buffered), compact boundaries truncate the
3706 // accumulator in-stream. Peak allocation is the OUTPUT size, not the
3707 // file size — a 151 MB session that is 84% stale attr-snaps allocates
3708 // ~32 MB instead of 159+64 MB. This matters because mimalloc does not
3709 // return those pages to the OS even after JS-level GC frees the backing
3710 // buffers (measured: arrayBuffers=0 after Bun.gc(true) but RSS stuck at
3711 // ~316 MB on the old scan+strip path vs ~155 MB here).

Callers 8

loadTranscriptFromFileFunction · 0.85
loadFullLogFunction · 0.85
loadSessionFileFunction · 0.85
getAgentTranscriptFunction · 0.85
findUnresolvedToolUseFunction · 0.85

Calls 15

isEnvTruthyFunction · 0.90
parseJSONLFunction · 0.90
statFunction · 0.85
readTranscriptForLoadFunction · 0.85
scanPreBoundaryMetadataFunction · 0.85
readFileFunction · 0.85
walkChainBeforeParseFunction · 0.85
isLegacyProgressEntryFunction · 0.85
isTranscriptMessageFunction · 0.85
isENOENTFunction · 0.85
applySnipRemovalsFunction · 0.85

Tested by

no test coverage detected