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

Function loadTranscriptFromFile

source code/utils/sessionStorage.ts:2296–2394  ·  view source on GitHub ↗
(
  filePath: string,
)

Source from the content-addressed store, hash-verified

2294 * @throws Error if file doesn't exist or contains invalid data
2295 */
2296export async function loadTranscriptFromFile(
2297 filePath: string,
2298): Promise<LogOption> {
2299 if (filePath.endsWith('.jsonl')) {
2300 const {
2301 messages,
2302 summaries,
2303 customTitles,
2304 tags,
2305 fileHistorySnapshots,
2306 attributionSnapshots,
2307 contextCollapseCommits,
2308 contextCollapseSnapshot,
2309 leafUuids,
2310 contentReplacements,
2311 worktreeStates,
2312 } = await loadTranscriptFile(filePath)
2313
2314 if (messages.size === 0) {
2315 throw new Error('No messages found in JSONL file')
2316 }
2317
2318 // Find the most recent leaf message using pre-computed leaf UUIDs
2319 const leafMessage = findLatestMessage(messages.values(), msg =>
2320 leafUuids.has(msg.uuid),
2321 )
2322
2323 if (!leafMessage) {
2324 throw new Error('No valid conversation chain found in JSONL file')
2325 }
2326
2327 // Build the conversation chain backwards from leaf to root
2328 const transcript = buildConversationChain(messages, leafMessage)
2329
2330 const summary = summaries.get(leafMessage.uuid)
2331 const customTitle = customTitles.get(leafMessage.sessionId as UUID)
2332 const tag = tags.get(leafMessage.sessionId as UUID)
2333 const sessionId = leafMessage.sessionId as UUID
2334 return {
2335 ...convertToLogOption(
2336 transcript,
2337 0,
2338 summary,
2339 customTitle,
2340 buildFileHistorySnapshotChain(fileHistorySnapshots, transcript),
2341 tag,
2342 filePath,
2343 buildAttributionSnapshotChain(attributionSnapshots, transcript),
2344 undefined,
2345 contentReplacements.get(sessionId) ?? [],
2346 ),
2347 contextCollapseCommits: contextCollapseCommits.filter(
2348 e => e.sessionId === sessionId,
2349 ),
2350 contextCollapseSnapshot:
2351 contextCollapseSnapshot?.sessionId === sessionId
2352 ? contextCollapseSnapshot
2353 : undefined,

Callers 1

runFunction · 0.85

Calls 10

loadTranscriptFileFunction · 0.85
findLatestMessageFunction · 0.85
buildConversationChainFunction · 0.85
convertToLogOptionFunction · 0.85
readFileFunction · 0.85
jsonParseFunction · 0.85
hasMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected