Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

terminalBufferReplay.ts

29 lines937 Bytes

1import { terminalDebugLog } from "./terminalDebugLog";
2​
3export const TERMINAL_BUFFER_REPLAY_STABILITY_DELAY_MS = 180;
4​
5export function getTerminalBufferReplayKey(input: {
6 readonly terminalKey: string;
7 readonly fontSize: number;
8}): string {
9 return `${input.terminalKey}:${input.fontSize}`;
11​
12export 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;