@pi-unipi/footer 2.19.1 → 2.19.3

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 +3 -3
  2. package/src/index.ts +22 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/footer",
3
- "version": "2.19.1",
3
+ "version": "2.19.3",
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.19.1",
36
- "@pi-unipi/background-tasks": "2.19.1"
35
+ "@pi-unipi/core": "2.19.3",
36
+ "@pi-unipi/background-tasks": "2.19.3"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@earendil-works/pi-coding-agent": "^0.84.0",
package/src/index.ts CHANGED
@@ -451,6 +451,28 @@ function installGlanceEditor(
451
451
  };
452
452
  }),
453
453
  );
454
+ // setCustomEditorComponent detaches the previous editor, but any open
455
+ // overlay captured it as its preFocus restore target — closing the overlay
456
+ // would refocus a dead component and swallow all input. Right after the
457
+ // swap, getFocusedComponent() is the new editor; retarget stale preFocus
458
+ // entries to it (skip preFocus that points at a live overlay).
459
+ const newEditor = typeof tui?.getFocusedComponent === "function" ? tui.getFocusedComponent() : null;
460
+ const internals = tui as ({
461
+ overlayStack?: Array<{ component?: unknown; preFocus?: unknown }>;
462
+ isComponentMounted?: (c: unknown) => boolean;
463
+ }) | null | undefined;
464
+ const overlayStack = internals?.overlayStack;
465
+ const isMounted = typeof internals?.isComponentMounted === "function"
466
+ ? internals.isComponentMounted.bind(tui)
467
+ : undefined;
468
+ if (newEditor && overlayStack && isMounted) {
469
+ const overlayComponents = new Set(overlayStack.map((entry) => entry.component));
470
+ for (const entry of overlayStack) {
471
+ if (entry.preFocus && entry.preFocus !== newEditor && !overlayComponents.has(entry.preFocus) && !isMounted(entry.preFocus)) {
472
+ entry.preFocus = newEditor;
473
+ }
474
+ }
475
+ }
454
476
  if (overlayOwner && tui) tui.setFocus(overlayOwner);
455
477
  st.glanceInstalled = true;
456
478
  } catch {