@ferris1225/pi-subagents 6.0.4 → 6.0.5

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.
@@ -1,10 +1,9 @@
1
1
  /** Run inspection, steering, completed-run follow-ups, and destructive cancellation. */
2
2
 
3
- import { randomUUID } from "node:crypto";
4
3
  import { copyFile, mkdir, mkdtemp, rm } from "node:fs/promises";
5
4
  import { basename, join } from "node:path";
6
5
  import type { Message } from "@earendil-works/pi-ai";
7
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
6
+ import type { ExtensionAPI, Theme } from "@earendil-works/pi-coding-agent";
8
7
  import { Text } from "@earendil-works/pi-tui";
9
8
  import { Type } from "typebox";
10
9
  import { DEFAULT_MAX_RESULT_LINES, loadConfig } from "../configuration/config.ts";
@@ -17,12 +16,12 @@ import { cancelActiveWork } from "./cancellation.ts";
17
16
  import { stopThreads } from "./stop.ts";
18
17
  import { formatCompletionBlock, matchRunIds } from "../presentation/format.ts";
19
18
  import { emptyUsage } from "../execution/run-control.ts";
20
- import { formatDuration, formatTaskSummary, monitor, runWaitLabel } from "../presentation/monitor.ts";
19
+ import { formatDuration, formatTaskSummary, monitor } from "../presentation/monitor.ts";
21
20
  import type { SubagentRuntime, SubagentThread } from "./runtime.ts";
22
21
  import { projectResultsRoot } from "./thread-shared.ts";
23
22
  import { getResultError } from "../execution/spawn.ts";
24
23
 
25
- function renderFirstLine(result: { content?: unknown }, label: string, theme: any): Text {
24
+ function renderFirstLine(result: { content?: unknown }, label: string, theme: Theme): Text {
26
25
  const parts = (result.content ?? []) as Array<{ type: string; text?: string }>;
27
26
  const text = parts
28
27
  .map((part) => (typeof part.text === "string" ? part.text : ""))
@@ -113,7 +112,6 @@ export function registerLookupTools(pi: ExtensionAPI, runtime: SubagentRuntime,
113
112
  executionCwd: thread.executionCwd,
114
113
  taskSummary: formatTaskSummary(thread.task, 80, false),
115
114
  state,
116
- waitReason: state === "queued" ? live?.waitReason : undefined,
117
115
  activity: live?.activity,
118
116
  recentActivity: live?.recentActivity ?? [],
119
117
  lastSteering: thread.lastSteering,
@@ -140,7 +138,7 @@ export function registerLookupTools(pi: ExtensionAPI, runtime: SubagentRuntime,
140
138
  const text = runs.length === 0
141
139
  ? params.id === undefined ? "No subagent runs in this parent session." : `No subagent run matches #${params.id}.`
142
140
  : runs.map((run) => {
143
- const wait = run.waitReason ? ` — ${runWaitLabel({ status: "queued", waitReason: run.waitReason })}` : "";
141
+ const wait = run.state === "queued" ? " — starting" : "";
144
142
  const lines = [`#${run.id} ${run.agent} · ${run.state} · ${formatDuration(run.elapsedMs)}${wait}`, ` task: ${run.taskSummary}`];
145
143
  if (run.isolationNote) lines.push(` isolation: ${run.isolationNote}`);
146
144
  if (run.lastSteering) lines.push(` last steering: ${run.lastSteering.disposition} · acknowledged ${formatDuration(Math.max(0, Date.now() - run.lastSteering.acknowledgedAt))} ago${run.lastSteering.requestId ? ` · request ${run.lastSteering.requestId}` : ""} · ${run.lastSteering.message}`);
@@ -191,13 +189,13 @@ export function registerLookupTools(pi: ExtensionAPI, runtime: SubagentRuntime,
191
189
  pi.registerTool({
192
190
  name: "subagent_message",
193
191
  label: "Subagent Message",
194
- description: "Send a steering message to a running subagent, or continue a successfully completed run. Omit context or use \"auto\" to reuse its retained session when available and otherwise start from a bounded summary, reporting the fallback. Use \"session\" only when full history is required; missing history is an error. Use \"summary\" for a new next step with only the earlier objective, result, and touched files. Session copies preserve history and the provider cache key; summary runs have neither. Use wait:true to receive a completed-run follow-up in this call; one-shot print/JSON sessions wait by default. Steering waits for the child RPC acknowledgement and reports queued, handled by an input hook, or accepted with queue state unknown. Receipt is not proof of model execution; status retains the latest acknowledgement.",
192
+ description: "Steer a running subagent, or continue a successfully completed run with a new bounded step in the same role and workspace. Steering waits for the child's RPC acknowledgement and reports queued, handled by an input hook, or accepted with queue state unknown; receipt is not proof of model execution, and status retains the latest acknowledgement. A continuation chooses its history with the context parameter. Use wait:true to receive its result in this call; one-shot print/JSON sessions wait by default.",
195
193
  exposure: "model-only",
196
194
  executionMode: "parallel",
197
195
  parameters: Type.Object({
198
196
  id: Type.Integer({ minimum: 1, description: "Exact run id in this parent session." }),
199
197
  message: Type.String({ minLength: 1, pattern: "\\S", description: "Additional instruction or follow-up question." }),
200
- context: Type.Optional(Type.String({ enum: ["auto", "session", "summary"], description: "auto (default) uses the retained session when available, otherwise a bounded summary and reports the fallback. session requires the full retained history and fails if unavailable. summary always starts fresh with the earlier objective, result, and touched files; no history or cache reuse." })),
198
+ context: Type.Optional(Type.String({ enum: ["auto", "session", "summary"], description: "Completed-run history. auto (default): continue a copy of the retained session when available, otherwise start from a bounded summary and report the fallback. session: require the full history, reusing the provider cache key; fails when unavailable. summary: start fresh with only the earlier objective, result, and touched files." })),
201
199
  wait: WaitSchema,
202
200
  }),
203
201
  async execute(_toolCallId, params, _signal, onUpdate, ctx) {
@@ -259,7 +257,7 @@ export function registerLookupTools(pi: ExtensionAPI, runtime: SubagentRuntime,
259
257
  if (thread.retired || thread.lifecycleOperation || thread.state !== "completed") throw new Error("The source run changed while the follow-up was prepared.");
260
258
  const selectedContext = copyDir ? "session" : "summary";
261
259
  const task = copyDir
262
- ? `Follow-up to run #${thread.id} (${randomUUID()}):\n${params.message}`
260
+ ? `Follow-up to run #${thread.id}:\n${params.message}`
263
261
  : buildSummaryFollowUp(thread, params.message);
264
262
  const wait = params.wait ?? (ctx.hasUI === false);
265
263
  const result = await dispatchCore.startBackground(thread.agentName, task, thread.cwd, thread.isolation, {
@@ -351,15 +349,12 @@ export function registerLookupTools(pi: ExtensionAPI, runtime: SubagentRuntime,
351
349
  }
352
350
 
353
351
  const { stopped, retainedIntegration, pendingIntegration, completionResults } = await stopThreads(runtime, targets);
354
- if (completionResults.length > 0) {
355
- runtime.sendCompletionGroup(completionResults.map((result) => ({
356
- agent: result.agent,
357
- block: formatCompletionBlock(result, DEFAULT_MAX_RESULT_LINES, { resultRoot: projectResultsRoot(runtime.configPath, result.projectCwd ?? ctx.cwd) }),
358
- triggerTurn: true,
359
- usage: result.usage,
360
- })));
361
- runtime.completionBatcher.flush();
362
- }
352
+ runtime.sendCompletionGroup(completionResults.map((result) => ({
353
+ agent: result.agent,
354
+ block: formatCompletionBlock(result, DEFAULT_MAX_RESULT_LINES, { resultRoot: projectResultsRoot(runtime.configPath, result.projectCwd ?? ctx.cwd) }),
355
+ usage: result.usage,
356
+ model: result.model,
357
+ })));
363
358
  return {
364
359
  content: [{
365
360
  type: "text",
@@ -1,30 +1,32 @@
1
1
  /** Session-start recovery, stale-model cleanup, and progress-surface installation. */
2
2
 
3
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
4
4
  import { loadConfig, saveConfig } from "../configuration/config.ts";
5
- import { availableModelsInScope, filterUnavailableModelOverrides } from "../configuration/models.ts";
5
+ import { filterUnavailableModelOverrides } from "../configuration/models.ts";
6
6
  import { ensureDefaultConfig } from "../configuration/setup.ts";
7
7
  import { announceRecoveryRecords, relocateRecoveryManifest } from "../isolation/recovery.ts";
8
8
  import type { SubagentRuntime } from "../lifecycle/runtime.ts";
9
9
  import { installActiveRunsWidget } from "./widget.ts";
10
10
 
11
- /** Drop unavailable model overrides back to dynamic main-model routing. */
11
+ /** Drop overrides that no authenticated model serves back to dynamic
12
+ * main-model routing. A session model scope only narrows this session's
13
+ * routing, so it never deletes a persisted override. */
12
14
  async function removeUnavailableAgentModels(
13
- ctx: { ui: { notify: (message: string, kind: "info" | "warning" | "error") => void } } & Parameters<typeof availableModelsInScope>[0],
15
+ ctx: Pick<ExtensionContext, "ui" | "modelRegistry">,
14
16
  runtime: SubagentRuntime,
15
17
  ): Promise<void> {
16
18
  try {
17
19
  const config = await loadConfig(runtime.configPath);
18
20
  const overrides = Object.entries(config.agentModels);
19
21
  if (overrides.length === 0) return;
20
- const { kept, dropped } = filterUnavailableModelOverrides(config.agentModels, availableModelsInScope(ctx));
22
+ const { kept, dropped } = filterUnavailableModelOverrides(config.agentModels, ctx.modelRegistry.getAvailable());
21
23
  const rewritten = JSON.stringify(kept) !== JSON.stringify(config.agentModels);
22
24
  if (!rewritten && dropped.length === 0) return;
23
25
  await saveConfig({ ...config, agentModels: kept }, runtime.configPath);
24
26
  if (dropped.length === 0) return;
25
27
  const list = dropped.map(({ agent, ref }) => `${agent}: ${ref}`).join(", ");
26
28
  ctx.ui.notify(
27
- `pi-subagents: removed stale agent model overrides that are no longer available (${list}). Those agents now use their role's default model route; run /subagents-setup to re-pick.`,
29
+ `pi-subagents: removed model overrides that are no longer available (${list}). Those roles now follow the main model; run /subagents-setup to choose another.`,
28
30
  "warning",
29
31
  );
30
32
  } catch {
@@ -4,15 +4,15 @@
4
4
  * and run-id matching.
5
5
  */
6
6
 
7
+ import { readFileSync } from "node:fs";
7
8
  import type { AgentConfig } from "../delegation/agents.ts";
8
9
  import { formatUsageCompact, runLabel, shrinkRunLabel } from "./monitor.ts";
9
10
  import { emptyUsage } from "../execution/run-control.ts";
10
11
  import {
11
- RESULT_LINE_MAX,
12
12
  getResultError,
13
13
  getResultOutput,
14
14
  isFailedResult,
15
- truncateResultOutput,
15
+ isModelLevelFailure,
16
16
  writeResultArtifact,
17
17
  type SingleResult,
18
18
  type UsageStats,
@@ -73,6 +73,34 @@ export interface CompletionFormatOptions {
73
73
  * tight enough to stay a hint rather than a second copy of the task. */
74
74
  const COMPLETION_LABEL_MAX = 24;
75
75
 
76
+ /** Characters of one full line in the inline budget of a completion block. */
77
+ export const RESULT_LINE_CHARS = 200;
78
+
79
+ /** The result's existing artifact when it already holds exactly this output.
80
+ * Results derived from a delivered one (a crash or stop wrapper) carry its path
81
+ * but different text, so they get their own file. */
82
+ function reusableArtifact(result: SingleResult, output: string): string | undefined {
83
+ if (!result.resultFile) return undefined;
84
+ try {
85
+ return readFileSync(result.resultFile, "utf8") === output ? result.resultFile : undefined;
86
+ } catch {
87
+ return undefined;
88
+ }
89
+ }
90
+
91
+ /** How an answer exceeds the inline budget of `maxLines` lines and the
92
+ * characters of that many full lines; undefined when it fits. Long prose lines
93
+ * fit, so only an oversized answer moves to its result file. */
94
+ function inlineOverflow(output: string, maxLines: number): string | undefined {
95
+ const lineCount = output.split("\n").length;
96
+ const maxChars = maxLines * RESULT_LINE_CHARS;
97
+ const overflow = [
98
+ lineCount > maxLines ? `${lineCount} lines` : undefined,
99
+ output.length > maxChars ? `${output.length} characters` : undefined,
100
+ ].filter(Boolean);
101
+ return overflow.length > 0 ? overflow.join(" · ") : undefined;
102
+ }
103
+
76
104
  export function formatCompletionBlock(
77
105
  result: SingleResult,
78
106
  maxResultLines: number,
@@ -83,7 +111,7 @@ export function formatCompletionBlock(
83
111
  const status = failed ? "failed" : "completed";
84
112
  const usage = formatUsage(result.usage);
85
113
  const output = getResultOutput(result);
86
- const { text, truncated, shownLines, totalLines, widthClipped } = truncateResultOutput(output, maxResultLines);
114
+ const overflow = inlineOverflow(output, maxResultLines);
87
115
  const fallbackNote = result.modelFallbackFrom
88
116
  ? ` (selected model ${result.modelFallbackFrom} failed → main ${result.model ?? "dynamic default"})`
89
117
  : "";
@@ -114,7 +142,7 @@ export function formatCompletionBlock(
114
142
  lines.push("");
115
143
  }
116
144
  if (result.isolationNote) lines.push(`Isolation: ${result.isolationNote}`, "");
117
- if (!truncated) lines.push(text);
145
+ if (!overflow) lines.push(output);
118
146
  // Failed-tool diagnostics ride along only when the run itself failed: they
119
147
  // explain the failure, while on a successful run a transient failed call
120
148
  // (no-match grep, rejected edit) is noise the agent already worked around.
@@ -125,28 +153,25 @@ export function formatCompletionBlock(
125
153
  ...failedTools.map((tool) => `- ${tool.toolName}: ${tool.error.trim() || "(no output)"}`),
126
154
  );
127
155
  }
128
- if (truncated) {
156
+ if (overflow) {
129
157
  // No inline copy at all: a truncated dump reads as complete while
130
158
  // hiding the rest, and the parent re-reads the full text from the file
131
159
  // anyway, paying for the same content twice. The notice only routes it.
132
- const artifact = options.resultRoot
133
- ? writeResultArtifact(output, result.agent, options.resultRoot)
134
- : "(result root unavailable)";
160
+ // Every delivery of the same result names one artifact.
161
+ const artifact = reusableArtifact(result, output)
162
+ ?? (options.resultRoot ? writeResultArtifact(output, result.agent, options.resultRoot) : "(result root unavailable)");
135
163
  if (options.resultRoot) result.resultFile = artifact;
136
- const loss = [
137
- shownLines < totalLines ? `${totalLines} lines` : undefined,
138
- widthClipped ? `lines wider than ${RESULT_LINE_MAX} characters` : undefined,
139
- ].filter(Boolean).join(" · ");
140
164
  lines.push(
141
165
  "",
142
- `⚠ The child's answer (${loss}) is not inlined here, so it is delivered exactly once. Read the complete result file \`${artifact}\`; it holds the full, untruncated output.`,
166
+ `⚠ The child's answer (${overflow}) is not inlined here, so it is delivered exactly once. Read the complete result file \`${artifact}\`; it holds the full, untruncated output.`,
143
167
  );
144
168
  }
169
+ if (failed && isModelLevelFailure(result)) lines.push("", modelLevelTakeoverNote(result));
145
170
  return lines.join("\n");
146
171
  }
147
172
 
148
173
  /** A terminal model failure hands the unfinished task to main, not another run. */
149
- export function modelLevelTakeoverNote(result: SingleResult): string {
174
+ function modelLevelTakeoverNote(result: SingleResult): string {
150
175
  const retry = result.modelFallbackFrom ? ", and the current main model also failed" : "";
151
176
  const cause = getResultError(result) ?? "its model was unavailable or failed";
152
177
  return `The sub-agent could not complete this task: ${cause}${retry}. Earlier edits and any retained result/session artifacts remain available. Main must inspect that work and finish with its own tools; do not re-dispatch this phase.`;
@@ -19,10 +19,8 @@ import type { IsolationMode, WorktreeFinalizationStatus } from "../isolation/wor
19
19
  // Types
20
20
  // ---------------------------------------------------------------------------
21
21
 
22
- export type RunStatus = "queued" | "running" | "interrupting" | "parked" | "done" | "failed";
23
-
24
22
  /** A queued run is preparing its child process; execution has no capacity wait. */
25
- export type RunWaitReason = "starting";
23
+ export type RunStatus = "queued" | "running" | "interrupting" | "parked" | "done" | "failed";
26
24
 
27
25
  export function isRunActiveStatus(status: RunStatus): boolean {
28
26
  return status === "queued" || status === "running" || status === "interrupting";
@@ -42,16 +40,12 @@ export interface RunView {
42
40
  * are doing, not just by their run id. */
43
41
  label?: string;
44
42
  model?: string;
45
- /** Selected model ref when the run handed off to current main. */
46
- modelFallbackFrom?: string;
47
43
  /** Effective thinking strength this run was launched with (setup override or role default). */
48
44
  thinking?: string;
49
45
  isolation?: IsolationMode;
50
46
  integrationStatus?: RunIntegrationStatus;
51
47
  worktreeId?: string;
52
48
  status: RunStatus;
53
- /** What a queued run is actually waiting for; see RunWaitReason. */
54
- waitReason?: RunWaitReason;
55
49
  usage: UsageStats;
56
50
  /** Concise current activity ("thinking", "read src/index.ts"); last writer wins. */
57
51
  activity?: string;
@@ -68,13 +62,6 @@ export interface RunView {
68
62
  endedAt?: number;
69
63
  }
70
64
 
71
- export interface RunChainMeta {
72
- isolation?: IsolationMode;
73
- worktreeId?: string;
74
- /** Initial startup state before the child emits activity. */
75
- waitReason?: RunWaitReason;
76
- }
77
-
78
65
  // ---------------------------------------------------------------------------
79
66
  // Formatting helpers
80
67
  // ---------------------------------------------------------------------------
@@ -288,7 +275,7 @@ function usageCostPart(usage: UsageStats | undefined): string | undefined {
288
275
  return usage?.cost ? `$${usage.cost.toFixed(4)}` : undefined;
289
276
  }
290
277
 
291
- /** Aggregate usage across several runs (chain steps or a completion group). */
278
+ /** Aggregate usage across the runs of a completion group. */
292
279
  export function sumUsage(parts: readonly UsageStats[]): UsageStats {
293
280
  const total: UsageStats = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 };
294
281
  for (const part of parts) {
@@ -308,7 +295,7 @@ export function formatDuration(ms: number): string {
308
295
  if (totalSeconds < 60) return `${totalSeconds}s`;
309
296
  const minutes = Math.floor(totalSeconds / 60);
310
297
  const seconds = totalSeconds % 60;
311
- // Seconds stay visible at every magnitude: a long-running chain is judged
298
+ // Seconds stay visible at every magnitude: a long-running run is judged
312
299
  // by whether it is still moving, and "5s ago" is exactly that signal.
313
300
  if (minutes < 60) return `${minutes}m${String(seconds).padStart(2, "0")}s`;
314
301
  const hours = Math.floor(minutes / 60);
@@ -481,7 +468,7 @@ export class MonitorStore {
481
468
  this.notify();
482
469
  }
483
470
 
484
- addRun(agent: string, task: string, model?: string, thinking?: string, meta?: RunChainMeta): number {
471
+ addRun(agent: string, task: string, model?: string, thinking?: string, isolation?: IsolationMode): number {
485
472
  const id = this.reserveRunId();
486
473
  this.runs.push({
487
474
  id,
@@ -491,10 +478,9 @@ export class MonitorStore {
491
478
  model,
492
479
  thinking,
493
480
  status: "queued",
494
- waitReason: meta?.waitReason ?? "starting",
495
481
  usage: emptyUsage(),
496
482
  elapsedMs: 0,
497
- ...(meta?.isolation ? { isolation: meta.isolation, integrationStatus: meta.isolation === "worktree" ? "pending" : undefined, ...(meta.worktreeId ? { worktreeId: meta.worktreeId } : {}) } : {}),
483
+ ...(isolation ? { isolation, integrationStatus: isolation === "worktree" ? "pending" : undefined } : {}),
498
484
  });
499
485
  this.notify();
500
486
  return id;
@@ -508,7 +494,6 @@ export class MonitorStore {
508
494
  const isExecuting = status === "running" || status === "interrupting";
509
495
  const now = Date.now();
510
496
  run.status = status;
511
- if (status !== "queued") run.waitReason = undefined;
512
497
  if (isExecuting && !wasExecuting) {
513
498
  run.startedAt ??= now;
514
499
  run.activeSince = now;
@@ -522,15 +507,6 @@ export class MonitorStore {
522
507
  }
523
508
  this.notify();
524
509
  }
525
- /** Record what a still-queued run is actually waiting for, at the exact
526
- * transition owned by the caller (lane wait begins, child process starts). */
527
- setWaitReason(id: number, waitReason: RunWaitReason): void {
528
- const run = this.find(id);
529
- if (!run || run.status !== "queued" || run.waitReason === waitReason) return;
530
- run.waitReason = waitReason;
531
- this.notify();
532
- }
533
-
534
510
  setUsage(id: number, usage: UsageStats, model?: string): void {
535
511
  const run = this.find(id);
536
512
  if (!run) return;
@@ -539,12 +515,11 @@ export class MonitorStore {
539
515
  this.notify();
540
516
  }
541
517
 
542
- /** Record the final actual model and selected-to-main transition. */
543
- setModel(id: number, model?: string, fallbackFrom?: string): void {
518
+ /** Record the model of the current attempt. */
519
+ setModel(id: number, model?: string): void {
544
520
  const run = this.find(id);
545
- if (!run) return;
546
- if (model) run.model = model;
547
- run.modelFallbackFrom = fallbackFrom;
521
+ if (!run || !model) return;
522
+ run.model = model;
548
523
  this.notify();
549
524
  }
550
525
 
@@ -707,21 +682,16 @@ export function statusIcon(status: RunStatus, theme: Theme): string {
707
682
  export function statusLabel(status: RunStatus): string {
708
683
  switch (status) {
709
684
  case "queued":
710
- return "queued";
685
+ return "starting";
711
686
  case "running":
712
687
  return "running";
713
688
  case "interrupting":
714
689
  return "interrupting";
715
690
  case "parked":
716
- return "parked";
691
+ return "interrupted";
717
692
  case "done":
718
693
  return "done";
719
694
  case "failed":
720
695
  return "stopped";
721
696
  }
722
697
  }
723
-
724
- /** Startup label for runs that have not emitted activity yet. */
725
- export function runWaitLabel(run: Pick<RunView, "status" | "waitReason">): string | undefined {
726
- return run.status === "queued" ? "starting" : undefined;
727
- }
@@ -11,10 +11,6 @@ const SUBAGENTS_WIDGET_ID = "pi-subagents";
11
11
  const MAX_WIDGET_LINES = 10;
12
12
  const SEPARATOR = " · ";
13
13
 
14
- function waitWord(run: Pick<RunView, "waitReason">): string {
15
- return run.waitReason === "starting" ? "starting" : "queued";
16
- }
17
-
18
14
  function worktreeBadge(run: RunView): string | undefined {
19
15
  if (run.isolation !== "worktree") return undefined;
20
16
  const state = run.integrationStatus;
@@ -55,7 +51,7 @@ function detailLine(activity: string | undefined, run: RunView | undefined, them
55
51
  }
56
52
 
57
53
  function runRow(run: RunView, theme: Theme, width: number, now: number): TaskRow {
58
- const state = run.status === "queued" ? waitWord(run) : run.integrationStatus === "finalizing" ? "applying" : run.status;
54
+ const state = run.status === "queued" ? "starting" : run.integrationStatus === "finalizing" ? "applying" : run.status;
59
55
  const label = run.label ?? formatTaskSummary(run.task, Math.max(1, width - 18));
60
56
  const narrowState = width < 60 && (run.status === "queued" || run.integrationStatus === "finalizing") ? " · " + state : "";
61
57
  const identity = statusIcon(run.status, theme) + " " + theme.fg("dim", "#" + run.id) + " " + run.agent + narrowState + " · " + label;
@@ -72,10 +68,9 @@ function runRow(run: RunView, theme: Theme, width: number, now: number): TaskRow
72
68
  function rowCost(row: TaskRow): number { return 1 + Number(Boolean(row.requiredDetail && row.detail)); }
73
69
 
74
70
  /** Select identities before optional details. Overflow describes only hidden work. */
75
- function renderBoard(rows: TaskRow[], theme: Theme, width: number, overview?: string): string[] {
76
- if (width <= 0 || !rows.length) return [];
71
+ function renderBoard(rows: TaskRow[], theme: Theme, width: number, overview: string): string[] {
77
72
  const totalCost = rows.reduce((cost, row) => cost + rowCost(row), 0);
78
- const lines = overview ? [overview] : [];
73
+ const lines = [overview];
79
74
  const capacity = MAX_WIDGET_LINES - lines.length - Number(totalCost + lines.length > MAX_WIDGET_LINES);
80
75
  const selected = new Set<TaskRow>();
81
76
  let used = 0;
@@ -102,11 +97,6 @@ function renderBoard(rows: TaskRow[], theme: Theme, width: number, overview?: st
102
97
  return lines.map((line) => truncateToWidth(line, width, "…"));
103
98
  }
104
99
 
105
- export function formatActiveRunLines(runs: readonly RunView[], theme: Theme, width: number, now = Date.now()): string[] {
106
- const rows = runs.filter((run) => isRunActiveStatus(run.status)).map((run) => runRow(run, theme, width, now));
107
- return rows.length ? renderBoard(rows, theme, width) : [];
108
- }
109
-
110
100
  export function formatSubagentWidgetLines(
111
101
  runs: readonly RunView[], theme: Theme, width: number, now = Date.now(),
112
102
  ): string[] {
@@ -117,7 +107,7 @@ export function formatSubagentWidgetLines(
117
107
  const states = new Map<string, number>();
118
108
  for (const row of rows) states.set(row.state, (states.get(row.state) ?? 0) + 1);
119
109
  const counts = ["failed", "interrupting", "running", "queued"]
120
- .filter((state) => states.has(state)).map((state) => states.get(state) + " " + state);
110
+ .filter((state) => states.has(state)).map((state) => states.get(state) + " " + (state === "queued" ? "starting" : state));
121
111
  const overview = theme.bold("Subagents") + theme.fg("dim", " " + counts.join(SEPARATOR));
122
112
  return renderBoard(rows, theme, width, overview);
123
113
  }