@pi-unipi/footer 2.14.0 → 2.14.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/footer",
3
- "version": "2.14.0",
3
+ "version": "2.14.2",
4
4
  "description": "Persistent status bar for Unipi — subscribes to UNIPI_EVENTS and renders key stats from all unipi packages",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -32,8 +32,8 @@
32
32
  "access": "public"
33
33
  },
34
34
  "dependencies": {
35
- "@pi-unipi/core": "2.14.0",
36
- "@pi-unipi/background-tasks": "2.14.0"
35
+ "@pi-unipi/core": "2.14.2",
36
+ "@pi-unipi/background-tasks": "2.14.2"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@earendil-works/pi-coding-agent": "^0.84.0",
@@ -63,6 +63,24 @@ function repeat(s: string, n: number): string {
63
63
  return s.repeat(Math.max(0, n));
64
64
  }
65
65
 
66
+ /**
67
+ * Frame width for a terminal of `terminalWidth` columns: one column SHORT of
68
+ * the terminal (legacy 8-column floor preserved below 9 columns).
69
+ *
70
+ * Issue #31 invariant — the frame is repainted every second and pi-tui joins
71
+ * the rewritten lines with "\r\n". A line at EXACTLY the terminal width hits
72
+ * the auto-wrap threshold: on terminals that wrap immediately (and whenever
73
+ * a glyph renders wider than visibleWidth() assumed) the cursor silently
74
+ * advances one extra row per line, desyncing the differential renderer —
75
+ * every refresh then paints a fresh frame copy one block lower until the
76
+ * screen fills. Never writing the last column keeps every frame line below
77
+ * the wrap threshold on every terminal.
78
+ */
79
+ export function glanceFrameWidth(terminalWidth: number): number {
80
+ if (!Number.isFinite(terminalWidth)) return 8;
81
+ return Math.max(8, terminalWidth - 1);
82
+ }
83
+
66
84
  function padLine(line: string, width: number): string {
67
85
  const w = visibleWidth(line);
68
86
  if (w === width) return line;
@@ -160,7 +178,8 @@ export class GlanceEditor extends CustomEditor {
160
178
  }
161
179
 
162
180
  override render(width: number): string[] {
163
- const safe = Math.max(8, width);
181
+ // One column short of the terminal — see glanceFrameWidth() / issue #31.
182
+ const safe = glanceFrameWidth(width);
164
183
  const inner = Math.max(0, safe - 2);
165
184
 
166
185
  // Base render at inner width: harvest content rows only (rules dropped).
package/src/index.ts CHANGED
@@ -354,8 +354,11 @@ function setupFooterUI(pi: ExtensionAPI, ctx: ExtensionContext, state: FooterSta
354
354
  // Hard safety net: never return a line wider than the terminal.
355
355
  // This catches any edge cases in layout math or visibleWidth()
356
356
  // inconsistencies with PUA characters + ANSI codes.
357
+ // Cap at width - 1 (issue #31): a line at EXACTLY the terminal width
358
+ // trips immediate-wrap terminals and desyncs the diff renderer.
357
359
  const line = layout.topContent;
358
- return [visibleWidth(line) > width ? truncateToWidth(line, width) : line];
360
+ const cap = Math.max(1, width - 1);
361
+ return [visibleWidth(line) > cap ? truncateToWidth(line, cap) : line];
359
362
  },
360
363
  };
361
364
  }, { placement: "aboveEditor" });
@@ -373,7 +376,9 @@ function setupFooterUI(pi: ExtensionAPI, ctx: ExtensionContext, state: FooterSta
373
376
  if (!strip) return [];
374
377
  // Centered under the input box.
375
378
  const w = visibleWidth(strip);
376
- if (w >= width) return [truncateToWidth(strip, width)];
379
+ // Truncate one column short of the terminal (issue #31 — same wrap
380
+ // desync as the glance frame; see glanceFrameWidth()).
381
+ if (w >= width) return [truncateToWidth(strip, Math.max(1, width - 1))];
377
382
  const leftPad = Math.floor((width - w) / 2);
378
383
  return [" ".repeat(leftPad) + strip];
379
384
  },
@@ -55,7 +55,9 @@ export function countBgProcesses(): BgProcessCounts | null {
55
55
  * Returns [] when there is nothing to show.
56
56
  */
57
57
  export function renderProcessLine(width: number): string[] {
58
- if (width <= 0) return [];
58
+ // One column can never host a meaningful one-liner, and any content would
59
+ // be exactly-full-width (issue #31 wrap desync) — render nothing.
60
+ if (width <= 1) return [];
59
61
  const counts = countBgProcesses();
60
62
  if (!counts) return [];
61
63
 
@@ -68,7 +70,9 @@ export function renderProcessLine(width: number): string[] {
68
70
 
69
71
  const line = parts.join(" ");
70
72
  const w = visibleWidth(line);
71
- if (w >= width) return [truncateToWidth(line, width)];
73
+ // One column short of the terminal (issue #31 — same wrap desync as the
74
+ // glance frame; see glanceFrameWidth() in glance-editor.ts).
75
+ if (w >= width) return [truncateToWidth(line, Math.max(1, width - 1))];
72
76
  const leftPad = Math.floor((width - w) / 2);
73
77
  return [" ".repeat(leftPad) + line];
74
78
  }