@hheei/pi-subagents 0.5.0 → 0.5.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.
package/dist/extension.js CHANGED
@@ -1,4 +1,4 @@
1
- import { errorMessage, getBackgroundDelivery, registerExtensionLifecycle, } from "@hheei/pi-ext-core";
1
+ import { createRenderThrottle, errorMessage, getBackgroundDelivery, registerExtensionLifecycle, } from "@hheei/pi-ext-core";
2
2
  import { discoverAgents } from "./agent-resolver.js";
3
3
  import { registerChildBridge } from "./child-bridge.js";
4
4
  import { registerParentCommands } from "./commands.js";
@@ -302,7 +302,10 @@ export default function piSubagentsExtension(pi) {
302
302
  registerParentCommands(pi, manager);
303
303
  const status = createSubagentStatus(context.ui, runtime.signal);
304
304
  let refreshVersion = 0;
305
- const refreshStatus = () => {
305
+ // The manager notifies on every lifecycle transition, and each notification costs an async
306
+ // list plus a full footer rebuild. The footer follows the shared streaming window instead;
307
+ // the first change still paints immediately and the last state is never dropped.
308
+ const repaintStatus = createRenderThrottle(() => {
306
309
  if (runtime.signal.aborted)
307
310
  return;
308
311
  const version = ++refreshVersion;
@@ -314,11 +317,13 @@ export default function piSubagentsExtension(pi) {
314
317
  status.refresh(children);
315
318
  })
316
319
  .catch((error) => diagnose(`Subagent status failed: ${errorMessage(error)}`));
317
- };
320
+ });
321
+ const refreshStatus = () => repaintStatus.request();
318
322
  const unsubscribe = manager.onChange(refreshStatus);
319
323
  refreshStatus();
320
324
  runtime.resources.add("subagent-status", () => {
321
325
  unsubscribe();
326
+ repaintStatus.dispose();
322
327
  status.dispose();
323
328
  });
324
329
  runtime.resources.add("subagent-manager", () => manager.closeLocalConnections());
@@ -36,6 +36,8 @@ export interface HostObservation {
36
36
  readonly identity: HostAttachmentIdentity;
37
37
  readonly alive: boolean;
38
38
  readonly known: boolean;
39
+ /** True when the underlying host container (tab, pane, or surface) no longer exists. */
40
+ readonly containerGone?: boolean;
39
41
  /**
40
42
  * Whether a human is looking at this panel. Absent when the host cannot say, which includes
41
43
  * both hosts without the capability and a lookup that failed just now; the caller must treat
@@ -138,10 +138,13 @@ export function createHerdrHostAdapter(options) {
138
138
  const listed = herdrListingSucceeded(tabs) && herdrListingSucceeded(workspaces)
139
139
  ? herdrPanelFocused(tabs.stdout, workspaces.stdout, target.tabId)
140
140
  : undefined;
141
+ const code = herdrErrorCode(process.stderr) ?? herdrErrorCode(process.stdout);
142
+ const containerGone = code === "pane_not_found" || code === "tab_not_found";
141
143
  const alive = herdrPaneAlive(process);
142
144
  return {
143
145
  process,
144
146
  ...(alive === undefined ? {} : { alive }),
147
+ ...(containerGone ? { containerGone: true } : {}),
145
148
  ...(listed === undefined ? {} : { focused: listed }),
146
149
  };
147
150
  },
@@ -187,7 +190,12 @@ export function createCmuxHostAdapter(options) {
187
190
  const process = await runner.run("cmux", ["--json", "list-panels"], { timeoutMs });
188
191
  if (process.timedOut || process.exitCode !== 0)
189
192
  return { process };
190
- return { process, alive: containsString(process.stdout, attachmentId) };
193
+ const alive = containsString(process.stdout, attachmentId);
194
+ return {
195
+ process,
196
+ alive,
197
+ ...(!alive ? { containerGone: true } : {}),
198
+ };
191
199
  },
192
200
  close: () => runner.run("cmux", ["--json", "close-surface", "--surface", attachmentId], {
193
201
  timeoutMs,
@@ -207,6 +215,7 @@ function hostAttachment(options) {
207
215
  // the caller drop the panel and the runtime evidence, so it is only ever said on purpose.
208
216
  alive: result.alive === true,
209
217
  known: result.alive !== undefined,
218
+ ...(result.containerGone ? { containerGone: true } : {}),
210
219
  ...(focused === undefined ? {} : { focused }),
211
220
  detail: result.process.stderr || result.process.stdout,
212
221
  };
package/dist/runtime.js CHANGED
@@ -154,11 +154,22 @@ export async function openChildPanel(options) {
154
154
  const combinedSignal = options.signal
155
155
  ? AbortSignal.any([options.signal, earlyExitAbort.signal])
156
156
  : earlyExitAbort.signal;
157
+ let childAppeared = false;
157
158
  let earlyExitObserved;
158
159
  const probeInterval = setInterval(async () => {
159
160
  try {
160
161
  const obs = await attachment.observe();
161
- if (obs.known && !obs.alive) {
162
+ if (!obs.known)
163
+ return;
164
+ if (obs.containerGone) {
165
+ earlyExitObserved = obs;
166
+ earlyExitAbort.abort();
167
+ return;
168
+ }
169
+ if (obs.alive) {
170
+ childAppeared = true;
171
+ }
172
+ else if (childAppeared) {
162
173
  earlyExitObserved = obs;
163
174
  earlyExitAbort.abort();
164
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hheei/pi-subagents",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Independent background Pi subagent sessions with durable identity and RPC control.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -35,7 +35,7 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@hheei/pi-ext-core": "^0.6.0"
38
+ "@hheei/pi-ext-core": "^0.6.1"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@earendil-works/pi-coding-agent": ">=1.3.0",