MCPcopy Create free account
hub / github.com/WJX20/claude-code / buildFileHistorySnapshotChain

Function buildFileHistorySnapshotChain

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

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

Callers 4

loadTranscriptFromFileFunction · 0.85
loadFullLogFunction · 0.85
getLastSessionLogFunction · 0.85

Calls 2

setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected