( entry: MakaPiTranscriptEntry, width: number, offScreen: boolean, )
| 1214 | // or a later render would serve corrupted content for that entry. The only |
| 1215 | // caller, renderMakaPiTranscript, spreads the lines into its own buffer. |
| 1216 | function 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 | |
| 1240 | function renderTranscriptEntryBlock(entry: MakaPiTranscriptEntry, width: number): string[] { |
| 1241 | switch (entry.kind) { |
no test coverage detected