@linxiraos/pi-tui 1.4.4 → 1.4.7

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 (363) hide show
  1. package/CHANGELOG.md +208 -207
  2. package/README.md +34 -34
  3. package/dist/types/app-keybindings.d.ts +20 -0
  4. package/dist/types/apps/session-picker.d.ts +5 -0
  5. package/dist/types/charts/chart-plan.d.ts +9 -7
  6. package/dist/types/chat/assistant-message.d.ts +15 -3
  7. package/dist/types/chat/bash-execution.d.ts +2 -0
  8. package/dist/types/chat/display-preferences.d.ts +2 -0
  9. package/dist/types/chat/extension-types.d.ts +31 -0
  10. package/dist/types/chat/reply-write.d.ts +48 -0
  11. package/dist/types/chat/table-chart.d.ts +4 -3
  12. package/dist/types/chat/tool-execution.d.ts +1 -2
  13. package/dist/types/chat/transcript-outline.d.ts +7 -0
  14. package/dist/types/chat/transcript-render-helpers.d.ts +2 -0
  15. package/dist/types/chrome/context-map.d.ts +15 -0
  16. package/dist/types/chrome/context-presentation.d.ts +48 -0
  17. package/dist/types/chrome/context-view-model.d.ts +77 -0
  18. package/dist/types/chrome/index.d.ts +1 -0
  19. package/dist/types/chrome/transcript-notice.d.ts +35 -0
  20. package/dist/types/chrome/transcript-status.d.ts +20 -8
  21. package/dist/types/components/editor.d.ts +8 -0
  22. package/dist/types/components/image.d.ts +20 -0
  23. package/dist/types/components/loader.d.ts +1 -1
  24. package/dist/types/components/markdown.d.ts +7 -0
  25. package/dist/types/native/blobs.d.ts +11 -1
  26. package/dist/types/native/picker.d.ts +4 -4
  27. package/dist/types/overlays/advisor-config.d.ts +6 -0
  28. package/dist/types/overlays/agent-hub-projection.d.ts +3 -1
  29. package/dist/types/overlays/annotation-overlay.d.ts +7 -1
  30. package/dist/types/overlays/annotation-types.d.ts +28 -0
  31. package/dist/types/overlays/ask-dialog.d.ts +12 -3
  32. package/dist/types/overlays/btw-history-panel.d.ts +16 -2
  33. package/dist/types/overlays/btw-history.d.ts +7 -0
  34. package/dist/types/overlays/btw-panel.d.ts +2 -0
  35. package/dist/types/overlays/context-viewer-format.d.ts +42 -0
  36. package/dist/types/overlays/context-viewer-overview.d.ts +70 -0
  37. package/dist/types/overlays/context-viewer.d.ts +25 -0
  38. package/dist/types/overlays/hook-input.d.ts +1 -0
  39. package/dist/types/overlays/login-dialog.d.ts +5 -1
  40. package/dist/types/overlays/mcp-add-wizard.d.ts +2 -0
  41. package/dist/types/overlays/model-browser.d.ts +10 -1
  42. package/dist/types/overlays/oauth-selector.d.ts +23 -0
  43. package/dist/types/overlays/pause-screen.d.ts +13 -3
  44. package/dist/types/overlays/plan-review-overlay.d.ts +2 -0
  45. package/dist/types/overlays/rewind-selector.d.ts +1 -1
  46. package/dist/types/overlays/running-subagent-badge.d.ts +7 -1
  47. package/dist/types/overlays/session-selector.d.ts +22 -2
  48. package/dist/types/prompt/composer.d.ts +43 -0
  49. package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
  50. package/dist/types/prompt/macos-spelling.d.ts +2 -2
  51. package/dist/types/render/extension-links.d.ts +65 -0
  52. package/dist/types/render/hyperlink.d.ts +38 -7
  53. package/dist/types/render/index.d.ts +1 -0
  54. package/dist/types/render/output-pane.d.ts +1 -1
  55. package/dist/types/render/render-utils.d.ts +7 -1
  56. package/dist/types/setup/scenes/glyph.d.ts +1 -1
  57. package/dist/types/setup/scenes/model.d.ts +1 -1
  58. package/dist/types/setup/scenes/outro.d.ts +5 -4
  59. package/dist/types/setup/scenes/sign-in.d.ts +13 -8
  60. package/dist/types/setup/scenes/types.d.ts +16 -1
  61. package/dist/types/setup/startup-splash.d.ts +1 -1
  62. package/dist/types/setup/wizard-overlay.d.ts +11 -7
  63. package/dist/types/setup/wizard.d.ts +5 -1
  64. package/dist/types/status-line/component.d.ts +3 -3
  65. package/dist/types/status-line/context-usage.d.ts +42 -35
  66. package/dist/types/status-line/host.d.ts +6 -2
  67. package/dist/types/terminal-capabilities.d.ts +7 -0
  68. package/dist/types/theme/symbols.d.ts +1 -1
  69. package/dist/types/theme/theme.d.ts +0 -23
  70. package/dist/types/tools/ask.d.ts +4 -0
  71. package/dist/types/tools/bash-interactive.d.ts +6 -0
  72. package/dist/types/tools/bash.d.ts +2 -0
  73. package/dist/types/tools/default-renderer.d.ts +6 -4
  74. package/dist/types/tools/edit.d.ts +3 -1
  75. package/dist/types/tools/fetch.d.ts +1 -0
  76. package/dist/types/tools/github.d.ts +3 -0
  77. package/dist/types/tools/grouped-file-output.d.ts +2 -0
  78. package/dist/types/tools/irc.d.ts +6 -0
  79. package/dist/types/tools/json-tree.d.ts +23 -4
  80. package/dist/types/tools/lsp.d.ts +2 -0
  81. package/dist/types/tools/mcp.d.ts +7 -6
  82. package/dist/types/tools/native-view.d.ts +1 -1
  83. package/dist/types/tools/read.d.ts +3 -0
  84. package/dist/types/tools/renderer.d.ts +2 -0
  85. package/dist/types/tools/streaming-output.d.ts +11 -0
  86. package/dist/types/tools/task.d.ts +9 -1
  87. package/dist/types/tools/url-scheme-host.d.ts +17 -0
  88. package/dist/types/tools/wait.d.ts +16 -2
  89. package/dist/types/tools/yield.d.ts +1 -1
  90. package/dist/types/tui.d.ts +9 -2
  91. package/dist/types/vim.d.ts +39 -0
  92. package/package.json +10 -14
  93. package/src/app-keybindings.d.ts +20 -0
  94. package/src/app-keybindings.ts +20 -0
  95. package/src/apps/session-picker.ts +7 -0
  96. package/src/charts/chart-plan.d.ts +9 -7
  97. package/src/charts/chart-plan.ts +20 -50
  98. package/src/chat/advisor-message.ts +2 -0
  99. package/src/chat/assistant-message.d.ts +15 -3
  100. package/src/chat/assistant-message.ts +137 -19
  101. package/src/chat/background-tan-message.ts +4 -0
  102. package/src/chat/bash-execution.d.ts +2 -0
  103. package/src/chat/bash-execution.ts +13 -1
  104. package/src/chat/chat-transcript-builder.ts +58 -28
  105. package/src/chat/compaction-summary-message.ts +2 -1
  106. package/src/chat/display-preferences.d.ts +2 -0
  107. package/src/chat/display-preferences.ts +3 -0
  108. package/src/chat/extension-types.d.ts +31 -0
  109. package/src/chat/extension-types.ts +34 -0
  110. package/src/chat/read-tool-group.ts +1 -2
  111. package/src/chat/reply-write.d.ts +48 -0
  112. package/src/chat/reply-write.ts +127 -0
  113. package/src/chat/skill-message.ts +2 -6
  114. package/src/chat/table-chart.d.ts +4 -3
  115. package/src/chat/table-chart.ts +10 -4
  116. package/src/chat/tool-execution.d.ts +1 -2
  117. package/src/chat/tool-execution.ts +20 -13
  118. package/src/chat/transcript-outline.d.ts +7 -0
  119. package/src/chat/transcript-outline.ts +27 -0
  120. package/src/chat/transcript-render-helpers.d.ts +2 -0
  121. package/src/chat/transcript-render-helpers.ts +66 -24
  122. package/src/chrome/context-map.ts +62 -0
  123. package/src/chrome/context-presentation.ts +26 -0
  124. package/src/chrome/context-view-model.ts +73 -0
  125. package/src/chrome/index.ts +1 -0
  126. package/src/chrome/transcript-container.ts +89 -59
  127. package/src/chrome/transcript-notice.d.ts +35 -0
  128. package/src/chrome/transcript-notice.ts +83 -0
  129. package/src/chrome/transcript-status.d.ts +20 -8
  130. package/src/chrome/transcript-status.ts +29 -29
  131. package/src/components/editor.d.ts +8 -0
  132. package/src/components/editor.ts +465 -14
  133. package/src/components/image.d.ts +20 -0
  134. package/src/components/image.ts +83 -18
  135. package/src/components/loader.d.ts +1 -1
  136. package/src/components/loader.ts +1 -1
  137. package/src/components/markdown.d.ts +7 -0
  138. package/src/components/markdown.ts +225 -13
  139. package/src/hotkeys-markdown.ts +2 -0
  140. package/src/native/backend.ts +5 -66
  141. package/src/native/blobs.d.ts +11 -1
  142. package/src/native/blobs.ts +5 -3
  143. package/src/native/picker.d.ts +4 -4
  144. package/src/native/picker.ts +4 -4
  145. package/src/overlays/advisor-config.ts +10 -12
  146. package/src/overlays/agent-hub-projection.d.ts +3 -1
  147. package/src/overlays/agent-hub-projection.ts +6 -5
  148. package/src/overlays/agent-hub.ts +51 -42
  149. package/src/overlays/annotation-overlay.ts +125 -37
  150. package/src/overlays/annotation-types.ts +24 -0
  151. package/src/overlays/ask-dialog.ts +125 -35
  152. package/src/overlays/btw-history-panel.ts +124 -12
  153. package/src/overlays/btw-history.ts +11 -0
  154. package/src/overlays/btw-panel.ts +8 -4
  155. package/src/overlays/context-viewer-format.ts +145 -0
  156. package/src/overlays/context-viewer-overview.ts +381 -0
  157. package/src/overlays/context-viewer.ts +728 -0
  158. package/src/overlays/hook-input.ts +2 -0
  159. package/src/overlays/hook-selector.ts +2 -2
  160. package/src/overlays/login-dialog.ts +31 -5
  161. package/src/overlays/mcp-add-wizard.ts +6 -1
  162. package/src/overlays/model-browser.ts +37 -0
  163. package/src/overlays/model-hub.ts +1 -7
  164. package/src/overlays/model-picker.ts +1 -10
  165. package/src/overlays/oauth-selector.ts +44 -6
  166. package/src/overlays/pause-screen.ts +166 -33
  167. package/src/overlays/plan-review-overlay.ts +13 -2
  168. package/src/overlays/rewind-selector.ts +29 -12
  169. package/src/overlays/running-subagent-badge.ts +12 -1
  170. package/src/overlays/session-selector.ts +313 -42
  171. package/src/overlays/settings-defs.ts +1 -0
  172. package/src/overlays/usage-dashboard.ts +20 -14
  173. package/src/prompt/composer.ts +216 -1
  174. package/src/prompt/custom-editor.ts +6 -1
  175. package/src/prompt/emoji-autocomplete.ts +0 -2
  176. package/src/prompt/interactive-context-helpers.ts +29 -4
  177. package/src/prompt/macos-spelling.ts +24 -15
  178. package/src/render/extension-links.d.ts +65 -0
  179. package/src/render/extension-links.ts +214 -0
  180. package/src/render/hyperlink.d.ts +38 -7
  181. package/src/render/hyperlink.ts +102 -23
  182. package/src/render/index.d.ts +1 -0
  183. package/src/render/index.ts +1 -0
  184. package/src/render/output-pane.d.ts +1 -1
  185. package/src/render/output-pane.ts +60 -17
  186. package/src/render/render-utils.d.ts +7 -1
  187. package/src/render/render-utils.ts +11 -2
  188. package/src/setup/scenes/composer.ts +2 -0
  189. package/src/setup/scenes/glyph.ts +3 -1
  190. package/src/setup/scenes/model.ts +192 -29
  191. package/src/setup/scenes/outro.ts +33 -15
  192. package/src/setup/scenes/sign-in.ts +194 -392
  193. package/src/setup/scenes/theme.ts +2 -0
  194. package/src/setup/scenes/types.ts +18 -1
  195. package/src/setup/startup-splash.ts +8 -7
  196. package/src/setup/wizard-overlay.ts +164 -35
  197. package/src/setup/wizard.ts +11 -2
  198. package/src/status-line/component.ts +10 -14
  199. package/src/status-line/context-usage.ts +122 -597
  200. package/src/status-line/host.ts +6 -2
  201. package/src/terminal-capabilities.d.ts +7 -0
  202. package/src/terminal-capabilities.ts +10 -0
  203. package/src/terminal.ts +24 -2
  204. package/src/theme/defaults.json +1 -0
  205. package/src/theme/loader.ts +1 -1
  206. package/src/theme/symbols.d.ts +1 -1
  207. package/src/theme/symbols.ts +16 -0
  208. package/src/theme/theme.d.ts +0 -23
  209. package/src/theme/theme.ts +2 -75
  210. package/src/tools/ask.d.ts +4 -0
  211. package/src/tools/ask.ts +4 -0
  212. package/src/tools/ast-grep.ts +3 -2
  213. package/src/tools/bash-interactive.d.ts +49 -0
  214. package/src/tools/bash-interactive.ts +6 -1
  215. package/src/tools/bash.d.ts +2 -0
  216. package/src/tools/bash.ts +7 -23
  217. package/src/tools/default-renderer.d.ts +6 -4
  218. package/src/tools/default-renderer.ts +9 -6
  219. package/src/tools/edit.d.ts +3 -1
  220. package/src/tools/edit.ts +8 -4
  221. package/src/tools/eval.ts +14 -4
  222. package/src/tools/fetch.d.ts +1 -0
  223. package/src/tools/fetch.ts +1 -0
  224. package/src/tools/find.ts +3 -10
  225. package/src/tools/github.d.ts +3 -0
  226. package/src/tools/github.ts +23 -3
  227. package/src/tools/glob.ts +4 -3
  228. package/src/tools/grep.ts +3 -4
  229. package/src/tools/grouped-file-output.d.ts +2 -0
  230. package/src/tools/grouped-file-output.ts +8 -2
  231. package/src/tools/irc.d.ts +6 -0
  232. package/src/tools/irc.ts +6 -0
  233. package/src/tools/job-widget.ts +13 -1
  234. package/src/tools/json-tree.d.ts +23 -4
  235. package/src/tools/json-tree.ts +132 -42
  236. package/src/tools/lsp.d.ts +2 -0
  237. package/src/tools/lsp.ts +36 -15
  238. package/src/tools/mcp.d.ts +7 -6
  239. package/src/tools/mcp.ts +41 -15
  240. package/src/tools/native-view.d.ts +1 -1
  241. package/src/tools/native-view.ts +3 -3
  242. package/src/tools/read.d.ts +3 -0
  243. package/src/tools/read.ts +3 -1
  244. package/src/tools/renderer.d.ts +2 -0
  245. package/src/tools/renderer.ts +2 -0
  246. package/src/tools/streaming-output.d.ts +11 -0
  247. package/src/tools/streaming-output.ts +41 -0
  248. package/src/tools/task.d.ts +9 -1
  249. package/src/tools/task.ts +59 -16
  250. package/src/tools/url-scheme-host.d.ts +17 -0
  251. package/src/tools/url-scheme-host.ts +21 -0
  252. package/src/tools/vibe.ts +14 -3
  253. package/src/tools/wait.d.ts +16 -2
  254. package/src/tools/wait.ts +16 -2
  255. package/src/tools/yield.d.ts +1 -1
  256. package/src/tools/yield.ts +18 -9
  257. package/src/tui.d.ts +9 -2
  258. package/src/tui.ts +102 -34
  259. package/src/vim.d.ts +39 -0
  260. package/src/vim.ts +313 -22
  261. package/dist/types/theme/defaults/index.d.ts +0 -10289
  262. package/src/theme/defaults/alabaster.json +0 -103
  263. package/src/theme/defaults/amethyst.json +0 -106
  264. package/src/theme/defaults/anthracite.json +0 -103
  265. package/src/theme/defaults/basalt.json +0 -101
  266. package/src/theme/defaults/birch.json +0 -105
  267. package/src/theme/defaults/dark-abyss.json +0 -101
  268. package/src/theme/defaults/dark-arctic.json +0 -114
  269. package/src/theme/defaults/dark-aurora.json +0 -105
  270. package/src/theme/defaults/dark-catppuccin.json +0 -117
  271. package/src/theme/defaults/dark-cavern.json +0 -101
  272. package/src/theme/defaults/dark-celestial.json +0 -116
  273. package/src/theme/defaults/dark-copper.json +0 -105
  274. package/src/theme/defaults/dark-cosmos.json +0 -100
  275. package/src/theme/defaults/dark-cyberpunk.json +0 -112
  276. package/src/theme/defaults/dark-dracula.json +0 -108
  277. package/src/theme/defaults/dark-eclipse.json +0 -101
  278. package/src/theme/defaults/dark-ember.json +0 -105
  279. package/src/theme/defaults/dark-equinox.json +0 -100
  280. package/src/theme/defaults/dark-forest.json +0 -106
  281. package/src/theme/defaults/dark-github.json +0 -115
  282. package/src/theme/defaults/dark-gruvbox.json +0 -122
  283. package/src/theme/defaults/dark-lavender.json +0 -105
  284. package/src/theme/defaults/dark-lunar.json +0 -99
  285. package/src/theme/defaults/dark-midnight.json +0 -105
  286. package/src/theme/defaults/dark-monochrome.json +0 -104
  287. package/src/theme/defaults/dark-monokai.json +0 -108
  288. package/src/theme/defaults/dark-nebula.json +0 -100
  289. package/src/theme/defaults/dark-neon-noir.json +0 -110
  290. package/src/theme/defaults/dark-nord.json +0 -108
  291. package/src/theme/defaults/dark-ocean.json +0 -111
  292. package/src/theme/defaults/dark-one.json +0 -110
  293. package/src/theme/defaults/dark-poimandres.json +0 -125
  294. package/src/theme/defaults/dark-rainforest.json +0 -101
  295. package/src/theme/defaults/dark-reef.json +0 -101
  296. package/src/theme/defaults/dark-retro.json +0 -102
  297. package/src/theme/defaults/dark-rose-pine.json +0 -106
  298. package/src/theme/defaults/dark-sakura.json +0 -105
  299. package/src/theme/defaults/dark-slate.json +0 -105
  300. package/src/theme/defaults/dark-solarized.json +0 -107
  301. package/src/theme/defaults/dark-solstice.json +0 -100
  302. package/src/theme/defaults/dark-starfall.json +0 -101
  303. package/src/theme/defaults/dark-sunset.json +0 -109
  304. package/src/theme/defaults/dark-swamp.json +0 -100
  305. package/src/theme/defaults/dark-synthwave.json +0 -113
  306. package/src/theme/defaults/dark-taiga.json +0 -101
  307. package/src/theme/defaults/dark-terminal.json +0 -105
  308. package/src/theme/defaults/dark-tokyo-night.json +0 -111
  309. package/src/theme/defaults/dark-tundra.json +0 -101
  310. package/src/theme/defaults/dark-twilight.json +0 -101
  311. package/src/theme/defaults/dark-volcanic.json +0 -101
  312. package/src/theme/defaults/graphite.json +0 -102
  313. package/src/theme/defaults/index.d.ts +0 -10289
  314. package/src/theme/defaults/index.ts +0 -203
  315. package/src/theme/defaults/light-arctic.json +0 -117
  316. package/src/theme/defaults/light-aurora-day.json +0 -101
  317. package/src/theme/defaults/light-canyon.json +0 -101
  318. package/src/theme/defaults/light-catppuccin.json +0 -116
  319. package/src/theme/defaults/light-cirrus.json +0 -100
  320. package/src/theme/defaults/light-coral.json +0 -105
  321. package/src/theme/defaults/light-cyberpunk.json +0 -106
  322. package/src/theme/defaults/light-dawn.json +0 -100
  323. package/src/theme/defaults/light-dunes.json +0 -101
  324. package/src/theme/defaults/light-eucalyptus.json +0 -105
  325. package/src/theme/defaults/light-forest.json +0 -110
  326. package/src/theme/defaults/light-frost.json +0 -105
  327. package/src/theme/defaults/light-github.json +0 -125
  328. package/src/theme/defaults/light-glacier.json +0 -101
  329. package/src/theme/defaults/light-gruvbox.json +0 -118
  330. package/src/theme/defaults/light-haze.json +0 -100
  331. package/src/theme/defaults/light-honeycomb.json +0 -105
  332. package/src/theme/defaults/light-lagoon.json +0 -101
  333. package/src/theme/defaults/light-lavender.json +0 -105
  334. package/src/theme/defaults/light-meadow.json +0 -101
  335. package/src/theme/defaults/light-mint.json +0 -105
  336. package/src/theme/defaults/light-monochrome.json +0 -111
  337. package/src/theme/defaults/light-ocean.json +0 -109
  338. package/src/theme/defaults/light-one.json +0 -109
  339. package/src/theme/defaults/light-opal.json +0 -101
  340. package/src/theme/defaults/light-orchard.json +0 -101
  341. package/src/theme/defaults/light-paper.json +0 -105
  342. package/src/theme/defaults/light-poimandres.json +0 -125
  343. package/src/theme/defaults/light-prism.json +0 -100
  344. package/src/theme/defaults/light-retro.json +0 -108
  345. package/src/theme/defaults/light-sand.json +0 -105
  346. package/src/theme/defaults/light-savanna.json +0 -101
  347. package/src/theme/defaults/light-solarized.json +0 -112
  348. package/src/theme/defaults/light-soleil.json +0 -100
  349. package/src/theme/defaults/light-sunset.json +0 -109
  350. package/src/theme/defaults/light-synthwave.json +0 -108
  351. package/src/theme/defaults/light-tokyo-night.json +0 -121
  352. package/src/theme/defaults/light-wetland.json +0 -101
  353. package/src/theme/defaults/light-zenith.json +0 -99
  354. package/src/theme/defaults/limestone.json +0 -104
  355. package/src/theme/defaults/mahogany.json +0 -107
  356. package/src/theme/defaults/marble.json +0 -103
  357. package/src/theme/defaults/obsidian.json +0 -101
  358. package/src/theme/defaults/onyx.json +0 -101
  359. package/src/theme/defaults/pearl.json +0 -103
  360. package/src/theme/defaults/porcelain.json +0 -101
  361. package/src/theme/defaults/quartz.json +0 -106
  362. package/src/theme/defaults/sandstone.json +0 -105
  363. package/src/theme/defaults/titanium.json +0 -100
@@ -5,6 +5,7 @@ import { Image, type ImageBudget } from "../components/image";
5
5
  import { ImageProtocol, TERMINAL } from "../terminal-capabilities";
6
6
  import {
7
7
  type DefaultTextStyle,
8
+ endsInsideOpenFence,
8
9
  holdPartialTableRow,
9
10
  Markdown,
10
11
  type MarkdownTheme,
@@ -14,10 +15,10 @@ import {
14
15
  } from "../components/markdown";
15
16
  import { Spacer } from "../components/spacer";
16
17
  import { Text } from "../components/text";
17
- import { formatDuration, formatNumber } from "@linxiraos/pi-utils";
18
+ import { formatDuration, formatNumber, logger } from "@linxiraos/pi-utils";
18
19
  import chalk from "@linxiraos/pi-utils/chalk";
19
20
  import { LRUCache } from "@linxiraos/pi-utils/lru";
20
- import type { AssistantThinkingRenderer } from "./extension-types";
21
+ import type { AssistantTextRenderer, AssistantTextRendering, AssistantThinkingRenderer } from "./extension-types";
21
22
  import { ensureThemeSync, getMarkdownTheme, getMarkdownThemeWithLinkTargets, getThemeEpoch, theme } from "../theme";
22
23
  import { card, col, elapsed, node, span, text } from "../native/describe";
23
24
  import { hasTranscriptActions, runTranscriptAction } from "./transcript-actions";
@@ -51,6 +52,8 @@ import { chartFence, hasChartTable, lookupTableChart, splitTableCharts } from ".
51
52
  */
52
53
  const MAX_TRANSCRIPT_ERROR_ROWS = 8;
53
54
  const EMPTY_STABLE_RENDER: readonly string[] = [];
55
+ /** Text renderers that threw once; each failure is logged once per renderer, not per frame. */
56
+ const failedTextRenderers = new WeakSet<AssistantTextRenderer>();
54
57
 
55
58
  /** The native head of a finished thinking block: "Thought for 12s", or "Thought" when it was never seen streaming. */
56
59
  function thoughtLabel(clock: { start: number; end?: number } | undefined): string {
@@ -245,6 +248,19 @@ function lerpHex(from: string, to: string, t: number): string {
245
248
  return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`;
246
249
  }
247
250
 
251
+ /**
252
+ * Drop the closing border the renderer draws for a source that ends inside an
253
+ * open fence. That row is not part of the message yet: the live block reaches
254
+ * it only when the closer arrives, so publishing it would make the settled
255
+ * prefix disagree with the block render and freeze mid-stream retirement.
256
+ */
257
+ function trimFabricatedCloser(rows: readonly string[], source: string): readonly string[] {
258
+ if (!endsInsideOpenFence(source)) return rows;
259
+ let last = rows.length;
260
+ while (last > 0 && rows[last - 1]!.trim() === "") last--;
261
+ return last > 0 ? rows.slice(0, last - 1) : rows;
262
+ }
263
+
248
264
  /**
249
265
  * Renders an assistant message; streaming content remains mutable until the
250
266
  * provider finalizes it because later deltas can revise earlier Markdown.
@@ -390,8 +406,10 @@ export class AssistantMessageComponent extends Container {
390
406
  #reactionTarget: ReactionTarget | undefined;
391
407
  /** Reaction lifted from the reply's opening emoji, once resolved. */
392
408
  #reaction: string | undefined;
393
- /** Display form of {@link #lastMessage} (reaction handled) the native description is built from. */
409
+ /** Display form of {@link #lastMessage} (reaction handled, extension text renderers applied) the native description is built from. */
394
410
  #displayedMessage: AssistantMessage | undefined;
411
+ /** {@link #displayedMessage} before extension text renderers: the reply as written, which thinking state and the native Copy follow. */
412
+ #answerMessage: AssistantMessage | undefined;
395
413
  /** Thinking-extension components per content index, recorded when the slow path mounts them. */
396
414
  #thinkingExtensions = new Map<number, Component[]>();
397
415
  /** Collapse state of thinking sections toggled in the terminal, by content index; cleared by {@link setHideThinkingBlock}. */
@@ -523,9 +541,65 @@ export class AssistantMessageComponent extends Container {
523
541
  content[index] = { ...block, text };
524
542
  return { ...message, content };
525
543
  }
544
+
545
+ /**
546
+ * Display form with the extension text renderers applied, in registration order: each gets the
547
+ * previous one's output. A renderer that throws or returns a non-string leaves its input drawn;
548
+ * a throw is logged once per renderer. A block whose text and `streaming` flag are unchanged
549
+ * since its last render reuses that output: a block sealed at a tool call keeps receiving
550
+ * updates while the call's arguments stream. {@link rerenderMessage} and
551
+ * {@link setTextRenderers} drop the reused output.
552
+ */
553
+ #renderText(message: AssistantMessage, streaming: boolean): AssistantMessage {
554
+ const rendering = this.#textRendering;
555
+ if (!rendering) return message;
556
+ // Renderers are display-only: hand them a deep copy so no edit, however nested, reaches the stored message.
557
+ let view: AssistantMessage | undefined;
558
+ let content: AssistantMessage["content"] | undefined;
559
+ // Blocks stream in order: only the last one can still grow.
560
+ const tail = message.content.length - 1;
561
+ for (let index = 0; index < message.content.length; index++) {
562
+ const block = message.content[index]!;
563
+ if (block.type !== "text" || block.text.length === 0) continue;
564
+ const blockStreaming = streaming && index === tail;
565
+ const cached = this.#renderedText.get(index);
566
+ let text: string;
567
+ if (cached?.input === block.text && cached.streaming === blockStreaming) {
568
+ text = cached.output;
569
+ } else {
570
+ view ??= structuredClone(message);
571
+ text = block.text;
572
+ for (const renderer of rendering.renderers) {
573
+ try {
574
+ const rendered = renderer({
575
+ message: view,
576
+ contentIndex: rendering.contentOffset + index,
577
+ text,
578
+ streaming: blockStreaming,
579
+ });
580
+ if (typeof rendered === "string") text = rendered;
581
+ } catch (error) {
582
+ if (failedTextRenderers.has(renderer)) continue;
583
+ failedTextRenderers.add(renderer);
584
+ logger.warn("Assistant text renderer failed; drawing its input", { error: String(error) });
585
+ }
586
+ }
587
+ this.#renderedText.set(index, { input: block.text, streaming: blockStreaming, output: text });
588
+ }
589
+ if (text === block.text) continue;
590
+ content ??= message.content.slice();
591
+ content[index] = { ...block, text };
592
+ }
593
+ return content ? { ...message, content } : message;
594
+ }
526
595
  #hideThinkingBlock: boolean;
527
596
  readonly #onImageUpdate?: () => void;
528
597
  readonly #thinkingRenderers: readonly AssistantThinkingRenderer[];
598
+ #textRendering: AssistantTextRendering | undefined;
599
+ /** Index in the full reply's `content` of this component's first block, kept across renderer swaps. */
600
+ readonly #textContentOffset: number;
601
+ /** Last renderer output per content index, reused while the block's input and `streaming` flag hold; see {@link #renderText}. */
602
+ readonly #renderedText = new Map<number, { input: string; streaming: boolean; output: string }>();
529
603
  readonly #imageBudget?: ImageBudget;
530
604
  #proseOnlyThinking: boolean;
531
605
  #expandThinkingBlocks: boolean;
@@ -539,11 +613,14 @@ export class AssistantMessageComponent extends Container {
539
613
  proseOnlyThinking = true,
540
614
  linkTargets?: ReadonlyMap<string, string>,
541
615
  expandThinkingBlocks = false,
616
+ textRendering?: AssistantTextRendering,
542
617
  ) {
543
618
  super();
544
619
  this.#hideThinkingBlock = hideThinkingBlock;
545
620
  this.#onImageUpdate = onImageUpdate;
546
621
  this.#thinkingRenderers = thinkingRenderers;
622
+ this.#textRendering = textRendering?.renderers.length ? textRendering : undefined;
623
+ this.#textContentOffset = textRendering?.contentOffset ?? 0;
547
624
  this.#imageBudget = imageBudget;
548
625
  this.#proseOnlyThinking = proseOnlyThinking;
549
626
  this.#expandThinkingBlocks = expandThinkingBlocks;
@@ -792,8 +869,9 @@ export class AssistantMessageComponent extends Container {
792
869
  return this.#transcriptBlockFinalized;
793
870
  }
794
871
 
795
- /** Whether a figure still waits for the raster of its final source; the transcript holds retirement meanwhile. */
872
+ /** Hold image and figure rendering until the completed block can enter immutable scrollback. */
796
873
  isTranscriptBlockPending(): boolean {
874
+ if (this.#showImages && this.#kittyConversionsAwaited.size > 0) return true;
797
875
  for (const block of this.#figureBlocks.values()) if (block.pending) return true;
798
876
  return false;
799
877
  }
@@ -815,7 +893,7 @@ export class AssistantMessageComponent extends Container {
815
893
  */
816
894
  override describe(cx?: DescribeContext): NativeNode {
817
895
  const media = cx?.supports("media") === true;
818
- const tail = this.#displayedMessage ? this.#thinkingTailIndex(this.#displayedMessage) : undefined;
896
+ const tail = this.#answerMessage ? this.#thinkingTailIndex(this.#answerMessage) : undefined;
819
897
  const rate =
820
898
  tail !== undefined && this.#lastUpdateTransient && this.#thinkingRateLive
821
899
  ? Math.round(Math.min(SPEED_MAX, sharedSpeedTracker.getSpeed()) * 10) / 10
@@ -886,13 +964,15 @@ export class AssistantMessageComponent extends Container {
886
964
  let answered = false;
887
965
  if (message) {
888
966
  const live = !this.#transcriptBlockFinalized && this.#lastUpdateTransient;
967
+ // Which block streams, and whether there is an answer to copy, follow the reply as written:
968
+ // text renderers change only how it is drawn (one may hide all of it).
969
+ const answer = this.#answerMessage ?? message;
889
970
  let tailIndex = -1;
890
- for (let index = 0; index < message.content.length; index++) {
891
- const content = message.content[index]!;
892
- if (
893
- (content.type === "text" && canonicalizeMessage(content.text)) ||
894
- (content.type === "thinking" && canonicalizeMessage(content.thinking))
895
- ) {
971
+ for (let index = 0; index < answer.content.length; index++) {
972
+ const content = answer.content[index]!;
973
+ const answerText = content.type === "text" && canonicalizeMessage(content.text) !== "";
974
+ answered ||= answerText;
975
+ if (answerText || (content.type === "thinking" && canonicalizeMessage(content.thinking))) {
896
976
  tailIndex = index;
897
977
  }
898
978
  }
@@ -900,7 +980,6 @@ export class AssistantMessageComponent extends Container {
900
980
  const content = message.content[index]!;
901
981
  const streaming = live && index === tailIndex;
902
982
  if (content.type === "text" && canonicalizeMessage(content.text)) {
903
- answered = true;
904
983
  // A native terminal sizes table columns by every row it gets: send a growing row once
905
984
  // its line ends. Hold before trimming, which would drop the newline ending a finished row.
906
985
  const source = (streaming ? holdPartialTableRow(content.text) : content.text).trim();
@@ -1157,7 +1236,7 @@ export class AssistantMessageComponent extends Container {
1157
1236
  /** The answer as the transcript shows it: its text blocks' markdown, a blank line apart, without thinking or tool calls. */
1158
1237
  #answerText(): string {
1159
1238
  const blocks: string[] = [];
1160
- for (const content of this.#displayedMessage?.content ?? []) {
1239
+ for (const content of this.#answerMessage?.content ?? []) {
1161
1240
  if (content.type === "text" && canonicalizeMessage(content.text)) blocks.push(content.text.trim());
1162
1241
  }
1163
1242
  return blocks.join("\n\n");
@@ -1219,7 +1298,8 @@ export class AssistantMessageComponent extends Container {
1219
1298
  * every guard skips publication and nothing ever retracts it.
1220
1299
  */
1221
1300
  #publishStableSnapshot(rendered: readonly string[], width: number): void {
1222
- if (!this.#midStreamPublication) return;
1301
+ // Extension text renderers may rewrite text they already drew, and published rows never retract.
1302
+ if (!this.#midStreamPublication || this.#textRendering) return;
1223
1303
  const parts = this.#currentStableSnapshot();
1224
1304
  if (!parts) return;
1225
1305
  const last = parts.at(-1);
@@ -1364,12 +1444,12 @@ export class AssistantMessageComponent extends Container {
1364
1444
  const renderer = role === "head" ? head : role === "replay" ? replay : head?.index === index ? head : replay;
1365
1445
  if (renderer?.index === index && renderer.kind === kind) {
1366
1446
  renderer.md.setText(trimmed);
1367
- return renderer.md.render(width);
1447
+ return trimFabricatedCloser(renderer.md.render(width), trimmed);
1368
1448
  }
1369
1449
  const md = this.#createMarkdown(kind, trimmed);
1370
1450
  if (role === "head") this.#stableHeadRenderer = { index, kind, md };
1371
1451
  else if (role === "replay") this.#stableReplayRenderer = { index, kind, md };
1372
- return md.render(width);
1452
+ return trimFabricatedCloser(md.render(width), trimmed);
1373
1453
  }
1374
1454
 
1375
1455
  /** Markdown for a text or thinking block; live children and stable-row renders share it so stable rows prefix the block render. */
@@ -1496,11 +1576,30 @@ export class AssistantMessageComponent extends Container {
1496
1576
  this.#stopThinkingAnimation();
1497
1577
  // If the live pulse was on screen when the block sealed, drop the fast path
1498
1578
  // and rebuild so the placeholder is removed — finalized blocks never animate.
1579
+ // A sealed block's text is also complete and can retire to scrollback before the
1580
+ // reply's final update reaches it: give the text renderers their final call now
1581
+ // (sealed renders pass `streaming: false`).
1582
+ const sealRenderers = this.#textRendering !== undefined && this.#lastUpdateTransient;
1499
1583
  if (this.#thinkingDots) {
1500
1584
  this.#fastPathKey = undefined;
1501
1585
  this.#fastPathItems = undefined;
1502
- if (this.#lastMessage) this.updateContent(this.#lastMessage, { transient: this.#lastUpdateTransient });
1503
1586
  }
1587
+ if ((this.#thinkingDots || sealRenderers) && this.#lastMessage) {
1588
+ this.updateContent(this.#lastMessage, { transient: this.#lastUpdateTransient });
1589
+ }
1590
+ }
1591
+
1592
+ /**
1593
+ * Swap the extension text renderers (the setting enabling them changed) and redraw with them.
1594
+ * Enabling them also drops rows already published as stable, since a renderer may rewrite them;
1595
+ * callers MUST pair this with a scrollback-clearing display reset, as for
1596
+ * {@link resetTranscriptStableRows}.
1597
+ */
1598
+ setTextRenderers(renderers: readonly AssistantTextRenderer[]): void {
1599
+ this.#textRendering = renderers.length ? { renderers, contentOffset: this.#textContentOffset } : undefined;
1600
+ this.#renderedText.clear();
1601
+ if (this.#textRendering) this.resetTranscriptStableRows();
1602
+ if (this.#lastMessage) this.updateContent(this.#lastMessage, { transient: this.#lastUpdateTransient });
1504
1603
  }
1505
1604
 
1506
1605
  applyRetryRecovery(retryRecovery: AssistantMessage["retryRecovery"]): void {
@@ -1509,6 +1608,18 @@ export class AssistantMessageComponent extends Container {
1509
1608
  this.updateContent({ ...this.#lastMessage, retryRecovery });
1510
1609
  }
1511
1610
 
1611
+ /**
1612
+ * Draw the current message again when it is the reply sent at `timestamp`, re-running the
1613
+ * extension text renderers; returns whether it was. The caller schedules the frame.
1614
+ */
1615
+ rerenderMessage(timestamp: number): boolean {
1616
+ if (this.#lastMessage?.timestamp !== timestamp) return false;
1617
+ // The renderers' state may have changed: run them again rather than reuse their last output.
1618
+ this.#renderedText.clear();
1619
+ this.updateContent(this.#lastMessage, { transient: this.#lastUpdateTransient });
1620
+ return true;
1621
+ }
1622
+
1512
1623
  messagePersistenceKey(): string | undefined {
1513
1624
  if (!this.#lastMessage) return undefined;
1514
1625
  return [
@@ -1620,6 +1731,7 @@ export class AssistantMessageComponent extends Container {
1620
1731
  })
1621
1732
  .catch(() => {
1622
1733
  this.#kittyConversionsAwaited.delete(key);
1734
+ this.#onImageUpdate?.();
1623
1735
  });
1624
1736
  }
1625
1737
  }
@@ -1811,6 +1923,12 @@ export class AssistantMessageComponent extends Container {
1811
1923
  // verbatim message so re-renders re-derive the reaction deterministically.
1812
1924
  // Narration the provider returned as thinking renders as answer text.
1813
1925
  message = this.#displayMessage(presentNarrationAsAnswer(message), this.#lastUpdateTransient);
1926
+ this.#answerMessage = message;
1927
+ // A sealed block (closed at a tool call) keeps receiving transient updates; its text is final.
1928
+ // Thinking state below reads `answer`: renderers transform display only, so one that hides the
1929
+ // streaming text must not make the closed thought before it look live again.
1930
+ const answer = message;
1931
+ message = this.#renderText(message, this.#lastUpdateTransient && !this.#transcriptBlockFinalized);
1814
1932
  this.#displayedMessage = message;
1815
1933
 
1816
1934
  // Streaming-speed gauge: only a live, in-flight render of the single
@@ -1828,7 +1946,7 @@ export class AssistantMessageComponent extends Container {
1828
1946
  // Native terminals show the live rate on visible thinking too, not only the hidden pulse.
1829
1947
  const isThinkingNow =
1830
1948
  this.#lastUpdateTransient &&
1831
- (isNativeRendering() ? this.#thinkingTailIndex(message) !== undefined : this.#shouldAnimateThinking(message));
1949
+ (isNativeRendering() ? this.#thinkingTailIndex(answer) !== undefined : this.#shouldAnimateThinking(answer));
1832
1950
  if (isThinkingNow) {
1833
1951
  const currentTokens = message.usage.reasoningTokens ?? message.usage.output;
1834
1952
  this.#thinkingTokens = currentTokens;
@@ -1931,7 +2049,7 @@ export class AssistantMessageComponent extends Container {
1931
2049
  if (this.#figureBlocks.get(index) !== block) block.dispose();
1932
2050
  }
1933
2051
 
1934
- if (this.#shouldAnimateThinking(message)) {
2052
+ if (this.#shouldAnimateThinking(answer)) {
1935
2053
  if (hasVisibleContent) this.#contentContainer.addChild(new Spacer(1));
1936
2054
  this.#thinkingDots = new Text(this.#thinkingDotsLabel(), 1, 0);
1937
2055
  this.#contentContainer.addChild(this.#thinkingDots);
@@ -3,6 +3,7 @@ import { replaceTabs } from "../render/render-utils";
3
3
  import { theme } from "../theme";
4
4
  import type { TranscriptBlock } from "../chrome/transcript-container";
5
5
  import { TranscriptStatusBlock } from "../chrome/transcript-status";
6
+ import { span } from "../native/describe";
6
7
 
7
8
  const TAN_WORK_PREVIEW_LENGTH = 56;
8
9
 
@@ -22,6 +23,8 @@ export function createBackgroundTanDispatchBlock(message: CustomMessage<unknown>
22
23
  const details = (message as CustomMessage<Partial<BackgroundTanDispatchDetails>>).details;
23
24
  const jobId = details?.jobId ?? "unknown";
24
25
  const work = details?.work ? previewWork(details.work) : undefined;
26
+ const spans = [span("Tangent dispatched"), span(" · ", "dim"), span(`task ${jobId}`, "dim")];
27
+ if (work) spans.push(span(" · ", "dim"), span(work, "dim"));
25
28
  return new TranscriptStatusBlock([
26
29
  {
27
30
  parts: [
@@ -30,6 +33,7 @@ export function createBackgroundTanDispatchBlock(message: CustomMessage<unknown>
30
33
  { text: jobId, color: "accent" },
31
34
  work ? { text: `${theme.format.dash} ${work}`, color: "dim" } : undefined,
32
35
  ],
36
+ native: { tone: "info", icon: "output", message: spans },
33
37
  },
34
38
  ]);
35
39
  }
@@ -37,6 +37,8 @@ export declare class BashExecutionComponent extends Container {
37
37
  appendOutput(chunk: string): void;
38
38
  /** Switch to PTY rendering and feed raw terminal bytes through the vterm replay. */
39
39
  appendPtyChunk(chunk: string): void;
40
+ /** Bytes a terminal would send for a key event, honoring the command's cursor-key mode; "" for key releases. */
41
+ encodePtyInput(data: string): string;
40
42
  setComplete(exitCode: number | undefined, cancelled: boolean, options?: {
41
43
  output?: string;
42
44
  truncation?: TruncationMeta;
@@ -16,6 +16,7 @@ import type { 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";
19
+ import { normalizeInputForPty } from "../tools/bash-interactive";
19
20
  import { getSixelLineMask, isSixelPassthroughEnabled, sanitizeWithOptionalSixelPassthrough } from "../render/sixel";
20
21
  import {
21
22
  buildExecutionFrame,
@@ -253,7 +254,13 @@ export class BashExecutionComponent extends Container {
253
254
  /** Switch to PTY rendering and feed raw terminal bytes through the vterm replay. */
254
255
  appendPtyChunk(chunk: string): void {
255
256
  if (this.#status !== "running" && !this.#ptyWriting && this.#ptyQueue.length === 0) return;
256
- this.#ptyMode = true;
257
+ if (!this.#ptyMode) {
258
+ this.#ptyMode = true;
259
+ // The pane's `styleLine` reads `#ptyMode`, so its styled rows change
260
+ // the moment this flips — with the rows themselves unchanged. The pane
261
+ // memoizes its styled output, so it has to be told.
262
+ this.#outputPane.invalidate();
263
+ }
257
264
  this.#ptyReplayFinalized = false;
258
265
  this.#ptyQueue.push(chunk);
259
266
  if (this.#ptyQueue.length > MAX_PTY_QUEUE_CHUNKS) {
@@ -280,6 +287,11 @@ export class BashExecutionComponent extends Container {
280
287
  this.#drainPtyQueue();
281
288
  }
282
289
 
290
+ /** Bytes a terminal would send for a key event, honoring the command's cursor-key mode; "" for key releases. */
291
+ encodePtyInput(data: string): string {
292
+ return normalizeInputForPty(data, this.#ptyTerminal?.modes.applicationCursorKeysMode ?? false);
293
+ }
294
+
283
295
  #drainPtyQueue(): void {
284
296
  const terminal = this.#ptyTerminal;
285
297
  if (!terminal || this.#ptyWriting) return;
@@ -65,8 +65,9 @@ import {
65
65
  routeLateDiagnostics,
66
66
  } from "./late-diagnostics-message";
67
67
  import { groupedReadUsageCallIds, ReadToolGroupComponent, readArgsCollapseIntoGroup } from "./read-tool-group";
68
+ import { isReplyWrite, ReplyWriteComponent, replyDisplayMessage, toolResultReplies } from "./reply-write";
68
69
  import { SkillMessageComponent } from "./skill-message";
69
- import { ToolExecutionComponent } from "./tool-execution";
70
+ import { ToolExecutionComponent, type ToolExecutionHandle } from "./tool-execution";
70
71
  import { TranscriptContainer } from "../chrome/transcript-container";
71
72
  import { createUsageRowBlock, TurnUsageTally, turnElapsedMs } from "../overlays/usage-row";
72
73
  import { CollapsedSyntheticMessageComponent, UserMessageComponent } from "./user-message";
@@ -90,7 +91,7 @@ export interface ChatTranscriptBuilderDeps {
90
91
 
91
92
  export class ChatTranscriptBuilder {
92
93
  readonly container = new TranscriptContainer();
93
- #pendingTools = new Map<string, ToolExecutionComponent | ReadToolGroupComponent>();
94
+ #pendingTools = new Map<string, ToolExecutionHandle>();
94
95
  #readArgs = new Map<string, Record<string, unknown>>();
95
96
  #readGroup: ReadToolGroupComponent | null = null;
96
97
  #pendingUsage: Usage | undefined;
@@ -203,6 +204,15 @@ export class ChatTranscriptBuilder {
203
204
  this.#expandables.push(component);
204
205
  }
205
206
 
207
+ /** Append assistant prose (a reply, a post-tool segment, or an `out://` reply write) with the transcript's display preferences. */
208
+ #mountProse(component: AssistantMessageComponent): void {
209
+ component.setImagesVisible(displayPreferences.showImages);
210
+ component.setToolResultImagesVisible(!displayPreferences.hideToolActivity);
211
+ component.setTableChartsVisible(this.#deps.tableCharts !== false);
212
+ this.#trackExpandable(component);
213
+ this.container.addChild(component);
214
+ }
215
+
206
216
  /** A `wait` showing all-running is displaced by the next `wait` call. */
207
217
  #resolveWaitingPoll(nextToolName?: string): void {
208
218
  const previous = this.#waitingPoll;
@@ -417,12 +427,8 @@ export class ChatTranscriptBuilder {
417
427
  this.#deps.linkTargets,
418
428
  expandThinkingBlocks,
419
429
  );
420
- assistantComponent.setImagesVisible(displayPreferences.showImages);
421
- assistantComponent.setToolResultImagesVisible(!displayPreferences.hideToolActivity);
422
- assistantComponent.setTableChartsVisible(this.#deps.tableCharts !== false);
423
- this.#trackExpandable(assistantComponent);
424
430
  assistantComponent.pickReactionTarget(this.container.children);
425
- this.container.addChild(assistantComponent);
431
+ this.#mountProse(assistantComponent);
426
432
  let lastAssistantComponent = assistantComponent;
427
433
 
428
434
  if (displayPreferences.cacheMissMarker) {
@@ -456,11 +462,7 @@ export class ChatTranscriptBuilder {
456
462
  this.#deps.linkTargets,
457
463
  expandThinkingBlocks,
458
464
  );
459
- component.setImagesVisible(displayPreferences.showImages);
460
- component.setToolResultImagesVisible(!displayPreferences.hideToolActivity);
461
- component.setTableChartsVisible(this.#deps.tableCharts !== false);
462
- this.#trackExpandable(component);
463
- this.container.addChild(component);
465
+ this.#mountProse(component);
464
466
  lastAssistantComponent = component;
465
467
  };
466
468
 
@@ -492,22 +494,37 @@ export class ChatTranscriptBuilder {
492
494
 
493
495
  this.#readGroup?.seal();
494
496
  this.#readGroup = null;
495
- const component = new ToolExecutionComponent(
496
- content.name,
497
- content.arguments,
498
- {
499
- useBuiltInRenderer: this.#deps.isBuiltInTool?.(content.name) ?? true,
500
- // Stable ids and Kitty placeholder cells keep images anchored
501
- // while the transcript viewport scrolls and reflows.
502
- showImages: displayPreferences.showImages,
503
- },
504
- this.#deps.getTool?.(content.name),
505
- this.#deps.ui,
506
- this.#deps.cwd,
507
- content.id,
508
- );
509
- this.#trackExpandable(component);
510
- this.container.addChild(component);
497
+ const builtIn = this.#deps.isBuiltInTool?.(content.name) ?? true;
498
+ let component: ToolExecutionHandle;
499
+ if (builtIn && isReplyWrite(content.name, content.arguments) === true) {
500
+ const reply = new ReplyWriteComponent({
501
+ requestRender: () => this.#deps.requestRender(),
502
+ imageBudget: this.#deps.ui.imageBudget,
503
+ linkTargets: this.#deps.linkTargets,
504
+ });
505
+ reply.updateArgs(content.arguments);
506
+ reply.setArgsComplete();
507
+ this.#mountProse(reply);
508
+ component = reply;
509
+ } else {
510
+ const card = new ToolExecutionComponent(
511
+ content.name,
512
+ content.arguments,
513
+ {
514
+ useBuiltInRenderer: builtIn,
515
+ // Stable ids and Kitty placeholder cells keep images anchored
516
+ // while the transcript viewport scrolls and reflows.
517
+ showImages: displayPreferences.showImages,
518
+ },
519
+ this.#deps.getTool?.(content.name),
520
+ this.#deps.ui,
521
+ this.#deps.cwd,
522
+ content.id,
523
+ );
524
+ this.#trackExpandable(card);
525
+ this.container.addChild(card);
526
+ component = card;
527
+ }
511
528
 
512
529
  if (hasErrorStop && errorMessage) {
513
530
  component.updateResult(
@@ -549,6 +566,19 @@ export class ChatTranscriptBuilder {
549
566
  this.#readArgs.delete(message.toolCallId);
550
567
  return;
551
568
  }
569
+ for (const reply of toolResultReplies(message.details)) {
570
+ this.#mountProse(
571
+ new AssistantMessageComponent(
572
+ replyDisplayMessage(reply),
573
+ false,
574
+ () => this.#deps.requestRender(),
575
+ [],
576
+ this.#deps.ui.imageBudget,
577
+ true,
578
+ this.#deps.linkTargets,
579
+ ),
580
+ );
581
+ }
552
582
  if (!pending) return;
553
583
  pending.updateResult(message, false, message.toolCallId);
554
584
  this.#pendingTools.delete(message.toolCallId);
@@ -10,6 +10,7 @@ import type { TspSpan } from "@linxiraos/pi-wire";
10
10
  import { md, node, span, text } from "../native/describe";
11
11
  import { type NativeChild, type NativeNode, type NativeUiEvent, rootToggleExpanded } from "../native/node";
12
12
  import { Memo } from "../native/memo";
13
+ import { noticeRow } from "../chrome/transcript-notice";
13
14
 
14
15
  /** Divider labels per compaction method; unknown/legacy methods fall back to "compacted". */
15
16
  const COMPACTION_METHOD_LABELS: Record<string, string> = {
@@ -237,7 +238,7 @@ function compactionNativeDetail(message: CompactionSummaryMessage): NativeChild[
237
238
  ? `Summary · ${frames} snapcompact frame${frames === 1 ? "" : "s"} attached`
238
239
  : "Summary of the earlier conversation";
239
240
  const detail: NativeChild[] = [text([span(caption, "dim")], { role: "zeta.compaction.caption", key: "caption" })];
240
- if (message.warning) detail.push(text([span(message.warning, "warning")], { wrap: "word", key: "warning" }));
241
+ if (message.warning) detail.push(noticeRow("warning", message.warning, { key: "warning" }));
241
242
  detail.push(md(message.summary, { key: "summary" }));
242
243
  return detail;
243
244
  }
@@ -6,6 +6,8 @@ export interface ChatTranscriptDisplayPreferences {
6
6
  cacheMissMarker: boolean;
7
7
  showTokenUsage: boolean;
8
8
  showTurnTime: boolean;
9
+ /** Max rows a collapsed advisor card shows below its header; 0 = no cap. */
10
+ advisorCollapsedLines: number;
9
11
  }
10
12
  /** Current transcript display preferences. */
11
13
  export declare const chatTranscriptDisplayPreferences: ChatTranscriptDisplayPreferences;
@@ -6,6 +6,8 @@ export interface ChatTranscriptDisplayPreferences {
6
6
  cacheMissMarker: boolean;
7
7
  showTokenUsage: boolean;
8
8
  showTurnTime: boolean;
9
+ /** Max rows a collapsed advisor card shows below its header; 0 = no cap. */
10
+ advisorCollapsedLines: number;
9
11
  }
10
12
 
11
13
  /** Current transcript display preferences. */
@@ -16,6 +18,7 @@ export const chatTranscriptDisplayPreferences: ChatTranscriptDisplayPreferences
16
18
  cacheMissMarker: false,
17
19
  showTokenUsage: false,
18
20
  showTurnTime: false,
21
+ advisorCollapsedLines: 0,
19
22
  };
20
23
 
21
24
  /** Apply host display preferences without pulling settings into the renderer. */
@@ -1,3 +1,4 @@
1
+ import type { AssistantMessage } from "@linxiraos/pi-ai";
1
2
  import type { Component, TUI } from "../tui";
2
3
  import type { Theme } from "../theme/theme";
3
4
  import type { CustomMessage, HookMessage } from "./messages";
@@ -17,6 +18,36 @@ export interface AssistantThinkingRenderContext {
17
18
  requestRender(): void;
18
19
  }
19
20
  export type AssistantThinkingRenderer = (context: AssistantThinkingRenderContext, theme: Theme) => Component | undefined;
21
+ export interface AssistantTextRenderContext {
22
+ /**
23
+ * The message being drawn; `message.timestamp` identifies the reply for `ctx.ui.rerenderMessage()`.
24
+ * After a tool call this is only the segment drawn there, so its `content` does not hold the whole reply.
25
+ * A deep copy: editing it, at any depth, cannot change the stored reply.
26
+ */
27
+ message: AssistantMessage;
28
+ /**
29
+ * The text block's index in the full reply's `content`, also when the reply is drawn in segments
30
+ * around tool calls; not an index into `message.content` for a segment. It counts the content as
31
+ * currently stored: a transcript rebuild that drops tool calls left without a result shifts later
32
+ * blocks down, so do not persist it as a permanent key.
33
+ */
34
+ contentIndex: number;
35
+ /** The block's markdown as drawn so far, after any earlier renderer. */
36
+ text: string;
37
+ /** True while the block may still grow; false for its final render, a block sealed at a tool call, and later redraws. */
38
+ streaming: boolean;
39
+ }
40
+ /**
41
+ * Display-only transform of one assistant text block: returns the markdown to draw, or `undefined`
42
+ * to draw `context.text` unchanged. The session, exports and model context keep the original text.
43
+ */
44
+ export type AssistantTextRenderer = (context: AssistantTextRenderContext) => string | undefined;
45
+ /** Extension text renderers for one assistant component, and where its content starts in the full reply. */
46
+ export interface AssistantTextRendering {
47
+ renderers: readonly AssistantTextRenderer[];
48
+ /** Index in the full reply's `content` of this component's first block; a segment after a tool call starts past it. */
49
+ contentOffset: number;
50
+ }
20
51
  export interface HookMessageRenderOptions {
21
52
  /** Whether the view is expanded */
22
53
  expanded: boolean;
@@ -1,3 +1,4 @@
1
+ import type { AssistantMessage } from "@linxiraos/pi-ai";
1
2
  import type { Component, TUI } from "../tui";
2
3
  import type { Theme } from "../theme/theme";
3
4
  import type { CustomMessage, HookMessage } from "./messages";
@@ -30,6 +31,39 @@ export type AssistantThinkingRenderer = (
30
31
  theme: Theme,
31
32
  ) => Component | undefined;
32
33
 
34
+ export interface AssistantTextRenderContext {
35
+ /**
36
+ * The message being drawn; `message.timestamp` identifies the reply for `ctx.ui.rerenderMessage()`.
37
+ * After a tool call this is only the segment drawn there, so its `content` does not hold the whole reply.
38
+ * A deep copy: editing it, at any depth, cannot change the stored reply.
39
+ */
40
+ message: AssistantMessage;
41
+ /**
42
+ * The text block's index in the full reply's `content`, also when the reply is drawn in segments
43
+ * around tool calls; not an index into `message.content` for a segment. It counts the content as
44
+ * currently stored: a transcript rebuild that drops tool calls left without a result shifts later
45
+ * blocks down, so do not persist it as a permanent key.
46
+ */
47
+ contentIndex: number;
48
+ /** The block's markdown as drawn so far, after any earlier renderer. */
49
+ text: string;
50
+ /** True while the block may still grow; false for its final render, a block sealed at a tool call, and later redraws. */
51
+ streaming: boolean;
52
+ }
53
+
54
+ /**
55
+ * Display-only transform of one assistant text block: returns the markdown to draw, or `undefined`
56
+ * to draw `context.text` unchanged. The session, exports and model context keep the original text.
57
+ */
58
+ export type AssistantTextRenderer = (context: AssistantTextRenderContext) => string | undefined;
59
+
60
+ /** Extension text renderers for one assistant component, and where its content starts in the full reply. */
61
+ export interface AssistantTextRendering {
62
+ renderers: readonly AssistantTextRenderer[];
63
+ /** Index in the full reply's `content` of this component's first block; a segment after a tool call starts past it. */
64
+ contentOffset: number;
65
+ }
66
+
33
67
  export interface HookMessageRenderOptions {
34
68
  /** Whether the view is expanded */
35
69
  expanded: boolean;