pi-tui-status-beautifier 1.6.0 → 1.7.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.
@@ -14,8 +14,12 @@ const COMMON_NAMES: Record<string, string> = {
14
14
  "pi-control-chrome": "chrome",
15
15
  chrome: "chrome",
16
16
  toolflow: "toolflow",
17
+ anchor: "anchor",
18
+ "pi-anchor": "anchor",
17
19
  };
18
20
 
21
+ const SPINNERS = ["◐", "◓", "◑", "◒"] as const;
22
+
19
23
  export interface CustomStyleConfig {
20
24
  prefix?: string;
21
25
  suffix?: string;
@@ -292,9 +296,32 @@ export function beautifyStatus(
292
296
 
293
297
  // 4. Determine state glyph & indicator
294
298
  const glyphMap = preset.glyphs || {};
295
- let glyph =
296
- glyphMap[state] ||
297
- (state === "warning" ? "◌" : state === "error" ? "▲" : state === "accent" ? "◆" : "●");
299
+ let defaultGlyph =
300
+ name === "anchor"
301
+ ? "⌖"
302
+ : name === "toolflow"
303
+ ? "⌬"
304
+ : state === "warning"
305
+ ? "◌"
306
+ : state === "error"
307
+ ? "▲"
308
+ : state === "accent"
309
+ ? "◆"
310
+ : "●";
311
+
312
+ // Dynamic micro-spinner for active in-progress / running states (running, working, starting, waiting)
313
+ if (
314
+ valLower.includes("running") ||
315
+ valLower.includes("working") ||
316
+ valLower.includes("starting") ||
317
+ valLower.includes("waiting") ||
318
+ valLower.includes("...")
319
+ ) {
320
+ const spinnerChar = SPINNERS[Math.floor(Date.now() / 300) % SPINNERS.length];
321
+ defaultGlyph = spinnerChar;
322
+ }
323
+
324
+ let glyph = glyphMap[state] || defaultGlyph;
298
325
 
299
326
  const hasThemeFg = theme && typeof theme.fg === "function";
300
327
  const coloredGlyph = hasThemeFg ? theme.fg(state, glyph) : glyph;
@@ -440,6 +467,58 @@ export function padToVisualWidth(str: string, targetWidth: number, padChar = " "
440
467
  return str + padChar.repeat(targetWidth - currentWidth);
441
468
  }
442
469
 
470
+ /**
471
+ * Formats multiple status badges with adaptive folding for narrow terminals (< 80 columns)
472
+ */
473
+ export function formatFoldedBadges(
474
+ rawBadges: Array<{ key: string; val: string; rendered: string; isHighPriority: boolean }>,
475
+ maxWidth: number,
476
+ theme: any
477
+ ): string {
478
+ const fullStr = rawBadges.map(b => b.rendered).join(" ");
479
+ if (getStringWidth(fullStr) <= maxWidth || rawBadges.length <= 2) {
480
+ return fullStr;
481
+ }
482
+
483
+ // Narrow terminal overflow: partition high priority from idle/ready badges
484
+ const highPriority = rawBadges.filter(b => b.isHighPriority);
485
+ const lowPriority = rawBadges.filter(b => !b.isHighPriority);
486
+
487
+ const foldBadge = (count: number) => {
488
+ const text = `(+${count} idle)`;
489
+ return theme && typeof theme.fg === "function" ? theme.fg("dim", text) : text;
490
+ };
491
+
492
+ if (highPriority.length === 0) {
493
+ let current = "";
494
+ let shown = 0;
495
+ for (const b of lowPriority) {
496
+ const candidate = (current ? current + " " : "") + b.rendered;
497
+ const withFold = candidate + " " + foldBadge(lowPriority.length - shown - 1);
498
+ if (getStringWidth(withFold) <= maxWidth) {
499
+ current = candidate;
500
+ shown++;
501
+ } else {
502
+ break;
503
+ }
504
+ }
505
+ if (shown < lowPriority.length) {
506
+ const remaining = lowPriority.length - shown;
507
+ return current ? `${current} ${foldBadge(remaining)}` : foldBadge(remaining);
508
+ }
509
+ return current;
510
+ }
511
+
512
+ const highStr = highPriority.map(b => b.rendered).join(" ");
513
+ if (lowPriority.length > 0) {
514
+ const withFold = highStr + " " + foldBadge(lowPriority.length);
515
+ if (getStringWidth(withFold) <= maxWidth) {
516
+ return withFold;
517
+ }
518
+ }
519
+ return highStr;
520
+ }
521
+
443
522
  /**
444
523
  * Full-Footer Renderer (Hooked via ctx.ui.setFooter)
445
524
  * Formats working folder, Git branch, token metrics, and active model on Line 1,
@@ -564,11 +643,24 @@ export function renderBeautifiedFooter(
564
643
  }
565
644
 
566
645
  if (extStatuses.length > 0) {
567
- const badges = extStatuses
568
- .map(([k, v]) => beautifyStatus(k, v, theme, style, customCfg))
569
- .filter(Boolean) as string[];
570
- if (badges.length > 0) {
571
- lines.push(badges.join(" "));
646
+ const rawBadges = extStatuses
647
+ .map(([k, v]) => {
648
+ const rendered = beautifyStatus(k, v, theme, style, customCfg);
649
+ if (!rendered) return null;
650
+ const valLower = (v || "").toLowerCase();
651
+ const isHigh =
652
+ valLower.includes("error") ||
653
+ valLower.includes("fail") ||
654
+ valLower.includes("warn") ||
655
+ valLower.includes("running") ||
656
+ valLower.includes("active") ||
657
+ valLower.includes("starting");
658
+ return { key: k, val: v, rendered, isHighPriority: isHigh };
659
+ })
660
+ .filter(Boolean) as Array<{ key: string; val: string; rendered: string; isHighPriority: boolean }>;
661
+
662
+ if (rawBadges.length > 0) {
663
+ lines.push(formatFoldedBadges(rawBadges, width - 2, theme));
572
664
  }
573
665
  }
574
666
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-tui-status-beautifier",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Minimalist status bar formatter & AI-customizable layout engine for Pi TUI.",
5
5
  "main": "extensions/tui-status-beautifier.ts",
6
6
  "keywords": [