MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / buildFileHistorySnapshotChain

Function buildFileHistorySnapshotChain

src/utils/sessionStorage.ts:2287–2311  ·  view source on GitHub ↗

* Builds a filie history snapshot chain from the conversation

(
  fileHistorySnapshots: Map<UUID, FileHistorySnapshotMessage>,
  conversation: TranscriptMessage[],
)

Source from the content-addressed store, hash-verified

2285 * Builds a filie history snapshot chain from the conversation
2286 */
2287function buildFileHistorySnapshotChain(
2288 fileHistorySnapshots: Map<UUID, FileHistorySnapshotMessage>,
2289 conversation: TranscriptMessage[],
2290): FileHistorySnapshot[] {
2291 const snapshots: FileHistorySnapshot[] = []
2292 // messageId → last index in snapshots[] for O(1) update lookup
2293 const indexByMessageId = new Map<string, number>()
2294 for (const message of conversation) {
2295 const snapshotMessage = fileHistorySnapshots.get(message.uuid)
2296 if (!snapshotMessage) {
2297 continue
2298 }
2299 const { snapshot, isSnapshotUpdate } = snapshotMessage
2300 const existingIndex = isSnapshotUpdate
2301 ? indexByMessageId.get(snapshot.messageId)
2302 : undefined
2303 if (existingIndex === undefined) {
2304 indexByMessageId.set(snapshot.messageId, snapshots.length)
2305 snapshots.push(snapshot)
2306 } else {
2307 snapshots[existingIndex] = snapshot
2308 }
2309 }
2310 return snapshots
2311}
2312
2313/**
2314 * Builds an attribution snapshot chain from the conversation.

Callers 4

loadTranscriptFromFileFunction · 0.85
loadFullLogFunction · 0.85
getLastSessionLogFunction · 0.85

Calls 3

setMethod · 0.80
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected