@modelstatus/cli 0.1.49 → 0.1.50

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 +1 -1
  2. package/src/tui/app.js +40 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelstatus/cli",
3
- "version": "0.1.49",
3
+ "version": "0.1.50",
4
4
  "description": "Track which AI models you use, where, and never get surprised by a retirement. Free offline model-health for any repo (mm status), browser sign-in for cloud inventory + alerts.",
5
5
  "keywords": [
6
6
  "llm",
package/src/tui/app.js CHANGED
@@ -40,6 +40,42 @@ const GATE_KEYS = [{ k: "1-8", label: "switch" }, { k: "7", label: "sign in" }];
40
40
  // toast, status, keybar, bottomRule) — the body fills whatever rows remain.
41
41
  const CHROME_ROWS = 10;
42
42
 
43
+ /**
44
+ * How many rows to leave UN-rendered below the frame so the window never clips.
45
+ *
46
+ * - 1 row everywhere: a frame that fills the full height makes ink write+newline
47
+ * the bottom line, which scrolls the buffer up by 1 each render; reserving the
48
+ * last row keeps it blank so nothing ever scrolls.
49
+ * - 6 rows in Warp: Warp keeps ~5 rows of block chrome (sticky command header +
50
+ * pinned input) drawn OVER the alternate screen and over-reports stdout.rows by
51
+ * that much, so the TOP clips unless we also subtract them (1 guard + 5 chrome;
52
+ * measured against the user's Warp build — see Warp issues #6428/#2373, the
53
+ * chrome area can't be reclaimed via alt_screen_padding). Gated on TERM_PROGRAM
54
+ * so non-Warp terminals keep the plain 1-row reserve (an extra reserve elsewhere
55
+ * would leave a blank band).
56
+ *
57
+ * MM_TUI_RESERVE_ROWS (integer ≥ 0) overrides the whole reserve so a user on a
58
+ * different Warp version / input position / timing-line setting can self-tune
59
+ * (e.g. =5 or =7) without waiting for a release; 0 opts out entirely.
60
+ */
61
+ export function rowsReserve(env = process.env) {
62
+ // Only a non-blank, integer-valued string overrides (so `MM_TUI_RESERVE_ROWS=`
63
+ // or stray whitespace falls back to the default rather than being read as 0 —
64
+ // `Number("")` is 0). `=0` is honored as an explicit opt-out.
65
+ const raw = env.MM_TUI_RESERVE_ROWS;
66
+ if (typeof raw === "string" && raw.trim() !== "") {
67
+ const n = Number(raw);
68
+ if (Number.isInteger(n) && n >= 0) return n;
69
+ }
70
+ return env.TERM_PROGRAM === "WarpTerminal" ? 6 : 1;
71
+ }
72
+
73
+ /** Frame height for a terminal of `rows` rows: reserve rows, then clamp to a
74
+ * sane window [8, 200]. Pure (env-injectable) so it's unit-testable. */
75
+ export function computeTermRows(rows, env = process.env) {
76
+ return Math.max(8, Math.min((rows || 24) - rowsReserve(env), 200));
77
+ }
78
+
43
79
  /** Full terminal dims, resize-aware. Fills the screen edge-to-edge.
44
80
  * MM_TUI_WIDTH / MM_TUI_HEIGHT force exact dims (reproducible screenshots). */
45
81
  function useTermDims() {
@@ -69,17 +105,10 @@ function useTermDims() {
69
105
  const cols = Number.isFinite(fw) && fw > 0 ? fw : dims.cols;
70
106
  const rows = Number.isFinite(fh) && fh > 0 ? fh : dims.rows;
71
107
  // Never exceed the real terminal width (a wider frame soft-wraps every chrome
72
- // line and shatters the window).
73
- //
74
- // Height: RESERVE THE LAST ROW (rows - 1). A frame that fills the full height
75
- // makes ink write+newline the bottom line, which scrolls the buffer up by 1
76
- // EVERY render; across the handful of renders during load/settle that scroll
77
- // accumulates and creeps the window's top off-screen (the "not full-screen after
78
- // the game / in Warp" clip). One row short keeps the last line blank so nothing
79
- // ever scrolls. This is safe now that the TUI lives in the ALT SCREEN: ink's
80
- // cursor-up diffing (which it uses when the frame is shorter than the terminal)
81
- // stays inside the fixed alt buffer and can't drift the way it did inline.
82
- return { outer: Math.min(cols || 80, 220), termRows: Math.max(8, Math.min((rows || 24) - 1, 200)) };
108
+ // line and shatters the window). Height reserves rows (see rowsReserve) so the
109
+ // frame never fills the screen and clips the top — 1 row everywhere (scroll
110
+ // guard), 6 in Warp (block chrome over-reports rows), MM_TUI_RESERVE_ROWS tunes.
111
+ return { outer: Math.min(cols || 80, 220), termRows: computeTermRows(rows) };
83
112
  }
84
113
 
85
114
  function PromptRow({ prompt }) {