pi-better-subagents 0.19.0 → 0.19.1

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/index.ts CHANGED
@@ -572,7 +572,15 @@ function syncWidgetNavSelection(running: RunMeta[]): void {
572
572
  */
573
573
  function renderWidget(): void {
574
574
  const ctx = uiCtx;
575
- if (!ctx || !ctx.hasUI) return;
575
+ if (!ctx) return;
576
+ // A run can exit after Pi replaced the session that captured this ctx; Pi then throws on any
577
+ // property read. That session's UI is gone, so drop the ctx instead of failing the finalizer.
578
+ try {
579
+ if (!ctx.hasUI) return;
580
+ } catch {
581
+ if (uiCtx === ctx) uiCtx = undefined;
582
+ return;
583
+ }
576
584
  updateNavigatorFooter(ctx);
577
585
  try { ctx.ui.setWidget("subagents", WIDGET_CLEAR); } catch { /* ignore */ }
578
586
  spendCache.clear();
@@ -1847,7 +1855,9 @@ export default function (pi: ExtensionAPI) {
1847
1855
  const snapshot = taskRuntime ? takeRecoverySnapshot(taskRuntime.policy.permissions) : undefined;
1848
1856
  if (snapshot?.started) {
1849
1857
  void snapshot.done.then((outcome) => {
1850
- if (!outcome.ok) ctx.ui?.notify?.(`Subagent ${id}: recovery snapshot failed (run continues): ${outcome.detail}`, "warning");
1858
+ if (outcome.ok) return;
1859
+ // The snapshot can finish after the session was replaced and ctx went stale.
1860
+ try { ctx.ui?.notify?.(`Subagent ${id}: recovery snapshot failed (run continues): ${outcome.detail}`, "warning"); } catch { /* ignore */ }
1851
1861
  });
1852
1862
  }
1853
1863
  const cmd = taskRuntime ? { file: taskRuntime.file, fileArgs: [...taskRuntime.fileArgs, ...args] } : { file: piBin, fileArgs: args };
@@ -2497,6 +2507,9 @@ export default function (pi: ExtensionAPI) {
2497
2507
  // running/orphaned children before dropping the session origin, so they
2498
2508
  // cannot become live process groups with no coordinator.
2499
2509
  stopCurrentSessionSubagents(ctx);
2510
+ // The stopped children exit after this handler returns; their finalizers
2511
+ // must not reach for a ctx that Pi invalidates once the session is replaced.
2512
+ uiCtx = undefined;
2500
2513
  agentSessionSettings.clear();
2501
2514
  catalogModelRegistry = undefined;
2502
2515
  activeCallbackOrigin = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-subagents",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "description": "Pi extension for detached, sandboxed subagent runs that keep the foreground session free.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -174,8 +174,9 @@ export function isNavigatorUiAvailable(ctx: ExtensionContext | undefined): boole
174
174
  }
175
175
  }
176
176
 
177
- export function navigatorFooterHint(count: number): string | null {
178
- return count > 0 ? `← work · ${count}` : null;
177
+ export function navigatorFooterHint(_count: number): string | null {
178
+ // Retain the compatibility helper so refresh/reload clears any old badge.
179
+ return null;
179
180
  }
180
181
 
181
182
  export function applyNavigatorFooter(ui: { setStatus(key: string, value: string | undefined): void }, count: number): string | null {