@xzzpig/pi-subagents 0.19.0 → 0.21.0

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 (153) hide show
  1. package/CHANGELOG.md +214 -0
  2. package/README.md +1 -1
  3. package/agents/oracle.md +8 -19
  4. package/agents/researcher.md +0 -3
  5. package/agents/reviewer.md +17 -61
  6. package/agents/scout.md +1 -4
  7. package/agents/worker.md +8 -25
  8. package/docs/agents.md +86 -11
  9. package/docs/configuration.md +68 -7
  10. package/docs/extension-api.md +37 -12
  11. package/docs/fork-extensions.md +1 -0
  12. package/docs/missions.md +48 -17
  13. package/docs/models.md +7 -3
  14. package/docs/observability.md +18 -8
  15. package/docs/tool-reference.md +138 -80
  16. package/docs/watchdog.md +8 -6
  17. package/docs/workflows.md +18 -9
  18. package/index.ts +5 -0
  19. package/package.json +5 -3
  20. package/prompts/council.md +1 -1
  21. package/skills/pi-subagents/SKILL.md +1 -1
  22. package/skills/pi-subagents/references/constraints-and-recipes.md +1 -1
  23. package/skills/pi-subagents/references/execution-controls.md +16 -16
  24. package/skills/pi-subagents/references/management-authoring-rpc.md +16 -12
  25. package/skills/pi-subagents/references/prompting-and-roles.md +3 -3
  26. package/src/agents/advertised-agent-prompt.ts +9 -1
  27. package/src/agents/agent-management.ts +4 -0
  28. package/src/agents/agent-memory.ts +3 -3
  29. package/src/agents/agent-scope.ts +4 -0
  30. package/src/agents/agent-serializer.ts +8 -1
  31. package/src/agents/agents.ts +224 -122
  32. package/src/api/preflight.ts +50 -5
  33. package/src/extension/config.ts +24 -2
  34. package/src/extension/context-injection.ts +6 -1
  35. package/src/extension/control-notices.ts +1 -9
  36. package/src/extension/declaration-pinning.ts +164 -0
  37. package/src/extension/doctor.ts +7 -10
  38. package/src/extension/fanout-child.ts +7 -8
  39. package/src/extension/index.ts +134 -145
  40. package/src/extension/public-execution.ts +3 -0
  41. package/src/extension/reply-workflow-script.ts +21 -12
  42. package/src/extension/rpc.ts +12 -7
  43. package/src/extension/schemas.ts +39 -33
  44. package/src/extension/subagent-guide.ts +86 -6
  45. package/src/extension/subagent-options.ts +47 -0
  46. package/src/extension/tool-activation.ts +3 -2
  47. package/src/extension/tool-description.ts +51 -68
  48. package/src/inspectors/actions.ts +37 -11
  49. package/src/inspectors/plugins.ts +3 -2
  50. package/src/inspectors/tmux/actions.ts +204 -0
  51. package/src/inspectors/tmux/client.ts +85 -0
  52. package/src/inspectors/tmux/plugin.ts +21 -0
  53. package/src/integrations/herdr-status.ts +18 -49
  54. package/src/integrations/program-status.ts +215 -0
  55. package/src/intercom/native-supervisor-channel.ts +77 -4
  56. package/src/intercom/result-intercom.ts +3 -2
  57. package/src/intercom/supervisor-ui.ts +2 -174
  58. package/src/missions/goal-driver.ts +44 -31
  59. package/src/missions/store.ts +35 -6
  60. package/src/profiles/profiles.ts +29 -23
  61. package/src/runs/background/active-async-capacity.ts +58 -8
  62. package/src/runs/background/async-execution.ts +231 -44
  63. package/src/runs/background/async-job-tracker.ts +12 -4
  64. package/src/runs/background/async-resume.ts +5 -2
  65. package/src/runs/background/await-async-run.ts +18 -11
  66. package/src/runs/background/binary-bootstrap.ts +2 -1
  67. package/src/runs/background/calendar-schedule.ts +90 -0
  68. package/src/runs/background/chain-root-attachment.ts +9 -5
  69. package/src/runs/background/control-channel.ts +43 -0
  70. package/src/runs/background/fleet-view.ts +5 -5
  71. package/src/runs/background/notify.ts +185 -12
  72. package/src/runs/background/result-files.ts +116 -5
  73. package/src/runs/background/result-watcher.ts +99 -66
  74. package/src/runs/background/resume-guidance.ts +2 -2
  75. package/src/runs/background/run-child-session.ts +29 -8
  76. package/src/runs/background/run-id-resolver.ts +8 -5
  77. package/src/runs/background/run-status.ts +21 -16
  78. package/src/runs/background/runner-aliases.ts +7 -4
  79. package/src/runs/background/runner-child-launch.ts +1 -0
  80. package/src/runs/background/runner-http-dispatcher.ts +3 -0
  81. package/src/runs/background/scheduled-runs.ts +282 -72
  82. package/src/runs/background/stale-run-reconciler.ts +13 -2
  83. package/src/runs/background/subagent-runner-bootstrap.ts +4 -1
  84. package/src/runs/background/subagent-runner.ts +75 -16
  85. package/src/runs/background/subagent-wait.ts +38 -19
  86. package/src/runs/background/terminal-run-index.ts +46 -1
  87. package/src/runs/background/wait-completions.ts +1 -0
  88. package/src/runs/background/wait-tool.ts +33 -23
  89. package/src/runs/background/workflow-terminal-proof.ts +39 -22
  90. package/src/runs/foreground/async-stop-action.ts +48 -22
  91. package/src/runs/foreground/command-action.ts +41 -0
  92. package/src/runs/foreground/execution.ts +109 -58
  93. package/src/runs/foreground/foreground-history.ts +1 -0
  94. package/src/runs/foreground/subagent-executor.ts +270 -89
  95. package/src/runs/shared/child-commands.ts +229 -0
  96. package/src/runs/shared/child-hooks.ts +4 -3
  97. package/src/runs/shared/child-launch.ts +3 -0
  98. package/src/runs/shared/child-session.ts +131 -40
  99. package/src/runs/shared/child-tool-plan.ts +14 -27
  100. package/src/runs/shared/claude-code-adapter.ts +157 -2
  101. package/src/runs/shared/dynamic-fanout.ts +2 -2
  102. package/src/runs/shared/external-cli-preflight.ts +54 -6
  103. package/src/runs/shared/external-cli-runner.ts +5 -1
  104. package/src/runs/shared/fork-command-result.ts +10 -0
  105. package/src/runs/shared/herdr-placed-run.ts +5 -4
  106. package/src/runs/shared/mcp-direct-tool-allowlist.ts +8 -5
  107. package/src/runs/shared/model-resolution-diagnostic.ts +25 -0
  108. package/src/runs/shared/model-resolution.ts +39 -2
  109. package/src/runs/shared/nested-events.ts +5 -0
  110. package/src/runs/shared/parallel-handoff.ts +56 -8
  111. package/src/runs/shared/parallel-utils.ts +4 -0
  112. package/src/runs/shared/partial-output.ts +48 -0
  113. package/src/runs/shared/run-history.ts +87 -0
  114. package/src/runs/shared/runner-launcher.ts +25 -0
  115. package/src/runs/shared/single-output.ts +53 -0
  116. package/src/runs/shared/structured-output.ts +14 -7
  117. package/src/runs/shared/subagent-control.ts +33 -18
  118. package/src/runs/shared/subagent-prompt-runtime.ts +59 -30
  119. package/src/runs/shared/workflow-async-child-guidance.ts +1 -1
  120. package/src/runs/shared/worktree-cleanup-apply.ts +160 -0
  121. package/src/runs/shared/worktree-cleanup-plan.ts +41 -19
  122. package/src/runs/shared/worktree-lock.ts +29 -0
  123. package/src/runs/shared/worktree.ts +12 -1
  124. package/src/shared/atomic-json.ts +4 -2
  125. package/src/shared/edit-distance.ts +33 -0
  126. package/src/shared/file-lease.ts +74 -0
  127. package/src/shared/formatters.ts +1 -5
  128. package/src/shared/model-info.ts +22 -0
  129. package/src/shared/package-version.ts +17 -0
  130. package/src/shared/parent-wake.ts +79 -0
  131. package/src/shared/pruned-fork.ts +7 -1
  132. package/src/shared/required-child-extensions.ts +39 -5
  133. package/src/shared/runtime-module-path.ts +19 -0
  134. package/src/shared/settings-file-lease.ts +36 -0
  135. package/src/shared/types.ts +42 -3
  136. package/src/shared/utils.ts +8 -6
  137. package/src/slash/slash-commands.ts +3 -3
  138. package/src/slash/subagent-cost.ts +9 -5
  139. package/src/slash/subagents-admin.ts +2 -1
  140. package/src/tui/fleet-native-transcript.ts +2 -0
  141. package/src/tui/fleet-transcript.ts +12 -3
  142. package/src/tui/fleet.ts +11 -8
  143. package/src/tui/render.ts +28 -20
  144. package/src/tui/subagent-messages.ts +305 -0
  145. package/src/watchdog/diff-tool.ts +2 -2
  146. package/src/watchdog/register-main.ts +2 -22
  147. package/src/watchdog/render.ts +2 -24
  148. package/src/watchdog/runtime.ts +6 -4
  149. package/src/watchdog/settings.ts +18 -13
  150. package/src/watchdog/tool-actions.ts +2 -2
  151. package/src/workflows/scripted-workflow.ts +20 -6
  152. package/src/workflows/workflow-receipt.ts +2 -2
  153. package/src/workflows/workflow-resources.ts +18 -4
@@ -455,6 +455,8 @@ export interface ParallelHandoffLaneBinding {
455
455
  }
456
456
 
457
457
  export interface ParallelHandoffCleanupTask {
458
+ /** Canonical parent recorded when the worktree was created; missing proof keeps old trees. */
459
+ recordedBaseDir?: string;
458
460
  index: number;
459
461
  path: string;
460
462
  branch: string;
@@ -838,6 +840,8 @@ export interface SteeringRecoveryDescriptor {
838
840
  sessionFile?: string;
839
841
  /** Git ref used to allocate managed worktrees for this run. */
840
842
  baseRef?: string;
843
+ /** Launcher name the run was wrapped with; resume re-reads its argv from current user config. Absence means unwrapped. */
844
+ launcher?: string;
841
845
  cwd: string;
842
846
  model?: string;
843
847
  modelProvider?: string;
@@ -914,6 +918,8 @@ export interface SubagentResultIntercomChild {
914
918
  status: SubagentResultStatus;
915
919
  /** Whether the child produced substantive output before its process ended. */
916
920
  outputState?: SubagentOutputState;
921
+ /** True when the output is unfinished streamed text recovered after a timeout or child error. */
922
+ outputPartial?: boolean;
917
923
  summary: string;
918
924
  index?: number;
919
925
  artifactPath?: string;
@@ -1277,6 +1283,8 @@ export interface SingleResult {
1277
1283
  index: number;
1278
1284
  /** Workflow child key that owns this result when returned from workflow details. */
1279
1285
  workflowKey?: string;
1286
+ /** Workflow child run id that produced this result; resumed rounds share a session file but not a run id. */
1287
+ runId?: string;
1280
1288
  agent: string;
1281
1289
  task: string;
1282
1290
  /** Human-readable display name for the child's own session (agent + task
@@ -1333,6 +1341,8 @@ export interface SingleResult {
1333
1341
  finalOutput?: string;
1334
1342
  /** Provenance-aware state for substantive child output, excluding synthetic lifecycle messages. */
1335
1343
  outputState?: SubagentOutputState;
1344
+ /** True when the output is unfinished streamed text recovered after a timeout or child error. */
1345
+ outputPartial?: boolean;
1336
1346
  outputMode?: OutputMode;
1337
1347
  savedOutputPath?: string;
1338
1348
  outputReference?: SavedOutputReference;
@@ -1390,6 +1400,8 @@ export interface WaitCompletionChild {
1390
1400
  sessionFile?: string;
1391
1401
  success?: boolean;
1392
1402
  outputState?: SubagentOutputState;
1403
+ /** True when the output is unfinished streamed text recovered after a timeout or child error. */
1404
+ outputPartial?: boolean;
1393
1405
  structuredOutput?: unknown;
1394
1406
  structuredOutputPath?: string;
1395
1407
  error?: string;
@@ -1439,6 +1451,7 @@ export interface AgentCapabilityRow {
1439
1451
  }
1440
1452
 
1441
1453
  export interface Details {
1454
+ commands?: import("../runs/shared/child-commands.ts").ChildCommandSnapshot[];
1442
1455
  mode: SubagentResultMode | "management";
1443
1456
  workflowReceiptPath?: string;
1444
1457
  runId?: string;
@@ -1462,8 +1475,8 @@ export interface Details {
1462
1475
  activeRunIds: string[];
1463
1476
  activeProviderItems: Array<{ provider: string; id: string }>;
1464
1477
  } | {
1465
- /** Non-terminal internal auto-drain yield; tracked work remains active. */
1466
- reason: "supervisor_request";
1478
+ /** Non-terminal yield for a supervisor request or a user message; tracked work remains active. */
1479
+ reason: "supervisor_request" | "user_input";
1467
1480
  timedOut: false;
1468
1481
  activeRunIds: string[];
1469
1482
  activeProviderItems: Array<{ provider: string; id: string }>;
@@ -1936,6 +1949,8 @@ export interface AsyncStatus {
1936
1949
  /** Linux PID namespace identity used to scope liveness probes. */
1937
1950
  pidNamespaceScope?: string;
1938
1951
  cwd?: string;
1952
+ /** User-configured launcher that wrapped the background runner (argv only, never environment). */
1953
+ launcher?: RunnerLauncher;
1939
1954
  /** Parent-resolved child session root retained for trusted restored transcript lookup. */
1940
1955
  sessionRoot?: string;
1941
1956
  currentStep?: number;
@@ -2163,6 +2178,8 @@ export interface ForegroundResumeChild {
2163
2178
  error?: string;
2164
2179
  finalOutput?: string;
2165
2180
  outputState?: SubagentOutputState;
2181
+ /** True when the output is unfinished streamed text recovered after a timeout or child error. */
2182
+ outputPartial?: boolean;
2166
2183
  outputMode?: OutputMode;
2167
2184
  savedOutputPath?: string;
2168
2185
  outputSaveError?: string;
@@ -2293,6 +2310,8 @@ export interface ForegroundRunControl {
2293
2310
  interrupt?: () => boolean;
2294
2311
  detach?: () => boolean;
2295
2312
  steer?: ForegroundChildControl["steer"];
2313
+ /** Set while a detached child runs: records it as stopped, then aborts it, when this runtime is replaced. */
2314
+ stopForRuntimeReplacement?: () => void;
2296
2315
  }
2297
2316
 
2298
2317
  export interface WaitSubscriptionRecord {
@@ -2433,6 +2452,13 @@ export const INTERCOM_DETACH_RESPONSE_EVENT = "pi-intercom:detach-response";
2433
2452
  /** pi-intercom asks each session for a fixed intercom ID at session start; `claim(id)` answers synchronously. */
2434
2453
  export const INTERCOM_SESSION_IDENTITY_EVENT = "intercom:session-identity";
2435
2454
  export const SUBAGENT_ASYNC_STARTED_EVENT = "subagent:async-started";
2455
+ /** Launcher names are plain identifiers so they survive frontmatter rewrites without quoting. */
2456
+ export const RUNNER_LAUNCHER_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u;
2457
+ export const RUNNER_LAUNCHER_NAME_RULE = "must start with a letter or digit and use only letters, digits, '.', '_' or '-' (at most 128 characters)";
2458
+ export interface RunnerLauncher {
2459
+ name: string;
2460
+ argv: string[];
2461
+ }
2436
2462
  export const SUBAGENT_ASYNC_COMPLETE_EVENT = "subagent:async-complete";
2437
2463
  export const SUBAGENT_PROCESS_TERMINAL_EVENT = "subagent:process-terminal";
2438
2464
  export const SUBAGENT_FOREGROUND_COMPLETE_EVENT = "subagent:foreground-complete";
@@ -2469,6 +2495,8 @@ export interface SubagentChildStatusEvent {
2469
2495
  export interface ForegroundChildSessionControls {
2470
2496
  steer: (text: string) => Promise<void>;
2471
2497
  followUp: (text: string) => Promise<void>;
2498
+ /** Abort the live child and report the run as stopped with `reason`. */
2499
+ stop: (reason: string) => void;
2472
2500
  }
2473
2501
 
2474
2502
  export interface RunSyncOptions {
@@ -2486,6 +2514,8 @@ export interface RunSyncOptions {
2486
2514
  permissions?: import("../runs/shared/permissions.ts").PermissionConfig;
2487
2515
  /** Session id of the direct parent session for permission-system ask forwarding. */
2488
2516
  parentSessionId?: string;
2517
+ /** The parent session's file, recorded as a new child session's `parentSession` header. */
2518
+ parentSessionFile?: string;
2489
2519
  /** Resolved launch context for this child. */
2490
2520
  context?: "fresh" | "fork";
2491
2521
  cwd?: string;
@@ -2636,6 +2666,7 @@ export interface ScheduledRunsConfig {
2636
2666
  }
2637
2667
 
2638
2668
  export type FleetViewPlacement = "aboveEditor" | "belowEditor";
2669
+ export type AsyncWidgetLayout = "adaptive" | "rows";
2639
2670
 
2640
2671
  export const FLEET_KEYBINDING_ACTIONS = [
2641
2672
  "close",
@@ -2699,8 +2730,16 @@ export interface ExtensionConfig {
2699
2730
  fleetKeybindings?: FleetKeybindingsConfig;
2700
2731
  /** Show the under-editor async runs widget. Defaults to true, including when FleetView is enabled. */
2701
2732
  asyncWidget?: boolean;
2733
+ /** Start the under-editor async runs widget folded. Defaults to false. */
2734
+ asyncWidgetCollapsed?: boolean;
2735
+ /** Unfolded async runs widget layout: "adaptive" fits run details to the terminal height, "rows" shows one line per run. Defaults to "adaptive". */
2736
+ asyncWidgetLayout?: AsyncWidgetLayout;
2737
+ /** Report subagent run state to the terminal with OSC 7501. Defaults to true. */
2738
+ programStatus?: boolean;
2702
2739
  /** Exact provider/model candidates mapped to operator-declared equivalent response IDs. Empty arrays add no accepted IDs. */
2703
2740
  modelResponseAliases?: Record<string, string[]>;
2741
+ /** Named argv prefixes for background runners; agents select one with `launcher: <name>`. User config only. */
2742
+ runnerLaunchers?: Record<string, string[]>;
2704
2743
  /** Tool description variant registered for the parent-facing subagent tool. Defaults to split metadata. */
2705
2744
  toolDescriptionMode?: ToolDescriptionMode;
2706
2745
  /** How a new parent session offers the subagent tool. Defaults to auto. */
@@ -2892,7 +2931,7 @@ export const POLL_INTERVAL_MS = 250;
2892
2931
  export const WIDGET_ANIMATION_INTERVAL_MS = 1000;
2893
2932
  export const MAX_WIDGET_JOBS = 4;
2894
2933
  export const DEFAULT_SUBAGENT_MAX_DEPTH = 2;
2895
- export const SUBAGENT_ACTIONS = ["list", "get", "models", "children.list", "guide", "validate", "create", "update", "delete", "eject", "disable", "enable", "reset", "mission.create", "mission.list", "mission.show", "mission.update", "mission.resolve-decision", "mission.attach-run", "mission.close", "worktree.discard", "worktree.cleanup", "lane.status", "lane.recordMerge", "lane.recordSupersession", "refine", "refine.show", "refine.rollback", "inspector.open", "inspector.command", "inspector.status", "inspector.close", "project.open", "project.status", "project.close", "status", "debug.run", "grant-spawn-budget", "interrupt", "resume", "steer", "stop", "dismiss", "doctor", "watchdog.status", "watchdog.check", "watchdog.configure", "watchdog.recommend-model", "schedule.create", "schedule.list", "schedule.show", "schedule.history", "schedule.pause", "schedule.resume", "schedule.run", "schedule.run-due", "schedule.delete"] as const;
2934
+ export const SUBAGENT_ACTIONS = ["list", "get", "models", "children.list", "guide", "validate", "create", "update", "delete", "eject", "disable", "enable", "reset", "mission.create", "mission.list", "mission.show", "mission.update", "mission.resolve-decision", "mission.attach-run", "mission.close", "worktree.discard", "worktree.cleanup", "lane.status", "lane.recordMerge", "lane.recordSupersession", "refine", "refine.show", "refine.rollback", "inspector.open", "inspector.command", "inspector.status", "inspector.close", "project.open", "project.status", "project.close", "status", "debug.run", "grant-spawn-budget", "interrupt", "resume", "steer", "stop", "command.status", "command.yield", "command.cancel", "dismiss", "doctor", "watchdog.status", "watchdog.check", "watchdog.configure", "watchdog.recommend-model", "schedule.create", "schedule.list", "schedule.show", "schedule.history", "schedule.pause", "schedule.resume", "schedule.run", "schedule.run-due", "schedule.delete"] as const;
2896
2935
 
2897
2936
  export const DEFAULT_FORK_PREAMBLE =
2898
2937
  "You are a delegated subagent running from a fork of the parent session. " +
@@ -321,12 +321,14 @@ function compactCompletedProgress(progress: AgentProgress): AgentProgress {
321
321
  };
322
322
  }
323
323
 
324
- function extractToolCallSummaries(messages: Message[] | undefined): ToolCallSummary[] {
325
- if (!messages?.length) return [];
324
+ /** Summaries of the latest `limit` tool calls, in chronological order; older calls are never read. */
325
+ function extractToolCallSummaries(messages: Message[] | undefined, limit = Infinity): ToolCallSummary[] {
326
326
  const summaries: ToolCallSummary[] = [];
327
- for (const msg of messages) {
327
+ for (let i = (messages?.length ?? 0) - 1; i >= 0 && summaries.length < limit; i--) {
328
+ const msg = messages![i]!;
328
329
  if (msg.role !== "assistant") continue;
329
- for (const part of msg.content) {
330
+ for (let j = msg.content.length - 1; j >= 0 && summaries.length < limit; j--) {
331
+ const part = msg.content[j]!;
330
332
  if (part.type !== "toolCall") continue;
331
333
  const args = typeof part.arguments === "object" && part.arguments !== null && !Array.isArray(part.arguments)
332
334
  ? part.arguments
@@ -337,7 +339,7 @@ function extractToolCallSummaries(messages: Message[] | undefined): ToolCallSumm
337
339
  });
338
340
  }
339
341
  }
340
- return summaries;
342
+ return summaries.reverse();
341
343
  }
342
344
 
343
345
  export function sumResultsUsage(results: SingleResult[]): Usage {
@@ -448,7 +450,7 @@ export function boundStreamedRecentOutput(recentOutput: string[]): string[] {
448
450
  * derives one from `messages`; bounded to the most recent calls.
449
451
  */
450
452
  export function boundStreamedToolCalls(result: Pick<SingleResult, "toolCalls" | "messages">): ToolCallSummary[] | undefined {
451
- const summaries = result.toolCalls?.length ? result.toolCalls : extractToolCallSummaries(result.messages);
453
+ const summaries = result.toolCalls?.length ? result.toolCalls : extractToolCallSummaries(result.messages, MAX_STREAMED_TOOL_CALLS);
452
454
  if (!summaries.length) return undefined;
453
455
  return summaries.slice(-MAX_STREAMED_TOOL_CALLS).map((summary) => ({ ...summary }));
454
456
  }
@@ -620,7 +620,7 @@ export function registerSlashCommands(
620
620
  };
621
621
  const showFleet = async (ctx: ExtensionContext) => {
622
622
  state.lastUiContext = ctx;
623
- if (!ctx.hasUI) {
623
+ if (ctx.mode !== "tui") {
624
624
  await runCommand(ctx, { action: "status", view: "fleet" });
625
625
  return;
626
626
  }
@@ -700,7 +700,7 @@ export function registerSlashCommands(
700
700
  description: "Host integration bridge: answer an async child inspection request with a correlated widget payload (no model turn)",
701
701
  handler: async (args, ctx) => {
702
702
  if (ctx.mode === "tui") {
703
- ctx.ui.notify("Inspection replies are emitted only on RPC surfaces. Use /subagents or subagent({ action: \"status\", view: \"transcript\" }) interactively.", "info");
703
+ ctx.ui.notify("Inspection replies are emitted only on RPC surfaces. Use /subagents or subagent({ action: \"status\", options: { view: \"transcript\" } }) interactively.", "info");
704
704
  return;
705
705
  }
706
706
  if (!ctx.hasUI) return;
@@ -803,7 +803,7 @@ export function registerSlashCommands(
803
803
  ctx.ui.notify(message, "error");
804
804
  return;
805
805
  }
806
- if (!ctx.hasUI) {
806
+ if (ctx.mode !== "tui") {
807
807
  sendSlashText(pi, stopFallbackText(targets));
808
808
  return;
809
809
  }
@@ -3,7 +3,7 @@ import * as path from "node:path";
3
3
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
4
4
  import { getArtifactPaths, getArtifactsDir } from "../shared/artifacts.ts";
5
5
  import { formatTokens } from "../shared/formatters.ts";
6
- import { DIRS, SLASH_RESULT_TYPE, type Details, type SingleResult, type SubagentState, type Usage } from "../shared/types.ts";
6
+ import { DIRS, SLASH_RESULT_TYPE, type Details, type SubagentState, type Usage } from "../shared/types.ts";
7
7
  import { readStatus } from "../shared/utils.ts";
8
8
  import { readWorkflowReceipt } from "../workflows/workflow-receipt.ts";
9
9
  import { resolveSlashMessageDetails } from "./slash-live-state.ts";
@@ -187,12 +187,12 @@ export function collectSubagentCost(
187
187
  if (parentUsage) addUsage(parent, parentUsage);
188
188
  const details = detailsFromSessionEntry(entry);
189
189
  if (!details) continue;
190
- if (details.mode === "workflow" && details.runId) workflowRunIds.add(details.runId);
190
+ // Only async workflows persist a receipt file; foreground workflow child usage is already in results.
191
+ if (details.mode === "workflow" && details.runId && details.asyncId) workflowRunIds.add(details.runId);
191
192
  // An async launch result has no child results; its usage lands in run artifacts.
192
193
  else if (details.asyncId && details.results.length === 0) asyncRunIds.add(details.asyncId);
193
194
  for (const result of details.results) {
194
- const resultRunId = (result as SingleResult & { runId?: unknown }).runId;
195
- addChild({ agent: result.agent, runId: typeof resultRunId === "string" ? resultRunId : undefined, usage: usageFromValue(result.usage), sessionFile: result.sessionFile });
195
+ addChild({ agent: result.agent, runId: typeof result.runId === "string" ? result.runId : undefined, usage: usageFromValue(result.usage), sessionFile: result.sessionFile });
196
196
  }
197
197
  for (const completion of details.completions ?? []) {
198
198
  if (completion.mode === "workflow") workflowRunIds.add(completion.runId);
@@ -248,7 +248,11 @@ export function collectSubagentCost(
248
248
  if (!usage || !addChild({ ...ref, usage })) unresolvedAsyncChildren += 1;
249
249
  }
250
250
  } catch (error) {
251
- if ((error as NodeJS.ErrnoException).code !== "ENOENT") console.error(`Failed to resolve async subagent usage for '${workflowRunId}':`, error);
251
+ // Without a receipt, a bg_wait completion cannot prove it reported every child (a stopped workflow may omit one).
252
+ unresolvedAsyncChildren += 1;
253
+ // A running workflow has no receipt yet; readWorkflowReceipt keeps the ENOENT as its cause.
254
+ const missing = (error as NodeJS.ErrnoException).code === "ENOENT" || ((error as Error).cause as NodeJS.ErrnoException | undefined)?.code === "ENOENT";
255
+ if (!missing) console.error(`Failed to resolve async subagent usage for '${workflowRunId}':`, error);
252
256
  }
253
257
  }
254
258
 
@@ -230,7 +230,8 @@ function metadataFor(agent: AgentConfig): string {
230
230
 
231
231
  async function selectFromList(ctx: ExtensionContext, title: string, subtitle: string | undefined, items: SelectorItem[]): Promise<string | undefined> {
232
232
  markAdminDialogSilent();
233
- if (typeof ctx.ui.custom === "function") {
233
+ // RPC mode defines ui.custom as a no-op that resolves undefined, so only TUI can show the component.
234
+ if (ctx.mode === "tui" && typeof ctx.ui.custom === "function") {
234
235
  const result = await ctx.ui.custom<SelectorResult>(
235
236
  (tui, theme, kb, done) => new SelectorComponent(tui, theme, kb, { title, subtitle, items, done }),
236
237
  { overlay: false },
@@ -84,6 +84,7 @@ export interface NativeFleetBuildInput {
84
84
  }
85
85
 
86
86
  export interface NativeFleetBuildResult {
87
+ readFailed?: true;
87
88
  lines: string[];
88
89
  conversationState: string;
89
90
  truncated: boolean;
@@ -370,6 +371,7 @@ export function buildNativeFleetTranscript(
370
371
  truncated: read.truncated,
371
372
  ...(read.warning ? { warning: read.warning } : {}),
372
373
  entryCount: 0,
374
+ ...(read.readFailed ? { readFailed: true } : {}),
373
375
  };
374
376
  }
375
377
 
@@ -58,6 +58,8 @@ export interface FleetTranscript {
58
58
  events: FleetTranscriptEvent[];
59
59
  truncated: boolean;
60
60
  warning?: string;
61
+ /** The path was refused or the file could not be read, as opposed to a read that only skipped records. */
62
+ readFailed?: true;
61
63
  }
62
64
 
63
65
  export interface FleetTranscriptReadOptions {
@@ -323,8 +325,12 @@ function parseTranscriptLines(lines: string[], conversationStarted = false): { e
323
325
  }
324
326
  if (role === "assistant") {
325
327
  assistantSeen = true;
328
+ // The transcript writer records the assistant message's provider-local id, which can itself contain a slash.
329
+ const rawModel = stringValue(record.model) ?? stringValue(message?.model);
330
+ const provider = stringValue(message?.provider);
331
+ const model = rawModel && provider ? `${provider}/${rawModel}` : rawModel;
326
332
  if (text) appendTextEvent(events, "assistant", text, {
327
- ...(stringValue(record.model) ? { model: stringValue(record.model) } : {}),
333
+ ...(model ? { model } : {}),
328
334
  ...(timestamp !== undefined ? { timestamp } : {}),
329
335
  });
330
336
  continue;
@@ -343,7 +349,7 @@ function parseTranscriptLines(lines: string[], conversationStarted = false): { e
343
349
  export function readFleetTranscript(filePath: string, options: FleetTranscriptReadOptions): FleetTranscript {
344
350
  const validated = validateTranscriptPath(filePath, options.trustedRoots, options.trustedFiles, options.trustedFileRoot);
345
351
  if (!validated.resolvedPath) {
346
- return { path: filePath, events: [], truncated: false, ...(validated.warning ? { warning: safeDisplayText(validated.warning) } : {}) };
352
+ return { path: filePath, events: [], truncated: false, readFailed: true, ...(validated.warning ? { warning: safeDisplayText(validated.warning) } : {}) };
347
353
  }
348
354
  const maxRecords = Math.max(1, options.maxRecords ?? DEFAULT_MAX_RECORDS);
349
355
  const tail = readTailLines(validated.resolvedPath, Math.max(1024, options.maxBytes ?? DEFAULT_MAX_BYTES));
@@ -358,11 +364,13 @@ export function readFleetTranscript(filePath: string, options: FleetTranscriptRe
358
364
  path: filePath,
359
365
  events: parsed.events,
360
366
  truncated: tail.truncated || tail.lines.length > maxRecords || parsed.explicitTruncation,
367
+ ...(tail.warning ? { readFailed: true as const } : {}),
361
368
  ...(warnings.length ? { warning: safeDisplayText(warnings.join(" ")) } : {}),
362
369
  };
363
370
  }
364
371
 
365
372
  export interface TranscriptRecordRead {
373
+ readFailed?: true;
366
374
  records: Array<Record<string, unknown>>;
367
375
  truncated: boolean;
368
376
  warning?: string;
@@ -377,7 +385,7 @@ export interface TranscriptRecordRead {
377
385
  export function readTranscriptRecords(filePath: string, options: FleetTranscriptReadOptions): TranscriptRecordRead {
378
386
  const validated = validateTranscriptPath(filePath, options.trustedRoots);
379
387
  if (!validated.resolvedPath) {
380
- return { records: [], truncated: false, ...(validated.warning ? { warning: safeDisplayText(validated.warning) } : {}) };
388
+ return { records: [], truncated: false, readFailed: true, ...(validated.warning ? { warning: safeDisplayText(validated.warning) } : {}) };
381
389
  }
382
390
  const maxRecords = Math.max(1, options.maxRecords ?? DEFAULT_MAX_RECORDS);
383
391
  const tail = readTailLines(validated.resolvedPath, Math.max(1024, options.maxBytes ?? DEFAULT_MAX_BYTES));
@@ -403,6 +411,7 @@ export function readTranscriptRecords(filePath: string, options: FleetTranscript
403
411
  ].filter((value): value is string => Boolean(value));
404
412
  return {
405
413
  records,
414
+ ...(tail.warning ? { readFailed: true as const } : {}),
406
415
  truncated: tail.truncated || tail.lines.length > maxRecords,
407
416
  ...(warnings.length ? { warning: safeDisplayText(warnings.join(" ")) } : {}),
408
417
  };
package/src/tui/fleet.ts CHANGED
@@ -812,8 +812,10 @@ interface FleetTranscriptCache {
812
812
 
813
813
  function transcriptFingerprint(filePath: string): string {
814
814
  try {
815
- const stat = fs.statSync(filePath);
816
- return `${stat.size}:${stat.mtimeMs}`;
815
+ // ino and ctime catch a same-size, same-mtime replacement. Bigint keeps
816
+ // Windows file ids, which exceed 2^53, exact.
817
+ const stat = fs.statSync(filePath, { bigint: true });
818
+ return `${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
817
819
  } catch {
818
820
  return "missing";
819
821
  }
@@ -882,7 +884,7 @@ export class SubagentFleetComponent implements Component {
882
884
  });
883
885
  }
884
886
 
885
- private nativeRenderedOutcome(mod: NativeTranscriptModule, target: { path: string; trustedRoots: string[]; trustedFiles?: string[]; trustedFileRoot?: string }, width: number): { body: string[]; conversationState: string; hasContent: boolean; warning?: string } {
887
+ private nativeRenderedOutcome(mod: NativeTranscriptModule, target: { path: string; trustedRoots: string[]; trustedFiles?: string[]; trustedFileRoot?: string }, width: number): { body: string[]; conversationState: string; hasContent: boolean; warning?: string; readFailed?: boolean } {
886
888
  try {
887
889
  const built = buildNativeFleetTranscript(mod, {
888
890
  filePath: target.path,
@@ -896,7 +898,7 @@ export class SubagentFleetComponent implements Component {
896
898
  cwd: this.state.baseCwd,
897
899
  theme: this.theme,
898
900
  });
899
- return { body: built.lines, conversationState: built.conversationState, hasContent: built.entryCount > 0, ...(built.warning ? { warning: built.warning } : {}) };
901
+ return { readFailed: built.readFailed, body: built.lines, conversationState: built.conversationState, hasContent: built.entryCount > 0, ...(built.warning ? { warning: built.warning } : {}) };
900
902
  } catch {
901
903
  // A native-render failure must never blank the inspector: degrade to
902
904
  // the legacy renderer for the rest of this inspector session.
@@ -905,7 +907,7 @@ export class SubagentFleetComponent implements Component {
905
907
  }
906
908
  }
907
909
 
908
- private legacyRenderedOutcome(target: { path: string; trustedRoots: string[]; trustedFiles?: string[]; trustedFileRoot?: string }, width: number): { body: string[]; conversationState: string; hasContent: boolean; warning?: string } {
910
+ private legacyRenderedOutcome(target: { path: string; trustedRoots: string[]; trustedFiles?: string[]; trustedFileRoot?: string }, width: number): { body: string[]; conversationState: string; hasContent: boolean; warning?: string; readFailed?: boolean } {
909
911
  const transcript = readFleetTranscript(target.path, {
910
912
  trustedRoots: target.trustedRoots,
911
913
  ...(target.trustedFiles ? { trustedFiles: target.trustedFiles } : {}),
@@ -926,6 +928,7 @@ export class SubagentFleetComponent implements Component {
926
928
  body,
927
929
  conversationState,
928
930
  hasContent: transcript.events.length > 0,
931
+ readFailed: transcript.readFailed,
929
932
  ...(transcript.warning ? { warning: transcript.warning } : {}),
930
933
  };
931
934
  }
@@ -936,7 +939,7 @@ export class SubagentFleetComponent implements Component {
936
939
  this.refreshTimer = undefined;
937
940
  if (this.disposed) return;
938
941
  try {
939
- this.invalidate();
942
+ this.refresh();
940
943
  this.tui.requestRender();
941
944
  } finally {
942
945
  this.scheduleRefresh();
@@ -1359,7 +1362,7 @@ export class SubagentFleetComponent implements Component {
1359
1362
  });
1360
1363
  }
1361
1364
 
1362
- private renderedTranscript(target: { path: string; trustedRoots: string[]; trustedFiles?: string[]; trustedFileRoot?: string }, width: number): { body: string[]; conversationState: string; hasContent: boolean; warning?: string } {
1365
+ private renderedTranscript(target: { path: string; trustedRoots: string[]; trustedFiles?: string[]; trustedFileRoot?: string }, width: number): { body: string[]; conversationState: string; hasContent: boolean; warning?: string; readFailed?: boolean } {
1363
1366
  const fingerprint = `${this.rendererMode}|${target.trustedRoots.join("\0")}|${target.trustedFiles?.join("\0") ?? ""}|${target.trustedFileRoot ?? ""}|${transcriptFingerprint(target.path)}`;
1364
1367
  if (this.transcriptCache
1365
1368
  && this.transcriptCache.mode === this.rendererMode
@@ -1381,7 +1384,7 @@ export class SubagentFleetComponent implements Component {
1381
1384
  const outcome = this.rendererMode === "native" && this.nativeModule
1382
1385
  ? this.nativeRenderedOutcome(this.nativeModule, target, width)
1383
1386
  : this.legacyRenderedOutcome(target, width);
1384
- this.transcriptCache = { mode: this.rendererMode, path: target.path, fingerprint, width, expandedTools: this.expandedTools, expandedThinking: this.expandedThinking, ...outcome, body: [...outcome.body] };
1387
+ this.transcriptCache = outcome.readFailed ? undefined : { mode: this.rendererMode, path: target.path, fingerprint, width, expandedTools: this.expandedTools, expandedThinking: this.expandedThinking, ...outcome, body: [...outcome.body] };
1385
1388
  return outcome;
1386
1389
  }
1387
1390
 
package/src/tui/render.ts CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  type AsyncJobState,
14
14
  type AsyncJobStep,
15
15
  type AsyncParallelGroupStatus,
16
+ type AsyncWidgetLayout,
16
17
  type Details,
17
18
  type HostStepState,
18
19
  type HostStepVerdict,
@@ -2520,6 +2521,7 @@ interface WidgetLayoutSession {
2520
2521
  columns: number;
2521
2522
  tier: WidgetRenderTier;
2522
2523
  lockedRows?: number;
2524
+ rootJobCount?: number;
2523
2525
  visibleJobKeys: string[];
2524
2526
  }
2525
2527
 
@@ -2760,7 +2762,7 @@ function fitWidgetLineBudget(lines: string[], theme: Theme, width: number, expan
2760
2762
  return [...lines.slice(0, visibleLines), truncLine(theme.fg("dim", hint), width)];
2761
2763
  }
2762
2764
 
2763
- function fitAdaptiveWidgetLines(jobs: AsyncJobState[], buildLines: () => string[], theme: Theme, width: number, expanded: boolean, frame?: number, projectionFor?: WorkflowWidgetProjectionLookup): string[] {
2765
+ function fitAdaptiveWidgetLines(jobs: AsyncJobState[], buildLines: () => string[], theme: Theme, width: number, expanded: boolean, frame?: number, projectionFor?: WorkflowWidgetProjectionLookup, layout: AsyncWidgetLayout = "adaptive"): string[] {
2764
2766
  if (expanded) {
2765
2767
  resetWidgetLayoutSession();
2766
2768
  return fitWidgetLineBudget(buildLines(), theme, width, true);
@@ -2779,24 +2781,30 @@ function fitAdaptiveWidgetLines(jobs: AsyncJobState[], buildLines: () => string[
2779
2781
  const session = widgetLayoutSession;
2780
2782
  const lockedRows = widgetLayoutSession.lockedRows;
2781
2783
  let rendered = buildProgressiveWidgetLines(jobs, theme, width, lockedRows, session.visibleJobKeys, frame, projectionFor);
2782
- // A job that starts after a content-sized lock can be hidden while the cap has room: grow the lock, never shrink it.
2784
+ // The height stays fixed across content-only updates (#186). It grows when a new job would be hidden while the cap
2785
+ // has room, and shrinks to content only when root jobs leave, so finished jobs leave no blank rows.
2783
2786
  const capRows = Math.min(availableRows, collapsedWidgetLineBudget(rows));
2784
2787
  if (rendered.visibleJobKeys.length < jobs.length && lockedRows < capRows) {
2785
2788
  rendered = buildProgressiveWidgetLines(jobs, theme, width, capRows, session.visibleJobKeys, frame, projectionFor);
2786
2789
  session.lockedRows = Math.max(lockedRows, rendered.contentRows);
2790
+ } else if (jobs.length < (session.rootJobCount ?? 0)) {
2791
+ session.lockedRows = rendered.contentRows;
2787
2792
  }
2793
+ session.rootJobCount = jobs.length;
2788
2794
  session.visibleJobKeys = rendered.visibleJobKeys;
2789
2795
  return rendered.lines.slice(0, session.lockedRows);
2790
2796
  }
2791
2797
 
2792
- const lines = buildLines();
2793
- if (lines.length <= availableRows) {
2794
- widgetLayoutSession = { expanded, rows, columns, tier: "full", visibleJobKeys: [] };
2795
- return fitWidgetLineBudget(lines, theme, width, false);
2796
- }
2797
- if (availableRows > 2 && jobs.length === 1 && projectionFor?.(jobs[0]!).stageProgress) {
2798
- widgetLayoutSession = { expanded, rows, columns, tier: "full", visibleJobKeys: [] };
2799
- return fitWidgetLineBudget(lines, theme, width, false);
2798
+ if (layout === "adaptive") {
2799
+ const lines = buildLines();
2800
+ if (lines.length <= availableRows) {
2801
+ widgetLayoutSession = { expanded, rows, columns, tier: "full", visibleJobKeys: [] };
2802
+ return fitWidgetLineBudget(lines, theme, width, false);
2803
+ }
2804
+ if (availableRows > 2 && jobs.length === 1 && projectionFor?.(jobs[0]!).stageProgress) {
2805
+ widgetLayoutSession = { expanded, rows, columns, tier: "full", visibleJobKeys: [] };
2806
+ return fitWidgetLineBudget(lines, theme, width, false);
2807
+ }
2800
2808
  }
2801
2809
 
2802
2810
  if (availableRows <= 2) {
@@ -2807,7 +2815,7 @@ function fitAdaptiveWidgetLines(jobs: AsyncJobState[], buildLines: () => string[
2807
2815
  // Lock to the rows the content fills so the fixed-height card has no blank padding.
2808
2816
  const rendered = buildProgressiveWidgetLines(jobs, theme, width, Math.min(availableRows, collapsedWidgetLineBudget(rows)), [], frame, projectionFor);
2809
2817
  const lockedRows = rendered.contentRows;
2810
- widgetLayoutSession = { expanded, rows, columns, tier: "progressive", lockedRows, visibleJobKeys: rendered.visibleJobKeys };
2818
+ widgetLayoutSession = { expanded, rows, columns, tier: "progressive", lockedRows, rootJobCount: jobs.length, visibleJobKeys: rendered.visibleJobKeys };
2811
2819
  return rendered.lines.slice(0, lockedRows);
2812
2820
  }
2813
2821
 
@@ -2900,7 +2908,7 @@ function materializedWidgetChildLines(job: AsyncJobState, theme: Theme, width: n
2900
2908
  return lines;
2901
2909
  }
2902
2910
 
2903
- function buildWidgetComponent(jobs: AsyncJobState[], ui: ExtensionContext["ui"]): (tui: { requestRender(): void }, theme: Theme) => Component {
2911
+ function buildWidgetComponent(jobs: AsyncJobState[], ui: ExtensionContext["ui"], initiallyCollapsed = false, layout: AsyncWidgetLayout): (tui: { requestRender(): void }, theme: Theme) => Component {
2904
2912
  return (tui, theme) => {
2905
2913
  const container = new Container();
2906
2914
  let cachedRenderWidth: number | undefined;
@@ -2908,7 +2916,7 @@ function buildWidgetComponent(jobs: AsyncJobState[], ui: ExtensionContext["ui"])
2908
2916
  let cachedExpanded: boolean | undefined;
2909
2917
  let cachedLines: string[] | undefined;
2910
2918
  let cachedCoverage = "[]";
2911
- let collapsed = false;
2919
+ let collapsed = initiallyCollapsed;
2912
2920
  const invalidate = (): void => {
2913
2921
  cachedLines = undefined;
2914
2922
  resetWidgetLayoutSession();
@@ -2978,7 +2986,7 @@ function buildWidgetComponent(jobs: AsyncJobState[], ui: ExtensionContext["ui"])
2978
2986
  cachedExpanded = expanded;
2979
2987
  cachedLines = (collapsed
2980
2988
  ? buildSingleLineWidgetLines(jobs, theme, width, frame)
2981
- : fitAdaptiveWidgetLines(roots, buildLines, theme, width, expanded, frame, projectionFor)
2989
+ : fitAdaptiveWidgetLines(roots, buildLines, theme, width, expanded, frame, projectionFor, layout)
2982
2990
  ).map((line) => paddedWidgetLine(line, renderWidth));
2983
2991
  return cachedLines;
2984
2992
  };
@@ -3080,7 +3088,7 @@ export function buildWidgetLines(jobs: AsyncJobState[], theme: Theme, width = ge
3080
3088
  /**
3081
3089
  * Render the async jobs widget
3082
3090
  */
3083
- export function renderWidget(ctx: ExtensionContext, jobs: AsyncJobState[]): void {
3091
+ export function renderWidget(ctx: ExtensionContext, jobs: AsyncJobState[], initiallyCollapsed = false, layout: AsyncWidgetLayout = "adaptive"): void {
3084
3092
  if (jobs.length === 0) {
3085
3093
  resetWidgetLayoutSession();
3086
3094
  asyncWidgetUpdates.delete(ctx.ui);
@@ -3096,7 +3104,7 @@ export function renderWidget(ctx: ExtensionContext, jobs: AsyncJobState[]): void
3096
3104
  // component instead so progress cannot move it past other extensions' widgets.
3097
3105
  const update = asyncWidgetUpdates.get(ctx.ui);
3098
3106
  if (update) update(jobs);
3099
- else ctx.ui.setWidget(WIDGET_KEY, buildWidgetComponent(jobs, ctx.ui));
3107
+ else ctx.ui.setWidget(WIDGET_KEY, buildWidgetComponent(jobs, ctx.ui, initiallyCollapsed, layout));
3100
3108
  }
3101
3109
 
3102
3110
  function renderSingleCompact(
@@ -3119,7 +3127,7 @@ function renderSingleCompact(
3119
3127
  const width = getTermWidth() - 4;
3120
3128
  const detailIndent = mainWindowIndent(layout, 1);
3121
3129
  const continuationIndent = mainWindowIndent(layout, 2) + (layout.horizontalSpacing > 0 ? " " : "");
3122
- const modelDisplay = modelThinkingBadge(theme, r.model ?? r.progress?.model, r.thinking ?? r.progress?.thinking);
3130
+ const modelDisplay = modelThinkingBadge(theme, r.progress?.model ?? r.model, r.thinking ?? r.progress?.thinking);
3123
3131
  c.addChild(new Text(truncLine(`${resultGlyph(r, output, theme, isRunning, undefined, frame)} ${theme.fg("toolTitle", theme.bold(foregroundSingleDisplayName(r)))}${modelDisplay}${contextBadge}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`, width), 0, 0));
3124
3132
 
3125
3133
  if (isRunning && r.progress) {
@@ -3378,7 +3386,7 @@ function renderMultiCompact(d: Details, theme: Theme, layout: MainWindowRenderLa
3378
3386
  const pendingLabel = rPending ? ` ${theme.fg("dim", "· pending")}` : "";
3379
3387
  const stepLabel = entry.rowLabel;
3380
3388
  const rowProgressModel = rProg && "status" in rProg ? rProg : undefined;
3381
- const rowModelDisplay = modelThinkingBadge(theme, r.model ?? rowProgressModel?.model, r.thinking ?? rowProgressModel?.thinking);
3389
+ const rowModelDisplay = modelThinkingBadge(theme, rowProgressModel?.model ?? r.model, r.thinking ?? rowProgressModel?.thinking);
3382
3390
  const labelPrefix = stepLabel ? `${stepLabel}: ` : "";
3383
3391
  const line = `${glyph} ${labelPrefix}${themeBold(theme, agentName)}${contextModeBadge(theme, r.context)}${rowModelDisplay}${stepStats ? ` ${theme.fg("dim", "·")} ${stepStats}` : ""}${pendingLabel}`;
3384
3392
  c.addChild(new Text(truncLine(`${rowIndent}${line}`, width), 0, 0));
@@ -3579,7 +3587,7 @@ export function renderSubagentResult(
3579
3587
  if (r.skillsWarning) {
3580
3588
  c.addChild(new Text(fit(theme.fg("warning", `Warning: ${r.skillsWarning}`)), 0, 0));
3581
3589
  }
3582
- c.addChild(new Text(fit(theme.fg("dim", formatUsage(r.usage, r.model))), 0, 0));
3590
+ c.addChild(new Text(fit(theme.fg("dim", formatUsage(r.usage, r.progress?.model ?? r.model))), 0, 0));
3583
3591
  if (r.sessionFile) {
3584
3592
  c.addChild(new Text(fit(theme.fg("dim", `Session: ${shortenPath(r.sessionFile)}`)), 0, 0));
3585
3593
  }
@@ -3725,7 +3733,7 @@ export function renderSubagentResult(
3725
3733
  const resultOutput = getSingleResultOutput(r);
3726
3734
  const rowPresentation = styledResultPresentation(resultPresentation(r, resultOutput, rRunning, progressRunningSeed(rProg), frame), theme);
3727
3735
  const stats = rProg ? ` | ${rProg.toolCount} tools, ${formatDuration(rProg.durationMs)}` : "";
3728
- const modelDisplay = modelThinkingBadge(theme, r.model ?? rProg?.model, r.thinking ?? rProg?.thinking);
3736
+ const modelDisplay = modelThinkingBadge(theme, rProg?.model ?? r.model, r.thinking ?? rProg?.thinking);
3729
3737
  const stepLabel = entry.rowLabel;
3730
3738
  const contextBadge = contextModeBadge(theme, r.context);
3731
3739
  const labelPrefix = stepLabel ? `${stepLabel}: ` : "";