@oh-my-pi/pi-tui 11.4.0 → 11.5.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/tui.ts +10 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-tui",
3
- "version": "11.4.0",
3
+ "version": "11.5.0",
4
4
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -47,8 +47,8 @@
47
47
  "bun": ">=1.3.7"
48
48
  },
49
49
  "dependencies": {
50
- "@oh-my-pi/pi-natives": "11.4.0",
51
- "@oh-my-pi/pi-utils": "11.4.0",
50
+ "@oh-my-pi/pi-natives": "11.5.0",
51
+ "@oh-my-pi/pi-utils": "11.5.0",
52
52
  "@types/mime-types": "^3.0.1",
53
53
  "chalk": "^5.6.2",
54
54
  "marked": "^17.0.1",
package/src/tui.ts CHANGED
@@ -677,11 +677,14 @@ export class TUI extends Container {
677
677
  minLinesNeeded = Math.max(minLinesNeeded, row + overlayLines.length);
678
678
  }
679
679
 
680
- // Ensure result covers the terminal working area to keep overlay positioning stable across resizes.
681
- // maxLinesRendered can exceed current content length after a shrink; pad to keep viewportStart consistent.
682
- const workingHeight = Math.max(this.maxLinesRendered, minLinesNeeded);
683
-
684
- // Extend result with empty lines if content is too short for overlay placement or working area
680
+ // Ensure result is tall enough for overlay placement.
681
+ // NOTE: Do not pad to maxLinesRendered.
682
+ // maxLinesRendered tracks the terminal "working area" (max lines ever rendered) and can be much larger
683
+ // than the current content. Padding to it can cause the renderer to output hundreds/thousands of blank
684
+ // lines, effectively scrolling the terminal when an overlay is shown.
685
+ const workingHeight = Math.max(result.length, minLinesNeeded);
686
+
687
+ // Extend result with empty lines if content is too short for overlay placement
685
688
  while (result.length < workingHeight) {
686
689
  result.push("");
687
690
  }
@@ -888,8 +891,8 @@ export class TUI extends Container {
888
891
  return;
889
892
  }
890
893
 
891
- // Content shrunk below the working area and no overlays - re-render to clear empty rows
892
- // (overlays need the padding, so only do this when no overlays are active)
894
+ // Content shrunk below the working area and no overlays - re-render to clear empty rows.
895
+ // When an overlay is active, avoid clearing to reduce flicker and avoid resetting scrollback.
893
896
  // Configurable via setClearOnShrink() or PI_CLEAR_ON_SHRINK=0 env var
894
897
  if (this.clearOnShrink && newLines.length < this.maxLinesRendered && this.overlayStack.length === 0) {
895
898
  logRedraw(`clearOnShrink (maxLinesRendered=${this.maxLinesRendered})`);