@linxiraos/pi-tui 1.4.7 → 1.4.10

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 (181) hide show
  1. package/CHANGELOG.md +154 -231
  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/setup/scenes/language.d.ts +3 -0
  33. package/dist/types/setup/scenes/types.d.ts +5 -0
  34. package/dist/types/setup/setup-version.d.ts +1 -1
  35. package/dist/types/setup/wizard.d.ts +1 -1
  36. package/dist/types/status-line/startup.d.ts +0 -15
  37. package/dist/types/terminal-capabilities.d.ts +1 -1
  38. package/dist/types/theme/symbols.d.ts +3 -1
  39. package/dist/types/theme/theme-class.d.ts +1 -0
  40. package/dist/types/theme/theme.d.ts +1 -1
  41. package/dist/types/theme/tui-adapters.d.ts +2 -0
  42. package/dist/types/thinking.d.ts +8 -6
  43. package/dist/types/tools/ast-grep.d.ts +2 -0
  44. package/dist/types/tools/eval.d.ts +2 -0
  45. package/dist/types/tools/find.d.ts +1 -1
  46. package/dist/types/tools/grouped-file-output.d.ts +100 -19
  47. package/dist/types/tools/hashline-format.d.ts +5 -0
  48. package/dist/types/tools/native-view.d.ts +2 -0
  49. package/dist/types/tools/output-meta.d.ts +27 -0
  50. package/dist/types/tools/read.d.ts +14 -4
  51. package/dist/types/tools/task.d.ts +4 -3
  52. package/dist/types/tools/wait.d.ts +2 -0
  53. package/dist/types/tui.d.ts +12 -0
  54. package/dist/types/utils.d.ts +4 -0
  55. package/package.json +9 -9
  56. package/src/app-keybindings.d.ts +5 -0
  57. package/src/app-keybindings.ts +5 -0
  58. package/src/apps/git/git-tui.ts +10 -17
  59. package/src/apps/git/sidebar.ts +21 -35
  60. package/src/apps/ps-top.ts +4 -12
  61. package/src/charts/chart-plan.ts +0 -29
  62. package/src/charts/table-data.d.ts +4 -2
  63. package/src/charts/table-data.ts +55 -6
  64. package/src/chat/bash-execution.d.ts +4 -1
  65. package/src/chat/bash-execution.ts +20 -9
  66. package/src/chat/chat-transcript-builder.ts +5 -2
  67. package/src/chat/eval-execution.d.ts +2 -0
  68. package/src/chat/eval-execution.ts +14 -7
  69. package/src/chat/execution-shared.d.ts +14 -8
  70. package/src/chat/execution-shared.ts +39 -18
  71. package/src/chat/figure-markdown.d.ts +2 -0
  72. package/src/chat/figure-markdown.ts +6 -4
  73. package/src/chat/read-tool-group.ts +56 -36
  74. package/src/chat/svg-figure.d.ts +5 -0
  75. package/src/chat/svg-figure.ts +55 -16
  76. package/src/chat/table-chart.d.ts +2 -0
  77. package/src/chat/table-chart.ts +19 -2
  78. package/src/chat/transcript-render-helpers.d.ts +11 -3
  79. package/src/chat/transcript-render-helpers.ts +70 -22
  80. package/src/chrome/dynamic-border.d.ts +6 -0
  81. package/src/chrome/dynamic-border.ts +28 -2
  82. package/src/chrome/transcript-status.d.ts +2 -2
  83. package/src/chrome/transcript-status.ts +5 -3
  84. package/src/components/editor.d.ts +15 -6
  85. package/src/components/editor.ts +123 -24
  86. package/src/components/image.d.ts +6 -0
  87. package/src/components/image.ts +13 -0
  88. package/src/components/key-value-list.ts +9 -9
  89. package/src/components/loader.d.ts +2 -0
  90. package/src/components/loader.ts +7 -0
  91. package/src/components/section.ts +1 -9
  92. package/src/components/table.ts +1 -9
  93. package/src/keybinding-matchers.d.ts +7 -0
  94. package/src/keybinding-matchers.ts +13 -0
  95. package/src/native/backend.ts +7 -3
  96. package/src/native/describe.d.ts +4 -2
  97. package/src/native/describe.ts +9 -4
  98. package/src/native/node.d.ts +2 -3
  99. package/src/native/node.ts +2 -3
  100. package/src/native/overlay.d.ts +42 -2
  101. package/src/native/overlay.ts +124 -16
  102. package/src/native/state.d.ts +4 -0
  103. package/src/native/state.ts +25 -5
  104. package/src/overlays/btw-history-panel.ts +106 -14
  105. package/src/overlays/btw-history.ts +65 -0
  106. package/src/overlays/btw-inject.ts +91 -0
  107. package/src/overlays/btw-panel.ts +53 -12
  108. package/src/overlays/extensions/extension-dashboard.ts +7 -8
  109. package/src/overlays/hook-editor.ts +6 -0
  110. package/src/overlays/jobs-panel.ts +82 -22
  111. package/src/overlays/login-dialog.ts +8 -26
  112. package/src/overlays/model-browser.ts +69 -10
  113. package/src/overlays/session-selector.ts +25 -5
  114. package/src/overlays/settings-defs.ts +2 -2
  115. package/src/overlays/settings-selector.ts +113 -11
  116. package/src/overlays/tree-selector.ts +83 -27
  117. package/src/overlays/usage-dashboard.ts +4 -6
  118. package/src/prompt/composer.ts +17 -5
  119. package/src/render/code-cell.ts +1 -1
  120. package/src/render/file-list.ts +4 -7
  121. package/src/render/render-utils.d.ts +23 -1
  122. package/src/render/render-utils.ts +38 -6
  123. package/src/setup/scenes/glyph.ts +1 -1
  124. package/src/setup/scenes/language.ts +122 -0
  125. package/src/setup/scenes/types.ts +6 -0
  126. package/src/setup/setup-version.ts +1 -1
  127. package/src/setup/wizard.ts +2 -0
  128. package/src/status-line/startup.ts +36 -70
  129. package/src/terminal-capabilities.d.ts +1 -1
  130. package/src/terminal-capabilities.ts +5 -0
  131. package/src/theme/symbols.d.ts +3 -1
  132. package/src/theme/symbols.ts +16 -9
  133. package/src/theme/theme-class.d.ts +1 -0
  134. package/src/theme/theme-class.ts +15 -3
  135. package/src/theme/theme.d.ts +1 -1
  136. package/src/theme/theme.ts +1 -0
  137. package/src/theme/tui-adapters.d.ts +2 -0
  138. package/src/theme/tui-adapters.ts +8 -3
  139. package/src/thinking.d.ts +8 -6
  140. package/src/thinking.ts +17 -11
  141. package/src/tmux.ts +1 -0
  142. package/src/tools/agent-tree.ts +13 -11
  143. package/src/tools/ask.ts +24 -37
  144. package/src/tools/ast-edit.ts +48 -93
  145. package/src/tools/ast-grep.d.ts +2 -0
  146. package/src/tools/ast-grep.ts +31 -67
  147. package/src/tools/bash.ts +7 -0
  148. package/src/tools/default-renderer.ts +1 -1
  149. package/src/tools/edit.ts +50 -43
  150. package/src/tools/eval.d.ts +2 -0
  151. package/src/tools/eval.ts +2 -0
  152. package/src/tools/fetch.ts +2 -1
  153. package/src/tools/find.d.ts +1 -1
  154. package/src/tools/find.ts +13 -5
  155. package/src/tools/github.ts +14 -46
  156. package/src/tools/glob.ts +2 -1
  157. package/src/tools/grep.ts +47 -277
  158. package/src/tools/grouped-file-output.d.ts +100 -19
  159. package/src/tools/grouped-file-output.ts +414 -103
  160. package/src/tools/hashline-format.d.ts +5 -0
  161. package/src/tools/hashline-format.ts +5 -0
  162. package/src/tools/json-tree.ts +1 -5
  163. package/src/tools/lsp.ts +210 -32
  164. package/src/tools/native-view.d.ts +2 -0
  165. package/src/tools/native-view.ts +11 -5
  166. package/src/tools/output-meta.d.ts +27 -0
  167. package/src/tools/output-meta.ts +68 -4
  168. package/src/tools/proc-render.ts +3 -3
  169. package/src/tools/read.d.ts +14 -4
  170. package/src/tools/read.ts +20 -5
  171. package/src/tools/task.d.ts +4 -3
  172. package/src/tools/task.ts +41 -81
  173. package/src/tools/vibe.ts +4 -4
  174. package/src/tools/wait.d.ts +2 -0
  175. package/src/tools/wait.ts +8 -5
  176. package/src/tools/write.ts +17 -27
  177. package/src/tools/yield.ts +1 -1
  178. package/src/tui.d.ts +12 -0
  179. package/src/tui.ts +91 -9
  180. package/src/utils.d.ts +4 -0
  181. package/src/utils.ts +10 -0
@@ -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
  ],
@@ -8,6 +8,8 @@ export interface FigureMarkdownOptions {
8
8
  charts: boolean;
9
9
  /** Shared inline-image budget for the figures. */
10
10
  budget?: ImageBudget;
11
+ /** 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. */
12
+ maxRows?: () => number | undefined;
11
13
  /** A figure's rows changed outside a text update (raster landed, fell back to code). */
12
14
  onChange: () => void;
13
15
  }
@@ -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
  /**