| 1 | import { terminalDebugLog } from "./terminalDebugLog"; |
| 2 | |
| 3 | export const TERMINAL_BUFFER_REPLAY_STABILITY_DELAY_MS = 180; |
| 4 | |
| 5 | export function getTerminalBufferReplayKey(input: { |
| 6 | readonly terminalKey: string; |
| 7 | readonly fontSize: number; |
| 8 | }): string { |
| 9 | return `${input.terminalKey}:${input.fontSize}`; |
| 10 | } |
| 11 | |
| 12 | export function getTerminalSurfaceReplayBuffer(input: { |
| 13 | readonly buffer: string; |
| 14 | readonly replayKey: string; |
| 15 | readonly readyReplayKey: string | null; |
| 16 | }): string { |
| 17 | // Pass live buffer whenever ready key is unset or matches. Only return "" when ready key is |
| 18 | // stale vs current replay key (e.g. mid font-size transition). |
| 19 | if (input.readyReplayKey !== null && input.readyReplayKey !== input.replayKey) { |
| 20 | terminalDebugLog("replay:stale-key-hiding-buffer", { |
| 21 | replayKey: input.replayKey, |
| 22 | readyReplayKey: input.readyReplayKey, |
| 23 | bufferLen: input.buffer.length, |
| 24 | }); |
| 25 | return ""; |
| 26 | } |
| 27 | |
| 28 | return input.buffer; |
| 29 | } |