@arhen/pi-core-subagent 1.0.1 → 1.0.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 +21 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arhen/pi-core-subagent",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "description": "pi extension: fast in-process subagents with single/parallel/chain, background runs, intercom and agent-to-agent mailbox. Leader defines agents inline.",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -385,8 +385,23 @@ class SubagentManager {
385
385
  private widgetTimer: ReturnType<typeof setTimeout> | undefined;
386
386
  private widgetRun: RunSnapshot | undefined;
387
387
 
388
+ turnActivity = false;
389
+
388
390
  constructor(private readonly pi: ExtensionAPI) {}
389
391
 
392
+ /** Hide the widget. Call on agent_start when the turn made no subagent calls. */
393
+ clearWidget(ctx: ExtensionContext): void {
394
+ this.widgetRun = undefined;
395
+ this.widgetTui = null;
396
+ if (ctx.hasUI) {
397
+ try {
398
+ ctx.ui.setWidget("subagents", undefined);
399
+ } catch {
400
+ /* ignore */
401
+ }
402
+ }
403
+ }
404
+
390
405
  listRuns(): RunSnapshot[] {
391
406
  return Array.from(this.runs.values()).sort((a, b) => b.createdAt - a.createdAt);
392
407
  }
@@ -812,6 +827,7 @@ class SubagentManager {
812
827
  task.roster = roster;
813
828
  }
814
829
  run.tasks.forEach((t) => (t.runId = run.id));
830
+ this.turnActivity = true;
815
831
  this.runs.set(run.id, run);
816
832
  this.settlers.set(run.id, () => {});
817
833
  this.runControllers.set(run.id, new AbortController());
@@ -1036,6 +1052,11 @@ export default function (pi: ExtensionAPI) {
1036
1052
  },
1037
1053
  });
1038
1054
 
1055
+ pi.on("agent_start", (_event, ctx) => {
1056
+ if (!manager.turnActivity) manager.clearWidget(ctx);
1057
+ manager.turnActivity = false;
1058
+ });
1059
+
1039
1060
  pi.on("session_start", async (_event, ctx) => {
1040
1061
  await manager.restoreFromSidecar(ctx);
1041
1062
  });