MCPcopy Index your code
hub / github.com/Noumena-Network/code / buildFileHistorySnapshotChain

Function buildFileHistorySnapshotChain

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

2406 * Builds a filie history snapshot chain from the conversation
2407 */
2408function buildFileHistorySnapshotChain(
2409 fileHistorySnapshots: Map<UUID, FileHistorySnapshotMessage>,
2410 conversation: TranscriptMessage[],
2411): FileHistorySnapshot[] {
2412 const snapshots: FileHistorySnapshot[] = []
2413 // messageId → last index in snapshots[] for O(1) update lookup
2414 const indexByMessageId = new Map<string, number>()
2415 for (const message of conversation) {
2416 const snapshotMessage = fileHistorySnapshots.get(message.uuid)
2417 if (!snapshotMessage) {
2418 continue
2419 }
2420 const { snapshot, isSnapshotUpdate } = snapshotMessage
2421 const existingIndex = isSnapshotUpdate
2422 ? indexByMessageId.get(snapshot.messageId)
2423 : undefined
2424 if (existingIndex === undefined) {
2425 indexByMessageId.set(snapshot.messageId, snapshots.length)
2426 snapshots.push(snapshot)
2427 } else {
2428 snapshots[existingIndex] = snapshot
2429 }
2430 }
2431 return snapshots
2432}
2433
2434/**
2435 * 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