@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
@@ -20,6 +20,7 @@ import { matchesKey } from "../../keys";
20
20
  import { col, compact, item, keyed, list, node, row, span, stableKey, text } from "../../native/describe";
21
21
  import { Memo } from "../../native/memo";
22
22
  import type { DescribeContext, NativeChild, NativeNode, NativeUiEvent } from "../../native/node";
23
+ import { actionButton, iconButton, quietButton, segmentedTabs } from "../../native/overlay";
23
24
  import type { TspProps, TspSpan } from "@linxiraos/pi-wire";
24
25
  import { TERMINAL } from "../../terminal-capabilities";
25
26
  import { truncateToWidth, visibleWidth } from "../../utils";
@@ -237,11 +238,6 @@ class GitFileTree {
237
238
  }
238
239
  }
239
240
 
240
- /** A quiet text button (`Stage all`): a clickable row the role sheet draws as `.btn.quiet`. */
241
- function quietButton(label: string, act: string, title: string): NativeNode {
242
- return node("row", { role: "zeta.app.qbtn", actions: { click: act }, title }, [text(label)], act);
243
- }
244
-
245
241
  /** A text field at rest: its value (or placeholder) as text; a click starts editing it. */
246
242
  function fieldText(
247
243
  value: string,
@@ -1099,8 +1095,7 @@ export class Sidebar {
1099
1095
  }
1100
1096
 
1101
1097
  #describeStyleToggle(): NativeNode {
1102
- return node(
1103
- "tabs",
1098
+ return segmentedTabs(
1104
1099
  {
1105
1100
  items: [
1106
1101
  { id: "path", label: "Path" },
@@ -1109,7 +1104,6 @@ export class Sidebar {
1109
1104
  active: this.viewStyle,
1110
1105
  role: "zeta.app.seg",
1111
1106
  },
1112
- undefined,
1113
1107
  "style",
1114
1108
  );
1115
1109
  }
@@ -1128,18 +1122,10 @@ export class Sidebar {
1128
1122
  area === "unstaged"
1129
1123
  ? [
1130
1124
  quietButton("Stage all", "stage-all", "Stage every change (space on the head)"),
1131
- node(
1132
- "icon",
1133
- {
1134
- name: "wand",
1135
- role: "zeta.app.ibtn",
1136
- title: "Stage by description…",
1137
- aria: "Stage by description",
1138
- actions: { click: "stage-ai" },
1139
- },
1140
- undefined,
1141
- "ai",
1142
- ),
1125
+ iconButton("wand", "stage-ai", "Stage by description…", {
1126
+ key: "ai",
1127
+ aria: "Stage by description",
1128
+ }),
1143
1129
  ]
1144
1130
  : [quietButton("Unstage all", "unstage-all", "Unstage every change (space on the head)")];
1145
1131
  const head = row(
@@ -1264,8 +1250,13 @@ export class Sidebar {
1264
1250
  "zeta.app.git.body",
1265
1251
  );
1266
1252
  const hasChanges = this.#model.staged.length > 0 || this.#model.unstaged.length > 0 || this.amend;
1267
- const canCommit =
1268
- hasChanges && !this.generating && (summary.trim().length > 0 || description.trim().length === 0);
1253
+ const blocked = !hasChanges
1254
+ ? "Nothing to commit"
1255
+ : this.generating
1256
+ ? "Generating the commit message…"
1257
+ : summary.trim().length === 0 && description.trim().length > 0
1258
+ ? "Write a summary line first"
1259
+ : undefined;
1269
1260
  const label = this.generating
1270
1261
  ? "Generating message…"
1271
1262
  : summary.trim().length === 0 && description.trim().length === 0
@@ -1273,8 +1264,13 @@ export class Sidebar {
1273
1264
  : this.#model.staged.length > 0
1274
1265
  ? "Commit"
1275
1266
  : "Stage all & commit";
1276
- // The panels' button (zeta-panels.css `zeta.btn`): accent while the keyboard is on it, muted when it can't run.
1277
- const commitTone = !canCommit ? "muted" : on({ kind: "commit-button" }) ? "accent" : undefined;
1267
+ // The panels' button: the primary while the keyboard is on it, disabled (saying why) when it can't run.
1268
+ const commit = actionButton(label, "commit", {
1269
+ title: this.#model.staged.length > 0 ? "Commit the staged changes" : "Stage everything, then commit",
1270
+ busy: this.generating,
1271
+ disabled: blocked,
1272
+ tone: on({ kind: "commit-button" }) ? "accent" : undefined,
1273
+ });
1278
1274
  return col(
1279
1275
  [
1280
1276
  keyed(summaryField, "summary"),
@@ -1289,17 +1285,7 @@ export class Sidebar {
1289
1285
  actions: { click: "amend" },
1290
1286
  title: "Amend the previous commit",
1291
1287
  }),
1292
- row(compact([this.generating && node("spinner", { style: "dots" }), text(label)]), {
1293
- gap: "xs",
1294
- align: "center",
1295
- role: "zeta.btn",
1296
- tone: commitTone,
1297
- actions: canCommit ? { click: "commit" } : undefined,
1298
- title:
1299
- this.#model.staged.length > 0
1300
- ? "Commit the staged changes"
1301
- : "Stage everything, then commit",
1302
- }),
1288
+ commit,
1303
1289
  ],
1304
1290
  { justify: "between", align: "center", role: "zeta.app.git.foot" },
1305
1291
  ),
@@ -17,7 +17,7 @@ import { type Component, TUI } from "../tui";
17
17
  import type { TspSpan, TspText, TspTone } from "@linxiraos/pi-wire";
18
18
  import { col, compact, elapsed, keyed, node, row, span, stableKey, text } from "../native/describe";
19
19
  import type { NativeNode, NativeUiEvent } from "../native/node";
20
- import { actionBar, actionButton } from "../native/overlay";
20
+ import { actionBar, actionButton, iconButton, segmentedTabs } from "../native/overlay";
21
21
  import { Memo } from "../native/memo";
22
22
  import { truncateToWidth } from "../utils";
23
23
  import { formatDuration } from "@linxiraos/pi-utils";
@@ -410,13 +410,7 @@ export class PsTopComponent implements Component {
410
410
  );
411
411
  } else {
412
412
  left.push(
413
- node("icon", {
414
- name: "back",
415
- role: "zeta.app.ibtn",
416
- title: "Back esc",
417
- aria: "Back",
418
- actions: { click: "back" },
419
- }),
413
+ iconButton("back", "back", "Back esc", { aria: "Back" }),
420
414
  text(
421
415
  this.#view === "logs" ? `Logs · ${entry?.row.snapshot.name ?? "?"}` : (entry?.row.snapshot.name ?? "?"),
422
416
  {
@@ -432,8 +426,7 @@ export class PsTopComponent implements Component {
432
426
  const right: NativeNode[] = [];
433
427
  if (this.#view === "table") {
434
428
  right.push(
435
- node(
436
- "tabs",
429
+ segmentedTabs(
437
430
  {
438
431
  items: [
439
432
  {
@@ -448,7 +441,6 @@ export class PsTopComponent implements Component {
448
441
  active: this.#all ? "all" : "current",
449
442
  role: "zeta.app.seg",
450
443
  },
451
- undefined,
452
444
  "scope",
453
445
  ),
454
446
  );
@@ -468,7 +460,7 @@ export class PsTopComponent implements Component {
468
460
  align: "center",
469
461
  role: "zeta.app.fresh",
470
462
  }),
471
- node("icon", { name: "x", role: "zeta.app.ibtn", title: "Quit q", aria: "Quit", actions: { click: "quit" } }),
463
+ iconButton("x", "quit", "Quit q", { aria: "Quit" }),
472
464
  );
473
465
  return keyed(
474
466
  row(
@@ -1523,10 +1523,6 @@ export function buildChart(table: TableAnalysis, plan: ChartPlan): ChartSpec | u
1523
1523
  // its rows are in different units.
1524
1524
  if (arrows.length === 1 && plan.kind !== "paired" && plan.kind !== "range" && !plan.transpose)
1525
1525
  return buildChart(table, { ...plan, kind: arrows[0]!.mixed ? "change" : "paired", series: [arrows[0]!.index] });
1526
- // A dumbbell of two measures beside their ratio (`pi-walker | Go | Speedup`): the ratio restates the gap the
1527
- // dumbbell draws (on a log axis its length), so the pair draws alone.
1528
- const pair = plan.kind === "paired" && !plan.transpose ? ratioPair(table, columns) : undefined;
1529
- if (pair) return buildChart(table, { ...plan, series: pair.map(column => column.index) });
1530
1526
  // Unitless before/after values spanning decades are rows of different quantities, and rows of very different
1531
1527
  // sizes beside a baseline column share no readable axis; their factors do (`3.95M → 190k` is 21× less).
1532
1528
  // Intervals keep their values: a range chart prints the factor between a pair's midpoints beside both.
@@ -2810,31 +2806,6 @@ function againstBaseline(
2810
2806
  return [baseline, ...columns.filter(column => column !== baseline)];
2811
2807
  }
2812
2808
 
2813
- /** Relative slack within which a ratio column restates the ratio of two others (`4.1×` for 75.3 / 18.2). */
2814
- const RATIO_SLACK = 0.05;
2815
-
2816
- /**
2817
- * Of three plotted columns, the two same-unit measures when the third is their ratio (`Speedup`
2818
- * `4.1×`, a `ratio` column) matching `a ÷ b` or `b ÷ a` within {@link RATIO_SLACK}
2819
- * in every row holding all three, two rows at least; else `undefined`.
2820
- */
2821
- function ratioPair(table: TableAnalysis, columns: readonly TableColumn[]): [TableColumn, TableColumn] | undefined {
2822
- if (columns.length !== 3) return undefined;
2823
- const ratio = columns.find(column => column.dim === "ratio");
2824
- const rest = columns.filter(column => column !== ratio);
2825
- const [a, b] = rest;
2826
- if (!ratio || !a || !b || a.dim !== b.dim || a.unit !== b.unit || a.dim === "ratio") return undefined;
2827
- const near = (value: number, target: number) => Math.abs(value - target) <= RATIO_SLACK * target;
2828
- let matched = 0;
2829
- for (const row of table.rows) {
2830
- const [x, y, r] = [a.cells[row], b.cells[row], ratio.cells[row]];
2831
- if (!isNumber(x) || !isNumber(y) || !isNumber(r) || x.value <= 0 || y.value <= 0) continue;
2832
- if (!near(r.value, x.value / y.value) && !near(r.value, y.value / x.value)) return undefined;
2833
- matched++;
2834
- }
2835
- return matched >= 2 ? [a, b] : undefined;
2836
- }
2837
-
2838
2809
  /**
2839
2810
  * Measure columns pairing a before condition with another over the same
2840
2811
  * metric (`Baseline Turns` → `Iter1 Turns`, `Baseline Tokens In` → `Iter1
@@ -101,8 +101,10 @@ export interface TableColumn {
101
101
  /**
102
102
  * Index of the measure column this one restates, read from the values: a
103
103
  * proportional copy (`pass` 33/38 beside `pass%` 87%, `Samples` beside `% of
104
- * Total`, `Leverage vs $200` beside the cost) or a running total of it
105
- * (`Offset` summing `Verts`). Such a column is never a measure of its own.
104
+ * Total`, `Leverage vs $200` beside the cost), a running total of it
105
+ * (`Offset` summing `Verts`), or its ratio to another column of its unit
106
+ * (`ratio` 0.997 for `Python (ms)` ÷ `C++ (ms)`, `Speedup` 4.1×: the
107
+ * numerator's index). Such a column is never a measure of its own.
106
108
  */
107
109
  readonly restates?: number;
108
110
  }
@@ -108,8 +108,10 @@ export interface TableColumn {
108
108
  /**
109
109
  * Index of the measure column this one restates, read from the values: a
110
110
  * proportional copy (`pass` 33/38 beside `pass%` 87%, `Samples` beside `% of
111
- * Total`, `Leverage vs $200` beside the cost) or a running total of it
112
- * (`Offset` summing `Verts`). Such a column is never a measure of its own.
111
+ * Total`, `Leverage vs $200` beside the cost), a running total of it
112
+ * (`Offset` summing `Verts`), or its ratio to another column of its unit
113
+ * (`ratio` 0.997 for `Python (ms)` ÷ `C++ (ms)`, `Speedup` 4.1×: the
114
+ * numerator's index). Such a column is never a measure of its own.
113
115
  */
114
116
  readonly restates?: number;
115
117
  }
@@ -906,10 +908,11 @@ function plainValue(column: TableColumn, row: number): NumberCell | undefined {
906
908
 
907
909
  /**
908
910
  * Columns restating another column's values: `y = k·x` within the written
909
- * precision over three or more rows where `x` varies, or a running total
910
- * (`Offset` stepping by `Verts`). Of a proportional pair the first column
911
- * stays, unless the second is a share summing to 100% beside counts or the
912
- * table bolded more of its cells (`**87%**` beside `33/38`).
911
+ * precision over three or more rows where `x` varies, a running total
912
+ * (`Offset` stepping by `Verts`), or the ratio of two others ({@link quotient}).
913
+ * Of a proportional pair the first column stays, unless the second is a share
914
+ * summing to 100% beside counts or the table bolded more of its cells
915
+ * (`**87%**` beside `33/38`).
913
916
  */
914
917
  function restatedColumns(measures: readonly TableColumn[], rows: readonly number[]): Map<number, number> {
915
918
  const restated = new Map<number, number>();
@@ -931,9 +934,55 @@ function restatedColumns(measures: readonly TableColumn[], rows: readonly number
931
934
  const source = measures.find(other => other !== column && runningTotal(column, other, rows));
932
935
  if (source) restated.set(column.index, source.index);
933
936
  }
937
+ const kept = measures.filter(column => !restated.has(column.index));
938
+ for (const ratio of kept) {
939
+ if (restated.has(ratio.index)) continue;
940
+ const terms = kept.filter(column => column !== ratio && !restated.has(column.index));
941
+ const over = terms
942
+ .flatMap(a => terms.map(b => [a, b] as const))
943
+ .find(([a, b]) => a !== b && quotient(ratio, a, b, rows));
944
+ if (over) restated.set(ratio.index, over[0].index);
945
+ }
934
946
  return restated;
935
947
  }
936
948
 
949
+ /** Most relative rounding a row's quotient may carry to count toward proving it (`2×` beside its terms proves little). */
950
+ const LOOSE_QUOTIENT = 0.05;
951
+
952
+ /**
953
+ * `ratio = a ÷ b` in every row holding all three, `a` and `b` in one unit
954
+ * (`Python (ms)` ÷ `old C++ (ms)` = `0.997`; `Go` ÷ `pi-walker` = `4.1×`),
955
+ * within the precision each figure is written to, over three or more rows
956
+ * pinned to {@link LOOSE_QUOTIENT}. Percent columns are left alone: a part's
957
+ * share of a whole (`Share` = `Tokens` ÷ `Total`) is a measure the table states.
958
+ *
959
+ * Bare numbers all read as counts, and of three columns related so each is
960
+ * the others' quotient or product (`C++ = Python ÷ ratio` holds too), the
961
+ * ratio is the one that varies less from row to row than both its terms:
962
+ * workloads of different sizes move both timings, not their ratio. Where none
963
+ * does, none is taken for the ratio.
964
+ */
965
+ function quotient(ratio: TableColumn, a: TableColumn, b: TableColumn, rows: readonly number[]): boolean {
966
+ if ((ratio.dim !== "count" && ratio.dim !== "ratio") || a.dim !== b.dim || a.unit !== b.unit) return false;
967
+ let tight = 0;
968
+ const matched: (readonly [number, number, number])[] = [];
969
+ for (const row of rows) {
970
+ const [r, x, y] = [plainValue(ratio, row), plainValue(a, row), plainValue(b, row)];
971
+ if (!r || !x || !y) continue;
972
+ if (x.value <= 0 || y.value <= 0 || r.value <= 0) return false;
973
+ const exact = x.value / y.value;
974
+ const slack = writtenSlack(r) + exact * (writtenSlack(x) / x.value + writtenSlack(y) / y.value) + 1e-9 * exact;
975
+ if (Math.abs(r.value - exact) > slack) return false;
976
+ if (slack <= LOOSE_QUOTIENT * exact) tight++;
977
+ matched.push([r.value, x.value, y.value]);
978
+ }
979
+ if (tight < 3) return false;
980
+ if (ratio.dim !== a.dim) return true;
981
+ const spread = (at: 0 | 1 | 2) =>
982
+ Math.max(...matched.map(values => values[at])) / Math.min(...matched.map(values => values[at]));
983
+ return spread(0) < spread(1) && spread(0) < spread(2);
984
+ }
985
+
937
986
  /** How many of `rows` the table bolded in `column`. */
938
987
  function emphasized(column: TableColumn, rows: readonly number[]): number {
939
988
  return rows.filter(row => column.cells[row]?.emphasis).length;
@@ -4,7 +4,7 @@
4
4
  import type { ImageContent } from "@linxiraos/pi-ai";
5
5
  import { Container, type TUI } from "../tui";
6
6
  import type { OutputArtifactError } from "../tools/streaming-output";
7
- import type { TruncationMeta } from "../tools/output-meta";
7
+ import type { MinimizedMeta, TruncationMeta } from "../tools/output-meta";
8
8
  import { type DescribeContext, type NativeNode, type NativeUiEvent } from "../native/node";
9
9
  /** PTY size for `!` commands: the execution frame's inner content area. */
10
10
  export declare function bashPtyViewport(ui: TUI): {
@@ -43,9 +43,12 @@ export declare class BashExecutionComponent extends Container {
43
43
  output?: string;
44
44
  truncation?: TruncationMeta;
45
45
  artifactError?: OutputArtifactError;
46
+ minimized?: MinimizedMeta;
46
47
  images?: readonly ImageContent[];
47
48
  showImages?: boolean;
48
49
  }): void;
50
+ /** The loader animates the bottom border from outside the child tree, so teardown stops it here. */
51
+ dispose(): void;
49
52
  render(width: number): readonly string[];
50
53
  /**
51
54
  * Get the raw output for creating BashExecutionMessage.
@@ -12,7 +12,7 @@ import { sanitizeText } from "@linxiraos/pi-utils";
12
12
  import type { Terminal as XtermTerminalType } from "@linxiraos/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
  });
@@ -37,7 +37,7 @@ import { theme } from "../theme";
37
37
  import {
38
38
  assistantHasVisibleContent,
39
39
  assistantUsageIsBilled,
40
- buildAsyncResultBlock,
40
+ buildAsyncResultComponent,
41
41
  buildFileMentionBlock,
42
42
  buildIrcMessageCard,
43
43
  buildLaunchCompletionBlock,
@@ -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
  });
@@ -599,7 +600,9 @@ export class ChatTranscriptBuilder {
599
600
  #appendCustomMessage(message: Extract<AgentMessage, { role: "custom" | "hookMessage" }>): void {
600
601
  if (!message.display) return;
601
602
  if (message.customType === "async-result") {
602
- const component = buildAsyncResultBlock(message);
603
+ const renderer = this.#deps.getMessageRenderer?.(message.customType);
604
+ const component = buildAsyncResultComponent(message, renderer);
605
+ this.#trackExpandable(component);
603
606
  this.container.addChild(component);
604
607
  return;
605
608
  }
@@ -32,6 +32,8 @@ export declare class EvalExecutionComponent extends Container {
32
32
  truncation?: TruncationMeta;
33
33
  artifactError?: OutputArtifactError;
34
34
  }): void;
35
+ /** The loader animates the bottom border from outside the child tree, so teardown stops it here. */
36
+ dispose(): void;
35
37
  getOutput(): string;
36
38
  getCode(): string;
37
39
  }
@@ -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,7 +10,8 @@ import { Loader } from "../components/loader";
10
10
  import { Text } from "../components/text";
11
11
  import { Container, type TUI } from "../tui";
12
12
  import type { OutputArtifactError } from "../tools/streaming-output";
13
- import { type TruncationMeta } from "../tools/output-meta";
13
+ import { type MinimizedMeta, type TruncationMeta } from "../tools/output-meta";
14
+ import { DynamicBorder } from "../chrome/dynamic-border";
14
15
  import type { TspText } from "@linxiraos/pi-wire";
15
16
  import type { NativeChild, NativeNode } from "../native/node";
16
17
  /** Output rows shown while an execution is collapsed. */
@@ -25,23 +26,26 @@ export type ExecutionColorKey = "dim" | "bashMode" | "pythonMode";
25
26
  /**
26
27
  * Build the spacer + top border + content container + bottom border scaffold
27
28
  * that bash and eval execution components share. The caller appends the
28
- * header (command vs `>>>` prompt) and the returned loader to
29
- * `contentContainer` so per-mode order is preserved.
29
+ * header (command vs `>>>` prompt) to `contentContainer` and keeps the run's
30
+ * state in `bottomBorder` ({@link executionStatusLabel}); the returned loader
31
+ * animates that label rather than taking a row of its own.
30
32
  */
31
33
  export declare function buildExecutionFrame(parent: Container, ui: TUI, colorKey: ExecutionColorKey): {
32
34
  contentContainer: Container;
33
35
  loader: Loader;
36
+ bottomBorder: DynamicBorder;
34
37
  };
38
+ /** The bottom-border marker of a settled run: `exit N` for a failure, `cancelled` for a cancel. */
39
+ export declare function executionStatusLabel(status: Exclude<ExecutionStatus, "running">, exitCode: number | undefined): string | undefined;
35
40
  /**
36
- * Build the post-run status block (hidden-line hint, exit/cancel marker,
37
- * truncation notice). Returns undefined when there is nothing to display so
38
- * callers can skip appending a stray Text child.
41
+ * Build the post-run status block (hidden-line hint, truncation notice).
42
+ * Returns undefined when there is nothing to display so callers can skip
43
+ * appending a stray Text child.
39
44
  */
40
45
  export declare function buildStatusFooter(opts: {
41
- status: ExecutionStatus;
42
- exitCode: number | undefined;
43
46
  truncation: TruncationMeta | undefined;
44
47
  artifactError?: OutputArtifactError;
48
+ minimized?: MinimizedMeta;
45
49
  hiddenLineCount: number;
46
50
  /** Suppress the "… N more lines" hint (used when sixel passthrough renders the full output). */
47
51
  suppressHiddenCount?: boolean;
@@ -64,6 +68,7 @@ export interface ExecutionCardInput {
64
68
  readonly exitCode: number | undefined;
65
69
  readonly truncation: TruncationMeta | undefined;
66
70
  readonly artifactError?: OutputArtifactError;
71
+ readonly minimized?: MinimizedMeta;
67
72
  }
68
73
  /**
69
74
  * Native card shared by user bash/eval runs: the head with a live `elapsed`
@@ -94,6 +99,7 @@ export interface ExecutionToolInput {
94
99
  readonly exitCode: number | undefined;
95
100
  readonly truncation: TruncationMeta | undefined;
96
101
  readonly artifactError?: OutputArtifactError;
102
+ readonly minimized?: MinimizedMeta;
97
103
  }
98
104
  /**
99
105
  * A user `!`/`$` run as the agent's `tool` frame (§6.6): a head with a `you`