MCPcopy Create free account
hub / github.com/apache/maka / replaceTranscriptWithStoredMessages

Function replaceTranscriptWithStoredMessages

packages/cli/src/pi-transcript.ts:312–338  ·  view source on GitHub ↗
(
  state: MakaPiTranscriptState,
  messages: readonly StoredMessage[],
)

Source from the content-addressed store, hash-verified

310}
311
312export function replaceTranscriptWithStoredMessages(
313 state: MakaPiTranscriptState,
314 messages: readonly StoredMessage[],
315): void {
316 const view = materializeSession(messages);
317 state.entries = foldStoredShellRunChildren(view.items.flatMap(chatItemToTranscriptEntries));
318 clearPendingInteractions(state);
319 state.pendingShellRunPolls.clear();
320 state.expandAllTools = false;
321 state.expandAllThinking = false;
322 // The old entries are gone; no position is known until the next render, and
323 // until then the toggles must not touch anything (a replacement entry could
324 // render above the still-scrolled viewport). viewportTop is left to the next
325 // layout render: when the replacement changes lines above it, pi-tui
326 // full-redraws and the layout's shadow diff resets the estimate to match;
327 // when the replacement is a pure truncation or identical content, pi-tui
328 // keeps its viewport and so does the estimate.
329 state.renderGeometry.entryFirstLine = undefined;
330 state.usage = { costUsd: 0, cacheHitInput: 0, cacheMissInput: 0 };
331 // Queues are per-active-run; a switched/reset session has none pending.
332 state.steering = [];
333 state.followup = [];
334 state.pendingFallback = [];
335 for (const msg of messages) {
336 if (msg.type === 'token_usage') accumulateUsage(state.usage, msg);
337 }
338}
339
340/**
341 * Fill durable tool details that are intentionally absent from Runtime Host

Callers 2

replaceTranscriptFunction · 0.85

Calls 5

materializeSessionFunction · 0.90
clearPendingInteractionsFunction · 0.85
accumulateUsageFunction · 0.85
clearMethod · 0.65

Tested by

no test coverage detected