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

Function loadTranscriptFile

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

Source from the content-addressed store, hash-verified

3472 * Returns the messages, summaries, custom titles, tags, file history snapshots, and attribution snapshots.
3473 */
3474export async function loadTranscriptFile(
3475 filePath: string,
3476 opts?: { keepAllLeaves?: boolean },
3477): Promise<{
3478 messages: Map<UUID, TranscriptMessage>
3479 summaries: Map<UUID, string>
3480 customTitles: Map<UUID, string>
3481 tags: Map<UUID, string>
3482 agentNames: Map<UUID, string>
3483 agentColors: Map<UUID, string>
3484 agentSettings: Map<UUID, string>
3485 prNumbers: Map<UUID, number>
3486 prUrls: Map<UUID, string>
3487 prRepositories: Map<UUID, string>
3488 modes: Map<UUID, string>
3489 worktreeStates: Map<UUID, PersistedWorktreeSession | null>
3490 fileHistorySnapshots: Map<UUID, FileHistorySnapshotMessage>
3491 attributionSnapshots: Map<UUID, AttributionSnapshotMessage>
3492 contentReplacements: Map<UUID, ContentReplacementRecord[]>
3493 agentContentReplacements: Map<AgentId, ContentReplacementRecord[]>
3494 contextCollapseCommits: ContextCollapseCommitEntry[]
3495 contextCollapseSnapshot: ContextCollapseSnapshotEntry | undefined
3496 leafUuids: Set<UUID>
3497}> {
3498 const messages = new Map<UUID, TranscriptMessage>()
3499 const summaries = new Map<UUID, string>()
3500 const customTitles = new Map<UUID, string>()
3501 const tags = new Map<UUID, string>()
3502 const agentNames = new Map<UUID, string>()
3503 const agentColors = new Map<UUID, string>()
3504 const agentSettings = new Map<UUID, string>()
3505 const prNumbers = new Map<UUID, number>()
3506 const prUrls = new Map<UUID, string>()
3507 const prRepositories = new Map<UUID, string>()
3508 const modes = new Map<UUID, string>()
3509 const worktreeStates = new Map<UUID, PersistedWorktreeSession | null>()
3510 const fileHistorySnapshots = new Map<UUID, FileHistorySnapshotMessage>()
3511 const attributionSnapshots = new Map<UUID, AttributionSnapshotMessage>()
3512 const contentReplacements = new Map<UUID, ContentReplacementRecord[]>()
3513 const agentContentReplacements = new Map<
3514 AgentId,
3515 ContentReplacementRecord[]
3516 >()
3517 // Array, not Map — commit order matters (nested collapses).
3518 const contextCollapseCommits: ContextCollapseCommitEntry[] = []
3519 // Last-wins — later entries supersede.
3520 let contextCollapseSnapshot: ContextCollapseSnapshotEntry | undefined
3521
3522 try {
3523 // For large transcripts, avoid materializing megabytes of stale content.
3524 // Single forward chunked read: attribution-snapshot lines are skipped at
3525 // the fd level (never buffered), compact boundaries truncate the
3526 // accumulator in-stream. Peak allocation is the OUTPUT size, not the
3527 // file size — a 151 MB session that is 84% stale attr-snaps allocates
3528 // ~32 MB instead of 159+64 MB. This matters because mimalloc does not
3529 // return those pages to the OS even after JS-level GC frees the backing
3530 // buffers (measured: arrayBuffers=0 after Bun.gc(true) but RSS stuck at
3531 // ~316 MB on the old scan+strip path vs ~155 MB here).

Callers 7

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

Calls 15

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

Tested by

no test coverage detected