@oh-my-pi/pi-tui 18.15.0 → 18.16.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 (67) hide show
  1. package/CHANGELOG.md +36 -18
  2. package/dist/types/app-keybindings.d.ts +5 -0
  3. package/dist/types/apps/session-picker.d.ts +5 -3
  4. package/dist/types/chat/bash-execution.d.ts +4 -1
  5. package/dist/types/chat/eval-execution.d.ts +2 -0
  6. package/dist/types/chat/execution-shared.d.ts +14 -8
  7. package/dist/types/chrome/dynamic-border.d.ts +6 -0
  8. package/dist/types/components/editor.d.ts +15 -6
  9. package/dist/types/components/loader.d.ts +2 -0
  10. package/dist/types/keybinding-matchers.d.ts +7 -0
  11. package/dist/types/overlays/btw-history-panel.d.ts +13 -0
  12. package/dist/types/overlays/btw-history.d.ts +24 -0
  13. package/dist/types/overlays/btw-inject.d.ts +22 -0
  14. package/dist/types/overlays/btw-panel.d.ts +7 -0
  15. package/dist/types/overlays/session-selector.d.ts +24 -3
  16. package/dist/types/render/render-utils.d.ts +4 -1
  17. package/dist/types/status-line/startup.d.ts +0 -15
  18. package/dist/types/theme/symbols.d.ts +3 -1
  19. package/dist/types/theme/theme-class.d.ts +1 -0
  20. package/dist/types/tools/output-meta.d.ts +27 -0
  21. package/dist/types/utils.d.ts +4 -0
  22. package/package.json +9 -9
  23. package/src/app-keybindings.ts +5 -0
  24. package/src/apps/session-picker.ts +7 -3
  25. package/src/chat/bash-execution.ts +20 -9
  26. package/src/chat/chat-transcript-builder.ts +1 -0
  27. package/src/chat/eval-execution.ts +14 -7
  28. package/src/chat/execution-shared.ts +39 -18
  29. package/src/chat/read-tool-group.ts +9 -16
  30. package/src/chat/transcript-render-helpers.ts +16 -4
  31. package/src/chrome/dynamic-border.ts +28 -2
  32. package/src/components/editor.ts +123 -24
  33. package/src/components/key-value-list.ts +9 -9
  34. package/src/components/loader.ts +7 -0
  35. package/src/components/section.ts +1 -9
  36. package/src/components/table.ts +1 -9
  37. package/src/keybinding-matchers.ts +13 -0
  38. package/src/overlays/btw-history-panel.ts +98 -14
  39. package/src/overlays/btw-history.ts +65 -0
  40. package/src/overlays/btw-inject.ts +91 -0
  41. package/src/overlays/btw-panel.ts +53 -12
  42. package/src/overlays/model-browser.ts +65 -8
  43. package/src/overlays/session-selector.ts +131 -26
  44. package/src/overlays/usage-dashboard.ts +2 -2
  45. package/src/render/code-cell.ts +1 -1
  46. package/src/render/render-utils.ts +5 -3
  47. package/src/setup/scenes/glyph.ts +1 -1
  48. package/src/status-line/startup.ts +36 -70
  49. package/src/theme/symbols.ts +16 -9
  50. package/src/theme/theme-class.ts +3 -0
  51. package/src/tools/agent-tree.ts +13 -11
  52. package/src/tools/ask.ts +13 -6
  53. package/src/tools/bash.ts +7 -0
  54. package/src/tools/default-renderer.ts +1 -1
  55. package/src/tools/edit.ts +39 -41
  56. package/src/tools/fetch.ts +2 -1
  57. package/src/tools/github.ts +14 -46
  58. package/src/tools/json-tree.ts +1 -5
  59. package/src/tools/lsp.ts +38 -10
  60. package/src/tools/output-meta.ts +68 -4
  61. package/src/tools/proc-render.ts +1 -1
  62. package/src/tools/task.ts +34 -77
  63. package/src/tools/vibe.ts +4 -4
  64. package/src/tools/wait.ts +2 -2
  65. package/src/tools/write.ts +17 -27
  66. package/src/tools/yield.ts +1 -1
  67. package/src/utils.ts +10 -0
@@ -44,6 +44,7 @@ interface AppKeybindings {
44
44
  "app.message.followUp": true;
45
45
  "app.retry": true;
46
46
  "app.message.dequeue": true;
47
+ "app.btw.inject": true;
47
48
  "app.clipboard.pasteImage": true;
48
49
  "app.clipboard.pasteTextRaw": true;
49
50
  "app.clipboard.copyLine": true;
@@ -182,6 +183,10 @@ export const KEYBINDINGS = {
182
183
  defaultKeys: ["alt+up", "shift+up"],
183
184
  description: "Dequeue message",
184
185
  },
186
+ "app.btw.inject": {
187
+ defaultKeys: "alt+i",
188
+ description: "Send a /btw answer's steering prompt to the main session",
189
+ },
185
190
  "app.clipboard.pasteImage": {
186
191
  defaultKeys: getDefaultPasteImageKeys(),
187
192
  description: "Paste image or text from clipboard",
@@ -1,8 +1,9 @@
1
1
  import { logger } from "@oh-my-pi/pi-utils";
2
2
  import {
3
3
  SessionSelectorComponent,
4
- type SessionSelectorEntry,
5
4
  type SessionHistoryMatcher,
5
+ type SessionListing,
6
+ type SessionSelectorEntry,
6
7
  } from "../overlays/session-selector";
7
8
  import { runStandaloneTui } from "./standalone-picker";
8
9
 
@@ -14,12 +15,14 @@ export interface SessionPickerHost<T extends SessionSelectorEntry = SessionSelec
14
15
  /** Rename the session and resolve with the title as stored, or null when it did not happen. */
15
16
  renameSession?(session: T, title: string): Promise<string | null>;
16
17
  setSessionPinned?(session: T, pinned: boolean): Promise<void>;
17
- loadAllSessions?(): Promise<T[]>;
18
+ loadAllSessions?(): Promise<SessionListing<T>>;
18
19
  }
19
20
 
20
21
  /** Presentation and capability controls for the standalone session picker. */
21
22
  export interface SessionPickerOptions<T extends SessionSelectorEntry = SessionSelectorEntry> {
22
- allSessions?: T[];
23
+ /** Complete listing replacing the preliminary `sessions` once it settles. */
24
+ completeSessions?: Promise<T[]>;
25
+ allSessions?: SessionListing<T>;
23
26
  title?: string;
24
27
  scopeLabel?: string | false;
25
28
  showCwd?: boolean;
@@ -71,6 +74,7 @@ export async function selectSession<T extends SessionSelectorEntry>(
71
74
  onRename: options.onRename ?? host.renameSession,
72
75
  onSetPinned: host.setSessionPinned,
73
76
  historyMatcher,
77
+ completeSessions: options.completeSessions,
74
78
  loadAllSessions: options.allowGlobalScope === false ? undefined : host.loadAllSessions,
75
79
  allSessions: options.allSessions,
76
80
  getTerminalRows: () => ui.terminal.rows,
@@ -12,7 +12,7 @@ import { sanitizeText } from "@oh-my-pi/pi-utils";
12
12
  import type { Terminal as XtermTerminalType } from "@oh-my-pi/pi-utils/vterm";
13
13
  import { theme } from "../theme/theme";
14
14
  import type { OutputArtifactError } from "../tools/streaming-output";
15
- import type { TruncationMeta } from "../tools/output-meta";
15
+ import type { MinimizedMeta, TruncationMeta } from "../tools/output-meta";
16
16
  import { resolveImageOptions } from "../render/render-utils";
17
17
  import { OutputPane } from "../render/output-pane";
18
18
  import { loadXtermTerminal, readTerminalRows, styleTerminalRow } from "../tools/terminal-output";
@@ -26,6 +26,7 @@ import {
26
26
  describeExecutionTool,
27
27
  type ExecutionColorKey,
28
28
  type ExecutionStatus,
29
+ executionStatusLabel,
29
30
  PREVIEW_LINES,
30
31
  resolveExecutionStatus,
31
32
  } from "./execution-shared";
@@ -34,6 +35,7 @@ import { type DescribeContext, type NativeNode, type NativeUiEvent, rootToggleEx
34
35
  import { NativeImageCache } from "../native/blobs";
35
36
  import { imageLinksEnabled, linkedImageSpan, linkedImageText } from "../prompt/image-references";
36
37
  import { Memo } from "../native/memo";
38
+ import type { DynamicBorder } from "../chrome/dynamic-border";
37
39
 
38
40
  const STREAMING_LINE_CAP = PREVIEW_LINES * 5;
39
41
  // Minimum interval between processing incoming chunks for display (ms).
@@ -59,8 +61,10 @@ export class BashExecutionComponent extends Container {
59
61
  #status: ExecutionStatus = "running";
60
62
  #exitCode: number | undefined = undefined;
61
63
  #loader: Loader;
64
+ readonly #bottomBorder: DynamicBorder;
62
65
  #truncation?: TruncationMeta;
63
66
  #artifactError?: OutputArtifactError;
67
+ #minimized?: MinimizedMeta;
64
68
  #expanded = false;
65
69
  // Post-finalize mutation counter (FinalizableBlock.getTranscriptBlockVersion):
66
70
  // a completed command's block still mutates on expansion toggles, and the
@@ -103,9 +107,10 @@ export class BashExecutionComponent extends Container {
103
107
  // Use dim border for excluded-from-context commands (!! prefix)
104
108
  const colorKey = excludeFromContext ? "dim" : "bashMode";
105
109
  this.#colorKey = colorKey;
106
- const { contentContainer, loader } = buildExecutionFrame(this, ui, colorKey);
110
+ const { contentContainer, loader, bottomBorder } = buildExecutionFrame(this, ui, colorKey);
107
111
  this.#contentContainer = contentContainer;
108
112
  this.#loader = loader;
113
+ this.#bottomBorder = bottomBorder;
109
114
  this.#outputPane = new OutputPane(theme, {
110
115
  expanded: false,
111
116
  collapsedMaxLines: PREVIEW_LINES,
@@ -121,7 +126,6 @@ export class BashExecutionComponent extends Container {
121
126
  // Command header
122
127
  this.#headerText = new Text(theme.fg(colorKey, theme.bold(`$ ${command}`)), 1, 0);
123
128
  this.#contentContainer.addChild(this.#headerText);
124
- this.#contentContainer.addChild(this.#loader);
125
129
  }
126
130
 
127
131
  /**
@@ -200,6 +204,7 @@ export class BashExecutionComponent extends Container {
200
204
  exitCode: this.#exitCode,
201
205
  truncation: this.#truncation,
202
206
  artifactError: this.#artifactError,
207
+ minimized: this.#minimized,
203
208
  };
204
209
  return dataFirst
205
210
  ? describeExecutionTool({
@@ -358,6 +363,7 @@ export class BashExecutionComponent extends Container {
358
363
  output?: string;
359
364
  truncation?: TruncationMeta;
360
365
  artifactError?: OutputArtifactError;
366
+ minimized?: MinimizedMeta;
361
367
  images?: readonly ImageContent[];
362
368
  showImages?: boolean;
363
369
  },
@@ -367,6 +373,7 @@ export class BashExecutionComponent extends Container {
367
373
  this.#endedAt ??= performance.now();
368
374
  this.#truncation = options?.truncation;
369
375
  this.#artifactError = options?.artifactError;
376
+ this.#minimized = options?.minimized;
370
377
  this.#images = options?.images ?? [];
371
378
  this.#showImages = options?.showImages ?? true;
372
379
  if (options?.output !== undefined && !this.#ptyMode) {
@@ -383,6 +390,12 @@ export class BashExecutionComponent extends Container {
383
390
  this.#updateDisplay();
384
391
  }
385
392
 
393
+ /** The loader animates the bottom border from outside the child tree, so teardown stops it here. */
394
+ override dispose(): void {
395
+ this.#loader.dispose();
396
+ super.dispose();
397
+ }
398
+
386
399
  override render(width: number): readonly string[] {
387
400
  if (this.#displayDirty) {
388
401
  this.#displayDirty = false;
@@ -440,15 +453,13 @@ export class BashExecutionComponent extends Container {
440
453
  }
441
454
  }
442
455
 
443
- // Loader or status
444
- if (this.#status === "running") {
445
- this.#contentContainer.addChild(this.#loader);
446
- } else {
456
+ // The bottom border keeps the live loader until the run settles, then its exit/cancel marker.
457
+ if (this.#status !== "running") {
458
+ this.#bottomBorder.setLabel(executionStatusLabel(this.#status, this.#exitCode));
447
459
  const footer = buildStatusFooter({
448
- status: this.#status,
449
- exitCode: this.#exitCode,
450
460
  truncation: this.#truncation,
451
461
  artifactError: this.#artifactError,
462
+ minimized: this.#minimized,
452
463
  hiddenLineCount,
453
464
  suppressHiddenCount: hasSixelOutput,
454
465
  });
@@ -356,6 +356,7 @@ export class ChatTranscriptBuilder {
356
356
  component.setComplete(message.exitCode, message.cancelled, {
357
357
  truncation: message.meta?.truncation,
358
358
  artifactError: message.meta?.artifactError,
359
+ minimized: message.meta?.minimized,
359
360
  images: message.images,
360
361
  showImages: displayPreferences.showImages,
361
362
  });
@@ -19,12 +19,14 @@ import {
19
19
  describeExecutionTool,
20
20
  type ExecutionColorKey,
21
21
  type ExecutionStatus,
22
+ executionStatusLabel,
22
23
  PREVIEW_LINES,
23
24
  resolveExecutionStatus,
24
25
  } from "./execution-shared";
25
26
  import { code, span } from "../native/describe";
26
27
  import { type DescribeContext, type NativeNode, type NativeUiEvent, rootToggleExpanded } from "../native/node";
27
28
  import { Memo } from "../native/memo";
29
+ import type { DynamicBorder } from "../chrome/dynamic-border";
28
30
 
29
31
  export type EvalExecutionLanguage = "python" | "js";
30
32
 
@@ -32,6 +34,7 @@ export class EvalExecutionComponent extends Container {
32
34
  #status: ExecutionStatus = "running";
33
35
  #exitCode: number | undefined = undefined;
34
36
  #loader: Loader;
37
+ readonly #bottomBorder: DynamicBorder;
35
38
  #truncation?: TruncationMeta;
36
39
  #artifactError?: OutputArtifactError;
37
40
  #expanded = false;
@@ -72,9 +75,10 @@ export class EvalExecutionComponent extends Container {
72
75
  this.#language = language;
73
76
 
74
77
  const colorKey: ExecutionColorKey = this.#excludeFromContext ? "dim" : "pythonMode";
75
- const { contentContainer, loader } = buildExecutionFrame(this, ui, colorKey);
78
+ const { contentContainer, loader, bottomBorder } = buildExecutionFrame(this, ui, colorKey);
76
79
  this.#contentContainer = contentContainer;
77
80
  this.#loader = loader;
81
+ this.#bottomBorder = bottomBorder;
78
82
  this.#outputPane = new OutputPane(theme, {
79
83
  expanded: false,
80
84
  collapsedMaxLines: PREVIEW_LINES,
@@ -89,7 +93,6 @@ export class EvalExecutionComponent extends Container {
89
93
  });
90
94
 
91
95
  this.#contentContainer.addChild(this.#formatHeader(colorKey));
92
- this.#contentContainer.addChild(this.#loader);
93
96
  }
94
97
 
95
98
  /**
@@ -188,6 +191,12 @@ export class EvalExecutionComponent extends Container {
188
191
  this.#updateDisplay();
189
192
  }
190
193
 
194
+ /** The loader animates the bottom border from outside the child tree, so teardown stops it here. */
195
+ override dispose(): void {
196
+ this.#loader.dispose();
197
+ super.dispose();
198
+ }
199
+
191
200
  #updateDisplay(): void {
192
201
  // Only the collapsed preview hides lines; when expanded the footer must
193
202
  // not keep advertising hidden lines / ctrl+o.
@@ -200,12 +209,10 @@ export class EvalExecutionComponent extends Container {
200
209
 
201
210
  if (this.#outputPane.lineCount > 0) this.#contentContainer.addChild(this.#outputPane);
202
211
 
203
- if (this.#status === "running") {
204
- this.#contentContainer.addChild(this.#loader);
205
- } else {
212
+ // The bottom border keeps the live loader until the run settles, then its exit/cancel marker.
213
+ if (this.#status !== "running") {
214
+ this.#bottomBorder.setLabel(executionStatusLabel(this.#status, this.#exitCode));
206
215
  const footer = buildStatusFooter({
207
- status: this.#status,
208
- exitCode: this.#exitCode,
209
216
  truncation: this.#truncation,
210
217
  artifactError: this.#artifactError,
211
218
  hiddenLineCount,
@@ -10,9 +10,15 @@
10
10
  import { Loader } from "../components/loader";
11
11
  import { Text } from "../components/text";
12
12
  import { Container, type TUI } from "../tui";
13
- import { getSymbolTheme, theme } from "../theme/theme";
13
+ import { theme } from "../theme/theme";
14
14
  import type { OutputArtifactError } from "../tools/streaming-output";
15
- import { formatArtifactErrorNotice, formatTruncationMetaNotice, type TruncationMeta } from "../tools/output-meta";
15
+ import {
16
+ formatArtifactErrorNotice,
17
+ formatMinimizedMeta,
18
+ formatTruncationMetaNotice,
19
+ type MinimizedMeta,
20
+ type TruncationMeta,
21
+ } from "../tools/output-meta";
16
22
  import { DynamicBorder } from "../chrome/dynamic-border";
17
23
  import { Ellipsis, truncateToWidth, visibleWidth } from "../utils";
18
24
  import { interruptKey } from "../chrome/keybinding-hints";
@@ -46,14 +52,15 @@ export type ExecutionColorKey = "dim" | "bashMode" | "pythonMode";
46
52
  /**
47
53
  * Build the spacer + top border + content container + bottom border scaffold
48
54
  * that bash and eval execution components share. The caller appends the
49
- * header (command vs `>>>` prompt) and the returned loader to
50
- * `contentContainer` so per-mode order is preserved.
55
+ * header (command vs `>>>` prompt) to `contentContainer` and keeps the run's
56
+ * state in `bottomBorder` ({@link executionStatusLabel}); the returned loader
57
+ * animates that label rather than taking a row of its own.
51
58
  */
52
59
  export function buildExecutionFrame(
53
60
  parent: Container,
54
61
  ui: TUI,
55
62
  colorKey: ExecutionColorKey,
56
- ): { contentContainer: Container; loader: Loader } {
63
+ ): { contentContainer: Container; loader: Loader; bottomBorder: DynamicBorder } {
57
64
  const borderColor = (str: string) => theme.fg(colorKey, str);
58
65
 
59
66
  parent.addChild(new DynamicBorder(borderColor));
@@ -66,23 +73,35 @@ export function buildExecutionFrame(
66
73
  spinner => theme.fg(colorKey, spinner),
67
74
  text => theme.fg("muted", text),
68
75
  `Running… (${interruptKey()} to cancel)`,
69
- getSymbolTheme().spinnerFrames,
76
+ // The status spinner, as on a running tool card's header.
77
+ theme.spinnerFrames,
70
78
  );
71
79
 
72
- parent.addChild(new DynamicBorder(borderColor));
73
- return { contentContainer, loader };
80
+ const bottomBorder = new DynamicBorder(borderColor);
81
+ bottomBorder.setLabel(() => loader.inlineText());
82
+ parent.addChild(bottomBorder);
83
+ return { contentContainer, loader, bottomBorder };
84
+ }
85
+
86
+ /** The bottom-border marker of a settled run: `exit N` for a failure, `cancelled` for a cancel. */
87
+ export function executionStatusLabel(
88
+ status: Exclude<ExecutionStatus, "running">,
89
+ exitCode: number | undefined,
90
+ ): string | undefined {
91
+ if (status === "cancelled") return theme.fg("warning", "cancelled");
92
+ if (status === "error") return theme.fg("error", `exit ${exitCode}`);
93
+ return undefined;
74
94
  }
75
95
 
76
96
  /**
77
- * Build the post-run status block (hidden-line hint, exit/cancel marker,
78
- * truncation notice). Returns undefined when there is nothing to display so
79
- * callers can skip appending a stray Text child.
97
+ * Build the post-run status block (hidden-line hint, truncation notice).
98
+ * Returns undefined when there is nothing to display so callers can skip
99
+ * appending a stray Text child.
80
100
  */
81
101
  export function buildStatusFooter(opts: {
82
- status: ExecutionStatus;
83
- exitCode: number | undefined;
84
102
  truncation: TruncationMeta | undefined;
85
103
  artifactError?: OutputArtifactError;
104
+ minimized?: MinimizedMeta;
86
105
  hiddenLineCount: number;
87
106
  /** Suppress the "… N more lines" hint (used when sixel passthrough renders the full output). */
88
107
  suppressHiddenCount?: boolean;
@@ -92,17 +111,15 @@ export function buildStatusFooter(opts: {
92
111
  if (opts.hiddenLineCount > 0 && !opts.suppressHiddenCount) {
93
112
  parts.push(theme.fg("dim", `… ${opts.hiddenLineCount} more lines (${expandKeyHint()} to expand)`));
94
113
  }
95
- if (opts.status === "cancelled") {
96
- parts.push(theme.fg("warning", "(cancelled)"));
97
- } else if (opts.status === "error") {
98
- parts.push(theme.fg("error", `(exit ${opts.exitCode})`));
99
- }
100
114
  if (opts.truncation) {
101
115
  parts.push(theme.fg("warning", formatTruncationMetaNotice(opts.truncation)));
102
116
  }
103
117
  if (opts.artifactError) {
104
118
  parts.push(theme.fg("warning", formatArtifactErrorNotice(opts.artifactError)));
105
119
  }
120
+ if (opts.minimized) {
121
+ parts.push(theme.fg("dim", `Minimized: ${formatMinimizedMeta(opts.minimized)}`));
122
+ }
106
123
 
107
124
  if (parts.length === 0) return undefined;
108
125
  return new Text(`\n${parts.join("\n")}`, 1, 0);
@@ -133,6 +150,7 @@ export interface ExecutionCardInput {
133
150
  readonly exitCode: number | undefined;
134
151
  readonly truncation: TruncationMeta | undefined;
135
152
  readonly artifactError?: OutputArtifactError;
153
+ readonly minimized?: MinimizedMeta;
136
154
  }
137
155
 
138
156
  /**
@@ -170,6 +188,7 @@ export function describeExecutionCard(input: ExecutionCardInput): NativeNode {
170
188
  if (input.status === "cancelled") note("(cancelled)", "warning");
171
189
  else if (input.status === "error") note(`(exit ${input.exitCode})`, "error");
172
190
  if (input.truncation) note(formatTruncationMetaNotice(input.truncation), "warning");
191
+ if (input.minimized) note(`Minimized: ${formatMinimizedMeta(input.minimized)}`, "muted");
173
192
  if (input.artifactError) note(formatArtifactErrorNotice(input.artifactError), "warning");
174
193
  if (notes.length > 0) children.push(text(notes, { wrap: "word", key: "notes" }));
175
194
  return card(
@@ -207,6 +226,7 @@ export interface ExecutionToolInput {
207
226
  readonly exitCode: number | undefined;
208
227
  readonly truncation: TruncationMeta | undefined;
209
228
  readonly artifactError?: OutputArtifactError;
229
+ readonly minimized?: MinimizedMeta;
210
230
  }
211
231
 
212
232
  const EXECUTION_RUN_STATE: Record<ExecutionStatus, RunState> = {
@@ -244,6 +264,7 @@ export function describeExecutionTool(input: ExecutionToolInput): NativeNode {
244
264
  state,
245
265
  exitCode: input.exitCode,
246
266
  elapsedMs: ms,
267
+ facts: input.minimized ? [`Minimized ${formatMinimizedMeta(input.minimized)}`] : undefined,
247
268
  meta: { truncation: input.truncation, artifactError: input.artifactError },
248
269
  }),
249
270
  ],
@@ -14,7 +14,13 @@ import {
14
14
  splitPathAndSel,
15
15
  splitReadQuery,
16
16
  } from "../tools/read";
17
- import { FILE_NAME_COLOR, formatStyledPath, PREVIEW_LIMITS, shortenPath } from "../render/render-utils";
17
+ import {
18
+ FILE_NAME_COLOR,
19
+ formatStatusIcon,
20
+ formatStyledPath,
21
+ PREVIEW_LIMITS,
22
+ shortenPath,
23
+ } from "../render/render-utils";
18
24
  import { fileHyperlink, renderCodeCell, renderMarkdownCell } from "../render";
19
25
  import { wrapTreeLine } from "../render/hanging-wrap";
20
26
  import { wrapTextWithAnsi } from "../utils";
@@ -930,7 +936,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
930
936
  if (displayRows.length === 1) {
931
937
  const row = displayRows[0]!;
932
938
  if (!this.#shouldRenderPreviewRow(row)) {
933
- const statusSymbol = this.#formatStatus(this.#statusForTargets(row.targets));
939
+ const statusSymbol = formatStatusIcon(this.#statusForTargets(row.targets), theme);
934
940
  const pathDisplay = this.#formatRowPath(row, HEADER_PATH_PAINT);
935
941
  const lines = [` ${statusSymbol} ${theme.fg("toolTitle", theme.bold("Read"))} ${pathDisplay}`.trimEnd()];
936
942
  const usageRows = this.#usageRowsBySummaryRow(displayRows).get(0) ?? [];
@@ -1096,7 +1102,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
1096
1102
 
1097
1103
  #formatRow(row: ReadSummaryRow): string {
1098
1104
  const status = this.#statusForTargets(row.targets);
1099
- const statusPrefix = status === "success" ? "" : `${this.#formatStatus(status)} `;
1105
+ const statusPrefix = status === "success" ? "" : `${formatStatusIcon(status, theme)} `;
1100
1106
  return `${statusPrefix}${this.#formatRowPath(row)}`;
1101
1107
  }
1102
1108
 
@@ -1279,17 +1285,4 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
1279
1285
  #shouldRenderPreview(entry: ReadEntry): boolean {
1280
1286
  return this.#showContentPreview && entry.contentText !== undefined;
1281
1287
  }
1282
-
1283
- #formatStatus(status: ReadEntry["status"]): string {
1284
- if (status === "success") {
1285
- return theme.fg("text", theme.status.enabled);
1286
- }
1287
- if (status === "warning") {
1288
- return theme.fg("warning", theme.status.warning);
1289
- }
1290
- if (status === "error") {
1291
- return theme.fg("error", theme.status.error);
1292
- }
1293
- return theme.fg("dim", theme.status.pending);
1294
- }
1295
1288
  }
@@ -13,7 +13,12 @@ import type { JobSnapshot } from "../tools/wait";
13
13
  import type { DaemonSnapshot } from "../tools/daemon";
14
14
  import { type CustomMessage, type FileMentionMessage, resolveAbortLabel, shouldRenderAbortReason } from "./messages";
15
15
  import { createIrcMessageCard } from "../tools/wait";
16
- import { formatArtifactErrorNotice, type OutputMeta } from "../tools/output-meta";
16
+ import {
17
+ formatArtifactErrorNotice,
18
+ formatMinimizedMeta,
19
+ type MinimizedMeta,
20
+ type OutputMeta,
21
+ } from "../tools/output-meta";
17
22
  import type { OutputArtifactError } from "../tools/streaming-output";
18
23
  import { formatStyledPath, replaceTabs, TRUNCATE_LENGTHS, truncateToWidth } from "../render/render-utils";
19
24
  import { canonicalizeMessage } from "./thinking-display";
@@ -67,7 +72,7 @@ export function buildAsyncResultBlock(message: CustomOrHookMessage): ToolActivit
67
72
  const duration = typeof job.durationMs === "number" ? formatDuration(job.durationMs) : undefined;
68
73
  rows.push({
69
74
  parts: [
70
- { text: `${theme.status.done} Background job completed`, color: "success" },
75
+ { text: `${theme.status.success} Background job completed`, color: "success" },
71
76
  { text: `[${type}]`, color: "dim" },
72
77
  { text: jobId, color: "accent" },
73
78
  duration ? { text: `(${duration})`, color: "dim" } : undefined,
@@ -78,6 +83,7 @@ export function buildAsyncResultBlock(message: CustomOrHookMessage): ToolActivit
78
83
  },
79
84
  });
80
85
  if (job.meta?.artifactError) rows.push(artifactErrorRow(job.meta.artifactError));
86
+ if (job.meta?.minimized) rows.push(minimizedRow(job.meta.minimized));
81
87
  }
82
88
  if (details?.meta?.artifactError) rows.push(artifactErrorRow(details.meta.artifactError));
83
89
  return new ToolActivityContainer(new TranscriptStatusBlock(rows));
@@ -121,6 +127,12 @@ function artifactErrorRow(error: OutputArtifactError): TranscriptStatusRow {
121
127
  return { parts: [{ text: notice, color: "warning" }], native: { tone: "warning", message: [span(notice)] } };
122
128
  }
123
129
 
130
+ /** The dim row under a background job whose output the minimizer shortened. */
131
+ function minimizedRow(minimized: MinimizedMeta): TranscriptStatusRow {
132
+ const fact = `Minimized: ${formatMinimizedMeta(minimized)}`;
133
+ return { parts: [{ text: fact, color: "dim" }], native: { tone: "info", message: [span(fact, "dim")] } };
134
+ }
135
+
124
136
  /**
125
137
  * Native notice spans for a row's trailing facts (kind, id, duration): each
126
138
  * after a dim ` · `, absent ones skipped.
@@ -140,7 +152,7 @@ export function buildLaunchCompletionBlock(message: CustomOrHookMessage): ToolAc
140
152
  const daemons = details?.daemons ?? [];
141
153
  if (daemons.length === 0 && typeof message.content === "string") {
142
154
  rows.push({
143
- parts: [{ text: `${theme.status.done} ${message.content}`, color: "dim" }],
155
+ parts: [{ text: `${theme.status.success} ${message.content}`, color: "dim" }],
144
156
  native: { tone: "success", message: [span(message.content)] },
145
157
  });
146
158
  }
@@ -156,7 +168,7 @@ export function buildLaunchCompletionBlock(message: CustomOrHookMessage): ToolAc
156
168
  parts: [
157
169
  failed
158
170
  ? { text: `${theme.status.error} ${label}`, color: "error" }
159
- : { text: `${theme.status.done} ${label}`, color: "success" },
171
+ : { text: `${theme.status.success} ${label}`, color: "success" },
160
172
  { text: daemon.name, color: "accent" },
161
173
  exit ? { text: `(${exit})`, color: "dim" } : undefined,
162
174
  duration ? { text: `(${duration})`, color: "dim" } : undefined,
@@ -1,4 +1,5 @@
1
1
  import type { Component } from "../tui";
2
+ import { truncateToWidth, visibleWidth } from "../utils";
2
3
  import { fgOrPlain, theme } from "../theme/index";
3
4
  import type { NativeNode } from "../native/node";
4
5
  import { EMPTY_NODE } from "../native/describe";
@@ -13,7 +14,9 @@ import { EMPTY_NODE } from "../native/describe";
13
14
  */
14
15
  export class DynamicBorder implements Component {
15
16
  #color: (str: string) => string;
17
+ #label: string | (() => string) | undefined;
16
18
  #cachedWidth = -1;
19
+ #cachedLabel: string | undefined;
17
20
  #cachedLines: string[] | undefined;
18
21
 
19
22
  constructor(color: (str: string) => string = str => fgOrPlain("border", str)) {
@@ -25,19 +28,42 @@ export class DynamicBorder implements Component {
25
28
  this.#cachedLines = undefined;
26
29
  }
27
30
 
31
+ /**
32
+ * Pre-styled text set into the rule after a short lead (`─── label ────`);
33
+ * undefined draws a plain rule. A function label is re-read every render,
34
+ * for live text such as a spinner.
35
+ */
36
+ setLabel(label: string | (() => string) | undefined): void {
37
+ if (label === this.#label) return;
38
+ this.#label = label;
39
+ this.invalidate();
40
+ }
41
+
28
42
  /** Native terminals draw their own chrome; a border rule describes nothing. */
29
43
  describe(): NativeNode {
30
44
  return EMPTY_NODE;
31
45
  }
32
46
 
33
47
  render(width: number): readonly string[] {
34
- if (this.#cachedLines && this.#cachedWidth === width) {
48
+ const label = typeof this.#label === "function" ? this.#label() : this.#label;
49
+ if (this.#cachedLines && this.#cachedWidth === width && this.#cachedLabel === label) {
35
50
  return this.#cachedLines;
36
51
  }
37
52
  const horizontal = typeof theme === "undefined" ? "─" : theme.boxRound.horizontal;
38
- const lines = [this.#color(horizontal.repeat(Math.max(1, width)))];
53
+ const lines = [this.#rule(horizontal, Math.max(1, width), label)];
39
54
  this.#cachedWidth = width;
55
+ this.#cachedLabel = label;
40
56
  this.#cachedLines = lines;
41
57
  return lines;
42
58
  }
59
+
60
+ #rule(horizontal: string, width: number, label: string | undefined): string {
61
+ const lead = horizontal.repeat(3);
62
+ // The label sits between single spaces and leaves at least one rule cell after it.
63
+ const labelRoom = width - visibleWidth(lead) - 3;
64
+ if (!label || labelRoom < 1) return this.#color(horizontal.repeat(width));
65
+ const fitted = ` ${truncateToWidth(label, labelRoom)} `;
66
+ const rest = width - visibleWidth(lead) - visibleWidth(fitted);
67
+ return `${this.#color(lead)}${fitted}${this.#color(horizontal.repeat(rest))}`;
68
+ }
43
69
  }