Files
orca/src/shared/terminal-preview.ts
T
Jinjing 5bee7b5ce9 P1 STA 3887 design Preview Kitty IME (#13940)
* fix(terminal): carry kitty flags through Preview snapshots and pair rele

Preview was omitting the live kitty mirror from the IME bridge and dropping kitty flags from snapshots, so every commit was evaluated at flags 0. A TUI that negotiated bit-3 (report_all_keys_as_escape_codes) would receive the legacy raw text it declined.

Now the snapshot carries proven kitty flags beside their sequence boundary, the forwarder reads flags once per commit, and bit-1 (report_event_types) commits are paired with exactly one release regardless of keyup/insertText ordering. Snapshot authorities expose only the active screen's proven flags, so an old host's absent field stays unknown rather than downgraded to a manufactured zero.

* fix(terminal): sync kitty flags and IME releases across snapshots

* trim wordinesss

* fix(terminal): settle owed IME release before fresh same-key press

When a keyup is lost and the same key is pressed again, settle the stale
record's owed release instead of discarding it — this maintains correct
IME state during recovery. Also refine Kitty flag propagation to only
carry proven baselines across snapshots, and tighten related comments.

* fix(terminal): gate kitty flags on sequence boundaries

- Remote snapshots only include flags when seq is present
- Daemon uses parsed flags value when defined
- Ensures correct flag ordering in snapshot replay
2026-08-11 22:00:44 -07:00

36 lines
1.2 KiB
TypeScript

export type TerminalPreviewSnapshot = {
data: string
cols: number
rows: number
seq?: number
scrollbackAnsi?: string
pendingEscapeTailAnsi?: string
/** Effective kitty keyboard flags the snapshot owner proved at this same
* `seq` boundary. Absent means unknown — Preview then keeps its tracker
* unproven and commits raw text rather than guessing zero. */
kittyKeyboardFlags?: number
}
/**
* How the renderer must apply one buffered chunk. `live` is a proven
* post-snapshot suffix, so kitty pushes advance the stack; `replay` is
* redelivery that may repeat the application's one-time push, so it applies
* idempotently (see TerminalKittyKeyboardModeTracker.scanReplay).
*/
export type TerminalPreviewReplayChunk = {
data: string
mode: 'live' | 'replay'
}
export type TerminalPreviewConnectResult = {
snapshot: TerminalPreviewSnapshot | null
/** Live bytes captured while the snapshot was being serialized. */
replay: TerminalPreviewReplayChunk[]
/** Snapshot acquisition overflowed twice; refresh without blanking the existing view. */
resyncRequired?: boolean
}
export type TerminalPreviewDataPayload =
| { type: 'data'; ptyId: string; data: string; bytes: number }
| { type: 'resync'; ptyId: string }