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

Function renderTranscriptEntryMemoized

packages/cli/src/pi-transcript.ts:1216–1238  ·  view source on GitHub ↗
(
  entry: MakaPiTranscriptEntry,
  width: number,
  offScreen: boolean,
)

Source from the content-addressed store, hash-verified

1214// or a later render would serve corrupted content for that entry. The only
1215// caller, renderMakaPiTranscript, spreads the lines into its own buffer.
1216function renderTranscriptEntryMemoized(
1217 entry: MakaPiTranscriptEntry,
1218 width: number,
1219 offScreen: boolean,
1220): string[] {
1221 // Off-screen entries live in terminal scrollback, which is immutable: any
1222 // change to their rendered lines forces pi-tui's differential renderer into a
1223 // scrollback-clearing full redraw (#1135). Serving the cached render keeps
1224 // the display consistent with what's already in the terminal. The underlying
1225 // entry state still updates — only the visual output is frozen. A width
1226 // change already triggered a pi-tui full redraw (re-anchoring viewportTop to
1227 // the tail), so a stale-width cache won't be served.
1228 if (offScreen) {
1229 const cached = transcriptEntryRenderCache.get(entry);
1230 if (cached && cached.width === width) return cached.lines;
1231 }
1232 const signature = transcriptEntrySignature(entry, width);
1233 const cached = transcriptEntryRenderCache.get(entry);
1234 if (cached && cached.signature === signature) return cached.lines;
1235 const lines = renderTranscriptEntryBlock(entry, width);
1236 transcriptEntryRenderCache.set(entry, { signature, lines, width });
1237 return lines;
1238}
1239
1240function renderTranscriptEntryBlock(entry: MakaPiTranscriptEntry, width: number): string[] {
1241 switch (entry.kind) {

Callers 1

renderMakaPiTranscriptFunction · 0.85

Calls 4

transcriptEntrySignatureFunction · 0.85
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected