@linxiraos/pi-tui 1.4.7 → 1.4.9

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 (172) hide show
  1. package/CHANGELOG.md +28 -109
  2. package/README.md +7 -1
  3. package/dist/types/app-keybindings.d.ts +5 -0
  4. package/dist/types/charts/table-data.d.ts +4 -2
  5. package/dist/types/chat/bash-execution.d.ts +4 -1
  6. package/dist/types/chat/eval-execution.d.ts +2 -0
  7. package/dist/types/chat/execution-shared.d.ts +14 -8
  8. package/dist/types/chat/figure-markdown.d.ts +2 -0
  9. package/dist/types/chat/svg-figure.d.ts +5 -0
  10. package/dist/types/chat/table-chart.d.ts +2 -0
  11. package/dist/types/chat/transcript-render-helpers.d.ts +11 -3
  12. package/dist/types/chrome/dynamic-border.d.ts +6 -0
  13. package/dist/types/chrome/transcript-status.d.ts +2 -2
  14. package/dist/types/components/editor.d.ts +15 -6
  15. package/dist/types/components/image.d.ts +6 -0
  16. package/dist/types/components/loader.d.ts +2 -0
  17. package/dist/types/keybinding-matchers.d.ts +7 -0
  18. package/dist/types/native/describe.d.ts +4 -2
  19. package/dist/types/native/node.d.ts +2 -3
  20. package/dist/types/native/overlay.d.ts +42 -2
  21. package/dist/types/native/state.d.ts +4 -0
  22. package/dist/types/overlays/btw-history-panel.d.ts +15 -0
  23. package/dist/types/overlays/btw-history.d.ts +24 -0
  24. package/dist/types/overlays/btw-inject.d.ts +22 -0
  25. package/dist/types/overlays/btw-panel.d.ts +7 -0
  26. package/dist/types/overlays/hook-editor.d.ts +2 -0
  27. package/dist/types/overlays/jobs-panel.d.ts +4 -0
  28. package/dist/types/overlays/model-browser.d.ts +1 -1
  29. package/dist/types/overlays/session-selector.d.ts +11 -2
  30. package/dist/types/prompt/composer.d.ts +13 -5
  31. package/dist/types/render/render-utils.d.ts +23 -1
  32. package/dist/types/status-line/startup.d.ts +0 -15
  33. package/dist/types/terminal-capabilities.d.ts +1 -1
  34. package/dist/types/theme/symbols.d.ts +3 -1
  35. package/dist/types/theme/theme-class.d.ts +1 -0
  36. package/dist/types/theme/theme.d.ts +1 -1
  37. package/dist/types/theme/tui-adapters.d.ts +2 -0
  38. package/dist/types/thinking.d.ts +8 -6
  39. package/dist/types/tools/ast-grep.d.ts +2 -0
  40. package/dist/types/tools/eval.d.ts +2 -0
  41. package/dist/types/tools/find.d.ts +1 -1
  42. package/dist/types/tools/grouped-file-output.d.ts +100 -19
  43. package/dist/types/tools/hashline-format.d.ts +5 -0
  44. package/dist/types/tools/native-view.d.ts +2 -0
  45. package/dist/types/tools/output-meta.d.ts +27 -0
  46. package/dist/types/tools/read.d.ts +14 -4
  47. package/dist/types/tools/task.d.ts +4 -3
  48. package/dist/types/tools/wait.d.ts +2 -0
  49. package/dist/types/tui.d.ts +12 -0
  50. package/dist/types/utils.d.ts +4 -0
  51. package/package.json +9 -9
  52. package/src/app-keybindings.d.ts +5 -0
  53. package/src/app-keybindings.ts +5 -0
  54. package/src/apps/git/git-tui.ts +10 -17
  55. package/src/apps/git/sidebar.ts +21 -35
  56. package/src/apps/ps-top.ts +4 -12
  57. package/src/charts/chart-plan.ts +0 -29
  58. package/src/charts/table-data.d.ts +4 -2
  59. package/src/charts/table-data.ts +55 -6
  60. package/src/chat/bash-execution.d.ts +4 -1
  61. package/src/chat/bash-execution.ts +20 -9
  62. package/src/chat/chat-transcript-builder.ts +5 -2
  63. package/src/chat/eval-execution.d.ts +2 -0
  64. package/src/chat/eval-execution.ts +14 -7
  65. package/src/chat/execution-shared.d.ts +14 -8
  66. package/src/chat/execution-shared.ts +39 -18
  67. package/src/chat/figure-markdown.d.ts +2 -0
  68. package/src/chat/figure-markdown.ts +6 -4
  69. package/src/chat/read-tool-group.ts +56 -36
  70. package/src/chat/svg-figure.d.ts +5 -0
  71. package/src/chat/svg-figure.ts +55 -16
  72. package/src/chat/table-chart.d.ts +2 -0
  73. package/src/chat/table-chart.ts +19 -2
  74. package/src/chat/transcript-render-helpers.d.ts +11 -3
  75. package/src/chat/transcript-render-helpers.ts +70 -22
  76. package/src/chrome/dynamic-border.d.ts +6 -0
  77. package/src/chrome/dynamic-border.ts +28 -2
  78. package/src/chrome/transcript-status.d.ts +2 -2
  79. package/src/chrome/transcript-status.ts +5 -3
  80. package/src/components/editor.d.ts +15 -6
  81. package/src/components/editor.ts +123 -24
  82. package/src/components/image.d.ts +6 -0
  83. package/src/components/image.ts +13 -0
  84. package/src/components/key-value-list.ts +9 -9
  85. package/src/components/loader.d.ts +2 -0
  86. package/src/components/loader.ts +7 -0
  87. package/src/components/section.ts +1 -9
  88. package/src/components/table.ts +1 -9
  89. package/src/keybinding-matchers.d.ts +7 -0
  90. package/src/keybinding-matchers.ts +13 -0
  91. package/src/native/backend.ts +7 -3
  92. package/src/native/describe.d.ts +4 -2
  93. package/src/native/describe.ts +9 -4
  94. package/src/native/node.d.ts +2 -3
  95. package/src/native/node.ts +2 -3
  96. package/src/native/overlay.d.ts +42 -2
  97. package/src/native/overlay.ts +124 -16
  98. package/src/native/state.d.ts +4 -0
  99. package/src/native/state.ts +25 -5
  100. package/src/overlays/btw-history-panel.ts +106 -14
  101. package/src/overlays/btw-history.ts +65 -0
  102. package/src/overlays/btw-inject.ts +91 -0
  103. package/src/overlays/btw-panel.ts +53 -12
  104. package/src/overlays/extensions/extension-dashboard.ts +7 -8
  105. package/src/overlays/hook-editor.ts +6 -0
  106. package/src/overlays/jobs-panel.ts +82 -22
  107. package/src/overlays/login-dialog.ts +8 -26
  108. package/src/overlays/model-browser.ts +69 -10
  109. package/src/overlays/session-selector.ts +25 -5
  110. package/src/overlays/settings-defs.ts +2 -2
  111. package/src/overlays/tree-selector.ts +83 -27
  112. package/src/overlays/usage-dashboard.ts +4 -6
  113. package/src/prompt/composer.ts +17 -5
  114. package/src/render/code-cell.ts +1 -1
  115. package/src/render/file-list.ts +4 -7
  116. package/src/render/render-utils.d.ts +23 -1
  117. package/src/render/render-utils.ts +38 -6
  118. package/src/setup/scenes/glyph.ts +1 -1
  119. package/src/status-line/startup.ts +36 -70
  120. package/src/terminal-capabilities.d.ts +1 -1
  121. package/src/terminal-capabilities.ts +5 -0
  122. package/src/theme/symbols.d.ts +3 -1
  123. package/src/theme/symbols.ts +16 -9
  124. package/src/theme/theme-class.d.ts +1 -0
  125. package/src/theme/theme-class.ts +15 -3
  126. package/src/theme/theme.d.ts +1 -1
  127. package/src/theme/theme.ts +1 -0
  128. package/src/theme/tui-adapters.d.ts +2 -0
  129. package/src/theme/tui-adapters.ts +8 -3
  130. package/src/thinking.d.ts +8 -6
  131. package/src/thinking.ts +17 -11
  132. package/src/tmux.ts +1 -0
  133. package/src/tools/agent-tree.ts +13 -11
  134. package/src/tools/ask.ts +24 -37
  135. package/src/tools/ast-edit.ts +48 -93
  136. package/src/tools/ast-grep.d.ts +2 -0
  137. package/src/tools/ast-grep.ts +31 -67
  138. package/src/tools/bash.ts +7 -0
  139. package/src/tools/default-renderer.ts +1 -1
  140. package/src/tools/edit.ts +50 -43
  141. package/src/tools/eval.d.ts +2 -0
  142. package/src/tools/eval.ts +2 -0
  143. package/src/tools/fetch.ts +2 -1
  144. package/src/tools/find.d.ts +1 -1
  145. package/src/tools/find.ts +13 -5
  146. package/src/tools/github.ts +14 -46
  147. package/src/tools/glob.ts +2 -1
  148. package/src/tools/grep.ts +47 -277
  149. package/src/tools/grouped-file-output.d.ts +100 -19
  150. package/src/tools/grouped-file-output.ts +414 -103
  151. package/src/tools/hashline-format.d.ts +5 -0
  152. package/src/tools/hashline-format.ts +5 -0
  153. package/src/tools/json-tree.ts +1 -5
  154. package/src/tools/lsp.ts +210 -32
  155. package/src/tools/native-view.d.ts +2 -0
  156. package/src/tools/native-view.ts +11 -5
  157. package/src/tools/output-meta.d.ts +27 -0
  158. package/src/tools/output-meta.ts +68 -4
  159. package/src/tools/proc-render.ts +3 -3
  160. package/src/tools/read.d.ts +14 -4
  161. package/src/tools/read.ts +20 -5
  162. package/src/tools/task.d.ts +4 -3
  163. package/src/tools/task.ts +41 -81
  164. package/src/tools/vibe.ts +4 -4
  165. package/src/tools/wait.d.ts +2 -0
  166. package/src/tools/wait.ts +8 -5
  167. package/src/tools/write.ts +17 -27
  168. package/src/tools/yield.ts +1 -1
  169. package/src/tui.d.ts +12 -0
  170. package/src/tui.ts +91 -9
  171. package/src/utils.d.ts +4 -0
  172. package/src/utils.ts +10 -0
@@ -14,6 +14,8 @@ export interface FigureMarkdownOptions {
14
14
  charts: boolean;
15
15
  /** Shared inline-image budget for the figures. */
16
16
  budget?: ImageBudget;
17
+ /** Rows each figure may fill, read on every render; callers reserve prose, chrome and separators themselves. Unset or `undefined` takes a share of the terminal viewport. */
18
+ maxRows?: () => number | undefined;
17
19
  /** A figure's rows changed outside a text update (raster landed, fell back to code). */
18
20
  onChange: () => void;
19
21
  }
@@ -108,8 +110,8 @@ export class FigureMarkdown extends Container {
108
110
  return old;
109
111
  }
110
112
  reshaped = true;
111
- const { budget, onChange } = this.#options;
112
- return { kind: "chart", figure: new TableChartFigure({ budget, onChange }), table: segment.table };
113
+ const { budget, maxRows, onChange } = this.#options;
114
+ return { kind: "chart", figure: new TableChartFigure({ budget, maxRows, onChange }), table: segment.table };
113
115
  }
114
116
  if (segment.kind === "markdown") {
115
117
  const text = segment.text.trim();
@@ -127,10 +129,10 @@ export class FigureMarkdown extends Container {
127
129
  return old;
128
130
  }
129
131
  reshaped = true;
130
- const { markdown, budget, onChange } = this.#options;
132
+ const { markdown, budget, maxRows, onChange } = this.#options;
131
133
  return {
132
134
  kind: "svg",
133
- figure: new SvgFigure({ markdown, budget, onChange }),
135
+ figure: new SvgFigure({ markdown, budget, maxRows, onChange }),
134
136
  source: segment.source,
135
137
  closed: segment.closed,
136
138
  };
@@ -3,7 +3,7 @@ import type { AssistantMessage, Usage } from "@linxiraos/pi-ai";
3
3
  import { type Component } from "../tui";
4
4
  import { Container } from "../tui";
5
5
  import { Text } from "../components/text";
6
- import { getLanguageFromPath, theme } from "../theme";
6
+ import { getLanguageFromPath, theme, type ThemeColor } from "../theme";
7
7
  import { parseLineRanges, selectorLineRanges } from "../tools/line-ranges";
8
8
  import {
9
9
  type ReadRenderArgs,
@@ -12,8 +12,15 @@ import {
12
12
  readResultIsMarkdown,
13
13
  readSourceFsPath,
14
14
  splitPathAndSel,
15
+ splitReadQuery,
15
16
  } from "../tools/read";
16
- import { 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";
17
24
  import { fileHyperlink, renderCodeCell, renderMarkdownCell } from "../render";
18
25
  import { wrapTreeLine } from "../render/hanging-wrap";
19
26
  import { wrapTextWithAnsi } from "../utils";
@@ -21,7 +28,7 @@ import { canonicalizeMessage } from "./thinking-display";
21
28
  import { internalUrlSchemeSpec, splitUrlScheme } from "../tools/url-scheme-host";
22
29
  import type { ToolExecutionHandle } from "./tool-execution";
23
30
  import { formatUsageRow } from "../overlays/usage-row";
24
- import { formatCount, sanitizeText, sanitizeTextDeep } from "@linxiraos/pi-utils";
31
+ import { formatCount, isUrlLikePath, sanitizeText, sanitizeTextDeep } from "@linxiraos/pi-utils";
25
32
  import type { TspCardStatus, TspSpan, TspText } from "@linxiraos/pi-wire";
26
33
  import type { NativeToolHead } from "../tools/renderer";
27
34
  import { card, code, keyed, md, node, span, text, withHidden } from "../native/describe";
@@ -34,7 +41,7 @@ import {
34
41
  } from "../native/node";
35
42
  import { plainText } from "../native/spans";
36
43
  import { Memo } from "../native/memo";
37
- import { fileHref, fileRow, inlineErrorView } from "../tools/native-view";
44
+ import { fileHref, fileRow, inlineErrorView, urlHref } from "../tools/native-view";
38
45
 
39
46
  /**
40
47
  * Extract the read call's target path. `path` is the canonical arg; `file_path`
@@ -158,6 +165,21 @@ const COLLAPSED_PREVIEW_LINES = PREVIEW_LIMITS.OUTPUT_COLLAPSED;
158
165
  */
159
166
  const TRIMMED_BODY_PREVIEW = { lines: 1000 } as const;
160
167
 
168
+ /** How a read path is painted: its path (`isUrl` for a whole URL) and its selectors' color. */
169
+ interface PathPaint {
170
+ path(filePath: string, isUrl: boolean): string;
171
+ selectors: ThemeColor;
172
+ }
173
+
174
+ /** A `Read <path>` header line keeps the accent subject color. */
175
+ const HEADER_PATH_PAINT: PathPaint = { path: filePath => theme.fg("accent", filePath), selectors: "accent" };
176
+
177
+ /** Group rows share the tool-body path style with muted selectors. */
178
+ const ROW_PATH_PAINT: PathPaint = {
179
+ path: (filePath, isUrl) => (isUrl ? theme.fg(FILE_NAME_COLOR, filePath) : formatStyledPath(filePath, theme)),
180
+ selectors: "muted",
181
+ };
182
+
161
183
  /** Native item tone per read status; successful reads stay neutral. */
162
184
  const READ_STATUS_TONE: Record<ReadEntry["status"], "pending" | "warning" | "error" | undefined> = {
163
185
  success: undefined,
@@ -695,7 +717,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
695
717
  return {
696
718
  target: filePath ? `${filePath}${split.sel ? `:${split.sel}` : ""}` : "…",
697
719
  targetKind: "path",
698
- href: fileHref(linkPathForTargets(row.targets)),
720
+ href: fileHref(linkPathForTargets(row.targets)) ?? urlHref(split.path),
699
721
  meta: correctedFrom ? [`corrected from ${shortenPath(correctedFrom)}`] : undefined,
700
722
  badges: conflicts
701
723
  ? [{ text: `${conflicts} conflict${conflicts === 1 ? "" : "s"}`, tone: "warning" }]
@@ -718,7 +740,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
718
740
  : undefined;
719
741
  return fileRow(shortenPath(split.sel ? split.path : row.targetPath), {
720
742
  range: split.sel ? `:${split.sel}` : undefined,
721
- href: fileHref(linkPathForTargets(row.targets)),
743
+ href: fileHref(linkPathForTargets(row.targets)) ?? urlHref(split.path),
722
744
  icon: status === "error" ? "x-circle" : undefined,
723
745
  tone: READ_STATUS_TONE[status],
724
746
  chip: conflicts ? { text: `${conflicts} conflict${conflicts === 1 ? "" : "s"}` } : undefined,
@@ -914,8 +936,8 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
914
936
  if (displayRows.length === 1) {
915
937
  const row = displayRows[0]!;
916
938
  if (!this.#shouldRenderPreviewRow(row)) {
917
- const statusSymbol = this.#formatStatus(this.#statusForTargets(row.targets));
918
- const pathDisplay = this.#formatRowPath(row);
939
+ const statusSymbol = formatStatusIcon(this.#statusForTargets(row.targets), theme);
940
+ const pathDisplay = this.#formatRowPath(row, HEADER_PATH_PAINT);
919
941
  const lines = [` ${statusSymbol} ${theme.fg("toolTitle", theme.bold("Read"))} ${pathDisplay}`.trimEnd()];
920
942
  const usageRows = this.#usageRowsBySummaryRow(displayRows).get(0) ?? [];
921
943
  this.#appendUsageRows(lines, usageRows, " ");
@@ -1080,16 +1102,17 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
1080
1102
 
1081
1103
  #formatRow(row: ReadSummaryRow): string {
1082
1104
  const status = this.#statusForTargets(row.targets);
1083
- const statusPrefix = status === "success" ? "" : `${this.#formatStatus(status)} `;
1105
+ const statusPrefix = status === "success" ? "" : `${formatStatusIcon(status, theme)} `;
1084
1106
  return `${statusPrefix}${this.#formatRowPath(row)}`;
1085
1107
  }
1086
1108
 
1087
- #formatRowPath(row: ReadSummaryRow): string {
1088
- return this.#formatPathValue(row.targetPath, {
1109
+ #formatRowPath(row: ReadSummaryRow, paint = ROW_PATH_PAINT): string {
1110
+ return this.#formatPathValue(row.targetPath, paint, {
1089
1111
  correctedFrom: this.#correctedFromForTargets(row.targets),
1090
1112
  conflictCount: this.#conflictCountForTargets(row.targets),
1091
1113
  line: firstSelectorLineForTargets(row.targets),
1092
1114
  linkPath: linkPathForTargets(row.targets),
1115
+ basePath: row.basePath,
1093
1116
  });
1094
1117
  }
1095
1118
 
@@ -1137,25 +1160,35 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
1137
1160
 
1138
1161
  #formatPathValue(
1139
1162
  value: string,
1140
- options: { correctedFrom?: string; conflictCount?: number; line?: number; linkPath?: string } = {},
1163
+ paint: PathPaint,
1164
+ options: {
1165
+ correctedFrom?: string;
1166
+ conflictCount?: number;
1167
+ line?: number;
1168
+ linkPath?: string;
1169
+ /** The path `value` selects from; merged selectors (`1-5,…,9`) do not parse back out of it. */
1170
+ basePath?: string;
1171
+ } = {},
1141
1172
  ): string {
1142
- const split = splitPathAndSel(value);
1143
- const selectorSuffix = split.sel ? `:${split.sel}` : "";
1144
- const baseValue = split.sel ? split.path : value;
1145
- const filePath = shortenPath(baseValue);
1146
- let pathDisplay = filePath ? theme.fg("accent", filePath) : theme.fg("toolOutput", "…");
1173
+ const { basePath } = options;
1174
+ const split =
1175
+ basePath !== undefined && value.startsWith(`${basePath}:`)
1176
+ ? { path: basePath, sel: value.slice(basePath.length + 1) }
1177
+ : splitPathAndSel(value);
1178
+ // `?q=…` queries read like selectors: they follow the path, outside its link.
1179
+ const target = splitReadQuery(split.sel ? split.path : value);
1180
+ const filePath = shortenPath(target.path);
1181
+ const selectors = split.sel ? `${target.query ?? ""}:${split.sel}` : (target.query ?? "");
1182
+ let pathDisplay = filePath ? paint.path(filePath, isUrlLikePath(target.path)) : theme.fg("toolOutput", "…");
1147
1183
  if (filePath && options.linkPath) {
1148
1184
  const linkOptions = options.line !== undefined ? { line: options.line } : undefined;
1149
1185
  pathDisplay = fileHyperlink(options.linkPath, pathDisplay, linkOptions);
1150
1186
  }
1151
- if (selectorSuffix) {
1152
- pathDisplay += theme.fg("accent", selectorSuffix);
1153
- }
1187
+ if (selectors) pathDisplay += theme.fg(paint.selectors, selectors);
1154
1188
  if (options.correctedFrom) {
1155
1189
  pathDisplay += theme.fg("dim", ` (corrected from ${shortenPath(options.correctedFrom)})`);
1156
1190
  }
1157
- pathDisplay += this.#formatConflictBadge(options.conflictCount);
1158
- return pathDisplay;
1191
+ return pathDisplay + this.#formatConflictBadge(options.conflictCount);
1159
1192
  }
1160
1193
 
1161
1194
  #formatConflictBadge(conflictCount: number | undefined): string {
@@ -1174,7 +1207,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
1174
1207
  const lang = getLanguageFromPath(split.path);
1175
1208
  const pathValue = shortenPath(entry.path);
1176
1209
  const pathDisplay = pathValue
1177
- ? this.#formatPathValue(entry.path, {
1210
+ ? this.#formatPathValue(entry.path, HEADER_PATH_PAINT, {
1178
1211
  correctedFrom: entry.correctedFrom,
1179
1212
  conflictCount: entry.conflictCount,
1180
1213
  line: firstSelectorLine(split.sel),
@@ -1252,17 +1285,4 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
1252
1285
  #shouldRenderPreview(entry: ReadEntry): boolean {
1253
1286
  return this.#showContentPreview && entry.contentText !== undefined;
1254
1287
  }
1255
-
1256
- #formatStatus(status: ReadEntry["status"]): string {
1257
- if (status === "success") {
1258
- return theme.fg("text", theme.status.enabled);
1259
- }
1260
- if (status === "warning") {
1261
- return theme.fg("warning", theme.status.warning);
1262
- }
1263
- if (status === "error") {
1264
- return theme.fg("error", theme.status.error);
1265
- }
1266
- return theme.fg("dim", theme.status.pending);
1267
- }
1268
1288
  }
@@ -16,6 +16,11 @@ export interface SvgFigureOptions {
16
16
  markdown?: (text: string) => Markdown;
17
17
  /** Shared inline-image budget; superseded rasters are released from it. */
18
18
  budget?: ImageBudget;
19
+ /**
20
+ * Rows the figure may fill, fallback code included, read on every render;
21
+ * zero hides it. Unset or `undefined` takes a share of the terminal viewport.
22
+ */
23
+ maxRows?: () => number | undefined;
19
24
  /** The figure's rows changed outside a text update: a raster landed or rendering fell back to code. */
20
25
  onChange: () => void;
21
26
  }
@@ -113,6 +113,11 @@ export interface SvgFigureOptions {
113
113
  markdown?: (text: string) => Markdown;
114
114
  /** Shared inline-image budget; superseded rasters are released from it. */
115
115
  budget?: ImageBudget;
116
+ /**
117
+ * Rows the figure may fill, fallback code included, read on every render;
118
+ * zero hides it. Unset or `undefined` takes a share of the terminal viewport.
119
+ */
120
+ maxRows?: () => number | undefined;
116
121
  /** The figure's rows changed outside a text update: a raster landed or rendering fell back to code. */
117
122
  onChange: () => void;
118
123
  }
@@ -149,12 +154,15 @@ interface Attempt {
149
154
 
150
155
  let nextFigureId = 0;
151
156
 
152
- /** Cells a figure rendered at `width` may fill: the image's width, a share of the viewport, and the raster edge cap. */
153
- function limitsFor(width: number, cell: CellDimensions): Limits {
154
- const viewportRows = Math.floor((process.stdout.rows || 24) * MAX_VIEWPORT_SHARE);
157
+ /** Cells a figure rendered at `width` may fill: the image's width, the caller's row ceiling (or a share of the viewport), and the raster edge cap. */
158
+ function limitsFor(
159
+ width: number,
160
+ cell: CellDimensions,
161
+ maxRows = Math.floor((process.stdout.rows || 24) * MAX_VIEWPORT_SHARE),
162
+ ): Limits {
155
163
  return {
156
164
  columns: Math.min(imageMaxColumns(width), Math.floor(MAX_EDGE_PX / cell.widthPx)),
157
- rows: Math.max(1, Math.min(viewportRows, Math.floor(MAX_EDGE_PX / cell.heightPx))),
165
+ rows: Math.max(1, Math.min(maxRows, Math.floor(MAX_EDGE_PX / cell.heightPx))),
158
166
  };
159
167
  }
160
168
 
@@ -178,7 +186,14 @@ export class SvgFigure implements Component {
178
186
  /** Last render width; rasters wait for the first render to know their room. */
179
187
  #width: number | undefined;
180
188
  #image: { raster: Raster; component: Image } | undefined;
181
- #fallback: { source: string; md: Markdown } | undefined;
189
+ #fallback:
190
+ | {
191
+ source: string;
192
+ md: Markdown;
193
+ /** `rows` cut to a ceiling, kept so unchanged frames return the same array. */
194
+ clip?: { of: readonly string[]; rows: readonly string[] };
195
+ }
196
+ | undefined;
182
197
  #placeholder: readonly string[] | undefined;
183
198
 
184
199
  constructor(options: SvgFigureOptions) {
@@ -203,21 +218,34 @@ export class SvgFigure implements Component {
203
218
 
204
219
  /** Whether the final source still waits for its raster (or for failing to render). */
205
220
  get pending(): boolean {
206
- return this.#final && this.#raster?.source !== this.#source && this.#failed !== this.#source;
221
+ return (
222
+ this.#maxRows() !== 0 && this.#final && this.#raster?.source !== this.#source && this.#failed !== this.#source
223
+ );
224
+ }
225
+
226
+ /** The caller's row ceiling, if any; a surface shorter than its chrome leaves none. */
227
+ #maxRows(): number | undefined {
228
+ const rows = this.#options.maxRows?.();
229
+ return rows === undefined ? undefined : Math.max(0, Math.floor(rows));
207
230
  }
208
231
 
209
232
  render(width: number): readonly string[] {
210
233
  // Width, cell size and theme are render-time inputs; a change re-rasterizes.
211
234
  this.#width = width;
212
235
  this.#schedule();
213
- if (this.#failed === this.#source) return this.#fallbackRows(width);
236
+ const maxRows = this.#maxRows();
237
+ if (maxRows === 0) return [];
238
+ if (this.#failed === this.#source) return this.#fallbackRows(width, maxRows);
214
239
  const raster = this.#raster;
215
240
  if (!raster) {
216
241
  if (!this.#options.markdown) return [];
217
242
  this.#placeholder ??= [` ${theme.fg("dim", "Drawing SVG…")}`];
218
243
  return this.#placeholder;
219
244
  }
220
- return this.#imageFor(raster).render(width);
245
+ const rows = this.#imageFor(raster, maxRows).render(width);
246
+ // A SIXEL band is six pixels whole: cells shorter than that reserve more
247
+ // rows than the ceiling, and a cut band would draw nothing anyway.
248
+ return maxRows !== undefined && rows.length > maxRows ? [] : rows;
221
249
  }
222
250
 
223
251
  invalidate(): void {
@@ -247,7 +275,7 @@ export class SvgFigure implements Component {
247
275
  const attempt = this.#attempt;
248
276
  if (this.#failed === this.#source) return false;
249
277
  const cell = getCellDimensions();
250
- const limits = limitsFor(width, cell);
278
+ const limits = limitsFor(width, cell, this.#maxRows());
251
279
  return (
252
280
  attempt === undefined ||
253
281
  attempt.source !== this.#source ||
@@ -280,6 +308,7 @@ export class SvgFigure implements Component {
280
308
  #schedule(): void {
281
309
  const width = this.#width;
282
310
  if (this.#disposed || this.#rasterizing || width === undefined) return;
311
+ if (this.#maxRows() === 0) return;
283
312
  if (this.#final && this.#timer) {
284
313
  clearTimeout(this.#timer);
285
314
  this.#timer = undefined;
@@ -302,7 +331,7 @@ export class SvgFigure implements Component {
302
331
  const attempt: Attempt = {
303
332
  source: this.#source,
304
333
  cell,
305
- limits: limitsFor(width, cell),
334
+ limits: limitsFor(width, cell, this.#maxRows()),
306
335
  themeEpoch: getThemeEpoch(),
307
336
  final: this.#final,
308
337
  };
@@ -364,13 +393,17 @@ export class SvgFigure implements Component {
364
393
  /**
365
394
  * The image for `raster` over the whole cells it was padded to. At the
366
395
  * cell size and room it was drawn for that box is its pixels exactly; a
367
- * raster outdated by a resize is scaled by {@link Image} until its redraw lands.
396
+ * raster outdated by a resize is scaled by {@link Image} until its redraw
397
+ * lands. A caller's ceiling (`maxRows`) refits the shown image at once.
368
398
  */
369
- #imageFor(raster: Raster): Image {
399
+ #imageFor(raster: Raster, maxRows = Number.POSITIVE_INFINITY): Image {
370
400
  const current = this.#image;
371
- if (current?.raster === raster) return current.component;
372
401
  const columns = raster.widthPx / raster.cell.widthPx;
373
- const rows = raster.heightPx / raster.cell.heightPx;
402
+ const rows = Math.min(raster.heightPx / raster.cell.heightPx, maxRows);
403
+ if (current?.raster === raster) {
404
+ current.component.setMaxHeightCells(rows);
405
+ return current.component;
406
+ }
374
407
  const component = new Image(
375
408
  raster.data,
376
409
  "image/png",
@@ -390,12 +423,18 @@ export class SvgFigure implements Component {
390
423
  }
391
424
 
392
425
  /** The source as the fenced code block it was written as, fenced longer than any backtick run inside. */
393
- #fallbackRows(width: number): readonly string[] {
426
+ #fallbackRows(width: number, maxRows?: number): readonly string[] {
394
427
  const source = this.#source;
395
428
  if (!this.#options.markdown) return [];
396
429
  if (this.#fallback?.source !== source) {
397
430
  this.#fallback = { source, md: this.#options.markdown(fencedCode("svg", source)) };
398
431
  }
399
- return this.#fallback.md.render(width);
432
+ const fallback = this.#fallback;
433
+ const rows = fallback.md.render(width);
434
+ if (maxRows === undefined || rows.length <= maxRows) return rows;
435
+ if (fallback.clip?.of !== rows || fallback.clip.rows.length !== maxRows) {
436
+ fallback.clip = { of: rows, rows: rows.slice(0, maxRows) };
437
+ }
438
+ return fallback.clip.rows;
400
439
  }
401
440
  }
@@ -64,6 +64,8 @@ export declare function chartFence(svg: string): string;
64
64
  export interface TableChartFigureOptions {
65
65
  /** Shared inline-image budget. */
66
66
  budget?: ImageBudget;
67
+ /** Rows the chart may fill, its separator included, read on every render; under two hides it. Unset or `undefined` takes a share of the terminal viewport. */
68
+ maxRows?: () => number | undefined;
67
69
  /** The chart's rows changed outside a text update: its pick or raster landed. */
68
70
  onChange: () => void;
69
71
  }
@@ -194,6 +194,8 @@ export function chartFence(svg: string): string {
194
194
  export interface TableChartFigureOptions {
195
195
  /** Shared inline-image budget. */
196
196
  budget?: ImageBudget;
197
+ /** Rows the chart may fill, its separator included, read on every render; under two hides it. Unset or `undefined` takes a share of the terminal viewport. */
198
+ maxRows?: () => number | undefined;
197
199
  /** The chart's rows changed outside a text update: its pick or raster landed. */
198
200
  onChange: () => void;
199
201
  }
@@ -215,7 +217,17 @@ export class TableChartFigure implements Component {
215
217
 
216
218
  constructor(options: TableChartFigureOptions) {
217
219
  this.#options = options;
218
- this.#figure = new SvgFigure({ budget: options.budget, onChange: options.onChange });
220
+ this.#figure = new SvgFigure({
221
+ budget: options.budget,
222
+ maxRows: () => this.#figureRows(),
223
+ onChange: options.onChange,
224
+ });
225
+ }
226
+
227
+ /** The image's share of the caller's ceiling: all but the separator row. */
228
+ #figureRows(): number | undefined {
229
+ const rows = this.#options.maxRows?.();
230
+ return rows === undefined ? undefined : Math.max(0, Math.floor(rows) - 1);
219
231
  }
220
232
 
221
233
  /** Point the figure at `table`. */
@@ -228,10 +240,15 @@ export class TableChartFigure implements Component {
228
240
 
229
241
  /** Whether the chart is still being looked up, picked or drawn. */
230
242
  get pending(): boolean {
231
- return this.#table !== undefined && (this.#chart === undefined || (this.#chart !== null && this.#figure.pending));
243
+ return (
244
+ this.#figureRows() !== 0 &&
245
+ this.#table !== undefined &&
246
+ (this.#chart === undefined || (this.#chart !== null && this.#figure.pending))
247
+ );
232
248
  }
233
249
 
234
250
  render(width: number): readonly string[] {
251
+ if (this.#figureRows() === 0) return [];
235
252
  if (this.#chart === undefined && !this.#waiting) this.#resolve();
236
253
  if (!this.#chart) return [];
237
254
  const rows = this.#figure.render(width);
@@ -8,6 +8,7 @@ import type { AgentMessage } from "@linxiraos/pi-agent-core";
8
8
  import { type Component } from "../tui";
9
9
  import { type FileMentionMessage } from "./messages";
10
10
  import { ToolActivityContainer } from "../chrome/tool-activity";
11
+ import type { MessageRenderer } from "./extension-types";
11
12
  import { type TranscriptBlock } from "../chrome/transcript-container";
12
13
  type CustomOrHookMessage = Extract<AgentMessage, {
13
14
  role: "custom" | "hookMessage";
@@ -21,6 +22,13 @@ type AssistantAgentMessage = Extract<AgentMessage, {
21
22
  * row per job.
22
23
  */
23
24
  export declare function buildAsyncResultBlock(message: CustomOrHookMessage): ToolActivityContainer;
25
+ /**
26
+ * The `async-result` card for both transcript surfaces: a registered renderer owns it (#14131);
27
+ * the built-in block covers no renderer, a declining renderer, and a throwing one.
28
+ */
29
+ export declare function buildAsyncResultComponent(message: CustomOrHookMessage, renderer: MessageRenderer | undefined): Component & {
30
+ setExpanded(expanded: boolean): void;
31
+ };
24
32
  /**
25
33
  * Render a `launch-completion` custom message (terminal supervised-process
26
34
  * exits from the launch broker) as a transcript block of one compact
@@ -28,9 +36,9 @@ export declare function buildAsyncResultBlock(message: CustomOrHookMessage): Too
28
36
  */
29
37
  export declare function buildLaunchCompletionBlock(message: CustomOrHookMessage): ToolActivityContainer;
30
38
  /**
31
- * Render a live IRC traffic custom message (`irc:incoming` / `irc:autoreply` /
32
- * `irc:relay`) as a transcript card. `getExpanded` supplies the live
33
- * expanded-state getter for the cached card.
39
+ * Render an IRC coordination custom message (`irc:incoming` / `irc:autoreply` /
40
+ * `irc:relay` / `irc:workpool`) as a tool-activity card. `getExpanded` supplies
41
+ * the live expanded-state getter for the cached card.
34
42
  */
35
43
  export declare function buildIrcMessageCard(message: CustomOrHookMessage, getExpanded: () => boolean): Component;
36
44
  /**
@@ -13,11 +13,18 @@ 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
- import { replaceTabs, TRUNCATE_LENGTHS, truncateToWidth } from "../render/render-utils";
23
+ import { formatStyledPath, replaceTabs, TRUNCATE_LENGTHS, truncateToWidth } from "../render/render-utils";
19
24
  import { canonicalizeMessage } from "./thinking-display";
20
25
  import { ToolActivityContainer } from "../chrome/tool-activity";
26
+ import { CustomMessageComponent } from "./custom-message";
27
+ import type { MessageRenderer } from "./extension-types";
21
28
  import { type TranscriptBlock } from "../chrome/transcript-container";
22
29
  import { TranscriptStatusBlock, type TranscriptStatusRow } from "../chrome/transcript-status";
23
30
  import { theme } from "../theme";
@@ -65,7 +72,7 @@ export function buildAsyncResultBlock(message: CustomOrHookMessage): ToolActivit
65
72
  const duration = typeof job.durationMs === "number" ? formatDuration(job.durationMs) : undefined;
66
73
  rows.push({
67
74
  parts: [
68
- { text: `${theme.status.done} Background job completed`, color: "success" },
75
+ { text: `${theme.status.success} Background job completed`, color: "success" },
69
76
  { text: `[${type}]`, color: "dim" },
70
77
  { text: jobId, color: "accent" },
71
78
  duration ? { text: `(${duration})`, color: "dim" } : undefined,
@@ -76,17 +83,56 @@ export function buildAsyncResultBlock(message: CustomOrHookMessage): ToolActivit
76
83
  },
77
84
  });
78
85
  if (job.meta?.artifactError) rows.push(artifactErrorRow(job.meta.artifactError));
86
+ if (job.meta?.minimized) rows.push(minimizedRow(job.meta.minimized));
79
87
  }
80
88
  if (details?.meta?.artifactError) rows.push(artifactErrorRow(details.meta.artifactError));
81
89
  return new ToolActivityContainer(new TranscriptStatusBlock(rows));
82
90
  }
83
91
 
92
+ /** Hosts an extension renderer; relays `display.hideToolActivity` to the nested built-in fallback block. */
93
+ class AsyncResultCard extends CustomMessageComponent {
94
+ readonly #block: ToolActivityContainer;
95
+
96
+ constructor(message: CustomOrHookMessage, renderer: MessageRenderer, block: ToolActivityContainer) {
97
+ super(message as CustomMessage<unknown>, (delegate, options, rendererTheme) => {
98
+ try {
99
+ return renderer(delegate, options, rendererTheme) ?? block;
100
+ } catch {
101
+ return block;
102
+ }
103
+ });
104
+ this.#block = block;
105
+ }
106
+
107
+ setToolActivityVisible(visible: boolean): void {
108
+ this.#block.setToolActivityVisible(visible);
109
+ }
110
+ }
111
+
112
+ /**
113
+ * The `async-result` card for both transcript surfaces: a registered renderer owns it (#14131);
114
+ * the built-in block covers no renderer, a declining renderer, and a throwing one.
115
+ */
116
+ export function buildAsyncResultComponent(
117
+ message: CustomOrHookMessage,
118
+ renderer: MessageRenderer | undefined,
119
+ ): Component & { setExpanded(expanded: boolean): void } {
120
+ const block = buildAsyncResultBlock(message);
121
+ return renderer ? new AsyncResultCard(message, renderer, block) : block;
122
+ }
123
+
84
124
  /** The warning row under a background job whose output artifact could not be saved. */
85
125
  function artifactErrorRow(error: OutputArtifactError): TranscriptStatusRow {
86
126
  const notice = formatArtifactErrorNotice(error);
87
127
  return { parts: [{ text: notice, color: "warning" }], native: { tone: "warning", message: [span(notice)] } };
88
128
  }
89
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
+
90
136
  /**
91
137
  * Native notice spans for a row's trailing facts (kind, id, duration): each
92
138
  * after a dim ` · `, absent ones skipped.
@@ -106,7 +152,7 @@ export function buildLaunchCompletionBlock(message: CustomOrHookMessage): ToolAc
106
152
  const daemons = details?.daemons ?? [];
107
153
  if (daemons.length === 0 && typeof message.content === "string") {
108
154
  rows.push({
109
- parts: [{ text: `${theme.status.done} ${message.content}`, color: "dim" }],
155
+ parts: [{ text: `${theme.status.success} ${message.content}`, color: "dim" }],
110
156
  native: { tone: "success", message: [span(message.content)] },
111
157
  });
112
158
  }
@@ -122,7 +168,7 @@ export function buildLaunchCompletionBlock(message: CustomOrHookMessage): ToolAc
122
168
  parts: [
123
169
  failed
124
170
  ? { text: `${theme.status.error} ${label}`, color: "error" }
125
- : { text: `${theme.status.done} ${label}`, color: "success" },
171
+ : { text: `${theme.status.success} ${label}`, color: "success" },
126
172
  { text: daemon.name, color: "accent" },
127
173
  exit ? { text: `(${exit})`, color: "dim" } : undefined,
128
174
  duration ? { text: `(${duration})`, color: "dim" } : undefined,
@@ -137,9 +183,9 @@ export function buildLaunchCompletionBlock(message: CustomOrHookMessage): ToolAc
137
183
  }
138
184
 
139
185
  /**
140
- * Render a live IRC traffic custom message (`irc:incoming` / `irc:autoreply` /
141
- * `irc:relay`) as a transcript card. `getExpanded` supplies the live
142
- * expanded-state getter for the cached card.
186
+ * Render an IRC coordination custom message (`irc:incoming` / `irc:autoreply` /
187
+ * `irc:relay` / `irc:workpool`) as a tool-activity card. `getExpanded` supplies
188
+ * the live expanded-state getter for the cached card.
143
189
  */
144
190
  export function buildIrcMessageCard(message: CustomOrHookMessage, getExpanded: () => boolean): Component {
145
191
  const details = (
@@ -161,19 +207,21 @@ export function buildIrcMessageCard(message: CustomOrHookMessage, getExpanded: (
161
207
  : message.customType === "irc:workpool"
162
208
  ? ("workpool" as const)
163
209
  : ("relay" as const);
164
- return createIrcMessageCard(
165
- {
166
- kind,
167
- from: details?.from,
168
- to: details?.to,
169
- body: kind === "incoming" ? details?.message : details?.body,
170
- replyTo: details?.replyTo,
171
- timestamp: message.timestamp,
172
- pool: details?.pool,
173
- mode: details?.mode,
174
- },
175
- getExpanded,
176
- theme,
210
+ return new ToolActivityContainer(
211
+ createIrcMessageCard(
212
+ {
213
+ kind,
214
+ from: details?.from,
215
+ to: details?.to,
216
+ body: kind === "incoming" ? details?.message : details?.body,
217
+ replyTo: details?.replyTo,
218
+ timestamp: message.timestamp,
219
+ pool: details?.pool,
220
+ mode: details?.mode,
221
+ },
222
+ getExpanded,
223
+ theme,
224
+ ),
177
225
  );
178
226
  }
179
227
 
@@ -201,7 +249,7 @@ export function buildFileMentionBlock(files: FileMentionMessage["files"], indent
201
249
  parts: [
202
250
  { text: theme.tree.last, color: "dim" },
203
251
  { text: "Read", color: "muted" },
204
- { text: file.path, color: "accent" },
252
+ { text: formatStyledPath(file.path, theme) },
205
253
  { text: `(${detail})`, color: "dim" },
206
254
  ],
207
255
  indent,
@@ -13,6 +13,12 @@ export declare class DynamicBorder implements Component {
13
13
  #private;
14
14
  constructor(color?: (str: string) => string);
15
15
  invalidate(): void;
16
+ /**
17
+ * Pre-styled text set into the rule after a short lead (`─── label ────`);
18
+ * undefined draws a plain rule. A function label is re-read every render,
19
+ * for live text such as a spinner.
20
+ */
21
+ setLabel(label: string | (() => string) | undefined): void;
16
22
  /** Native terminals draw their own chrome; a border rule describes nothing. */
17
23
  describe(): NativeNode;
18
24
  render(width: number): readonly string[];