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

Function buildFileHistorySnapshotChain

src/utils/sessionStorage.ts:2248–2272  ·  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

2246 * Builds a filie history snapshot chain from the conversation
2247 */
2248function buildFileHistorySnapshotChain(
2249 fileHistorySnapshots: Map<UUID, FileHistorySnapshotMessage>,
2250 conversation: TranscriptMessage[],
2251): FileHistorySnapshot[] {
2252 const snapshots: FileHistorySnapshot[] = []
2253 // messageId → last index in snapshots[] for O(1) update lookup
2254 const indexByMessageId = new Map<string, number>()
2255 for (const message of conversation) {
2256 const snapshotMessage = fileHistorySnapshots.get(message.uuid)
2257 if (!snapshotMessage) {
2258 continue
2259 }
2260 const { snapshot, isSnapshotUpdate } = snapshotMessage
2261 const existingIndex = isSnapshotUpdate
2262 ? indexByMessageId.get(snapshot.messageId)
2263 : undefined
2264 if (existingIndex === undefined) {
2265 indexByMessageId.set(snapshot.messageId, snapshots.length)
2266 snapshots.push(snapshot)
2267 } else {
2268 snapshots[existingIndex] = snapshot
2269 }
2270 }
2271 return snapshots
2272}
2273
2274/**
2275 * Builds an attribution snapshot chain from the conversation.

Callers 4

loadTranscriptFromFileFunction · 0.85
loadFullLogFunction · 0.85
getLastSessionLogFunction · 0.85

Calls 3

getMethod · 0.65
setMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected