zidane-ui 9.2.2 → 9.3.1

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 (320) hide show
  1. package/dist/adapters/browser-keybindings-host.js +3 -1
  2. package/dist/adapters/live.d.ts +6 -0
  3. package/dist/adapters/live.js +16 -8
  4. package/dist/adapters/server-composer-host.js +22 -9
  5. package/dist/adapters/server-host.js +143 -18
  6. package/dist/adapters/server-media.d.ts +9 -1
  7. package/dist/adapters/server-media.js +14 -1
  8. package/dist/adapters/server-settings-host.js +30 -3
  9. package/dist/adapters/server-settings-sections.js +23 -1
  10. package/dist/adapters/server-sidebar-host.d.ts +3 -1
  11. package/dist/adapters/server-sidebar-host.js +10 -1
  12. package/dist/app/ModalProvider.js +1 -1
  13. package/dist/approvals/ApprovalShell.js +1 -1
  14. package/dist/chat/DaemonOrb.d.ts +29 -1
  15. package/dist/chat/DaemonOrb.js +25 -12
  16. package/dist/chat/HostTranscript.d.ts +0 -12
  17. package/dist/chat/HostTranscript.js +6 -1
  18. package/dist/chat/SessionStreamsProvider.d.ts +8 -0
  19. package/dist/chat/SessionStreamsProvider.js +11 -2
  20. package/dist/chat/StatusDot.js +8 -2
  21. package/dist/chat/Transcript.d.ts +20 -11
  22. package/dist/chat/Transcript.js +335 -162
  23. package/dist/chat/composer/ComposerEditor.js +1 -1
  24. package/dist/chat/headless/host.d.ts +43 -7
  25. package/dist/chat/headless/index.d.ts +8 -6
  26. package/dist/chat/headless/index.js +11 -9
  27. package/dist/chat/headless/labels.d.ts +30 -0
  28. package/dist/chat/headless/labels.js +29 -0
  29. package/dist/chat/headless/markdown-chunks.d.ts +2 -1
  30. package/dist/chat/headless/markdown-chunks.js +12 -20
  31. package/dist/chat/headless/markdown-scan.d.ts +66 -0
  32. package/dist/chat/headless/markdown-scan.js +124 -0
  33. package/dist/chat/headless/markdown-stream.d.ts +64 -0
  34. package/dist/chat/headless/markdown-stream.js +143 -0
  35. package/dist/chat/headless/output-pager.d.ts +68 -0
  36. package/dist/chat/headless/output-pager.js +113 -0
  37. package/dist/chat/headless/session-list.d.ts +20 -0
  38. package/dist/chat/headless/sidebar/activity.d.ts +14 -0
  39. package/dist/chat/headless/sidebar/activity.js +32 -0
  40. package/dist/chat/headless/sidebar/directory.d.ts +17 -2
  41. package/dist/chat/headless/sidebar/directory.js +50 -54
  42. package/dist/chat/headless/sidebar/environment.d.ts +5 -2
  43. package/dist/chat/headless/sidebar/environment.js +11 -2
  44. package/dist/chat/headless/sidebar/host.d.ts +15 -0
  45. package/dist/chat/headless/sidebar/inbox.d.ts +12 -3
  46. package/dist/chat/headless/sidebar/inbox.js +18 -9
  47. package/dist/chat/headless/sidebar/index.d.ts +2 -2
  48. package/dist/chat/headless/sidebar/index.js +2 -2
  49. package/dist/chat/headless/sidebar/labels.d.ts +38 -2
  50. package/dist/chat/headless/sidebar/labels.js +16 -0
  51. package/dist/chat/headless/sidebar/prewarm.d.ts +68 -0
  52. package/dist/chat/headless/sidebar/prewarm.js +114 -0
  53. package/dist/chat/headless/streams/actions.d.ts +2 -0
  54. package/dist/chat/headless/streams/actions.js +1 -0
  55. package/dist/chat/headless/streams/event-bytes.d.ts +6 -0
  56. package/dist/chat/headless/streams/event-bytes.js +34 -0
  57. package/dist/chat/headless/streams/live-events.d.ts +25 -1
  58. package/dist/chat/headless/streams/live-events.js +53 -2
  59. package/dist/chat/headless/streams/selectors.d.ts +3 -0
  60. package/dist/chat/headless/streams/selectors.js +8 -1
  61. package/dist/chat/headless/streams/session-streams.d.ts +15 -3
  62. package/dist/chat/headless/streams/session-streams.js +31 -3
  63. package/dist/chat/headless/streams/store.d.ts +24 -1
  64. package/dist/chat/headless/streams/store.js +51 -26
  65. package/dist/chat/headless/streams/transcript-map.d.ts +57 -0
  66. package/dist/chat/headless/streams/transcript-map.js +88 -0
  67. package/dist/chat/headless/streams/transcript.d.ts +4 -2
  68. package/dist/chat/headless/streams/transcript.js +19 -7
  69. package/dist/chat/headless/transcript/batch.js +5 -1
  70. package/dist/chat/headless/transcript/blob-media.d.ts +15 -0
  71. package/dist/chat/headless/transcript/blob-media.js +23 -0
  72. package/dist/chat/headless/transcript/collapse.d.ts +10 -0
  73. package/dist/chat/headless/transcript/collapse.js +32 -6
  74. package/dist/chat/headless/transcript/derive.d.ts +98 -0
  75. package/dist/chat/headless/transcript/derive.js +89 -0
  76. package/dist/chat/headless/transcript/exchange-media.d.ts +3 -1
  77. package/dist/chat/headless/transcript/exchange-media.js +8 -5
  78. package/dist/chat/headless/transcript/fold-actions.d.ts +8 -3
  79. package/dist/chat/headless/transcript/fold-actions.js +16 -0
  80. package/dist/chat/headless/transcript/fold-attachments.d.ts +2 -0
  81. package/dist/chat/headless/transcript/fold-attachments.js +3 -2
  82. package/dist/chat/headless/transcript/fold.d.ts +4 -2
  83. package/dist/chat/headless/transcript/fold.js +37 -7
  84. package/dist/chat/headless/transcript/incremental.d.ts +53 -0
  85. package/dist/chat/headless/transcript/incremental.js +181 -0
  86. package/dist/chat/headless/transcript/index.d.ts +2 -1
  87. package/dist/chat/headless/transcript/index.js +2 -1
  88. package/dist/chat/headless/transcript/nesting.js +2 -1
  89. package/dist/chat/headless/transcript/rail.d.ts +142 -0
  90. package/dist/chat/headless/transcript/rail.js +290 -0
  91. package/dist/chat/headless/transcript/rows.d.ts +11 -1
  92. package/dist/chat/headless/transcript/run-failures.d.ts +4 -0
  93. package/dist/chat/headless/transcript/run-failures.js +31 -2
  94. package/dist/chat/headless/transcript/seams.d.ts +78 -0
  95. package/dist/chat/headless/transcript/seams.js +116 -0
  96. package/dist/chat/headless/transcript/tool-media.d.ts +6 -7
  97. package/dist/chat/headless/transcript/tool-media.js +27 -9
  98. package/dist/chat/headless/transcript-labels.d.ts +1 -0
  99. package/dist/chat/headless/turn-labels.d.ts +1 -0
  100. package/dist/chat/headless/turn-labels.js +2 -1
  101. package/dist/chat/index.d.ts +10 -8
  102. package/dist/chat/index.js +9 -7
  103. package/dist/chat/interactions/ElicitationCard.js +1 -1
  104. package/dist/chat/interactions/InteractionCard.js +1 -1
  105. package/dist/chat/interactions/PlanCard.js +3 -3
  106. package/dist/chat/interactions/QuestionField.js +4 -4
  107. package/dist/chat/interactions/QuestionForm.js +3 -3
  108. package/dist/chat/interactions/SecretInput.js +1 -1
  109. package/dist/chat/sidebar/ProjectIcon.d.ts +1 -1
  110. package/dist/chat/sidebar/ProjectIcon.js +1 -1
  111. package/dist/chat/sidebar/RowChips.d.ts +3 -2
  112. package/dist/chat/sidebar/RowChips.js +6 -3
  113. package/dist/chat/sidebar/SessionSidebar.js +13 -14
  114. package/dist/chat/sidebar/SidebarFooter.d.ts +8 -5
  115. package/dist/chat/sidebar/SidebarFooter.js +6 -6
  116. package/dist/chat/sidebar/SidebarFrame.d.ts +2 -0
  117. package/dist/chat/sidebar/SidebarFrame.js +5 -2
  118. package/dist/chat/sidebar/SidebarSessionRow.d.ts +3 -1
  119. package/dist/chat/sidebar/SidebarSessionRow.js +3 -1
  120. package/dist/chat/sidebar/SpacesSection.d.ts +20 -1
  121. package/dist/chat/sidebar/SpacesSection.js +34 -13
  122. package/dist/chat/sidebar/index.d.ts +2 -2
  123. package/dist/chat/sidebar/session-menu.d.ts +11 -2
  124. package/dist/chat/sidebar/session-menu.js +50 -5
  125. package/dist/chat/sidebar/sidebar-live.js +1 -1
  126. package/dist/chat/sidebar/useInboxRows.js +43 -2
  127. package/dist/chat/sidebar/useInboxTriage.js +19 -14
  128. package/dist/chat/testing/contract.d.ts +5 -3
  129. package/dist/chat/testing/contract.js +66 -1
  130. package/dist/chat/testing/fixture-sidebar-host.d.ts +7 -1
  131. package/dist/chat/testing/fixture-sidebar-host.js +12 -0
  132. package/dist/chat/testing/sidebar.contract.d.ts +6 -0
  133. package/dist/chat/testing/sidebar.contract.js +24 -0
  134. package/dist/chat/transcript/DiffLines.d.ts +6 -1
  135. package/dist/chat/transcript/DiffLines.js +35 -20
  136. package/dist/chat/transcript/EditDiffBlock.d.ts +5 -1
  137. package/dist/chat/transcript/EditDiffBlock.js +89 -30
  138. package/dist/chat/transcript/InteractionToolBody.js +1 -1
  139. package/dist/chat/transcript/LazyRow.d.ts +40 -40
  140. package/dist/chat/transcript/LazyRow.js +101 -149
  141. package/dist/chat/transcript/MermaidDiagram.js +2 -1
  142. package/dist/chat/transcript/SelectCursor.d.ts +11 -1
  143. package/dist/chat/transcript/SelectCursor.js +10 -5
  144. package/dist/chat/transcript/SubagentBlock.js +3 -2
  145. package/dist/chat/transcript/TranscriptRail.d.ts +109 -0
  146. package/dist/chat/transcript/TranscriptRail.js +579 -0
  147. package/dist/chat/transcript/TranscriptRow.d.ts +4 -7
  148. package/dist/chat/transcript/TranscriptRow.js +9 -5
  149. package/dist/chat/transcript/actions.d.ts +43 -3
  150. package/dist/chat/transcript/actions.js +27 -1
  151. package/dist/chat/transcript/clipped-output.d.ts +58 -0
  152. package/dist/chat/transcript/clipped-output.js +131 -0
  153. package/dist/chat/transcript/fold-attachments.js +10 -5
  154. package/dist/chat/transcript/fold-worker.js +3 -2
  155. package/dist/chat/transcript/fold.js +21 -2
  156. package/dist/chat/transcript/index.d.ts +11 -9
  157. package/dist/chat/transcript/index.js +10 -8
  158. package/dist/chat/transcript/markdown-cache.d.ts +7 -1
  159. package/dist/chat/transcript/markdown-cache.js +12 -1
  160. package/dist/chat/transcript/markdown.js +116 -54
  161. package/dist/chat/transcript/media-gallery.d.ts +3 -2
  162. package/dist/chat/transcript/media-gallery.js +10 -7
  163. package/dist/chat/transcript/notices.d.ts +23 -1
  164. package/dist/chat/transcript/notices.js +110 -28
  165. package/dist/chat/transcript/prompt.js +6 -4
  166. package/dist/chat/transcript/prose.js +3 -1
  167. package/dist/chat/transcript/receipt-parts.d.ts +22 -0
  168. package/dist/chat/transcript/receipt-parts.js +87 -0
  169. package/dist/chat/transcript/root-items.d.ts +96 -0
  170. package/dist/chat/transcript/root-items.js +180 -0
  171. package/dist/chat/transcript/row-mount.d.ts +165 -0
  172. package/dist/chat/transcript/row-mount.js +498 -0
  173. package/dist/chat/transcript/row-parking.d.ts +125 -0
  174. package/dist/chat/transcript/row-parking.js +135 -0
  175. package/dist/chat/transcript/row-ui-state.d.ts +37 -0
  176. package/dist/chat/transcript/row-ui-state.js +53 -0
  177. package/dist/chat/transcript/run-rows.js +6 -78
  178. package/dist/chat/transcript/script-input.d.ts +1 -1
  179. package/dist/chat/transcript/scroll-clamp.js +1 -1
  180. package/dist/chat/transcript/tasks.js +3 -2
  181. package/dist/chat/transcript/tool-media.d.ts +4 -2
  182. package/dist/chat/transcript/tool-media.js +15 -7
  183. package/dist/chat/transcript/tool-parts.d.ts +27 -4
  184. package/dist/chat/transcript/tool-parts.js +31 -5
  185. package/dist/chat/transcript/tool-payload.js +26 -11
  186. package/dist/chat/transcript/tool-row.d.ts +2 -1
  187. package/dist/chat/transcript/tool-row.js +38 -19
  188. package/dist/chat/transcript/use-transcript-rows.d.ts +24 -7
  189. package/dist/chat/transcript/use-transcript-rows.js +28 -46
  190. package/dist/chat/transcript/useSettledReveal.js +15 -3
  191. package/dist/chat/transcript/useStickToBottom.js +4 -4
  192. package/dist/chat/transcript/useTranscriptSearch.js +30 -14
  193. package/dist/chat/transcript/view-scope.d.ts +26 -6
  194. package/dist/chat/transcript/view-scope.js +106 -20
  195. package/dist/components/ChoiceCards.js +1 -1
  196. package/dist/components/ConfirmDialog.js +1 -1
  197. package/dist/components/CopyValue.d.ts +33 -0
  198. package/dist/components/CopyValue.js +54 -0
  199. package/dist/components/Form.js +1 -1
  200. package/dist/components/HowItWorks.js +1 -1
  201. package/dist/components/Menu.js +1 -1
  202. package/dist/components/StepFrame.js +2 -2
  203. package/dist/components/SwatchPicker.js +1 -1
  204. package/dist/components/ToggleCard.js +1 -1
  205. package/dist/components/floating/HoverCard.js +2 -3
  206. package/dist/components/floating/hover-delay.d.ts +4 -0
  207. package/dist/components/floating/hover-delay.js +6 -0
  208. package/dist/core.css +14 -12
  209. package/dist/dist/{index-Betz0OWq.d.ts → index-C6-t1SS9.d.ts} +21 -2
  210. package/dist/dist/index-De9AbmxS.d.ts +1 -0
  211. package/dist/dist/index.d.ts +5 -5
  212. package/dist/dist/sandbox-CSUihARm.d.ts +2 -0
  213. package/dist/dist/{timeout-CyU7HLyz.d.ts → timeout-CmTx6V9y.d.ts} +1 -0
  214. package/dist/extensions/ExtensionDialogHost.js +1 -1
  215. package/dist/files/TreeColumn.js +3 -1
  216. package/dist/files/headless/host.d.ts +2 -2
  217. package/dist/git/ImportRepoDialog.js +1 -1
  218. package/dist/git/MoveSessionDialog.js +2 -2
  219. package/dist/git/SandboxManager.d.ts +42 -0
  220. package/dist/git/SandboxManager.js +297 -0
  221. package/dist/git/SyncChip.js +1 -1
  222. package/dist/git/headless/index.d.ts +2 -1
  223. package/dist/git/headless/index.js +2 -1
  224. package/dist/git/headless/labels.d.ts +29 -0
  225. package/dist/git/headless/labels.js +34 -1
  226. package/dist/git/headless/sandboxes.d.ts +43 -0
  227. package/dist/git/headless/sandboxes.js +52 -0
  228. package/dist/git/index.d.ts +2 -1
  229. package/dist/git/index.js +2 -1
  230. package/dist/index.d.ts +2 -1
  231. package/dist/index.js +2 -1
  232. package/dist/keybindings/headless/catalog.d.ts +1 -1
  233. package/dist/keybindings/headless/catalog.js +12 -0
  234. package/dist/machines/HostsSection.d.ts +1 -1
  235. package/dist/machines/headless/labels.js +2 -2
  236. package/dist/motion/flip-list.js +3 -10
  237. package/dist/motion/presence.d.ts +10 -0
  238. package/dist/motion/presence.js +20 -1
  239. package/dist/motion/swap.d.ts +8 -2
  240. package/dist/motion/swap.js +5 -2
  241. package/dist/onboarding/conversation.js +27 -15
  242. package/dist/onboarding/demos/how-it-works.js +1 -1
  243. package/dist/onboarding/skills/parts.js +4 -4
  244. package/dist/onboarding/sources/SourceBrowser.js +1 -1
  245. package/dist/onboarding/steps/ReadyStep.js +1 -1
  246. package/dist/onboarding/steps/connect/KeyForm.js +1 -1
  247. package/dist/palette/headless/app-sources.js +20 -0
  248. package/dist/palette/headless/labels.js +2 -0
  249. package/dist/session/PlanTracker.js +3 -3
  250. package/dist/session/SecretsPanel.js +1 -1
  251. package/dist/session/SessionHeader.d.ts +18 -6
  252. package/dist/session/SessionHeader.js +68 -12
  253. package/dist/session/SessionPlaceMenu.d.ts +35 -0
  254. package/dist/session/SessionPlaceMenu.js +299 -0
  255. package/dist/session/SessionShell.js +1 -1
  256. package/dist/session/TurnDetailsDialog.js +1 -1
  257. package/dist/session/headless/index.d.ts +2 -1
  258. package/dist/session/headless/index.js +2 -1
  259. package/dist/session/headless/labels.d.ts +73 -0
  260. package/dist/session/headless/labels.js +73 -0
  261. package/dist/session/headless/place.d.ts +49 -0
  262. package/dist/session/headless/place.js +57 -0
  263. package/dist/session/index.d.ts +2 -1
  264. package/dist/session/index.js +2 -1
  265. package/dist/settings/ConversationPresetsCard.js +1 -1
  266. package/dist/settings/SettingCard.js +2 -2
  267. package/dist/settings/SettingsRowsPage.js +1 -1
  268. package/dist/settings/headless/fixture-performance.js +4 -2
  269. package/dist/settings/headless/fixture-sections.js +7 -0
  270. package/dist/settings/headless/labels.d.ts +1 -1
  271. package/dist/settings/headless/labels.js +1 -1
  272. package/dist/settings/headless/layout.d.ts +4 -4
  273. package/dist/settings/headless/layout.js +1 -1
  274. package/dist/settings/headless/performance.d.ts +4 -0
  275. package/dist/settings/headless/search.d.ts +2 -2
  276. package/dist/settings/headless/sections-host.d.ts +20 -2
  277. package/dist/settings/sections/claude-import/ClaudeImportDialog.js +1 -1
  278. package/dist/settings/sections/enabled-list/EnabledListSection.js +2 -2
  279. package/dist/settings/sections/environments/EnvironmentsSection.d.ts +9 -3
  280. package/dist/settings/sections/environments/EnvironmentsSection.js +292 -52
  281. package/dist/settings/sections/environments/labels.d.ts +15 -0
  282. package/dist/settings/sections/environments/labels.js +18 -3
  283. package/dist/settings/sections/extensions/ChangeOriginDialog.js +1 -1
  284. package/dist/settings/sections/extensions/ExtensionSourceBrowser.js +1 -1
  285. package/dist/settings/sections/extensions/ExtensionsSection.d.ts +3 -2
  286. package/dist/settings/sections/extensions/ExtensionsSection.js +9 -3
  287. package/dist/settings/sections/host-catalog/HostCatalogSection.js +15 -5
  288. package/dist/settings/sections/keybindings/labels.d.ts +2 -0
  289. package/dist/settings/sections/keybindings/labels.js +2 -0
  290. package/dist/settings/sections/keybindings/rows.js +8 -0
  291. package/dist/settings/sections/models/SpacesDefaultsSection.d.ts +7 -3
  292. package/dist/settings/sections/models/SpacesDefaultsSection.js +11 -5
  293. package/dist/settings/sections/performance/PerformanceSection.js +8 -1
  294. package/dist/settings/sections/performance/labels.d.ts +2 -0
  295. package/dist/settings/sections/performance/labels.js +2 -0
  296. package/dist/settings/sections/skills/SkillGroups.js +1 -1
  297. package/dist/settings/server-app.d.ts +4 -2
  298. package/dist/settings/server-app.js +7 -3
  299. package/dist/settings/testing/sections.contract.d.ts +7 -1
  300. package/dist/settings/testing/sections.contract.js +37 -0
  301. package/dist/styles.css +243 -19
  302. package/dist/terminal/TerminalDrawer.js +3 -1
  303. package/dist/views/headless/answers.d.ts +8 -2
  304. package/dist/views/headless/answers.js +58 -1
  305. package/dist/views/headless/placement.d.ts +78 -0
  306. package/dist/views/headless/placement.js +154 -44
  307. package/dist/workspace/SidePanel.js +3 -1
  308. package/package.json +2 -2
  309. package/src/styles/base.css +13 -0
  310. package/src/styles/chat.css +30 -0
  311. package/src/styles/components.css +0 -10
  312. package/src/styles/files.css +5 -0
  313. package/src/styles/sidebar.css +29 -7
  314. package/src/styles/terminal.css +6 -0
  315. package/src/styles/tokens.css +5 -0
  316. package/src/styles/transcript.css +138 -0
  317. package/src/styles/workspace.css +6 -0
  318. package/dist/dist/index-QcFzZlao.d.ts +0 -1
  319. package/dist/dist/sandbox-D0zsW8I1.d.ts +0 -2
  320. /package/dist/dist/{types-_Dtoq_No.d.ts → execution-failure-SREfl-EZ.d.ts} +0 -0
@@ -0,0 +1,98 @@
1
+ /**
2
+ * The transcript's row pipeline, events to the rows a transcript paints:
3
+ *
4
+ * filter cache notices and a codemode script's calls, per the settings
5
+ * gatherCommandNotes a `/` command's notes close its exchange as one line
6
+ * collapseEvents events → rows (pairs tool calls, merges text, edits, spawns)
7
+ * nestToolCalls nested calls under their calling row
8
+ * batch* tool runs, thinking chains, task bursts
9
+ * markRunFailures a run that ended early → one row that can continue or retry
10
+ * dockRunReceipts run receipts onto their reply
11
+ * foldExchanges compact density: each exchange's work behind one row
12
+ * clusterByOwner subagent rows → blocks per spawn
13
+ *
14
+ * {@link deriveRowsPart} runs it over one part of a transcript (a run of
15
+ * whole exchanges) so the incremental deriver (`incremental.ts`) can join
16
+ * parts; {@link deriveTranscriptRows} runs it over a whole transcript.
17
+ */
18
+ import { ChatEvent } from "../host.js";
19
+ import { Cluster, Row } from "./rows.js";
20
+ import { RunReceipt } from "zidane/chat/pure";
21
+ /** The display options that shape the rows. */
22
+ export interface TranscriptRowOptions {
23
+ /** Show cache notices (cache expired / break, dropped reasoning). */
24
+ showCacheNotices: boolean;
25
+ /** Show the calls a codemode script makes (those running a subagent always show). */
26
+ codemodeShowCalls: boolean;
27
+ /** Show edit diffs on edit tool rows. */
28
+ showEditDiffs: boolean;
29
+ /** Batch tool rows across the whole exchange, not only adjacent ones. */
30
+ groupToolCalls: boolean;
31
+ /** Dock run receipts under their reply; off hides them. */
32
+ showRunReceipt: boolean;
33
+ /** Compact density: fold each exchange's work behind one row. */
34
+ compact: boolean;
35
+ }
36
+ /** The rows of one part of a transcript. */
37
+ export interface DerivedRowsPart {
38
+ /** The rows after every pass, in paint order. */
39
+ rows: readonly Row[];
40
+ /** Run receipts docked under their reply, by the reply row's id. */
41
+ receipts: ReadonlyMap<string, RunReceipt>;
42
+ /** `rows` grouped into subagent blocks. */
43
+ clusters: readonly Cluster[];
44
+ /** The last row the collapse made up to the end of this part (the seam for the next part). */
45
+ lastCollapsed: Row | undefined;
46
+ /** The reply still streaming in this part, if any. */
47
+ lastStreaming: Row | null;
48
+ }
49
+ /** The rows a transcript paints and what it derives from them. */
50
+ export interface DerivedTranscriptRows {
51
+ /** The rows after every pass, in paint order. */
52
+ visibleRows: readonly Row[];
53
+ /** Run receipts docked under their reply, by the reply row's id. */
54
+ receiptByRowId: ReadonlyMap<string, RunReceipt>;
55
+ /** The failure row that offers to pick the work back up (the transcript's last word, once idle). */
56
+ resumableId: string | null;
57
+ /** `visibleRows` grouped into subagent blocks (`clusterByOwner`). */
58
+ clusters: readonly Cluster[];
59
+ /** The reply still streaming: the only row with a caret. */
60
+ lastStreamingRow: Row | null | undefined;
61
+ }
62
+ /**
63
+ * The events every later pass sees: cache notices and a codemode script's
64
+ * calls filtered per the settings, a `/` command's notes gathered at the end
65
+ * of its exchange.
66
+ *
67
+ * @param events - Transcript events in order.
68
+ * @param options - The display options.
69
+ */
70
+ export declare function shownEvents(events: readonly ChatEvent[], options: Pick<TranscriptRowOptions, 'showCacheNotices' | 'codemodeShowCalls'>): readonly ChatEvent[];
71
+ /**
72
+ * The pipeline over one part of a transcript: whole exchanges, which no pass
73
+ * looks across (the incremental deriver makes sure of it).
74
+ *
75
+ * @param events - The part's events.
76
+ * @param streaming - A run is in flight.
77
+ * @param options - The display options.
78
+ * @param final - The part ends the transcript (its last exchange may be live).
79
+ * @param before - The last collapsed row of the parts above, if any.
80
+ */
81
+ export declare function deriveRowsPart(events: readonly ChatEvent[], streaming: boolean, options: TranscriptRowOptions, final: boolean, before: Row | undefined): DerivedRowsPart;
82
+ /**
83
+ * The failure row that offers to pick the work back up: the transcript's last
84
+ * word (past separators and receipts) once idle.
85
+ *
86
+ * @param parts - The rows, in parts, oldest first.
87
+ * @param streaming - A run is in flight.
88
+ */
89
+ export declare function resumableRowId(parts: ReadonlyArray<readonly Row[]>, streaming: boolean): string | null;
90
+ /**
91
+ * The whole pipeline over a whole transcript, in one go: what the incremental
92
+ * deriver must equal.
93
+ *
94
+ * @param events - Transcript events in order.
95
+ * @param streaming - A run is in flight.
96
+ * @param options - The display options.
97
+ */
98
+ export declare function deriveTranscriptRows(events: readonly ChatEvent[], streaming: boolean, options: TranscriptRowOptions): DerivedTranscriptRows;
@@ -0,0 +1,89 @@
1
+ import { batchTaskRuns, batchThinkingRuns, batchToolRuns, clusterByOwner } from "./batch.js";
2
+ import { collapseEvents, collapseSeamRow } from "./collapse.js";
3
+ import { dockRunReceipts, findLastStreamingRow, foldExchanges } from "./fold.js";
4
+ import { nestToolCalls, nestedCallVisible } from "./nesting.js";
5
+ import { markRunFailures } from "./run-failures.js";
6
+ import { gatherCommandNotes, isCacheNotice, noteTranscriptPass } from "zidane/chat/pure";
7
+ // src/chat/headless/transcript/derive.ts
8
+ /**
9
+ * The events every later pass sees: cache notices and a codemode script's
10
+ * calls filtered per the settings, a `/` command's notes gathered at the end
11
+ * of its exchange.
12
+ *
13
+ * @param events - Transcript events in order.
14
+ * @param options - The display options.
15
+ */
16
+ function shownEvents(events, options) {
17
+ const { showCacheNotices, codemodeShowCalls } = options;
18
+ let shown = events;
19
+ if (!showCacheNotices || !codemodeShowCalls) {
20
+ noteTranscriptPass("filter", events.length);
21
+ shown = events.filter((event) => (showCacheNotices || !isCacheNotice(event.notice)) && nestedCallVisible(event, codemodeShowCalls));
22
+ }
23
+ return gatherCommandNotes(shown);
24
+ }
25
+ /**
26
+ * The pipeline over one part of a transcript: whole exchanges, which no pass
27
+ * looks across (the incremental deriver makes sure of it).
28
+ *
29
+ * @param events - The part's events.
30
+ * @param streaming - A run is in flight.
31
+ * @param options - The display options.
32
+ * @param final - The part ends the transcript (its last exchange may be live).
33
+ * @param before - The last collapsed row of the parts above, if any.
34
+ */
35
+ function deriveRowsPart(events, streaming, options, final, before) {
36
+ const shown = shownEvents(events, options);
37
+ const collapsed = collapseEvents(shown, options.showEditDiffs, streaming);
38
+ const seam = collapseSeamRow(shown, before);
39
+ const nested = nestToolCalls(seam ? [seam, ...collapsed] : collapsed);
40
+ const batched = batchTaskRuns(batchThinkingRuns(batchToolRuns(nested, options.groupToolCalls)));
41
+ const failed = markRunFailures(batched);
42
+ const { visibleRows, receiptByRowId } = dockRunReceipts(failed, options.showRunReceipt);
43
+ const rows = options.compact ? foldExchanges(visibleRows, streaming, final) : visibleRows;
44
+ return {
45
+ rows,
46
+ receipts: receiptByRowId,
47
+ clusters: clusterByOwner(rows),
48
+ lastCollapsed: collapsed.at(-1) ?? seam ?? before,
49
+ lastStreaming: findLastStreamingRow(rows)
50
+ };
51
+ }
52
+ /**
53
+ * The failure row that offers to pick the work back up: the transcript's last
54
+ * word (past separators and receipts) once idle.
55
+ *
56
+ * @param parts - The rows, in parts, oldest first.
57
+ * @param streaming - A run is in flight.
58
+ */
59
+ function resumableRowId(parts, streaming) {
60
+ if (streaming) return null;
61
+ for (let p = parts.length - 1; p >= 0; p--) {
62
+ const rows = parts[p];
63
+ for (let i = rows.length - 1; i >= 0; i--) {
64
+ const row = rows[i];
65
+ if (row.kind === "separator" || row.kind === "run-summary") continue;
66
+ return row.kind === "error" && row.failure ? row.id : null;
67
+ }
68
+ }
69
+ return null;
70
+ }
71
+ /**
72
+ * The whole pipeline over a whole transcript, in one go: what the incremental
73
+ * deriver must equal.
74
+ *
75
+ * @param events - Transcript events in order.
76
+ * @param streaming - A run is in flight.
77
+ * @param options - The display options.
78
+ */
79
+ function deriveTranscriptRows(events, streaming, options) {
80
+ const part = deriveRowsPart(events, streaming, options, true, void 0);
81
+ return {
82
+ visibleRows: part.rows,
83
+ receiptByRowId: part.receipts,
84
+ resumableId: resumableRowId([part.rows], streaming),
85
+ clusters: part.clusters,
86
+ lastStreamingRow: part.lastStreaming
87
+ };
88
+ }
89
+ export { deriveRowsPart, deriveTranscriptRows, resumableRowId, shownEvents };
@@ -38,6 +38,7 @@ export type ExchangeMedium = {
38
38
  name: string;
39
39
  callId: string;
40
40
  index: number;
41
+ hash?: string;
41
42
  };
42
43
  /** Keys a component names its medium by. */
43
44
  export declare const mediumKey: {
@@ -64,5 +65,6 @@ export declare function mediaRefsOf(text: string): MediaRef[];
64
65
  * the first prompt, index n what the n-th top-level prompt started.
65
66
  *
66
67
  * @param events - The transcript's events, oldest first.
68
+ * @param attachmentSrc - Where a prompt's attachment loads from (default: its `dataUrl`); one with none is left out.
67
69
  */
68
- export declare function exchangesMedia(events: readonly ChatEvent[]): ExchangeMedium[][];
70
+ export declare function exchangesMedia(events: readonly ChatEvent[], attachmentSrc?: (att: NonNullable<ChatEvent['attachments']>[number]) => string | undefined): ExchangeMedium[][];
@@ -45,8 +45,9 @@ function isText(mediaType) {
45
45
  * the first prompt, index n what the n-th top-level prompt started.
46
46
  *
47
47
  * @param events - The transcript's events, oldest first.
48
+ * @param attachmentSrc - Where a prompt's attachment loads from (default: its `dataUrl`); one with none is left out.
48
49
  */
49
- function exchangesMedia(events) {
50
+ function exchangesMedia(events, attachmentSrc = (att) => att.dataUrl) {
50
51
  const exchanges = [[]];
51
52
  let current = exchanges[0];
52
53
  const seen = /* @__PURE__ */ new Set();
@@ -75,7 +76,8 @@ function exchangesMedia(events) {
75
76
  exchanges.push(current);
76
77
  seen.clear();
77
78
  (event.attachments ?? []).forEach((att, index) => {
78
- if (!att.dataUrl) return;
79
+ const dataUrl = attachmentSrc(att);
80
+ if (!dataUrl) return;
79
81
  const kind = att.mediaType.startsWith("image/") ? "image" : isPdf(att.mediaType) ? "pdf" : isText(att.mediaType) ? "text" : null;
80
82
  if (kind) add({
81
83
  key: mediumKey.attachment(index),
@@ -84,7 +86,7 @@ function exchangesMedia(events) {
84
86
  name: att.name,
85
87
  mediaType: att.mediaType,
86
88
  size: att.size,
87
- dataUrl: att.dataUrl
89
+ dataUrl
88
90
  });
89
91
  });
90
92
  addRefs(event.text);
@@ -96,13 +98,14 @@ function exchangesMedia(events) {
96
98
  }
97
99
  if (event.kind === "tool-result" && event.callId && event.text.includes("[")) {
98
100
  const callId = event.callId;
99
- for (const item of parseToolMedia(event.text).media) add({
101
+ for (const item of parseToolMedia(event.text, void 0, event.mediaRefs).media) add({
100
102
  key: mediumKey.tool(callId, item.index),
101
103
  from: "tool",
102
104
  kind: item.kind,
103
105
  name: event.tool ?? item.mediaType,
104
106
  callId,
105
- index: item.index
107
+ index: item.index,
108
+ ...item.hash ? { hash: item.hash } : {}
106
109
  });
107
110
  }
108
111
  }
@@ -21,14 +21,17 @@ type ThinkingRow = Extract<Row, {
21
21
  type SetupRow = Extract<Row, {
22
22
  kind: 'environment-setup';
23
23
  }>;
24
+ type CompactRow = Extract<Row, {
25
+ kind: 'compact-summary';
26
+ }>;
24
27
  /** `waiting`: a `spawn` call that has not started yet, every slot being taken. */
25
28
  export type FoldActionState = 'waiting' | 'running' | 'ok' | 'err';
26
- /** One overview line of a folded exchange: a tool call, a run of thoughts, a worker, or a note. */
29
+ /** One overview line of a folded exchange: a tool call, a run of thoughts, a worker, a note, or a compaction. */
27
30
  export interface FoldActionItem {
28
31
  /** Stable per action (its first row's id), so lists animate entries, not text changes. */
29
32
  id: string;
30
- /** What the line stands for: a `tool` call, consecutive `thought` segments, a `worker` (subagent), a `note`, or the environment's `setup`. */
31
- kind: 'tool' | 'thought' | 'worker' | 'note' | 'setup';
33
+ /** What the line stands for: a `tool` call, consecutive `thought` segments, a `worker` (subagent), a `note`, the environment's `setup`, or a `compact`ion the run went through. */
34
+ kind: 'tool' | 'thought' | 'worker' | 'note' | 'setup' | 'compact';
32
35
  /** The overview: "Ran bun test", "Read select-stops.ts", "Thought". */
33
36
  label: string;
34
37
  /** Quiet context after the label: a file's directory, "+2" chained commands. */
@@ -64,6 +67,8 @@ export interface FoldActionItem {
64
67
  children?: FoldActionItem[];
65
68
  /** A `setup` line's attempt: its steps and output are the details. */
66
69
  setup?: SetupRow;
70
+ /** A `compact` line's compaction: its model and tokens ride the line, its summary is the details. */
71
+ compact?: CompactRow;
67
72
  }
68
73
  /**
69
74
  * The overview item for one tool call: the shared words, plus what the details show.
@@ -140,6 +140,12 @@ function foldUnits(rows) {
140
140
  kind: "note"
141
141
  });
142
142
  break;
143
+ case "compact-summary":
144
+ units.push({
145
+ item: row,
146
+ kind: "compact"
147
+ });
148
+ break;
143
149
  case "environment-setup": {
144
150
  const state = setupState(row);
145
151
  const { startedAt, endedAt } = row.setup;
@@ -210,6 +216,16 @@ function actionItem(step) {
210
216
  }
211
217
  case "worker": return workerItem(step);
212
218
  case "setup": return setupAction(step.items[0]);
219
+ case "compact": {
220
+ const row = step.items[0];
221
+ return {
222
+ id: row.id,
223
+ kind: "compact",
224
+ label: `${row.compact.replacedCount} turns compacted`,
225
+ state: "ok",
226
+ compact: row
227
+ };
228
+ }
213
229
  case "tool": return callItem(step.call);
214
230
  }
215
231
  }
@@ -14,6 +14,8 @@ export interface FoldAttachment {
14
14
  index: number;
15
15
  /** The call's overview line ("Screenshot localhost:5173"): the image's name in the lightbox. */
16
16
  label: string;
17
+ /** The blob hash the store holds it by, when it does (`TranscriptActions.blobMediaUrl`). */
18
+ hash?: string;
17
19
  }
18
20
  /**
19
21
  * Whether two lists show the same images under the same names, in the same
@@ -12,11 +12,12 @@ function callImages(tool) {
12
12
  let images = NONE;
13
13
  if (callId && typeof result === "string" && result.includes("[image:")) {
14
14
  const label = toolAction(tool).label;
15
- images = parseToolMedia(result).media.filter((m) => m.kind === "image").map((m) => ({
15
+ images = parseToolMedia(result, void 0, tool.mediaRefs).media.filter((m) => m.kind === "image").map((m) => ({
16
16
  key: `${callId}:${m.index}`,
17
17
  callId,
18
18
  index: m.index,
19
- label
19
+ label,
20
+ ...m.hash ? { hash: m.hash } : {}
20
21
  }));
21
22
  }
22
23
  CACHE.set(tool, images);
@@ -39,7 +39,8 @@ export declare function dockRunReceipts(rows: readonly Row[], show: boolean): {
39
39
  * Compact density: fold every exchange's work behind one `exchange-fold`
40
40
  * row. An exchange is the span between two boundary rows (`user-prompt`,
41
41
  * `separator`, `compact-summary`); rows that {@link foldsInCompact} move
42
- * into the fold, which sits RIGHT UNDER the exchange's prompt, ahead of the
42
+ * into the fold, and so does a compaction the run went on after
43
+ * ({@link compactionInRun}), which sits RIGHT UNDER the exchange's prompt, ahead of the
43
44
  * prose (prose written before the first call still reads after the work
44
45
  * indicator, never between the prompt and it).
45
46
  *
@@ -56,8 +57,9 @@ export declare function dockRunReceipts(rows: readonly Row[], show: boolean): {
56
57
  *
57
58
  * @param rows - The transcript rows after batching and receipt docking, oldest first.
58
59
  * @param isStreaming - A run is in flight, so the last exchange is live.
60
+ * @param final - `rows` end the transcript. False for a part that more rows (opening with a boundary) follow: its last exchange is then settled.
59
61
  */
60
- export declare function foldExchanges(rows: readonly Row[], isStreaming: boolean): Row[];
62
+ export declare function foldExchanges(rows: readonly Row[], isStreaming: boolean, final?: boolean): Row[];
61
63
  /**
62
64
  * A worker's (subagent's) own rows folded like an exchange of the main
63
65
  * transcript: its tool calls, thoughts and the workers it started behind one
@@ -1,7 +1,7 @@
1
1
  import { FOLD_CACHE, IdHold, TOOL_GROUP_BOUNDARIES, sameMembers } from "./batch.js";
2
2
  import { toolFailed } from "./collapse.js";
3
3
  import { foldUnits } from "./fold-actions.js";
4
- import { countTaskOutcomes, foldSummary, foldsInCompactShape, planFold, taskOutcome } from "zidane/chat/pure";
4
+ import { countTaskOutcomes, foldSummary, foldsInCompactShape, noteTranscriptPass, planFold, taskOutcome } from "zidane/chat/pure";
5
5
  // src/chat/headless/transcript/fold.ts
6
6
  /**
7
7
  * Fold `run-summary` rows into the assistant row that closed the run: the
@@ -31,6 +31,7 @@ import { countTaskOutcomes, foldSummary, foldsInCompactShape, planFold, taskOutc
31
31
  * @param show - Whether to show run receipts. When false they are dropped.
32
32
  */
33
33
  function dockRunReceipts(rows, show) {
34
+ noteTranscriptPass("dock-receipts", rows.length);
34
35
  const receiptByRowId = /* @__PURE__ */ new Map();
35
36
  const visibleRows = [];
36
37
  let lastAssistantRowId = null;
@@ -100,7 +101,8 @@ function rowStats(stats) {
100
101
  * Compact density: fold every exchange's work behind one `exchange-fold`
101
102
  * row. An exchange is the span between two boundary rows (`user-prompt`,
102
103
  * `separator`, `compact-summary`); rows that {@link foldsInCompact} move
103
- * into the fold, which sits RIGHT UNDER the exchange's prompt, ahead of the
104
+ * into the fold, and so does a compaction the run went on after
105
+ * ({@link compactionInRun}), which sits RIGHT UNDER the exchange's prompt, ahead of the
104
106
  * prose (prose written before the first call still reads after the work
105
107
  * indicator, never between the prompt and it).
106
108
  *
@@ -117,8 +119,10 @@ function rowStats(stats) {
117
119
  *
118
120
  * @param rows - The transcript rows after batching and receipt docking, oldest first.
119
121
  * @param isStreaming - A run is in flight, so the last exchange is live.
122
+ * @param final - `rows` end the transcript. False for a part that more rows (opening with a boundary) follow: its last exchange is then settled.
120
123
  */
121
- function foldExchanges(rows, isStreaming) {
124
+ function foldExchanges(rows, isStreaming, final = true) {
125
+ noteTranscriptPass("fold-exchanges", rows.length);
122
126
  const out = [];
123
127
  const used = /* @__PURE__ */ new Set();
124
128
  let boundary = null;
@@ -159,7 +163,12 @@ function foldExchanges(rows, isStreaming) {
159
163
  folded = [];
160
164
  visible = [];
161
165
  };
162
- for (const row of rows) {
166
+ for (let i = 0; i < rows.length; i++) {
167
+ const row = rows[i];
168
+ if (row.kind === "compact-summary" && boundary?.kind === "user-prompt" && compactionInRun(rows, i, isStreaming && final)) {
169
+ folded.push(row);
170
+ continue;
171
+ }
163
172
  if (TOOL_GROUP_BOUNDARIES.has(row.kind)) {
164
173
  flush(false);
165
174
  out.push(row);
@@ -169,9 +178,23 @@ function foldExchanges(rows, isStreaming) {
169
178
  if (foldsInCompact(row)) folded.push(row);
170
179
  else visible.push(row);
171
180
  }
172
- flush(true);
181
+ flush(final);
173
182
  return out;
174
183
  }
184
+ /**
185
+ * The compaction at `at` happened inside its prompt's run: the run went on
186
+ * after it (anything but another boundary follows, past further
187
+ * compactions), or it is the live tail. Then it is one of the run's steps;
188
+ * a compaction between runs (a manual `/compact`, one the next prompt
189
+ * follows) stays a boundary of its own.
190
+ */
191
+ function compactionInRun(rows, at, isStreaming) {
192
+ for (let i = at + 1; i < rows.length; i++) {
193
+ const kind = rows[i].kind;
194
+ if (kind !== "compact-summary") return !TOOL_GROUP_BOUNDARIES.has(kind);
195
+ }
196
+ return isStreaming;
197
+ }
175
198
  const REBASED = /* @__PURE__ */ new WeakMap();
176
199
  /**
177
200
  * A worker's (subagent's) own rows folded like an exchange of the main
@@ -256,9 +279,16 @@ function groupMessages(visible, boundary, live, used) {
256
279
  function findLastStreamingRow(rows) {
257
280
  for (let i = rows.length - 1; i >= 0; i -= 1) {
258
281
  const row = rows[i];
259
- if (row.kind === "markdown" && row.streaming) return row;
260
- if (row.kind === "message-group" && row.current.kind === "markdown" && row.current.streaming) return row.current;
282
+ if (row.kind === "markdown" && row.streaming) {
283
+ noteTranscriptPass("last-streaming", rows.length - i);
284
+ return row;
285
+ }
286
+ if (row.kind === "message-group" && row.current.kind === "markdown" && row.current.streaming) {
287
+ noteTranscriptPass("last-streaming", rows.length - i);
288
+ return row.current;
289
+ }
261
290
  }
291
+ noteTranscriptPass("last-streaming", rows.length);
262
292
  return null;
263
293
  }
264
294
  /** A background task's dot, by how it ended. */
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The row pipeline (`derive.ts`), incremental: a transcript store's settled
3
+ * exchanges (`TranscriptEvents.chunks`) derive once, in blocks that no pass
4
+ * looks across (`seams.ts`), and each frame derives only the open exchange
5
+ * (the tail) and joins. The settled rows and clusters keep their identity
6
+ * across frames, and so does the settled part's array while only the open
7
+ * exchange changes (`parts.settled`). An exchange tied to the open one
8
+ * (a subagent writing across a prompt, a setup, a repaired environment)
9
+ * derives with it, so the result always equals the whole pipeline's.
10
+ *
11
+ * Handed a plain array, the deriver splits it into exchanges first (one walk,
12
+ * reusing the exchanges it saw last time); an array a transcript store made
13
+ * (`transcriptArray`) maps back to its store for free.
14
+ */
15
+ import { ChatEvent } from "../host.js";
16
+ import { DerivedTranscriptRows, TranscriptRowOptions } from "./derive.js";
17
+ import { Cluster, Row } from "./rows.js";
18
+ import { RunReceipt, TranscriptEvents } from "zidane/chat/pure";
19
+ /** Rows and their clusters, for one side of the settled / open split. */
20
+ export interface TranscriptRowsSlice {
21
+ /** The rows, in paint order. */
22
+ rows: readonly Row[];
23
+ /** The rows grouped into subagent blocks. */
24
+ clusters: readonly Cluster[];
25
+ /** The run receipts docked on these rows, by row id. */
26
+ receipts?: ReadonlyMap<string, RunReceipt>;
27
+ }
28
+ /** The derived rows, whole and in their two parts. */
29
+ export interface IncrementalTranscriptRows extends DerivedTranscriptRows {
30
+ /**
31
+ * `visibleRows` and `clusters` in two parts: the settled exchanges (the same
32
+ * arrays while only the open exchange changes) and the open one. A renderer
33
+ * can read these instead of the joined arrays: those are joined on first
34
+ * read (a copy of every row), these are not.
35
+ */
36
+ parts: {
37
+ settled: TranscriptRowsSlice;
38
+ open: TranscriptRowsSlice;
39
+ };
40
+ }
41
+ /** Derives a transcript's rows, keeping what it derived for the settled exchanges. One per transcript view. */
42
+ export interface TranscriptRowsDeriver {
43
+ /**
44
+ * The rows of `source`: a transcript store, or an array (mapped back to its store when one made it).
45
+ *
46
+ * @param source - The transcript.
47
+ * @param streaming - A run is in flight.
48
+ * @param options - The display options.
49
+ */
50
+ derive: (source: readonly ChatEvent[] | TranscriptEvents<ChatEvent>, streaming: boolean, options: TranscriptRowOptions) => IncrementalTranscriptRows;
51
+ }
52
+ /** A deriver for one transcript view (it keeps the settled exchanges' rows of the transcript it last derived). */
53
+ export declare function createTranscriptRowsDeriver(): TranscriptRowsDeriver;