@prometheus-ai/tui 0.5.4 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/types/autocomplete.d.ts +3 -1
  2. package/dist/types/components/box.d.ts +1 -1
  3. package/dist/types/components/editor.d.ts +35 -2
  4. package/dist/types/components/image.d.ts +22 -3
  5. package/dist/types/components/input.d.ts +6 -1
  6. package/dist/types/components/loader.d.ts +9 -2
  7. package/dist/types/components/markdown.d.ts +3 -1
  8. package/dist/types/components/scroll-view.d.ts +23 -1
  9. package/dist/types/components/select-list.d.ts +19 -1
  10. package/dist/types/components/settings-list.d.ts +87 -7
  11. package/dist/types/components/spacer.d.ts +1 -1
  12. package/dist/types/components/tab-bar.d.ts +37 -4
  13. package/dist/types/components/text.d.ts +2 -2
  14. package/dist/types/components/truncated-text.d.ts +1 -1
  15. package/dist/types/fuzzy.d.ts +10 -1
  16. package/dist/types/index.d.ts +1 -0
  17. package/dist/types/keybindings.d.ts +5 -3
  18. package/dist/types/keys.d.ts +1 -1
  19. package/dist/types/kill-ring.d.ts +0 -7
  20. package/dist/types/kitty-graphics.d.ts +16 -31
  21. package/dist/types/loop-watchdog.d.ts +39 -0
  22. package/dist/types/mouse.d.ts +41 -0
  23. package/dist/types/stdin-buffer.d.ts +17 -0
  24. package/dist/types/terminal-capabilities.d.ts +74 -18
  25. package/dist/types/terminal.d.ts +34 -36
  26. package/dist/types/tui.d.ts +191 -79
  27. package/dist/types/utils.d.ts +5 -2
  28. package/package.json +4 -4
  29. package/src/autocomplete.ts +79 -65
  30. package/src/components/box.ts +43 -63
  31. package/src/components/editor.ts +471 -136
  32. package/src/components/image.ts +85 -9
  33. package/src/components/input.ts +12 -3
  34. package/src/components/loader.ts +35 -21
  35. package/src/components/markdown.ts +174 -53
  36. package/src/components/scroll-view.ts +63 -2
  37. package/src/components/select-list.ts +233 -38
  38. package/src/components/settings-list.ts +626 -64
  39. package/src/components/spacer.ts +9 -5
  40. package/src/components/tab-bar.ts +153 -28
  41. package/src/components/text.ts +6 -2
  42. package/src/components/truncated-text.ts +10 -2
  43. package/src/fuzzy.ts +214 -59
  44. package/src/index.ts +3 -1
  45. package/src/keybindings.ts +72 -14
  46. package/src/keys.ts +1 -1
  47. package/src/kill-ring.ts +5 -0
  48. package/src/kitty-graphics.ts +2 -101
  49. package/src/loop-watchdog.ts +106 -0
  50. package/src/mouse.ts +55 -0
  51. package/src/stdin-buffer.ts +291 -81
  52. package/src/terminal-capabilities.ts +206 -168
  53. package/src/terminal.ts +367 -110
  54. package/src/tui.ts +2102 -1729
  55. package/src/utils.ts +92 -60
@@ -1,13 +1,26 @@
1
+ /**
2
+ * Kitty graphics: Unicode placeholder placement (`U=1` + U+10EEEE), with
3
+ * runtime feature state and env overrides.
4
+ *
5
+ * Unicode placeholders let a transmitted image be displayed by writing ordinary
6
+ * text cells — the placeholder char U+10EEEE plus row/column combining
7
+ * diacritics — instead of a cursor-positioned `a=p` direct placement. The image
8
+ * then participates in the normal text grid, so it survives horizontal slicing,
9
+ * reflow and overlapping draws (each cell names its own row+column, so a sliced
10
+ * row still maps to the correct sub-region). See kitty
11
+ * `docs/graphics-protocol.rst` "Unicode placeholders for relative placements".
12
+ *
13
+ * This module is intentionally free of `./terminal-capabilities` imports so the
14
+ * dependency stays one-way (capabilities → kitty-graphics) and no import cycle
15
+ * forms. Protocol gating (`imageProtocol === Kitty`) lives in the caller.
16
+ */
1
17
  /** Kitty Unicode placeholder base character (U+10EEEE, Plane 16 PUA). */
2
18
  export declare const KITTY_PLACEHOLDER = "\uDBFB\uDEEE";
3
19
  /** Largest row/column index expressible with the diacritic table (one cell each). */
4
20
  export declare const KITTY_PLACEHOLDER_MAX_CELLS: number;
5
- export type KittyTransmissionMedium = "direct" | "temp-file";
6
21
  export interface KittyGraphicsFeatures {
7
22
  /** Display images via Unicode placeholders instead of direct `a=p` placement. */
8
23
  unicodePlaceholders: boolean;
9
- /** How image data reaches the terminal: in-band base64 or a temp file. */
10
- transmissionMedium: KittyTransmissionMedium;
11
24
  }
12
25
  /**
13
26
  * Whether the detected terminal renders Kitty Unicode placeholders (`U=1` +
@@ -29,16 +42,8 @@ export interface KittyGraphicsFeatures {
29
42
  export declare function detectKittyUnicodePlaceholdersSupport(terminalId: string, env?: NodeJS.ProcessEnv): boolean;
30
43
  export declare function getKittyGraphics(): Readonly<KittyGraphicsFeatures>;
31
44
  export declare function setKittyGraphics(partial: Partial<KittyGraphicsFeatures>): void;
32
- /**
33
- * Whether temp-file transmission may be promoted at runtime: forced via env,
34
- * disabled via env, otherwise auto (local sessions only — a temp file written
35
- * locally is not readable by a terminal on the far side of an SSH link).
36
- */
37
- export declare function kittyTempFileAllowed(): boolean;
38
45
  /** Whether a `columns`×`rows` placeholder grid fits within the diacritic table. */
39
46
  export declare function kittyPlaceholdersFit(columns: number, rows: number): boolean;
40
- /** True when the base64 payload is a PNG (kitty `f=100` / temp-file path only). */
41
- export declare function isPngBase64(base64Data: string): boolean;
42
47
  /**
43
48
  * Virtual placement APC (`a=p,U=1`): tells the terminal that placeholder cells
44
49
  * carrying image id `i` should display the transmitted image, scaled to fit the
@@ -72,23 +77,3 @@ export declare function renderKittyPlaceholderLines(opts: {
72
77
  columns: number;
73
78
  rows: number;
74
79
  }): string[];
75
- /**
76
- * Transmit a PNG via a temp file (`t=t`): decode the base64 to bytes once, write
77
- * them to a temp file, and send the base64-encoded file path as payload. Returns
78
- * the APC string, or `null` on any failure (caller falls back to direct base64).
79
- *
80
- * Synchronous filesystem writes are mandated by the synchronous render pipeline
81
- * (`Image.render` → `renderImage` are sync); there is no async seam here.
82
- */
83
- export declare function encodeKittyTempFileTransmit(base64Png: string, imageId: number): string | null;
84
- /**
85
- * Encode a temp-file support probe: write a tiny PNG to a temp file and ask the
86
- * terminal to query it (`a=q,t=t`). A conforming terminal replies
87
- * `ESC _ G i=<probeId>;OK ESC \`. Returns the query APC plus a `cleanup` that
88
- * removes the probe file (best-effort; kitty self-deletes the magic-named file).
89
- * Returns `null` if the temp file cannot be written.
90
- */
91
- export declare function encodeKittyTempFileProbe(probeId: number): {
92
- sequence: string;
93
- cleanup: () => void;
94
- } | null;
@@ -0,0 +1,39 @@
1
+ export interface LoopWatchdogOptions {
2
+ /** How far ahead each probe tick is scheduled, in ms. Default 250. */
3
+ intervalMs?: number;
4
+ /** A tick later than this past its deadline counts as a block. Default 250. */
5
+ thresholdMs?: number;
6
+ /** Monotonic clock source; injectable for tests. Default `performance.now`. */
7
+ now?: () => number;
8
+ /** Timer source; injectable for tests. Default `setTimeout`. */
9
+ schedule?: (cb: () => void, ms: number) => LoopWatchdogTimer;
10
+ }
11
+ /**
12
+ * Timer handle the watchdog arms. `cancel`, when present, is invoked on stop()
13
+ * so a stopped watchdog leaves no armed timer to wake the loop even once.
14
+ */
15
+ interface LoopWatchdogTimer {
16
+ unref?(): void;
17
+ cancel?(): void;
18
+ }
19
+ /**
20
+ * Always-on event-loop lag probe. Each tick is scheduled `intervalMs` ahead of
21
+ * a recorded deadline; a tick that fires `thresholdMs` past its deadline means
22
+ * the loop was blocked that long. The overshoot is logged once on the rising
23
+ * edge (one block ⇒ one line, deduped via `#wasBlocked`), tagged with the phase
24
+ * active during the elapsed interval via {@link takeRecentLoopPhase} — which
25
+ * survives the synchronous push/pop the instrumented hot paths do before this
26
+ * delayed tick can run — so the stall names its cause instead of "unknown".
27
+ *
28
+ * The handle is `unref`'d so the probe never keeps the process alive, and stop()
29
+ * cancels the armed timer when the handle exposes `cancel` (the default
30
+ * `setTimeout` handle does, via `clearTimeout`). The `#generation` guard remains
31
+ * as a fallback for injected handles that cannot cancel.
32
+ */
33
+ export declare class LoopWatchdog {
34
+ #private;
35
+ constructor(options?: LoopWatchdogOptions);
36
+ start(): void;
37
+ stop(): void;
38
+ }
39
+ export {};
@@ -0,0 +1,41 @@
1
+ /**
2
+ * SGR mouse report parsing (`\x1b[<button;col;rowM` / `…m`).
3
+ *
4
+ * Mouse tracking is enabled only while a fullscreen overlay holds the
5
+ * alternate screen (see tui.ts MOUSE_TRACKING_ON), so consumers are
6
+ * fullscreen components hit-testing against their own rendered frame:
7
+ * the frame paints from screen row 0, hence `row`/`col` are exposed
8
+ * 0-based for direct indexing into rendered lines.
9
+ */
10
+ /** A decoded SGR mouse report. */
11
+ export interface SgrMouseEvent {
12
+ /** Raw button code (bit 32 = motion, bit 64 = wheel, low bits = button). */
13
+ button: number;
14
+ /** 0-based column of the event. */
15
+ col: number;
16
+ /** 0-based row of the event. */
17
+ row: number;
18
+ /** True for a release report (`m` suffix). */
19
+ release: boolean;
20
+ /** Wheel direction: -1 up, 1 down, null when not a wheel event. */
21
+ wheel: -1 | 1 | null;
22
+ /** True when the pointer moved (hover or drag) rather than clicked. */
23
+ motion: boolean;
24
+ /** True for a left-button press (not motion, not release, not wheel). */
25
+ leftClick: boolean;
26
+ }
27
+ /**
28
+ * Decode an SGR mouse report, or return null when `data` is not one.
29
+ * Callers on hot keypress paths should pre-check `data.startsWith("\x1b[<")`
30
+ * before paying for the regex.
31
+ */
32
+ export declare function parseSgrMouse(data: string): SgrMouseEvent | null;
33
+ /**
34
+ * Implemented by components that accept routed mouse events at frame-local
35
+ * coordinates. Hosts translate screen coordinates to the component's own
36
+ * rendered lines before forwarding.
37
+ */
38
+ export interface MouseRoutable {
39
+ /** `line`/`col` are 0-based within the component's rendered output. */
40
+ routeMouse(event: SgrMouseEvent, line: number, col: number): void;
41
+ }
@@ -23,6 +23,23 @@ export type StdinBufferOptions = {
23
23
  * After this time, a genuinely incomplete escape is flushed.
24
24
  */
25
25
  timeout?: number;
26
+ /**
27
+ * Maximum extra time (default: 150ms) an unambiguous escape partial — an
28
+ * SGR mouse prefix, or any dangling escape while the kitty keyboard
29
+ * protocol is active — is held past `timeout` waiting for its tail.
30
+ */
31
+ partialHoldTimeout?: number;
32
+ /**
33
+ * Paste-mode inactivity watchdog (default: 1000ms). If no input arrives for
34
+ * this long while waiting for the bracketed-paste end marker, the paste is
35
+ * assumed truncated: accumulated bytes are delivered and input recovers.
36
+ */
37
+ pasteTimeout?: number;
38
+ /**
39
+ * Paste-mode byte cap (default: 64 MiB). Exceeding it aborts paste mode the
40
+ * same way, bounding memory when the end marker never arrives.
41
+ */
42
+ pasteByteLimit?: number;
26
43
  };
27
44
  export type StdinBufferEventMap = {
28
45
  data: [string];
@@ -16,14 +16,20 @@ export declare class TerminalInfo {
16
16
  readonly trueColor: boolean;
17
17
  readonly hyperlinks: boolean;
18
18
  readonly notifyProtocol: NotifyProtocol;
19
- readonly eagerEraseScrollbackRisk: boolean;
20
19
  readonly deccara: boolean;
21
20
  readonly supportsScreenToScrollback: boolean;
22
21
  /** Renders the Kitty OSC 66 text-sizing protocol (scaled spans). Kitty only. */
23
22
  readonly textSizing: boolean;
24
- constructor(id: TerminalId, imageProtocol: ImageProtocol | null, trueColor: boolean, hyperlinks: boolean, notifyProtocol?: NotifyProtocol, eagerEraseScrollbackRisk?: boolean, deccara?: boolean, supportsScreenToScrollback?: boolean,
23
+ constructor(id: TerminalId, imageProtocol: ImageProtocol | null, trueColor: boolean, hyperlinks: boolean, notifyProtocol?: NotifyProtocol, deccara?: boolean, supportsScreenToScrollback?: boolean,
25
24
  /** Renders the Kitty OSC 66 text-sizing protocol (scaled spans). Kitty only. */
26
25
  textSizing?: boolean);
26
+ /**
27
+ * Mutable clone for the {@link TERMINAL} singleton: copies every field and
28
+ * keeps the prototype methods, so the builder and runtime setters flip
29
+ * runtime-resolved {@link RuntimeTerminal} capabilities in place instead of
30
+ * reconstructing positional constructor args.
31
+ */
32
+ clone(): RuntimeTerminal;
27
33
  isImageLine(line: string): boolean;
28
34
  formatNotification(message: string | TerminalNotification): string;
29
35
  sendNotification(message: string | TerminalNotification): void;
@@ -36,23 +42,28 @@ export declare function isNotificationSuppressed(): boolean;
36
42
  */
37
43
  export declare function isWindowsTerminalPreviewSixelSupported(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): boolean;
38
44
  /**
39
- * Whether live-frame native scrollback rebuilds are unsafe when the terminal
40
- * viewport position is unobservable.
41
- *
42
- * A TUI history rebuild emits xterm ED3 (`CSI 3 J`, erase saved lines). Many
43
- * terminals either clamp a scrolled reader back to the active tail or erase host
44
- * scrollback when ED3 lands. The important property is not the brand name — it
45
- * is that an unknown viewport position cannot be proven safe. Environment
46
- * markers are therefore only used to prove *risk* or a strongly-known profile;
47
- * unknown POSIX/remote/multiplexer shapes default to risky for passive renders.
45
+ * Resolve an explicit user override for DEC 2026 synchronized output. Returns
46
+ * `false` for an opt-out, `true` for a force-on, or `null` when the user has
47
+ * expressed no preference. Shared by the static default and the runtime DECRQM
48
+ * probe so both honor the same precedence an opt-out beats a force-on.
49
+ */
50
+ export declare function synchronizedOutputUserOverride(env?: NodeJS.ProcessEnv): boolean | null;
51
+ /**
52
+ * Whether DEC 2026 synchronized-output wrappers should be enabled by default.
48
53
  *
49
- * Native win32 is excluded here because the renderer has dedicated ConPTY
50
- * deferral paths; a `WT_SESSION` sighting on POSIX means Windows Terminal is the
51
- * outer host fronting WSL, where the same ED3 yank applies. See #1610/#1682/#1799.
54
+ * Policy (highest precedence first):
55
+ * 1. Explicit user override (`PROMETHEUS_NO_SYNC_OUTPUT`/`PROMETHEUS_TUI_SYNC_OUTPUT=0` off,
56
+ * `PROMETHEUS_FORCE_SYNC_OUTPUT=1`/`PROMETHEUS_TUI_SYNC_OUTPUT=1` on).
57
+ * 2. Positive `TERM_FEATURES` advertisement (`Sy`) — survives SSH/mux wrapping.
58
+ * 3. Windows Terminal (1.24+) via `WT_SESSION`, on native win32 and the
59
+ * WSL/SSH-fronted host alike.
60
+ * 4. Known direct terminals with confirmed support. SSH does *not* disable —
61
+ * DEC 2026 passes through SSH when the outer terminal honors it.
62
+ * 5. Everything else starts off, including risky multiplexers; the runtime
63
+ * DECRQM probe upgrades any of them when the terminal actually reports
64
+ * `?2026` supported (current zellij, tmux master, foot, contour, mintty…).
52
65
  */
53
- export declare function detectTerminalEagerEraseScrollbackRisk(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): boolean;
54
- /** Whether DEC 2026 synchronized-output wrappers should be enabled by default. */
55
- export declare function shouldEnableSynchronizedOutputByDefault(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, terminalId?: TerminalId): boolean;
66
+ export declare function shouldEnableSynchronizedOutputByDefault(env?: NodeJS.ProcessEnv, terminalId?: TerminalId): boolean;
56
67
  /**
57
68
  * Whether the terminal applies Kitty-style DECCARA rectangular SGR changes
58
69
  * (`CSI Pt ; Pl ; Pb ; Pr ; <sgr> $ r`) extended to background color, so large
@@ -74,8 +85,53 @@ export declare function shouldEnableSynchronizedOutputByDefault(env?: NodeJS.Pro
74
85
  * `PROMETHEUS_NO_DECCARA` kill switch. Pure helper for tests and `TERMINAL` construction.
75
86
  */
76
87
  export declare function detectRectangularSgrSupport(terminalId: TerminalId, env?: NodeJS.ProcessEnv): boolean;
88
+ /**
89
+ * Resolve an explicit user override for OSC 8 hyperlinks. Returns `false` for
90
+ * an opt-out, `true` for a force-on, or `null` when the user has expressed no
91
+ * preference. Opt-out beats force-on so a kill switch is unambiguous, mirroring
92
+ * {@link synchronizedOutputUserOverride}.
93
+ */
94
+ export declare function hyperlinksUserOverride(env?: NodeJS.ProcessEnv): boolean | null;
95
+ /**
96
+ * Whether OSC 8 hyperlinks should be enabled by default.
97
+ *
98
+ * Policy (highest precedence first):
99
+ * 1. Explicit user override (`PROMETHEUS_NO_HYPERLINKS=1` off, `PROMETHEUS_FORCE_HYPERLINKS=1`
100
+ * on). Opt-out wins ties.
101
+ * 2. Static terminal capability — terminals whose {@link TerminalInfo} marks
102
+ * `hyperlinks: false` (e.g. `base`) stay off unless the user forced on.
103
+ * 3. GNU screen's explicit session marker (`STY`) always off, even if tmux is
104
+ * also present: a screen layer anywhere in the path cannot forward OSC 8.
105
+ * 4. tmux session (`TMUX` set): enabled when tmux self-reports >= 3.4 via
106
+ * `TERM_PROGRAM_VERSION` (tmux 3.4 stores OSC 8 as a cell attribute and
107
+ * forwards it to outer terminals whose `terminal-features` include
108
+ * `hyperlinks`). Older or unknown versions stay off; on outer terminals
109
+ * without the feature configured, tmux silently drops the sequence —
110
+ * identical to today. Checked before the screen-family TERM heuristic
111
+ * because tmux's historical `default-terminal` is `screen-256color`, so
112
+ * `TERM=screen*` inside a tmux session must NOT short-circuit to off.
113
+ * 5. screen-family TERM without `TMUX` always off: screen never gained OSC 8
114
+ * support.
115
+ * 6. tmux-family TERM without `TMUX` env — unusual (e.g. inspection scripts);
116
+ * no version available, so off.
117
+ * 7. Otherwise honor the static terminal capability.
118
+ */
119
+ export declare function shouldEnableHyperlinksByDefault(env?: NodeJS.ProcessEnv, terminalId?: TerminalId): boolean;
77
120
  export declare const TERMINAL_ID: TerminalId;
78
- export declare const TERMINAL: TerminalInfo;
121
+ /**
122
+ * The process-wide {@link TERMINAL} singleton: a {@link TerminalInfo} whose
123
+ * post-construction capabilities — the image protocol and the probe-driven
124
+ * flags — are writable, so the runtime setters and tests mutate them directly
125
+ * instead of through an unsound cast. Every other field stays readonly.
126
+ */
127
+ export interface RuntimeTerminal extends TerminalInfo {
128
+ imageProtocol: ImageProtocol | null;
129
+ hyperlinks: boolean;
130
+ deccara: boolean;
131
+ supportsScreenToScrollback: boolean;
132
+ textSizing: boolean;
133
+ }
134
+ export declare const TERMINAL: RuntimeTerminal;
79
135
  /**
80
136
  * Override terminal image protocol at runtime after capability probes complete.
81
137
  */
@@ -1,3 +1,26 @@
1
+ /**
2
+ * Split `data` into chunks whose encoded UTF-8 byte length is no greater than
3
+ * `maxChunkBytes`, preferring a line boundary (`\n`) as the cut point so
4
+ * escape sequences (which never contain `\n`) stay intact. The TUI's
5
+ * full-paint buffers are line-structured (`buffer += "\r\n"` between rows),
6
+ * so a newline almost always exists within the window. The fallback for a
7
+ * buffer with no newline in range is a hard cut at the last UTF-8 code-point
8
+ * boundary that still fits — the ConPTY viewport bug from a single oversized
9
+ * write is strictly worse than a one-frame escape-sequence glitch on a
10
+ * buffer the renderer effectively never produces.
11
+ *
12
+ * UTF-16 code units are walked manually rather than measuring with
13
+ * `Buffer.byteLength` per slice candidate: each code unit's UTF-8 width is
14
+ * known from its value (BMP `<0x80` → 1, `<0x800` → 2, surrogate pair → 4
15
+ * bytes across two units, other BMP → 3), and surrogate pairs are kept
16
+ * together so the chunker never splits a non-BMP character.
17
+ *
18
+ * Exported for unit testing of the chunking contract; `#safeWrite` is the
19
+ * sole production caller.
20
+ */
21
+ export declare function chunkForConPTY(data: string, maxChunkBytes?: number): string[];
22
+ /** Record alternate-screen state (called by the TUI on `?1049h`/`?1049l` writes). */
23
+ export declare function setAltScreenActive(active: boolean): void;
1
24
  /**
2
25
  * Emergency terminal restore - call this from signal/crash handlers
3
26
  * Resets terminal state without requiring access to the ProcessTerminal instance
@@ -19,6 +42,7 @@ export interface Terminal {
19
42
  get columns(): number;
20
43
  get rows(): number;
21
44
  get kittyProtocolActive(): boolean;
45
+ get kittyEnableSequence(): string | null;
22
46
  moveBy(lines: number): void;
23
47
  hideCursor(): void;
24
48
  showCursor(): void;
@@ -27,42 +51,6 @@ export interface Terminal {
27
51
  clearScreen(): void;
28
52
  setTitle(title: string): void;
29
53
  setProgress(active: boolean): void;
30
- /**
31
- * Returns whether the native terminal viewport is at the scrollback tail when
32
- * the host exposes that state. `undefined` means the terminal cannot report it.
33
- *
34
- * `ProcessTerminal` deliberately does not implement this — no real terminal
35
- * can answer it truthfully:
36
- *
37
- * - POSIX terminals expose no scrollback-position API at all.
38
- * - Every modern Windows terminal host (Windows Terminal, VS Code, Tabby,
39
- * Hyper, Alacritty, WezTerm, JetBrains, …) fronts console apps through
40
- * ConPTY, where kernel32's `GetConsoleScreenBufferInfo` describes the
41
- * pseudo-console buffer. That buffer is pinned to the visible grid —
42
- * scrollback lives in the host UI, invisible to console APIs
43
- * (microsoft/terminal#10191) — so a probe reads "at bottom" no matter
44
- * where the user scrolled. Trusting it let streaming-time rebuilds emit
45
- * `\x1b[3J` and yank scrolled readers: #1635 (Windows Terminal), #1746
46
- * (Tabby and other ConPTY hosts). No env var distinguishes these hosts
47
- * (Tabby sets none), so trust cannot be conditional on the environment.
48
- * - Legacy conhost (the only non-ConPTY host) keeps a real scrollback
49
- * buffer, but its window follows the output cursor: a probe comparing
50
- * `srWindow.Bottom` against `dwSize.Y - 1` reads "scrolled up" for a user
51
- * following live output until all ~9001 buffer rows fill, permanently
52
- * blocking checkpoint scrollback reconciliation.
53
- *
54
- * The renderer treats a missing implementation / `undefined` as "unknown":
55
- * live mutations defer destructive rebuilds and reconcile native scrollback
56
- * at explicit checkpoints (prompt submit), where the user's keystroke has
57
- * already pinned the host viewport to the bottom. Only test terminals
58
- * (xterm.js-backed) implement this with a real answer.
59
- */
60
- isNativeViewportAtBottom?(): boolean | undefined;
61
- /**
62
- * Override the global terminal-profile ED3 risk decision for custom/test
63
- * terminals. `undefined` falls back to the resolved `TERMINAL` profile.
64
- */
65
- hasEagerEraseScrollbackRisk?(): boolean | undefined;
66
54
  /**
67
55
  * Register a callback for terminal appearance (dark/light) changes.
68
56
  * Detection uses OSC 11 background color query with Mode 2031 as a change trigger.
@@ -77,12 +65,22 @@ export interface Terminal {
77
65
  */
78
66
  onPrivateModeReport?(callback: (mode: number, supported: boolean) => void): void;
79
67
  }
68
+ /**
69
+ * True when stdout flows through a ConPTY pseudo-console (native win32, or
70
+ * Linux running under WSL where stdout still crosses into ConPTY at the
71
+ * `wslhost` boundary). ConPTY hosts share the per-WriteFile viewport-tracking
72
+ * quirks documented above and on {@link MAX_CONPTY_WRITE_CHUNK_BYTES}, so both
73
+ * `#safeWrite` and the renderer's post-big-paint settle gate hang off this
74
+ * single predicate.
75
+ */
76
+ export declare function isConPTYHosted(): boolean;
80
77
  /**
81
78
  * Real terminal using process.stdin/stdout
82
79
  */
83
80
  export declare class ProcessTerminal implements Terminal {
84
81
  #private;
85
82
  get kittyProtocolActive(): boolean;
83
+ get kittyEnableSequence(): string | null;
86
84
  get appearance(): TerminalAppearance | undefined;
87
85
  onAppearanceChange(callback: (appearance: TerminalAppearance) => void): void;
88
86
  onPrivateModeReport(callback: (mode: number, supported: boolean) => void): void;