@xzzpig/pi-subagents 0.1.0 → 0.3.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 (108) hide show
  1. package/CHANGELOG.md +135 -0
  2. package/README.md +4 -0
  3. package/agents/reviewer.md +3 -4
  4. package/docs/agents.md +343 -0
  5. package/docs/configuration.md +395 -0
  6. package/docs/extension-api.md +308 -0
  7. package/docs/missions.md +121 -0
  8. package/docs/models.md +192 -0
  9. package/docs/observability.md +198 -0
  10. package/docs/tool-reference.md +343 -0
  11. package/docs/watchdog.md +176 -0
  12. package/docs/workflows.md +163 -0
  13. package/package.json +13 -11
  14. package/skills/pi-subagents/references/constraints-and-recipes.md +1 -1
  15. package/skills/pi-subagents/references/execution-controls.md +7 -7
  16. package/skills/pi-subagents/references/management-authoring-rpc.md +1 -1
  17. package/skills/pi-subagents/references/prompting-and-roles.md +1 -1
  18. package/src/agents/agents.ts +53 -23
  19. package/src/agents/frontmatter.ts +7 -3
  20. package/src/agents/skills.ts +2 -9
  21. package/src/api/preflight.ts +1 -1
  22. package/src/api/project-panes.ts +30 -0
  23. package/src/extension/config.ts +54 -1
  24. package/src/extension/doctor.ts +40 -0
  25. package/src/extension/fanout-child.ts +5 -4
  26. package/src/extension/index.ts +114 -38
  27. package/src/extension/public-execution.ts +35 -4
  28. package/src/extension/rpc.ts +10 -15
  29. package/src/extension/schemas.ts +33 -11
  30. package/src/extension/subagent-guide.ts +39 -0
  31. package/src/extension/tool-description.ts +38 -18
  32. package/src/inspectors/herdr/actions.ts +11 -2
  33. package/src/inspectors/herdr/inspector-runner.ts +16 -3
  34. package/src/inspectors/herdr/project-panes.ts +459 -63
  35. package/src/intercom/intercom-bridge.ts +7 -2
  36. package/src/intercom/native-supervisor-channel.ts +102 -4
  37. package/src/missions/actions.ts +25 -2
  38. package/src/missions/lifecycle.ts +25 -9
  39. package/src/missions/store.ts +89 -7
  40. package/src/missions/types.ts +33 -0
  41. package/src/missions/workflow-state.ts +25 -15
  42. package/src/runs/background/active-async-capacity.ts +431 -0
  43. package/src/runs/background/active-run-index.ts +46 -0
  44. package/src/runs/background/async-execution.ts +158 -71
  45. package/src/runs/background/async-job-tracker.ts +297 -133
  46. package/src/runs/background/async-resume.ts +37 -5
  47. package/src/runs/background/async-status.ts +39 -5
  48. package/src/runs/background/chain-append.ts +33 -15
  49. package/src/runs/background/completion-replay.ts +267 -0
  50. package/src/runs/background/control-channel.ts +95 -54
  51. package/src/runs/background/fleet-view.ts +18 -5
  52. package/src/runs/background/owned-process-tree.ts +104 -0
  53. package/src/runs/background/process-terminal.ts +17 -3
  54. package/src/runs/background/result-watcher.ts +113 -10
  55. package/src/runs/background/resume-guidance.ts +53 -0
  56. package/src/runs/background/retained-children.ts +14 -6
  57. package/src/runs/background/run-status.ts +119 -5
  58. package/src/runs/background/scheduled-runs.ts +25 -1
  59. package/src/runs/background/stale-run-reconciler.ts +12 -24
  60. package/src/runs/background/subagent-runner.ts +127 -41
  61. package/src/runs/background/subagent-wait.ts +5 -2
  62. package/src/runs/background/wait-completions.ts +39 -5
  63. package/src/runs/background/wait-subscriptions.ts +21 -5
  64. package/src/runs/foreground/async-dismiss-action.ts +85 -0
  65. package/src/runs/foreground/async-steering-action.ts +7 -8
  66. package/src/runs/foreground/chain-execution.ts +40 -2
  67. package/src/runs/foreground/execution.ts +97 -19
  68. package/src/runs/foreground/foreground-control.ts +12 -0
  69. package/src/runs/foreground/foreground-history.ts +137 -0
  70. package/src/runs/foreground/prompt-audit.ts +172 -0
  71. package/src/runs/foreground/subagent-executor.ts +1274 -243
  72. package/src/runs/foreground/workflow-foreground-steering.ts +187 -0
  73. package/src/runs/shared/acceptance.ts +13 -4
  74. package/src/runs/shared/completion-guard.ts +17 -1
  75. package/src/runs/shared/dynamic-fanout.ts +1 -1
  76. package/src/runs/shared/llm-intent-arbiter.ts +302 -0
  77. package/src/runs/shared/model-fallback.ts +8 -4
  78. package/src/runs/shared/model-scope.ts +12 -2
  79. package/src/runs/shared/parallel-utils.ts +3 -0
  80. package/src/runs/shared/pi-args.ts +44 -1
  81. package/src/runs/shared/run-fanout-budget.ts +280 -0
  82. package/src/runs/shared/single-output.ts +4 -2
  83. package/src/runs/shared/subagent-prompt-runtime.ts +94 -9
  84. package/src/runs/shared/task-intent.ts +19 -3
  85. package/src/runs/shared/worktree.ts +20 -7
  86. package/src/shared/agent-stream-options.ts +5 -0
  87. package/src/shared/artifacts.ts +17 -21
  88. package/src/shared/display-text.ts +150 -0
  89. package/src/shared/file-coalescer.ts +9 -0
  90. package/src/shared/fork-context.ts +13 -0
  91. package/src/shared/formatters.ts +4 -6
  92. package/src/shared/node-executable.ts +21 -0
  93. package/src/shared/prompt-resources.ts +51 -0
  94. package/src/shared/settings.ts +15 -2
  95. package/src/shared/types.ts +158 -4
  96. package/src/shared/utf8.ts +11 -0
  97. package/src/shared/utils.ts +46 -34
  98. package/src/slash/prompt-workflows.ts +2 -15
  99. package/src/slash/slash-commands.ts +22 -2
  100. package/src/tui/fleet-status.ts +29 -17
  101. package/src/tui/fleet-transcript.ts +1 -48
  102. package/src/tui/fleet.ts +362 -37
  103. package/src/tui/render.ts +235 -71
  104. package/src/watchdog/change-signature.ts +4 -3
  105. package/src/watchdog/permission-arbiter.ts +2 -1
  106. package/src/watchdog/review.ts +4 -3
  107. package/src/workflows/chat-progress.ts +8 -2
  108. package/src/workflows/scripted-workflow.ts +273 -20
package/src/tui/render.ts CHANGED
@@ -15,9 +15,12 @@ import {
15
15
  type NestedRunSummary,
16
16
  type NestedStepSummary,
17
17
  type WorkflowNodeStatus,
18
+ type MainWindowRendererConfig,
18
19
  MAX_WIDGET_JOBS,
20
+ POLL_INTERVAL_MS,
19
21
  WIDGET_KEY,
20
22
  } from "../shared/types.ts";
23
+ import { sanitizeDisplayText, truncateDisplayText } from "../shared/display-text.ts";
21
24
  import { formatTokens, formatUsage, formatDuration, formatModelThinking, formatToolCall, shortenPath } from "../shared/formatters.ts";
22
25
  import { getDisplayItems, getSingleResultOutput } from "../shared/utils.ts";
23
26
  import { flatToLogicalStepIndex } from "../runs/background/parallel-groups.ts";
@@ -28,6 +31,38 @@ import { buildWorkflowChatProgressRows, type WorkflowChatProgressRow } from "../
28
31
 
29
32
  type Theme = ExtensionContext["ui"]["theme"];
30
33
 
34
+ interface MainWindowRenderLayout {
35
+ horizontalSpacing: number;
36
+ compactResultMaxLines?: number;
37
+ }
38
+
39
+ function resolveMainWindowRenderLayout(config?: MainWindowRendererConfig): MainWindowRenderLayout {
40
+ return {
41
+ horizontalSpacing: config?.horizontalSpacing ?? 2,
42
+ ...(config?.compactResultMaxLines !== undefined ? { compactResultMaxLines: config.compactResultMaxLines } : {}),
43
+ };
44
+ }
45
+
46
+ function mainWindowIndent(layout: MainWindowRenderLayout, level: number): string {
47
+ return " ".repeat(Math.max(0, layout.horizontalSpacing * level));
48
+ }
49
+
50
+ function capCompactMainWindowResult(component: Component, layout: MainWindowRenderLayout, theme: Theme, enabled: boolean): Component {
51
+ const maxLines = layout.compactResultMaxLines;
52
+ if (!enabled || maxLines === undefined) return component;
53
+ const capped = new Container();
54
+ capped.render = (width: number): string[] => {
55
+ const lines = component.render(width);
56
+ if (lines.length <= maxLines) return lines;
57
+ const visibleRows = maxLines === 1 ? 1 : maxLines - 1;
58
+ const hiddenCount = lines.length - visibleRows;
59
+ const hint = theme.fg("accent", `… ${hiddenCount} rows hidden · ${liveDetailKeyText()} expands`);
60
+ if (maxLines === 1) return [truncLine(`${lines[0] ?? ""} ${hint}`, width)];
61
+ return [...lines.slice(0, visibleRows), truncLine(hint, width)];
62
+ };
63
+ return capped;
64
+ }
65
+
31
66
  function liveDetailKeyText(): string {
32
67
  return keyText("app.tools.expand");
33
68
  }
@@ -202,12 +237,130 @@ function getToolCallLines(
202
237
  return result.toolCalls?.map((toolCall) => expanded ? toolCall.expandedText : toolCall.text) ?? [];
203
238
  }
204
239
 
240
+ const ansiEscapePattern = /\x1b\[[0-9;]*m/g;
241
+ const noisyStatusPatterns = [
242
+ /^(?:i|we)\s+(?:will|need|can|should|am|are)\b/i,
243
+ /^i(?:'m|’m| am)\b/i,
244
+ /\bso i (?:will|need|can)\b/i,
245
+ /^(?:checking|fetching|reading|inspecting|verifying|collecting|confirming|polling)\b/i,
246
+ /^(?:async\s+subagent\s+)?[\w.-]+\s*·\s*(?:step|agent)\s+\d+\/\d+\s*·/i,
247
+ /^(?:Step|Agent)\s+\d+\/\d+:\s+[\w.-]+\s*·\s*(?:running|queued|pending|complete|completed)\b/i,
248
+ /^Press\s+\S+\s+for\s+live\s+detail$/i,
249
+ /^output:\s+.+\/async-subagent-runs\//i,
250
+ ];
251
+ const liveOutputWordSignalPattern = /\b(?:access denied|denied|error|exception|fail(?:ed|ure)?|fatal|panic|rejected|timeout|timed out|unable|warning)\b/i;
252
+ const liveOutputCodeSignalPattern = /\bE[A-Z0-9_]{2,}\b/;
253
+
254
+ function oneLine(text: string): string {
255
+ return text.replace(ansiEscapePattern, "").replace(/\s+/g, " ").trim();
256
+ }
257
+
258
+ function hasLiveOutputSignal(line: string): boolean {
259
+ const clean = oneLine(line);
260
+ return liveOutputWordSignalPattern.test(clean) || liveOutputCodeSignalPattern.test(clean);
261
+ }
262
+
263
+ function isNoisyStatusLine(line: string): boolean {
264
+ const clean = oneLine(line);
265
+ return clean.length > 0
266
+ && clean.length <= 240
267
+ && !hasLiveOutputSignal(clean)
268
+ && noisyStatusPatterns.some((pattern) => pattern.test(clean));
269
+ }
270
+
271
+ function latestActivityText(line: string): string {
272
+ return oneLine(line)
273
+ .replace(/^i (?:will|can|need to|am going to)\s+/i, "")
274
+ .replace(/^i(?:'m|’m| am)\s+/i, "");
275
+ }
276
+
277
+ function progressUpdateSummary(lines: string[]): string {
278
+ const counts = new Map<string, number>();
279
+ for (const line of lines) counts.set(line.toLowerCase(), (counts.get(line.toLowerCase()) ?? 0) + 1);
280
+ const exactRepeatCount = Math.max(...counts.values());
281
+ const latest = latestActivityText(lines[lines.length - 1]!);
282
+ const repeat = exactRepeatCount > 1 ? ` · repeated ${exactRepeatCount}×` : "";
283
+ return `↻ ${lines.length} progress updates${repeat} · latest: ${latest}`;
284
+ }
285
+
286
+ function compactRecentOutputLines(recentOutput: string[] | undefined): string[] {
287
+ const lines: string[] = [];
288
+ const noisyLines: string[] = [];
289
+ const otherLines: string[] = [];
290
+ for (const rawLine of recentOutput ?? []) {
291
+ const line = oneLine(rawLine);
292
+ if (!line || line === "(running...)") continue;
293
+ lines.push(line);
294
+ (isNoisyStatusLine(line) ? noisyLines : otherLines).push(line);
295
+ }
296
+ if (noisyLines.length >= 4 && !otherLines.some(hasLiveOutputSignal)) {
297
+ if (otherLines.length === 0) {
298
+ return [
299
+ progressUpdateSummary(noisyLines),
300
+ "pattern: repeated short status lines",
301
+ ];
302
+ }
303
+ const visibleTail = otherLines.slice(-3);
304
+ const hiddenSignals = otherLines.slice(0, -3).filter(hasLiveOutputSignal);
305
+ return [
306
+ progressUpdateSummary(noisyLines),
307
+ ...(hiddenSignals.length > 0 ? [`… ${hiddenSignals.length} older signal ${hiddenSignals.length === 1 ? "line" : "lines"}: ${hiddenSignals.at(-1)}`] : []),
308
+ ...visibleTail,
309
+ ].slice(0, 5);
310
+ }
311
+ if (lines.length <= 5) return lines;
312
+
313
+ const tail = lines.slice(-5);
314
+ const hiddenSignals = lines.slice(0, -5).filter(hasLiveOutputSignal);
315
+ if (hiddenSignals.length === 0) return tail;
316
+ return [
317
+ `… ${hiddenSignals.length} older signal ${hiddenSignals.length === 1 ? "line" : "lines"}: ${hiddenSignals.at(-1)}`,
318
+ ...lines.slice(-4),
319
+ ];
320
+ }
321
+
322
+ function compactWorkflowError(error: string): string {
323
+ const outputMatch = error.match(/(?:^|\n)Output:\s*([\s\S]+)/);
324
+ if (!outputMatch) return oneLine(error);
325
+ const prefix = oneLine(error.slice(0, outputMatch.index)).replace(/:$/, "") || "Failed";
326
+ const outputLines = outputMatch[1]!.split(/\r?\n/).map(oneLine).filter(Boolean);
327
+ const allOutputLinesAreNoisy = outputLines.length > 0 && outputLines.every(isNoisyStatusLine);
328
+ const latest = outputLines.at(-1);
329
+ return allOutputLinesAreNoisy && latest
330
+ ? `${prefix} · latest: ${latestActivityText(latest)}`
331
+ : `${prefix} · ${oneLine(outputMatch[1] ?? "")}`;
332
+ }
333
+
334
+ const WORKFLOW_LIVE_ROW_LIMIT = 8;
335
+
336
+ function visibleWorkflowRows(rows: WorkflowChatProgressRow[]): { rows: WorkflowChatProgressRow[]; hiddenRows: number } {
337
+ if (rows.length <= WORKFLOW_LIVE_ROW_LIMIT) return { rows, hiddenRows: 0 };
338
+ const selected = new Set<string>();
339
+ const add = (row: WorkflowChatProgressRow): void => {
340
+ if (selected.size >= WORKFLOW_LIVE_ROW_LIMIT || selected.has(row.key)) return;
341
+ selected.add(row.key);
342
+ };
343
+ for (const row of [...rows].reverse()) {
344
+ if (row.state === "failed") add(row);
345
+ }
346
+ for (const row of [...rows].reverse()) add(row);
347
+ return {
348
+ rows: rows.filter((row) => selected.has(row.key)),
349
+ hiddenRows: rows.length - selected.size,
350
+ };
351
+ }
205
352
 
206
353
  function snapshotNowForProgress(progress: Pick<AgentProgress, "currentToolStartedAt" | "durationMs" | "lastActivityAt">): number | undefined {
207
354
  if (progress.currentToolStartedAt !== undefined && progress.durationMs !== undefined) return progress.currentToolStartedAt + progress.durationMs;
208
355
  return progress.lastActivityAt;
209
356
  }
210
357
 
358
+ function renderToolArgsPreview(value: string, maxLength: number, expanded: boolean): string {
359
+ const normalized = sanitizeDisplayText(value);
360
+ if (expanded || normalized.length <= maxLength) return normalized;
361
+ return `${truncateDisplayText(normalized, maxLength)}...`;
362
+ }
363
+
211
364
  function formatCurrentToolLine(
212
365
  progress: Pick<AgentProgress, "currentTool" | "currentToolArgs" | "currentToolStartedAt">,
213
366
  availableWidth: number,
@@ -217,9 +370,7 @@ function formatCurrentToolLine(
217
370
  if (!progress.currentTool) return undefined;
218
371
  const maxToolArgsLen = Math.max(50, availableWidth - 20);
219
372
  const toolArgsPreview = progress.currentToolArgs
220
- ? (expanded || progress.currentToolArgs.length <= maxToolArgsLen
221
- ? progress.currentToolArgs
222
- : `${progress.currentToolArgs.slice(0, maxToolArgsLen)}...`)
373
+ ? renderToolArgsPreview(progress.currentToolArgs, maxToolArgsLen, expanded)
223
374
  : "";
224
375
  const durationSuffix = progress.currentToolStartedAt !== undefined && snapshotNow !== undefined
225
376
  ? ` | ${formatDuration(Math.max(0, snapshotNow - progress.currentToolStartedAt))}`
@@ -510,7 +661,7 @@ function widgetStepActivity(step: NonNullable<AsyncJobState["steps"]>[number], s
510
661
  }
511
662
 
512
663
 
513
- function widgetChainDetails(job: AsyncJobState, theme: Theme, expanded = false, width = getTermWidth()): string[] {
664
+ function widgetChainDetails(job: AsyncJobState, theme: Theme, expanded = false, width = getTermWidth(), frame?: number): string[] {
514
665
  if (!job.steps?.length) return [];
515
666
  const total = job.chainStepCount ?? job.steps.length;
516
667
  const lines: string[] = [];
@@ -518,7 +669,7 @@ function widgetChainDetails(job: AsyncJobState, theme: Theme, expanded = false,
518
669
  const steps = job.steps.slice(span.start, span.start + span.count);
519
670
  if (span.isParallel) {
520
671
  const status = aggregateStepStatus(steps);
521
- lines.push(` ${widgetStepGlyph(status, theme, widgetStepsRunningSeed(steps))} Step ${span.stepIndex + 1}/${total}: ${themeBold(theme, "parallel group")} ${theme.fg("dim", "·")} ${theme.fg("dim", formatParallelOutcome(steps, span.count))}`);
672
+ lines.push(` ${widgetStepGlyph(status, theme, widgetStepsRunningSeed(steps), frame)} Step ${span.stepIndex + 1}/${total}: ${themeBold(theme, "parallel group")} ${theme.fg("dim", "·")} ${theme.fg("dim", formatParallelOutcome(steps, span.count))}`);
522
673
  continue;
523
674
  }
524
675
  const step = steps[0];
@@ -526,15 +677,15 @@ function widgetChainDetails(job: AsyncJobState, theme: Theme, expanded = false,
526
677
  lines.push(` ${theme.fg("dim", `◦ Step ${span.stepIndex + 1}/${total}: pending`)}`);
527
678
  continue;
528
679
  }
529
- lines.push(...foregroundStyleWidgetStepLines(job, theme, step, "Step", span.stepIndex + 1, total, expanded, width));
680
+ lines.push(...foregroundStyleWidgetStepLines(job, theme, step, "Step", span.stepIndex + 1, total, expanded, width, frame));
530
681
  }
531
682
  return lines;
532
683
  }
533
684
 
534
- function widgetParallelAgentDetails(job: AsyncJobState, theme: Theme, expanded = false, width = getTermWidth()): string[] {
685
+ function widgetParallelAgentDetails(job: AsyncJobState, theme: Theme, expanded = false, width = getTermWidth(), frame?: number): string[] {
535
686
  if (!job.steps?.length) return [];
536
687
  if (job.mode !== "parallel" && job.mode !== "chain") return [];
537
- if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length) return widgetChainDetails(job, theme, expanded, width);
688
+ if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length) return widgetChainDetails(job, theme, expanded, width, frame);
538
689
  const total = job.stepsTotal ?? job.steps.length;
539
690
  const lines: string[] = [];
540
691
  for (const [index, step] of job.steps.entries()) {
@@ -542,7 +693,7 @@ function widgetParallelAgentDetails(job: AsyncJobState, theme: Theme, expanded =
542
693
  const activity = widgetStepActivity(step, job.updatedAt);
543
694
  const itemTitle = job.mode === "parallel" || job.activeParallelGroup ? "Agent" : "Step";
544
695
  const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
545
- lines.push(` ${theme.fg("dim", `${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index))} ${itemTitle} ${index + 1}/${total}: ${step.agent} · ${widgetStepStatus(step.status, theme)}${modelDisplay}${activity ? ` · ${activity}` : ""}`)}`);
696
+ lines.push(` ${theme.fg("dim", `${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index), frame)} ${itemTitle} ${index + 1}/${total}: ${step.agent} · ${widgetStepStatus(step.status, theme)}${modelDisplay}${activity ? ` · ${activity}` : ""}`)}`);
546
697
  for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, expanded, job.updatedAt, expanded ? 8 : 6)) lines.push(` ${nestedLine}`);
547
698
  }
548
699
  return lines;
@@ -1035,10 +1186,10 @@ function foregroundStyleWidgetStepLines(
1035
1186
  if (liveStatus && liveStatus !== activity) lines.push(` ${theme.fg("accent", liveStatus)}`);
1036
1187
  for (const tool of step.recentTools?.slice(-3) ?? []) {
1037
1188
  const maxArgsLen = Math.max(40, width - 30);
1038
- const argsPreview = tool.args.length <= maxArgsLen ? tool.args : `${tool.args.slice(0, maxArgsLen)}...`;
1189
+ const argsPreview = renderToolArgsPreview(tool.args, maxArgsLen, expanded);
1039
1190
  lines.push(` ${theme.fg("dim", `${tool.tool}${argsPreview ? `: ${argsPreview}` : ""}`)}`);
1040
1191
  }
1041
- for (const line of step.recentOutput?.slice(-5) ?? []) {
1192
+ for (const line of compactRecentOutputLines(step.recentOutput)) {
1042
1193
  lines.push(` ${theme.fg("dim", line)}`);
1043
1194
  }
1044
1195
  }
@@ -1051,7 +1202,7 @@ function foregroundStyleWidgetDetails(job: AsyncJobState, theme: Theme, expanded
1051
1202
  ` ${theme.fg("dim", `⎿ ${widgetActivity(job)}`)}`,
1052
1203
  ...formatNestedWidgetLines(job.nestedChildren, theme, width, expanded, job.updatedAt, expanded ? 12 : 6).map((line) => ` ${line}`),
1053
1204
  ];
1054
- if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length) return widgetChainDetails(job, theme, expanded, width);
1205
+ if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length) return widgetChainDetails(job, theme, expanded, width, frame);
1055
1206
  const total = job.stepsTotal ?? job.steps.length;
1056
1207
  const itemTitle = job.mode === "parallel" || job.activeParallelGroup ? "Agent" : "Step";
1057
1208
  const lines: string[] = [];
@@ -1299,10 +1450,10 @@ function fitWidgetLineBudget(lines: string[], theme: Theme, width: number, expan
1299
1450
  return [...lines.slice(0, visibleLines), truncLine(theme.fg("dim", hint), width)];
1300
1451
  }
1301
1452
 
1302
- function fitAdaptiveWidgetLines(jobs: AsyncJobState[], lines: string[], theme: Theme, width: number, expanded: boolean, frame?: number): string[] {
1453
+ function fitAdaptiveWidgetLines(jobs: AsyncJobState[], buildLines: () => string[], theme: Theme, width: number, expanded: boolean, frame?: number): string[] {
1303
1454
  if (expanded) {
1304
1455
  resetWidgetLayoutSession();
1305
- return fitWidgetLineBudget(lines, theme, width, true);
1456
+ return fitWidgetLineBudget(buildLines(), theme, width, true);
1306
1457
  }
1307
1458
 
1308
1459
  const hasMatchingSession = widgetSessionMatches(expanded);
@@ -1320,6 +1471,7 @@ function fitAdaptiveWidgetLines(jobs: AsyncJobState[], lines: string[], theme: T
1320
1471
  return rendered.lines;
1321
1472
  }
1322
1473
 
1474
+ const lines = buildLines();
1323
1475
  if (lines.length <= availableRows) {
1324
1476
  widgetLayoutSession = { expanded, rows, columns, tier: "full", visibleJobKeys: [] };
1325
1477
  return fitWidgetLineBudget(lines, theme, width, false);
@@ -1341,12 +1493,13 @@ function buildWidgetComponent(jobs: AsyncJobState[], expanded: boolean): (_tui:
1341
1493
  const container = new Container();
1342
1494
  container.render = (renderWidth: number): string[] => {
1343
1495
  const width = Math.max(0, renderWidth - 2);
1344
- const lines = expanded
1345
- ? buildWidgetLines(jobs, theme, width, true)
1496
+ const frame = Math.floor(Date.now() / POLL_INTERVAL_MS);
1497
+ const buildLines = (): string[] => expanded
1498
+ ? buildWidgetLines(jobs, theme, width, true, frame)
1346
1499
  : jobs.length === 1
1347
- ? compactSingleWidgetLines(jobs[0]!, theme, width)
1348
- : buildWidgetLines(jobs, theme, width, false);
1349
- return fitAdaptiveWidgetLines(jobs, lines, theme, width, expanded).map((line) => paddedWidgetLine(line, renderWidth));
1500
+ ? compactSingleWidgetLines(jobs[0]!, theme, width, frame)
1501
+ : buildWidgetLines(jobs, theme, width, false, frame);
1502
+ return fitAdaptiveWidgetLines(jobs, buildLines, theme, width, expanded, frame).map((line) => paddedWidgetLine(line, renderWidth));
1350
1503
  };
1351
1504
  return container;
1352
1505
  };
@@ -1376,7 +1529,7 @@ export function buildWidgetLines(jobs: AsyncJobState[], theme: Theme, width = ge
1376
1529
  items.push([
1377
1530
  `${widgetStatusGlyph(job, theme, frame)} ${themeBold(theme, widgetJobName(job))}${contextModeBadge(theme, job.context)}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`,
1378
1531
  ` ${theme.fg("dim", `⎿ ${widgetActivity(job)}`)}`,
1379
- ...widgetParallelAgentDetails(job, theme, expanded, width),
1532
+ ...widgetParallelAgentDetails(job, theme, expanded, width, frame),
1380
1533
  ]);
1381
1534
  slots--;
1382
1535
  }
@@ -1393,7 +1546,7 @@ export function buildWidgetLines(jobs: AsyncJobState[], theme: Theme, width = ge
1393
1546
  items.push([
1394
1547
  `${widgetStatusGlyph(job, theme, frame)} ${themeBold(theme, widgetJobName(job))}${contextModeBadge(theme, job.context)}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`,
1395
1548
  ` ${theme.fg("dim", `⎿ ${widgetActivity(job)}`)}`,
1396
- ...widgetParallelAgentDetails(job, theme, expanded, width),
1549
+ ...widgetParallelAgentDetails(job, theme, expanded, width, frame),
1397
1550
  ]);
1398
1551
  slots--;
1399
1552
  }
@@ -1435,7 +1588,7 @@ export function renderWidget(ctx: ExtensionContext, jobs: AsyncJobState[]): void
1435
1588
  ctx.ui.setWidget(WIDGET_KEY, buildWidgetComponent(jobs, ctx.ui.getToolsExpanded?.() ?? false));
1436
1589
  }
1437
1590
 
1438
- function renderSingleCompact(d: Details, r: Details["results"][number], theme: Theme, frame?: number): Component {
1591
+ function renderSingleCompact(d: Details, r: Details["results"][number], theme: Theme, layout: MainWindowRenderLayout, frame?: number): Component {
1439
1592
  const output = r.truncation?.text || getSingleResultOutput(r);
1440
1593
  const progress = r.progress || r.progressSummary;
1441
1594
  const isRunning = isResultRunning(r);
@@ -1446,40 +1599,43 @@ function renderSingleCompact(d: Details, r: Details["results"][number], theme: T
1446
1599
  ]);
1447
1600
  const c = new Container();
1448
1601
  const width = getTermWidth() - 4;
1602
+ const detailIndent = mainWindowIndent(layout, 1);
1603
+ const continuationIndent = mainWindowIndent(layout, 2) + (layout.horizontalSpacing > 0 ? " " : "");
1449
1604
  const modelDisplay = modelThinkingBadge(theme, r.model ?? r.progress?.model, r.thinking ?? r.progress?.thinking);
1450
1605
  c.addChild(new Text(truncLine(`${resultGlyph(r, output, theme, isRunning, undefined, frame)} ${theme.fg("toolTitle", theme.bold(r.agent))}${modelDisplay}${contextBadge}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`, width), 0, 0));
1451
1606
 
1452
1607
  if (isRunning && r.progress) {
1453
1608
  const progressSnapshotNow = snapshotNowForProgress(r.progress);
1454
1609
  const activity = compactCurrentActivity(r.progress);
1455
- c.addChild(new Text(truncLine(theme.fg("dim", ` ⎿ ${activity}`), width), 0, 0));
1610
+ c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}⎿ ${activity}`), width), 0, 0));
1456
1611
  const liveStatus = buildLiveStatusLine(r.progress, progressSnapshotNow);
1457
- if (liveStatus && liveStatus !== activity) c.addChild(new Text(truncLine(theme.fg("dim", ` ${liveStatus}`), width), 0, 0));
1612
+ if (liveStatus && liveStatus !== activity) c.addChild(new Text(truncLine(theme.fg("dim", `${continuationIndent}${liveStatus}`), width), 0, 0));
1458
1613
  for (const nestedLine of formatNestedWidgetLines(r.children, theme, width, false, progressSnapshotNow)) {
1459
- c.addChild(new Text(truncLine(` ${nestedLine}`, width), 0, 0));
1614
+ c.addChild(new Text(truncLine(`${detailIndent}${nestedLine}`, width), 0, 0));
1460
1615
  }
1461
- c.addChild(new Text(truncLine(theme.fg("accent", ` ${liveDetailHintText()}`), width), 0, 0));
1462
- if (r.artifactPaths) c.addChild(new Text(truncLine(theme.fg("dim", ` output: ${shortenPath(r.artifactPaths.outputPath)}`), width), 0, 0));
1616
+ c.addChild(new Text(truncLine(theme.fg("accent", `${detailIndent}${liveDetailHintText()}`), width), 0, 0));
1617
+ if (r.artifactPaths) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}output: ${shortenPath(r.artifactPaths.outputPath)}`), width), 0, 0));
1463
1618
  return c;
1464
1619
  }
1465
1620
 
1466
1621
  for (const nestedLine of formatNestedWidgetLines(r.children, theme, width, false, r.progress?.lastActivityAt)) {
1467
- c.addChild(new Text(truncLine(` ${nestedLine}`, width), 0, 0));
1622
+ c.addChild(new Text(truncLine(`${detailIndent}${nestedLine}`, width), 0, 0));
1468
1623
  }
1469
- c.addChild(new Text(truncLine(theme.fg("dim", ` ⎿ ${resultStatusLine(r, output)}`), width), 0, 0));
1624
+ c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}⎿ ${resultStatusLine(r, output)}`), width), 0, 0));
1470
1625
  const preview = firstOutputLine(output);
1471
1626
  if (preview && r.exitCode === 0 && !hasEmptyTextOutputWithoutOutputTarget(r.task, output)) {
1472
- c.addChild(new Text(truncLine(theme.fg("dim", ` ${preview}`), width), 0, 0));
1627
+ c.addChild(new Text(truncLine(theme.fg("dim", `${continuationIndent}${preview}`), width), 0, 0));
1473
1628
  }
1474
- if (r.sessionFile) c.addChild(new Text(truncLine(theme.fg("dim", ` session: ${shortenPath(r.sessionFile)}`), width), 0, 0));
1475
- if (r.artifactPaths) c.addChild(new Text(truncLine(theme.fg("dim", ` output: ${shortenPath(r.artifactPaths.outputPath)}`), width), 0, 0));
1476
- if (r.truncation?.artifactPath) c.addChild(new Text(truncLine(theme.fg("dim", ` full output: ${shortenPath(r.truncation.artifactPath)}`), width), 0, 0));
1629
+ if (r.sessionFile) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}session: ${shortenPath(r.sessionFile)}`), width), 0, 0));
1630
+ if (r.artifactPaths) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}output: ${shortenPath(r.artifactPaths.outputPath)}`), width), 0, 0));
1631
+ if (r.truncation?.artifactPath) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}full output: ${shortenPath(r.truncation.artifactPath)}`), width), 0, 0));
1477
1632
  return c;
1478
1633
  }
1479
1634
 
1480
1635
  function workflowRowGlyph(row: WorkflowChatProgressRow, theme: Theme, frame?: number): string {
1481
1636
  if (row.state === "running") return theme.fg("accent", runningGlyph(frame));
1482
1637
  if (row.state === "complete") return theme.fg("success", "✓");
1638
+ if (row.state === "stopped") return theme.fg("warning", "■");
1483
1639
  return theme.fg("error", "✗");
1484
1640
  }
1485
1641
 
@@ -1487,6 +1643,7 @@ function workflowRowStateLabel(row: WorkflowChatProgressRow, theme: Theme): stri
1487
1643
  const label = (row.state === "complete" ? "complete" : row.state).padEnd(8);
1488
1644
  if (row.state === "running") return theme.fg("accent", label);
1489
1645
  if (row.state === "complete") return theme.fg("success", label);
1646
+ if (row.state === "stopped") return theme.fg("warning", label);
1490
1647
  return theme.fg("error", label);
1491
1648
  }
1492
1649
 
@@ -1496,7 +1653,7 @@ function workflowOverallState(rows: WorkflowChatProgressRow[], hasTerminalValue:
1496
1653
  return "running";
1497
1654
  }
1498
1655
 
1499
- function renderWorkflowChatProgress(d: Details, result: AgentToolResult<Details>, theme: Theme, frame?: number): Component {
1656
+ function renderWorkflowChatProgress(d: Details, result: AgentToolResult<Details>, theme: Theme, layout: MainWindowRenderLayout, frame?: number): Component {
1500
1657
  const workflow = d.workflow;
1501
1658
  const rows = workflow ? buildWorkflowChatProgressRows(workflow.trace) : [];
1502
1659
  const state = workflowOverallState(rows, workflow?.value !== undefined, result.isError);
@@ -1506,26 +1663,29 @@ function renderWorkflowChatProgress(d: Details, result: AgentToolResult<Details>
1506
1663
  const repoLabel = d.chatProgress?.repoLabel ?? (d.chatProgress?.repoRelation === "same" ? "same repo" : "other repo");
1507
1664
  const phase = rows.find((row) => row.state === "running" && row.phase)?.phase ?? [...rows].reverse().find((row) => row.phase)?.phase;
1508
1665
  const c = new Container();
1666
+ const rowIndent = mainWindowIndent(layout, 1);
1509
1667
  c.addChild(new Text(truncLine(`${glyph} ${theme.fg("toolTitle", theme.bold("workflow"))} ${runId} ${theme.fg("dim", "·")} ${d.chatProgress?.repoRelation === "same" ? "same repo" : "other repo"} ${theme.fg("dim", "·")} ${state}`, width), 0, 0));
1510
- c.addChild(new Text(truncLine(theme.fg("dim", ` Repo ${repoLabel}`), width), 0, 0));
1511
- if (phase) c.addChild(new Text(truncLine(theme.fg("dim", ` Phase ${phase}`), width), 0, 0));
1668
+ c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}Repo ${repoLabel}`), width), 0, 0));
1669
+ if (phase) c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}Phase ${phase}`), width), 0, 0));
1512
1670
  if (rows.length === 0) {
1513
- c.addChild(new Text(truncLine(theme.fg("dim", " ◦ waiting for workflow child launches"), width), 0, 0));
1671
+ c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}◦ waiting for workflow child launches`), width), 0, 0));
1514
1672
  return c;
1515
1673
  }
1516
- for (const row of rows) {
1674
+ const visible = visibleWorkflowRows(rows);
1675
+ if (visible.hiddenRows > 0) c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}… ${visible.hiddenRows} older workflow rows hidden`), width), 0, 0));
1676
+ for (const row of visible.rows) {
1517
1677
  const status = workflowRowStateLabel(row, theme);
1518
- const label = row.label && row.label !== row.key ? ` ${row.label}` : "";
1678
+ const label = row.label && row.label !== row.key ? ` ${oneLine(row.label)}` : "";
1519
1679
  const duration = row.durationMs !== undefined ? ` ${theme.fg("dim", `· ${formatDuration(row.durationMs)}`)}` : "";
1520
1680
  const run = row.runId ? ` ${theme.fg("dim", `[${row.runId.slice(0, 8)}]`)}` : "";
1521
- const error = row.error ? ` ${theme.fg("error", `· ${row.error}`)}` : "";
1522
- c.addChild(new Text(truncLine(` ${workflowRowGlyph(row, theme, frame)} ${status} ${theme.bold(row.key)}${label}${run}${duration}${error}`, width), 0, 0));
1681
+ const error = row.error ? ` ${theme.fg("error", `· ${compactWorkflowError(row.error)}`)}` : "";
1682
+ c.addChild(new Text(truncLine(`${rowIndent}${workflowRowGlyph(row, theme, frame)} ${status} ${theme.bold(row.key)}${label}${run}${duration}${error}`, width), 0, 0));
1523
1683
  }
1524
- if (workflow?.emits.length) c.addChild(new Text(truncLine(theme.fg("dim", ` Emits ${workflow.emits.length}`), width), 0, 0));
1684
+ if (workflow?.emits.length) c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}Emits ${workflow.emits.length}`), width), 0, 0));
1525
1685
  return c;
1526
1686
  }
1527
1687
 
1528
- function renderMultiCompact(d: Details, theme: Theme, frame?: number): Component {
1688
+ function renderMultiCompact(d: Details, theme: Theme, layout: MainWindowRenderLayout, frame?: number): Component {
1529
1689
  const hasRunning = detailsHaveRunningResult(d);
1530
1690
  const detached = d.results.some((r) => r.detached)
1531
1691
  || workflowGraphHasStatus(d, ["detached"]);
@@ -1565,6 +1725,9 @@ function renderMultiCompact(d: Details, theme: Theme, frame?: number): Component
1565
1725
  const contextBadge = contextModeBadge(theme, d.context);
1566
1726
  const c = new Container();
1567
1727
  const width = getTermWidth() - 4;
1728
+ const rowIndent = mainWindowIndent(layout, 1);
1729
+ const detailIndent = mainWindowIndent(layout, 2);
1730
+ const continuationIndent = mainWindowIndent(layout, 3) + (layout.horizontalSpacing > 0 ? " " : "");
1568
1731
  c.addChild(new Text(truncLine(`${glyph} ${theme.fg("toolTitle", theme.bold(d.mode))}${contextBadge}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`, width), 0, 0));
1569
1732
 
1570
1733
  const useResultsDirectly = multiLabel.hasParallelInChain || !d.chainAgents?.length;
@@ -1582,8 +1745,8 @@ function renderMultiCompact(d: Details, theme: Theme, frame?: number): Component
1582
1745
  if (entry.kind === "placeholder") {
1583
1746
  const glyph = widgetStepGlyph(entry.status as AsyncJobStep["status"], theme);
1584
1747
  const statusLabel = widgetStepStatus(entry.status as AsyncJobStep["status"], theme);
1585
- c.addChild(new Text(truncLine(` ${glyph} ${entry.stepLabel}: ${themeBold(theme, entry.agentName)} ${theme.fg("dim", "·")} ${statusLabel}`, width), 0, 0));
1586
- if (entry.error) c.addChild(new Text(truncLine(theme.fg("error", ` ⎿ Error: ${entry.error}`), width), 0, 0));
1748
+ c.addChild(new Text(truncLine(`${rowIndent}${glyph} ${entry.stepLabel}: ${themeBold(theme, entry.agentName)} ${theme.fg("dim", "·")} ${statusLabel}`, width), 0, 0));
1749
+ if (entry.error) c.addChild(new Text(truncLine(theme.fg("error", `${detailIndent}⎿ Error: ${entry.error}`), width), 0, 0));
1587
1750
  continue;
1588
1751
  }
1589
1752
  const i = entry.resultIndex;
@@ -1592,7 +1755,7 @@ function renderMultiCompact(d: Details, theme: Theme, frame?: number): Component
1592
1755
  const agentName = entry.agentName;
1593
1756
  if (!r) {
1594
1757
  const pendingLabel = entry.rowLabel ?? `${itemTitle} ${rowNumber}`;
1595
- c.addChild(new Text(truncLine(theme.fg("dim", ` ◦ ${pendingLabel}: ${agentName} · pending`), width), 0, 0));
1758
+ c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}◦ ${pendingLabel}: ${agentName} · pending`), width), 0, 0));
1596
1759
  continue;
1597
1760
  }
1598
1761
  const output = getSingleResultOutput(r);
@@ -1608,28 +1771,28 @@ function renderMultiCompact(d: Details, theme: Theme, frame?: number): Component
1608
1771
  const rowProgressModel = rProg && "status" in rProg ? rProg : undefined;
1609
1772
  const rowModelDisplay = modelThinkingBadge(theme, r.model ?? rowProgressModel?.model, r.thinking ?? rowProgressModel?.thinking);
1610
1773
  const line = `${glyph} ${stepLabel}: ${themeBold(theme, agentName)}${contextModeBadge(theme, r.context)}${rowModelDisplay}${stepStats ? ` ${theme.fg("dim", "·")} ${stepStats}` : ""}${pendingLabel}`;
1611
- c.addChild(new Text(truncLine(` ${line}`, width), 0, 0));
1774
+ c.addChild(new Text(truncLine(`${rowIndent}${line}`, width), 0, 0));
1612
1775
  if (rRunning && rProg && "status" in rProg) {
1613
1776
  const liveProgress = rProg as AgentProgress;
1614
1777
  const activity = compactCurrentActivity(liveProgress);
1615
- c.addChild(new Text(truncLine(theme.fg("dim", ` ⎿ ${activity}`), width), 0, 0));
1778
+ c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}⎿ ${activity}`), width), 0, 0));
1616
1779
  for (const nestedLine of formatNestedWidgetLines(r.children, theme, width, false, snapshotNowForProgress(liveProgress))) {
1617
- c.addChild(new Text(truncLine(` ${nestedLine}`, width), 0, 0));
1780
+ c.addChild(new Text(truncLine(`${detailIndent}${nestedLine}`, width), 0, 0));
1618
1781
  }
1619
- c.addChild(new Text(truncLine(theme.fg("accent", ` ${liveDetailHintText()}`), width), 0, 0));
1782
+ c.addChild(new Text(truncLine(theme.fg("accent", `${detailIndent}${liveDetailHintText()}`), width), 0, 0));
1620
1783
  } else if (!rPending && (r.exitCode !== 0 || r.interrupted || r.detached || hasEmptyTextOutputWithoutOutputTarget(r.task, output))) {
1621
- c.addChild(new Text(truncLine(theme.fg(r.exitCode !== 0 ? "error" : "dim", ` ⎿ ${resultStatusLine(r, output)}`), width), 0, 0));
1784
+ c.addChild(new Text(truncLine(theme.fg(r.exitCode !== 0 ? "error" : "dim", `${detailIndent}⎿ ${resultStatusLine(r, output)}`), width), 0, 0));
1622
1785
  }
1623
1786
  if (!rRunning && !rPending) {
1624
1787
  for (const nestedLine of formatNestedWidgetLines(r.children, theme, width, false, r.progress?.lastActivityAt)) {
1625
- c.addChild(new Text(truncLine(` ${nestedLine}`, width), 0, 0));
1788
+ c.addChild(new Text(truncLine(`${detailIndent}${nestedLine}`, width), 0, 0));
1626
1789
  }
1627
1790
  }
1628
1791
  const outputTarget = extractOutputTarget(r.task);
1629
- if (outputTarget) c.addChild(new Text(truncLine(theme.fg("dim", ` output: ${outputTarget}`), width), 0, 0));
1630
- if (r.artifactPaths) c.addChild(new Text(truncLine(theme.fg("dim", ` output: ${shortenPath(r.artifactPaths.outputPath)}`), width), 0, 0));
1792
+ if (outputTarget) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}output: ${outputTarget}`), width), 0, 0));
1793
+ if (r.artifactPaths) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}output: ${shortenPath(r.artifactPaths.outputPath)}`), width), 0, 0));
1631
1794
  }
1632
- if (d.artifacts) c.addChild(new Text(truncLine(theme.fg("dim", ` artifacts: ${shortenPath(d.artifacts.dir)}`), width), 0, 0));
1795
+ if (d.artifacts) c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}artifacts: ${shortenPath(d.artifacts.dir)}`), width), 0, 0));
1633
1796
  return c;
1634
1797
  }
1635
1798
 
@@ -1680,22 +1843,28 @@ export function renderSubagentResult(
1680
1843
  options: { expanded: boolean },
1681
1844
  theme: Theme,
1682
1845
  frame?: number,
1846
+ rendererConfig?: MainWindowRendererConfig,
1683
1847
  ): Component {
1848
+ const layout = resolveMainWindowRenderLayout(rendererConfig);
1849
+ const compact = (component: Component): Component => capCompactMainWindowResult(component, layout, theme, !options.expanded);
1684
1850
  const d = result.details;
1685
- if (d?.mode === "workflow" && d.chatProgress?.mode === "live-card" && !result.isError && d.workflow?.value === undefined) return renderWorkflowChatProgress(d, result, theme, frame);
1851
+ if (d?.mode === "workflow" && d.chatProgress?.mode === "live-card" && !result.isError && d.workflow?.value === undefined) {
1852
+ return compact(renderWorkflowChatProgress(d, result, theme, options.expanded ? resolveMainWindowRenderLayout() : layout, frame));
1853
+ }
1686
1854
  if (!d || !d.results.length) {
1687
1855
  const t = result.content[0];
1688
1856
  const text = t?.type === "text" ? t.text : "(no output)";
1689
1857
  const contextPrefix = contextModePrefix(theme, d?.context);
1690
1858
  const width = getTermWidth() - 4;
1691
- if (!text.includes("\n")) return new Text(truncLine(`${contextPrefix}${text}`, width), 0, 0);
1859
+ if (!text.includes("\n")) return compact(new Text(truncLine(`${contextPrefix}${text}`, width), 0, 0));
1692
1860
  if (d && !options.expanded && !result.isError) {
1693
1861
  const lines = text.split(/\r?\n/);
1694
1862
  const firstNonEmptyLine = lines.find((line) => line.trim())?.trim() || "(no output)";
1695
1863
  const c = new Container();
1864
+ const detailIndent = mainWindowIndent(layout, 1);
1696
1865
  c.addChild(new Text(truncLine(`${contextPrefix}${firstNonEmptyLine} · ${lines.length} lines`, width), 0, 0));
1697
- c.addChild(new Text(truncLine(theme.fg("accent", ` Press ${liveDetailKeyText()} for full output`), width), 0, 0));
1698
- return c;
1866
+ c.addChild(new Text(truncLine(theme.fg("accent", `${detailIndent}Press ${liveDetailKeyText()} for full output`), width), 0, 0));
1867
+ return compact(c);
1699
1868
  }
1700
1869
  const c = new Container();
1701
1870
  const wrapped = wrapPlainText(`${contextPrefix}${text}`, width);
@@ -1708,8 +1877,8 @@ export function renderSubagentResult(
1708
1877
 
1709
1878
  if (d.mode === "single" && d.results.length === 1) {
1710
1879
  const r = d.results[0];
1711
- if (!r) return renderMultiCompact(d, theme, frame);
1712
- if (!expanded) return renderSingleCompact(d, r, theme, frame);
1880
+ if (!r) return compact(renderMultiCompact(d, theme, layout, frame));
1881
+ if (!expanded) return compact(renderSingleCompact(d, r, theme, layout, frame));
1713
1882
  const isRunning = isResultRunning(r);
1714
1883
  const contextBadge = contextModeBadge(theme, r.context ?? d.context);
1715
1884
  const output = r.truncation?.text || getSingleResultOutput(r);
@@ -1756,13 +1925,11 @@ export function renderSubagentResult(
1756
1925
  if (r.progress.recentTools?.length) {
1757
1926
  for (const t of r.progress.recentTools.slice(-3)) {
1758
1927
  const maxArgsLen = Math.max(40, w - 24);
1759
- const argsPreview = expanded || t.args.length <= maxArgsLen
1760
- ? t.args
1761
- : `${t.args.slice(0, maxArgsLen)}...`;
1928
+ const argsPreview = renderToolArgsPreview(t.args, maxArgsLen, expanded);
1762
1929
  c.addChild(new Text(fit(theme.fg("dim", `${t.tool}: ${argsPreview}`)), 0, 0));
1763
1930
  }
1764
1931
  }
1765
- for (const line of (r.progress.recentOutput ?? []).slice(-5)) {
1932
+ for (const line of compactRecentOutputLines(r.progress.recentOutput)) {
1766
1933
  c.addChild(new Text(fit(theme.fg("dim", ` ${line}`)), 0, 0));
1767
1934
  }
1768
1935
  if (toolLine || liveStatusLine || r.progress.recentTools?.length || r.progress.recentOutput?.length || r.artifactPaths) {
@@ -1804,7 +1971,7 @@ export function renderSubagentResult(
1804
1971
  return c;
1805
1972
  }
1806
1973
 
1807
- if (!expanded) return renderMultiCompact(d, theme, frame);
1974
+ if (!expanded) return compact(renderMultiCompact(d, theme, layout, frame));
1808
1975
 
1809
1976
  const hasRunning = detailsHaveRunningResult(d);
1810
1977
  const detached = d.results.some((r) => r.detached)
@@ -1989,14 +2156,11 @@ export function renderSubagentResult(
1989
2156
  if (rProg.recentTools?.length) {
1990
2157
  for (const t of rProg.recentTools.slice(-3)) {
1991
2158
  const maxArgsLen = Math.max(40, w - 30);
1992
- const argsPreview = expanded || t.args.length <= maxArgsLen
1993
- ? t.args
1994
- : `${t.args.slice(0, maxArgsLen)}...`;
2159
+ const argsPreview = renderToolArgsPreview(t.args, maxArgsLen, expanded);
1995
2160
  c.addChild(new Text(fit(theme.fg("dim", ` ${t.tool}: ${argsPreview}`)), 0, 0));
1996
2161
  }
1997
2162
  }
1998
- const recentLines = (rProg.recentOutput ?? []).slice(-5);
1999
- for (const line of recentLines) {
2163
+ for (const line of compactRecentOutputLines(rProg.recentOutput)) {
2000
2164
  c.addChild(new Text(fit(theme.fg("dim", ` ${line}`)), 0, 0));
2001
2165
  }
2002
2166
  }
@@ -2,10 +2,11 @@ import { spawnSync } from "node:child_process";
2
2
  import { createHash } from "node:crypto";
3
3
  import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
+ import { PROJECT_SUBAGENTS_RELATIVE_DIR } from "../shared/artifacts.ts";
5
6
 
6
- const IGNORED_CHANGE_PREFIXES = [".pi-subagents/", "tmp/", "node_modules/"];
7
- const IGNORED_CHANGE_PATHS = new Set([".pi-subagents", "tmp", "node_modules"]);
8
- const IGNORED_CHANGE_SEGMENTS = new Set([".git", ".pi-subagents", "node_modules"]);
7
+ const IGNORED_CHANGE_PREFIXES = [`${PROJECT_SUBAGENTS_RELATIVE_DIR}/`, "tmp/", "node_modules/"];
8
+ const IGNORED_CHANGE_PATHS = new Set([PROJECT_SUBAGENTS_RELATIVE_DIR, "tmp", "node_modules"]);
9
+ const IGNORED_CHANGE_SEGMENTS = new Set([".git", "node_modules"]);
9
10
 
10
11
  const DEFAULT_MAX_HASH_FILE_BYTES = 64 * 1024 * 1024;
11
12
  const DEFAULT_MAX_HASH_TOTAL_BYTES = 64 * 1024 * 1024;
@@ -3,6 +3,7 @@ import { convertToLlm, type ExtensionContext } from "@earendil-works/pi-coding-a
3
3
  import { streamSimple } from "@earendil-works/pi-ai/compat";
4
4
  import { Type, type Static } from "typebox";
5
5
  import { appendPermissionAudit, permissionArgsPreview } from "../runs/shared/permissions.ts";
6
+ import { agentStreamOptions } from "../shared/agent-stream-options.ts";
6
7
  import { decodeChildWatchdogConfig } from "./child-status.ts";
7
8
  import { childResolvedConfig } from "./register-child.ts";
8
9
  import { resolveWatchdogReviewModel } from "./review.ts";
@@ -112,7 +113,7 @@ export function createWatchdogPermissionArbiter(options: WatchdogPermissionArbit
112
113
  tools: [tool],
113
114
  },
114
115
  convertToLlm,
115
- streamFn: streamFn,
116
+ streamFn: streamFn,
116
117
  getApiKey: (providerName) => providerName === selection.model.provider ? auth.apiKey : undefined,
117
118
  beforeToolCall: async ({ toolCall }) => toolCall.name === tool.name ? undefined : { block: true, reason: `Permission arbiter tool '${toolCall.name}' is not allowed.` },
118
119
  toolExecution: "sequential",