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

Function buildFileHistorySnapshotChain

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

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

Callers 4

loadTranscriptFromFileFunction · 0.85
loadFullLogFunction · 0.85
getLastSessionLogFunction · 0.85

Calls 2

getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected