@gajae-code/tui 0.11.11 → 0.12.0

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.
package/CHANGELOG.md CHANGED
@@ -2,7 +2,21 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
- ## [0.11.11] - 2026-07-26
5
+ ## [0.12.0] - 2026-07-28
6
+
7
+ ### Changed
8
+
9
+ - Mouse wheel scrolling now moves the session viewport by exactly three lines (`DEFAULT_WHEEL_LINES = 3`) instead of a full page. PageUp/PageDown keep page-sized steps with edge pinning.
10
+ - Manual transcript scrolling now keeps a valid registered status/composer boundary fixed at the bottom independently of output-source registration. Output sources control only the exact semantic new-output notice; transcript selection excludes pinned chrome, short transcript lanes emit blanks instead of duplicating suffix rows, and constrained heights retain the focused suffix component before decorative rows.
11
+ - Manual viewport revisions now advance for semantic changes in a visible capped sidebar even without an inline component; duplicate, elided, hidden, geometry-only, and theme-only changes do not raise a false new-output notice. Equal output-source updates do not render, and constrained pinned suffixes avoid copying transcript-length prefixes.
12
+ - A downward manual scroll (wheel or `PageDown`) that reaches the true transcript bottom now transitions through the existing live-follow transaction instead of repainting another manual frame, so wheel and PageDown automatically return to live output at the bottom. A partial downward movement retains manual ownership and the notice; upward movement never follows. The transition preserves editor focus, pinned chrome, notice clearing, and fatal terminal transaction semantics, clears manual anchor state through the existing transaction, and does not replay manual-era output into native/host scrollback.
13
+
14
+ ### Fixed
15
+
16
+ - `waitForRenderCommit` / generation-scoped render tokens resolve only after a successful buffer write (or fail open on stopped/unavailable terminals), enabling awaitable progress frames for interactive resume without hanging (#2914).
17
+ - Streaming layout contraction followed by regrowth no longer re-admits an already committed logical row into native terminal scrollback, preventing occasional duplicated assistant lines after Markdown reflow.
18
+ - Repeated clearing of an already-clear viewport output source is now a render-request no-op, matching identical non-null source updates.
19
+ - A terminal width change now ends in one forced full redraw 1000ms after the last observed resize event, repairing stale bands left by lines wrapped at the old column count — across the full transcript, including scrollback history, on every host. Interim resize frames keep their cheap per-host path; the debounce is what makes the one full replay safe, so drag-resizing still does not replay the transcript per `SIGWINCH`. While the user is reading scrollback (manual viewport), the repair is deferred and runs when they return to live output. Height-only changes are unaffected (#3360, #3361).
6
20
 
7
21
  ## [0.11.7] - 2026-07-22
8
22
  ### Fixed
package/README.md CHANGED
@@ -56,6 +56,14 @@ tui.requestRender(); // Request a re-render
56
56
  tui.onDebug = () => console.log("Debug triggered");
57
57
  ```
58
58
 
59
+ ### Manual viewport and pinned suffix
60
+
61
+ `setBottomPinnedComponent(component)` marks a direct-child boundary. During manual viewport ownership, that child and all later direct children remain fixed at the bottom while rows before it form the scrollable lane; this does not require an output source. `scrollViewportPages()` moves by the lane height minus one; `scrollViewportBy()` supports smaller row steps and rejects non-finite deltas.
62
+
63
+ `setViewportOutputSource({ identity, revision })` reports semantic output changes without coupling the TUI to message types. A same-identity revision advance while manually scrolled displays the exact notice `New output — type to follow`; following live or changing/removing the identity clears it, while a stale same-identity revision rollback does not.
64
+
65
+ Pinned rows and the notice are excluded from transcript mouse-selection coordinates. When the terminal is too short, the focused direct-child suffix component is retained before decorative or lower-priority suffix rows.
66
+
59
67
  ### Component Interface
60
68
 
61
69
  All components implement:
@@ -48,6 +48,7 @@ export interface RenderMetricsSnapshot {
48
48
  timerGauges: Record<string, number>;
49
49
  helperStats: Record<string, HelperStat>;
50
50
  lineCounts: Record<string, LineCountGauge>;
51
+ structuralCounters: Record<string, number>;
51
52
  }
52
53
  export declare class RenderMetrics {
53
54
  #private;
@@ -73,6 +74,8 @@ export declare class RenderMetrics {
73
74
  recordHelper(name: string, durationMs: number): void;
74
75
  /** Record a per-render line-count gauge (e.g. "rendered", "normalized", "diffed"). */
75
76
  recordLineCount(name: string, value: number): void;
77
+ /** Accumulate deterministic structural render work without retaining frame data. */
78
+ recordStructuralCounter(name: string, value?: number): void;
76
79
  /**
77
80
  * Force a GC when the runtime exposes one and sample RSS as the post-run
78
81
  * "return" value used by the memory-leak gate. Callers should drop large
@@ -1,5 +1,7 @@
1
1
  import type { Terminal } from "./terminal";
2
2
  import { visibleWidth } from "./utils";
3
+ /** Discrete mouse-wheel notch size in terminal rows (xterm/less-style). */
4
+ export declare const DEFAULT_WHEEL_LINES = 3;
3
5
  type InputListenerResult = {
4
6
  consume?: boolean;
5
7
  data?: string;
@@ -99,6 +101,11 @@ export interface ViewportAnchorProvider extends Component {
99
101
  export interface ViewportAnchorSource {
100
102
  id: ViewportAnchorId;
101
103
  }
104
+ /** Identity and monotonic revision of the logical output producer. */
105
+ export type ViewportOutputSource = {
106
+ identity: string;
107
+ revision: bigint;
108
+ };
102
109
  export interface ViewportAnchorSourceRenderer extends Component {
103
110
  renderWithViewportAnchorSource(width: number, source: ViewportAnchorSource): ViewportAnchorRender;
104
111
  }
@@ -231,6 +238,13 @@ export declare class TUI extends Container {
231
238
  constructor(terminal: Terminal, showHardwareCursor?: boolean, options?: {
232
239
  enableMouse?: boolean;
233
240
  copySelection?: (text: string) => void | Promise<void>;
241
+ /**
242
+ * Trailing debounce for the settled width repair, in ms. `0` disables the
243
+ * settled repair (deterministic harnesses need this — a wall-clock-timed
244
+ * full replay lands at nondeterministic logical positions). Defaults to
245
+ * `GJC_TUI_WIDTH_SETTLE_MS` / `PI_TUI_WIDTH_SETTLE_MS`, then 1000.
246
+ */
247
+ widthSettleMs?: number;
234
248
  });
235
249
  dispose(): void;
236
250
  get fullRedraws(): number;
@@ -244,7 +258,11 @@ export declare class TUI extends Container {
244
258
  */
245
259
  setClearOnShrink(enabled: boolean): void;
246
260
  setFocus(component: Component | null): void;
261
+ removeChild(component: Component): void;
262
+ clear(): void;
247
263
  setBottomPinnedComponent(component: Component | null): void;
264
+ /** Report the logical output producer revision without coupling TUI to message types. */
265
+ setViewportOutputSource(source: ViewportOutputSource | null): void;
248
266
  /** Register the direct child whose rows are eligible for semantic viewport anchoring. */
249
267
  setViewportAnchorComponent(component: Component | null): void;
250
268
  /** Clear manual viewport ownership before replacing the transcript identity namespace. */
@@ -253,6 +271,10 @@ export declare class TUI extends Container {
253
271
  prepareViewportAnchorForTranscriptRebuild(): void;
254
272
  /** Reveal a semantic viewport anchor without changing the rendered content width. */
255
273
  revealViewportAnchor(id: ViewportAnchorId, alignment: "top" | "center" | "bottom"): boolean;
274
+ scrollViewportBy(deltaRows: number, options?: {
275
+ /** edge: PageUp/PageDown pin; stable: preserve/center pin for fine wheel motion */
276
+ pin?: "edge" | "stable";
277
+ }): boolean;
256
278
  scrollViewportPages(direction: -1 | 1): boolean;
257
279
  followLiveViewport(): boolean;
258
280
  /**
@@ -266,6 +288,15 @@ export declare class TUI extends Container {
266
288
  hasOverlay(): boolean;
267
289
  invalidate(): void;
268
290
  start(): void;
291
+ /**
292
+ * Wait for a specific render request generation to be written successfully.
293
+ *
294
+ * Render requests are coalesced, so committing a newer generation also commits
295
+ * every older generation represented by that frame. A stopped or unavailable
296
+ * terminal resolves waiters false so UI callers can fail open instead of
297
+ * holding a session operation behind a dead renderer.
298
+ */
299
+ waitForRenderCommit(generation: number, timeoutMs?: number): Promise<boolean>;
269
300
  get terminalAvailable(): boolean;
270
301
  addInputListener(listener: InputListener): () => void;
271
302
  removeInputListener(listener: InputListener): void;
@@ -294,6 +325,7 @@ export declare class TUI extends Container {
294
325
  */
295
326
  requestResizeRender(): void;
296
327
  requestRender(force?: boolean, source?: string): void;
328
+ requestRenderWithGeneration(force?: boolean, source?: string): number;
297
329
  getLineRenderCacheStats(): {
298
330
  normalizationSize: number;
299
331
  truncationSize: number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gajae-code/tui",
4
- "version": "0.11.11",
4
+ "version": "0.12.0",
5
5
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
6
6
  "homepage": "https://gajae-code.com",
7
7
  "author": "Yeachan-Heo and Gajae Code Contributors",
@@ -36,8 +36,8 @@
36
36
  "fmt": "biome format --write ."
37
37
  },
38
38
  "dependencies": {
39
- "@gajae-code/natives": "0.11.11",
40
- "@gajae-code/utils": "0.11.11",
39
+ "@gajae-code/natives": "0.12.0",
40
+ "@gajae-code/utils": "0.12.0",
41
41
  "lru-cache": "11.3.6",
42
42
  "marked": "18.0.6"
43
43
  },
package/src/metrics.ts CHANGED
@@ -124,6 +124,7 @@ export interface RenderMetricsSnapshot {
124
124
  timerGauges: Record<string, number>;
125
125
  helperStats: Record<string, HelperStat>;
126
126
  lineCounts: Record<string, LineCountGauge>;
127
+ structuralCounters: Record<string, number>;
127
128
  }
128
129
 
129
130
  function emptyDurationStats(): DurationStats {
@@ -160,6 +161,7 @@ export class RenderMetrics {
160
161
  #timerGauges = new Map<string, number>();
161
162
  #helpers = new Map<string, { count: number; totalMs: number }>();
162
163
  #lineGauges = new Map<string, LineCountGauge>();
164
+ #structuralCounters = new Map<string, number>();
163
165
  #rssReturn: number | null = null;
164
166
  #heapBaseline: number | null = null;
165
167
  #heapReturn: number | null = null;
@@ -200,6 +202,7 @@ export class RenderMetrics {
200
202
  this.#timerGauges.clear();
201
203
  this.#helpers.clear();
202
204
  this.#lineGauges.clear();
205
+ this.#structuralCounters.clear();
203
206
  this.#rssReturn = null;
204
207
  this.#heapBaseline = null;
205
208
  this.#heapReturn = null;
@@ -296,6 +299,13 @@ export class RenderMetrics {
296
299
  this.#lineGauges.set(retained, cur);
297
300
  }
298
301
 
302
+ /** Accumulate deterministic structural render work without retaining frame data. */
303
+ recordStructuralCounter(name: string, value = 1): void {
304
+ if (!this.#enabled) return;
305
+ const retained = retainedLabel(this.#structuralCounters, name);
306
+ this.#structuralCounters.set(retained, (this.#structuralCounters.get(retained) ?? 0) + value);
307
+ }
308
+
299
309
  /**
300
310
  * Force a GC when the runtime exposes one and sample RSS as the post-run
301
311
  * "return" value used by the memory-leak gate. Callers should drop large
@@ -345,6 +355,10 @@ export class RenderMetrics {
345
355
  return out;
346
356
  }
347
357
 
358
+ #structuralCounterStats(): Record<string, number> {
359
+ return Object.fromEntries(this.#structuralCounters);
360
+ }
361
+
348
362
  snapshot(): RenderMetricsSnapshot {
349
363
  return {
350
364
  enabled: this.#enabled,
@@ -374,6 +388,7 @@ export class RenderMetrics {
374
388
  timerGauges: Object.fromEntries(this.#timerGauges),
375
389
  helperStats: this.#helperStats(),
376
390
  lineCounts: this.#lineCountStats(),
391
+ structuralCounters: this.#structuralCounterStats(),
377
392
  };
378
393
  }
379
394
  }