@pi-unipi/footer 2.17.0 → 2.17.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +14 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/footer",
3
- "version": "2.17.0",
3
+ "version": "2.17.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",
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;