MCPcopy Create free account
hub / github.com/HELPMEEADICE/doge-code / loadTranscriptFile

Function loadTranscriptFile

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

Source from the content-addressed store, hash-verified

3516 * Returns the messages, summaries, custom titles, tags, file history snapshots, and attribution snapshots.
3517 */
3518export async function loadTranscriptFile(
3519 filePath: string,
3520 opts?: { keepAllLeaves?: boolean },
3521): Promise<{
3522 messages: Map<UUID, TranscriptMessage>
3523 summaries: Map<UUID, string>
3524 customTitles: Map<UUID, string>
3525 tags: Map<UUID, string>
3526 agentNames: Map<UUID, string>
3527 agentColors: Map<UUID, string>
3528 agentSettings: Map<UUID, string>
3529 prNumbers: Map<UUID, number>
3530 prUrls: Map<UUID, string>
3531 prRepositories: Map<UUID, string>
3532 modes: Map<UUID, string>
3533 worktreeStates: Map<UUID, PersistedWorktreeSession | null>
3534 fileHistorySnapshots: Map<UUID, FileHistorySnapshotMessage>
3535 attributionSnapshots: Map<UUID, AttributionSnapshotMessage>
3536 contentReplacements: Map<UUID, ContentReplacementRecord[]>
3537 agentContentReplacements: Map<AgentId, ContentReplacementRecord[]>
3538 contextCollapseCommits: ContextCollapseCommitEntry[]
3539 contextCollapseSnapshot: ContextCollapseSnapshotEntry | undefined
3540 leafUuids: Set<UUID>
3541}> {
3542 const messages = new Map<UUID, TranscriptMessage>()
3543 const summaries = new Map<UUID, string>()
3544 const customTitles = new Map<UUID, string>()
3545 const tags = new Map<UUID, string>()
3546 const agentNames = new Map<UUID, string>()
3547 const agentColors = new Map<UUID, string>()
3548 const agentSettings = new Map<UUID, string>()
3549 const prNumbers = new Map<UUID, number>()
3550 const prUrls = new Map<UUID, string>()
3551 const prRepositories = new Map<UUID, string>()
3552 const modes = new Map<UUID, string>()
3553 const worktreeStates = new Map<UUID, PersistedWorktreeSession | null>()
3554 const fileHistorySnapshots = new Map<UUID, FileHistorySnapshotMessage>()
3555 const attributionSnapshots = new Map<UUID, AttributionSnapshotMessage>()
3556 const contentReplacements = new Map<UUID, ContentReplacementRecord[]>()
3557 const agentContentReplacements = new Map<
3558 AgentId,
3559 ContentReplacementRecord[]
3560 >()
3561 // Array, not Map — commit order matters (nested collapses).
3562 const contextCollapseCommits: ContextCollapseCommitEntry[] = []
3563 // Last-wins — later entries supersede.
3564 let contextCollapseSnapshot: ContextCollapseSnapshotEntry | undefined
3565
3566 try {
3567 // For large transcripts, avoid materializing megabytes of stale content.
3568 // Single forward chunked read: attribution-snapshot lines are skipped at
3569 // the fd level (never buffered), compact boundaries truncate the
3570 // accumulator in-stream. Peak allocation is the OUTPUT size, not the
3571 // file size — a 151 MB session that is 84% stale attr-snaps allocates
3572 // ~32 MB instead of 159+64 MB. This matters because mimalloc does not
3573 // return those pages to the OS even after JS-level GC frees the backing
3574 // buffers (measured: arrayBuffers=0 after Bun.gc(true) but RSS stuck at
3575 // ~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