@arhen/pi-core-subagent 1.0.5 → 1.0.7

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 +29 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arhen/pi-core-subagent",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
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
@@ -253,7 +253,7 @@ function compactLines(run: RunSnapshot): string[] {
253
253
  */
254
254
  class SubagentsWidget implements Component {
255
255
  constructor(
256
- private readonly getRun: () => RunSnapshot | undefined,
256
+ private readonly getRuns: () => RunSnapshot[],
257
257
  private readonly theme: Theme,
258
258
  ) {}
259
259
 
@@ -262,28 +262,33 @@ class SubagentsWidget implements Component {
262
262
  }
263
263
 
264
264
  render(width: number): string[] {
265
- const run = this.getRun();
266
- if (!run || run.tasks.length === 0) return [];
267
- const done = run.tasks.filter((t) => TERMINAL.includes(t.status)).length;
268
- const active = !TERMINAL.includes(run.status);
269
- const head = active ? "accent" : "dim";
270
- const lines = [truncateToWidth(`${this.theme.fg(head, active ? "●" : "○")} ${this.theme.fg(head, `Subagents (${done}/${run.tasks.length})`)}`, width, "")];
271
- const allDone = TERMINAL.includes(run.status);
272
- const visible = run.tasks.slice(0, MAX_TASKS);
273
- visible.forEach((task, i) => {
274
- const last = i === visible.length - 1 && run.tasks.length <= MAX_TASKS;
275
- const conn = this.theme.fg("dim", last ? "└─" : "├─");
276
- const activity =
277
- !TERMINAL.includes(task.status) && task.lastActivity
278
- ? `${this.theme.fg("dim", `→ ${task.lastActivity}`)} · `
279
- : "";
280
- // Completed run: dim everything except the agent name.
281
- const line = allDone
282
- ? `${this.theme.fg("dim", `${statusIcon(task.status)} `)}${task.agent} ${this.theme.fg("dim", `· ${taskStatsWithUsage(task)} · ${taskTimer(task)}`)}`
283
- : `${statusIcon(task.status)} ${task.agent} · ${activity}${taskStatsWithUsage(task)} · ${taskTimer(task)}`;
284
- lines.push(truncateToWidth(`${conn} ${line}`, width, "…"));
265
+ const runs = this.getRuns();
266
+ if (runs.length === 0) return [];
267
+ const lines: string[] = [];
268
+ runs.forEach((run, ri) => {
269
+ if (run.tasks.length === 0) return;
270
+ if (ri > 0) lines.push("");
271
+ const done = run.tasks.filter((t) => TERMINAL.includes(t.status)).length;
272
+ const active = !TERMINAL.includes(run.status);
273
+ const head = active ? "accent" : "dim";
274
+ lines.push(truncateToWidth(`${this.theme.fg(head, active ? "●" : "○")} ${this.theme.fg(head, `Subagents (${done}/${run.tasks.length})`)}`, width, "…"));
275
+ const allDone = TERMINAL.includes(run.status);
276
+ const visible = run.tasks.slice(0, MAX_TASKS);
277
+ visible.forEach((task, i) => {
278
+ const last = i === visible.length - 1 && run.tasks.length <= MAX_TASKS;
279
+ const conn = this.theme.fg("dim", last ? "└─" : "├─");
280
+ const activity =
281
+ !TERMINAL.includes(task.status) && task.lastActivity
282
+ ? `${this.theme.fg("dim", `→ ${task.lastActivity}`)} · `
283
+ : "";
284
+ // Finished run: dim everything except the agent name.
285
+ const line = allDone
286
+ ? `${this.theme.fg("dim", `${statusIcon(task.status)} `)}${task.agent} ${this.theme.fg("dim", `· ${taskStatsWithUsage(task)} · ${taskTimer(task)}`)}`
287
+ : `${statusIcon(task.status)} ${task.agent} · ${activity}${taskStatsWithUsage(task)} · ${taskTimer(task)}`;
288
+ lines.push(truncateToWidth(`${conn} ${line}`, width, "…"));
289
+ });
290
+ if (run.tasks.length > MAX_TASKS) lines.push(`${this.theme.fg("dim", "└─")} ${this.theme.fg("dim", `+${run.tasks.length - MAX_TASKS} more`)}`);
285
291
  });
286
- if (run.tasks.length > MAX_TASKS) lines.push(`${this.theme.fg("dim", "└─")} ${this.theme.fg("dim", `+${run.tasks.length - MAX_TASKS} more`)}`);
287
292
  return lines;
288
293
  }
289
294
  }
@@ -397,13 +402,14 @@ class SubagentManager {
397
402
  return false;
398
403
  }
399
404
 
400
- /** Hide the widget. */
405
+ /** Hide the widget + clear the footer status entry. */
401
406
  clearWidget(ctx: ExtensionContext): void {
402
407
  this.widgetRuns = [];
403
408
  this.widgetTui = null;
404
409
  if (ctx.hasUI) {
405
410
  try {
406
411
  ctx.ui.setWidget("subagents", undefined);
412
+ ctx.ui.setStatus("subagents", undefined);
407
413
  } catch {
408
414
  /* ignore */
409
415
  }