@pi-unipi/footer 2.17.0 → 2.18.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/footer",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
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.17.0",
36
- "@pi-unipi/background-tasks": "2.17.0"
35
+ "@pi-unipi/core": "2.18.0",
36
+ "@pi-unipi/background-tasks": "2.18.0"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@earendil-works/pi-coding-agent": "^0.84.0",
@@ -40,7 +40,7 @@ export interface GlanceStatus {
40
40
  * `Fusion · <lead> <effort> ◆ <sidekick>` — lead lit, sidekick muted —
41
41
  * and the plain thinking slot is suppressed (efforts are inline).
42
42
  */
43
- fusion: { leadName: string; leadEffort: string; sidekickName: string; sidekickEffort: string; savedUsd?: number } | null;
43
+ fusion: { leadName: string; leadEffort: string; sidekickName: string; sidekickEffort: string; savedUsd?: number; busy?: boolean; leadToolCalls?: number; sidekickToolCalls?: number } | null;
44
44
  }
45
45
 
46
46
  const BORDER = {
@@ -57,6 +57,26 @@ const RESET = "\x1b[0m";
57
57
  const LEAD_FG = "\x1b[1m\x1b[38;2;181;189;104m"; // bold accent (matches success tint)
58
58
  const DIM_FG = "\x1b[38;2;120;124;134m"; // muted grey
59
59
 
60
+ type FusionDisplay = NonNullable<GlanceStatus["fusion"]>;
61
+
62
+ export function renderFusionStatus(fusion: FusionDisplay): string {
63
+ const lead = `${fusion.leadName}${fusion.leadEffort ? ` ${fusion.leadEffort}` : ""}`;
64
+ const side = `${fusion.sidekickName}${fusion.sidekickEffort ? ` ${fusion.sidekickEffort}` : ""}`;
65
+ const busy = fusion.busy === true;
66
+ const leadCalls = fusion.leadToolCalls ?? 0;
67
+ const sidekickCalls = fusion.sidekickToolCalls ?? 0;
68
+ const totalCalls = leadCalls + sidekickCalls;
69
+ const saved = fusion.savedUsd !== undefined && fusion.savedUsd > 0.005
70
+ ? ` · saved $${fusion.savedUsd.toFixed(2)}`
71
+ : "";
72
+ const split = totalCalls > 0 ? ` · ${String(sidekickCalls)}/${String(totalCalls)} calls` : "";
73
+ const core = busy
74
+ ? `${DIM_FG}Fusion · ${lead}${RESET} ${LEAD_FG}◆ ${side} · working${RESET}`
75
+ : `${LEAD_FG}Fusion · ${lead}${RESET} ${DIM_FG}◆ ${side}${RESET}`;
76
+ const tail = `${split}${saved}`;
77
+ return tail ? `${core}${DIM_FG}${tail}${RESET}` : core;
78
+ }
79
+
60
80
  /**
61
81
  * Every invisible sequence pi-tui embeds in editor lines: CSI SGR, OSC 133
62
82
  * prompt-zone markers (`\x1b]133;A\x07`), and CURSOR_MARKER (`\x1b_pi:c\x07`,
@@ -226,13 +246,7 @@ export class GlanceEditor extends CustomEditor {
226
246
  const winLabel = st.contextWindow > 0 ? `/${fmtTokens(st.contextWindow)}` : "";
227
247
  rightParts.push(`${pctLabel}${winLabel}`);
228
248
  if (st.fusion) {
229
- // The working lead is lit; the sidekick stays muted. Efforts are
230
- // inline so the separate thinking slot is dropped.
231
- const lead = `${st.fusion.leadName}${st.fusion.leadEffort ? ` ${st.fusion.leadEffort}` : ""}`;
232
- const side = `${st.fusion.sidekickName}${st.fusion.sidekickEffort ? ` ${st.fusion.sidekickEffort}` : ""}`;
233
- rightParts.push(
234
- `${LEAD_FG}Fusion · ${lead}${RESET} ${DIM_FG}◆ ${side}${st.fusion.savedUsd !== undefined && st.fusion.savedUsd > 0.005 ? ` · saved $${st.fusion.savedUsd.toFixed(2)}` : ""}${RESET}`,
235
- );
249
+ rightParts.push(renderFusionStatus(st.fusion));
236
250
  } else {
237
251
  if (st.modelName) rightParts.push(st.modelName);
238
252
  if (st.thinkingLevel && st.thinkingLevel !== "off") {
package/src/index.ts CHANGED
@@ -153,13 +153,10 @@ export default function footerExtension(pi: ExtensionAPI): void {
153
153
  // Glance-style input surface (pi-glance-inspired). Preserves all default
154
154
  // editor behavior via CustomEditor subclassing; only paint differs.
155
155
  //
156
- // FOCUS-SAFETY DEFERRAL: setEditorComponent() internally calls
157
- // ui.setFocus(newEditor). info-screen (loaded before us) opens its boot
158
- // dashboard during ITS session_start handler, so our session_start runs
159
- // while that overlay owns keyboard focus. Swapping now would steal focus
160
- // and strand the dashboard unclosable (q/Esc would type into the editor).
161
- // The boot overlay auto-closes after ~2s; we install after a grace period
162
- // longer than any sane bootTimeoutMs.
156
+ // FOCUS-SAFETY DEFERRAL: the timer remains a grace period for the boot
157
+ // dashboard, but installGlanceEditor also restores any overlay focus after
158
+ // setEditorComponent() calls ui.setFocus(newEditor). This covers the
159
+ // updater prompt too, so q/Esc cannot be stranded in the editor.
163
160
  state.glanceInstallTimer = setTimeout(() => installGlanceEditor(state, ctx), 3500);
164
161
 
165
162
  // Sync TPS cursor with persisted assistant messages so streaming-hook
@@ -420,6 +417,15 @@ function installGlanceEditor(
420
417
  ): void {
421
418
  if (st.glanceInstalled || !st.piContext || !st.glanceMode) return;
422
419
  try {
420
+ const tui = st.tuiRef as (import("@earendil-works/pi-tui").TUI & {
421
+ isOverlayFocused?: () => boolean;
422
+ getFocusedComponent?: () => import("@earendil-works/pi-tui").Component | null;
423
+ }) | null | undefined;
424
+ const overlayFocused = tui !== undefined && tui !== null
425
+ && (typeof tui.isOverlayFocused === "function" ? tui.isOverlayFocused() : tui.hasOverlay());
426
+ const overlayOwner = overlayFocused && typeof tui?.getFocusedComponent === "function"
427
+ ? tui.getFocusedComponent() ?? null
428
+ : null;
423
429
  const piCtx = st.piContext as Record<string, unknown> | undefined;
424
430
  const cwd = (piCtx?.sessionManager as any)?.getCwd?.() ?? (piCtx as any)?.cwd ?? process.cwd();
425
431
  const workspace = String(cwd).split("/").filter(Boolean).pop() ?? "~";
@@ -445,6 +451,7 @@ function installGlanceEditor(
445
451
  };
446
452
  }),
447
453
  );
454
+ if (overlayOwner && tui) tui.setFocus(overlayOwner);
448
455
  st.glanceInstalled = true;
449
456
  } catch {
450
457
  st.glanceInstalled = false;