@oh-my-pi/pi-tui 18.9.2 → 18.10.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/src/tui.ts CHANGED
@@ -251,10 +251,6 @@ export interface Component {
251
251
  */
252
252
  render(width: number): readonly string[];
253
253
 
254
- /** Inline decision panels must keep displaced settled transcript rows in
255
- * native scrollback even when mounted inside a transient editor container. */
256
- readonly retireDisplacedTranscript?: boolean;
257
-
258
254
  /**
259
255
  * Describe the component semantically for a Tern Surface Protocol
260
256
  * terminal (see `native/node.ts`). Called instead of `render()` when the
@@ -820,6 +816,10 @@ export class TUI extends Container {
820
816
  // rows the paint prepended for a short viewport. Negative while prepended
821
817
  // blanks outweigh replaced rows; zero on ordinary frames.
822
818
  #providerViewportPadTop = 0;
819
+ // Whether native history holds rows the provider committed since the last
820
+ // destructive reset. Only paints write history and only a destructive reset
821
+ // erases it; an `append` resize replay keeps the rows it replays beneath.
822
+ #providerHistoryWritten = false;
823
823
  // Viewport-relative row of the hardware cursor after the last normal paint
824
824
  // (0 = parked at the viewport top). A resize reflows the normal buffer
825
825
  // before the app hears about it; terminals keep the cursor attached to its
@@ -1365,6 +1365,27 @@ export class TUI extends Container {
1365
1365
  return { top: this.#providerViewportTop - this.#providerViewportPadTop, length: this.#providerWindow.length };
1366
1366
  }
1367
1367
 
1368
+ /**
1369
+ * Rows of native history the last paint left on screen above a mutable
1370
+ * viewport that reached the bottom row, or `undefined` when that paint left
1371
+ * rows free below it (or none happened, or a destructive reset will repaint
1372
+ * from row zero). Rows above a bottom-reaching viewport may already sit in
1373
+ * native scrollback, which a later shrink cannot pull back down.
1374
+ */
1375
+ getFilledHistoryRows(): number | undefined {
1376
+ if (!this.#hasEverRendered || this.#clearScrollbackOnNextRender) return undefined;
1377
+ const height = this.terminal.rows;
1378
+ if (this.#providerWindow.length === 0 || this.#providerViewportTop + this.#providerWindow.length < height) {
1379
+ return undefined;
1380
+ }
1381
+ return Math.min(this.#providerViewportTop, height);
1382
+ }
1383
+
1384
+ /** Whether native history holds rows the frame provider committed since the last destructive reset. */
1385
+ hasProviderHistory(): boolean {
1386
+ return this.#providerHistoryWritten && !this.#clearScrollbackOnNextRender;
1387
+ }
1388
+
1368
1389
  /**
1369
1390
  * Probe for opt-in normal-buffer click capture. The provider is read every
1370
1391
  * frame; while it returns true (and no fullscreen overlay owns the
@@ -3441,6 +3462,7 @@ export class TUI extends Container {
3441
3462
  this.#providerViewportTop = 0;
3442
3463
  this.#providerWindow = [];
3443
3464
  this.#providerPreparedRows = [];
3465
+ this.#providerHistoryWritten = false;
3444
3466
  }
3445
3467
  // The viewport stays anchored directly below whatever history remains on
3446
3468
  // screen. Appending K history rows moves the anchor down by K; the write
@@ -3633,6 +3655,7 @@ export class TUI extends Container {
3633
3655
  this.#resizeBurstWidthChanged = false;
3634
3656
  this.#resizeBurstResized = false;
3635
3657
  this.#previousFrameLength = mutablePreparedLines.length;
3658
+ if (preparedHistory.lines.length > 0 || replayViewportRows > 0) this.#providerHistoryWritten = true;
3636
3659
  this.#clearScrollbackOnNextRender = false;
3637
3660
  this.#forceViewportRepaintOnNextRender = false;
3638
3661
  this.#hasEverRendered = true;