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
@@ -1,9 +1,10 @@
1
1
  import { inheritRowIdentity } from "../transcript/collapse.js";
2
- import { applyLiveEvent, closeThinkingSegment, finishLive } from "./live-events.js";
2
+ import { applyLiveEventToTranscript, endTurnInTranscript, finishLiveTranscript } from "./live-events.js";
3
3
  import { mergeLiveTail } from "./merge.js";
4
4
  import { mergePromptPreviews, missingPreviewData } from "./prompt-previews.js";
5
5
  import { defaultFrameScheduler } from "./scheduler.js";
6
- import { applyHistoryOp, applyHistorySince, dedupeEnvironmentSetups, discardThinking, finalizeStreamingMarkdownForOwner, readFreshness, reconcileEvents } from "zidane/chat/pure";
6
+ import { TranscriptMap } from "./transcript-map.js";
7
+ import { appendTranscriptEvent, applyHistoryOp, applyHistorySince, dedupeEnvironmentSetups, readFreshness, reconcileEvents, transcriptDiscardThinking } from "zidane/chat/pure";
7
8
  // src/chat/headless/streams/store.ts
8
9
  const PARENT_OWNER = "parent";
9
10
  /** Numberings a window remembers leaving (`_retiredHistoryIds`). */
@@ -72,7 +73,8 @@ const NOTIFY_FALLBACK_MS = 50;
72
73
  * @typeParam K - The session key type (the desktop app's branded `SessionKey`). Default: `string`.
73
74
  */
74
75
  var SessionStreamStore = class {
75
- _events = /* @__PURE__ */ new Map();
76
+ /** Each session's events as a transcript store: a streamed delta copies only the open exchange (`TranscriptMap`). */
77
+ _events = new TranscriptMap();
76
78
  _running = /* @__PURE__ */ new Map();
77
79
  _scheduler;
78
80
  _markdown;
@@ -187,6 +189,16 @@ var SessionStreamStore = class {
187
189
  return this._events.get(sessionId) ?? EMPTY_EVENTS;
188
190
  }
189
191
  /**
192
+ * A session's events as a transcript store (settled exchanges and the open
193
+ * one), for a consumer that derives per exchange. `getEventsSnapshot` is
194
+ * its array (`transcriptOfArray` maps one to the other).
195
+ *
196
+ * @param sessionId - The session.
197
+ */
198
+ getTranscriptSnapshot(sessionId) {
199
+ return this._events.transcript(sessionId);
200
+ }
201
+ /**
190
202
  * Whether a run is in flight for the session.
191
203
  *
192
204
  * @param sessionId - The session, or `null` for none.
@@ -282,6 +294,14 @@ var SessionStreamStore = class {
282
294
  return this._events.has(sessionId);
283
295
  }
284
296
  /**
297
+ * About how many bytes the session's rows hold (`eventsBytes`): what the prewarm window budgets by.
298
+ *
299
+ * @param sessionId - The session.
300
+ */
301
+ eventBytes(sessionId) {
302
+ return this._events.bytes(sessionId);
303
+ }
304
+ /**
285
305
  * Whether the session's window was hydrated from DISK (`setEventsPage`),
286
306
  * as opposed to merely having a record. `markRunning` and every live
287
307
  * signal seed `_events` for a session this window never loaded — a run
@@ -297,6 +317,14 @@ var SessionStreamStore = class {
297
317
  return this._pages.has(sessionId);
298
318
  }
299
319
  /**
320
+ * The sessions whose window was hydrated from disk (see `isHydrated`). An
321
+ * app keeps their live signals coming (`sessions.subscribe`): a window
322
+ * that stops getting them goes stale. `subscribeHas` fires when this changes.
323
+ */
324
+ hydratedSessions() {
325
+ return [...this._pages.keys()];
326
+ }
327
+ /**
300
328
  * The session's scrollback bookkeeping (a shared empty state when it was never hydrated). Stable identity until a page write.
301
329
  *
302
330
  * @param sessionId - The session, or `null` for none.
@@ -737,7 +765,6 @@ var SessionStreamStore = class {
737
765
  */
738
766
  appendUserPrompt(sessionId, text, refs, rawAttachments, clientMessageId) {
739
767
  const had = this._events.has(sessionId);
740
- const events = this._events.get(sessionId)?.slice() ?? [];
741
768
  const attachments = rawAttachments === void 0 || missingPreviewData(rawAttachments) ? mergePromptPreviews(rawAttachments, this.takePromptPreviews(sessionId, text)) : rawAttachments;
742
769
  const event = {
743
770
  kind: "user-prompt",
@@ -745,7 +772,6 @@ var SessionStreamStore = class {
745
772
  ...refs && refs.length > 0 ? { refs: [...refs] } : {},
746
773
  ...attachments && attachments.length > 0 ? { attachments: [...attachments] } : {}
747
774
  };
748
- events.push(event);
749
775
  const pending = this._pendingEcho.get(sessionId) ?? [];
750
776
  pending.push({
751
777
  text,
@@ -753,7 +779,7 @@ var SessionStreamStore = class {
753
779
  event
754
780
  });
755
781
  this._pendingEcho.set(sessionId, pending);
756
- this._events.set(sessionId, events);
782
+ this._events.setTranscript(sessionId, appendTranscriptEvent(this._events.transcriptOrEmpty(sessionId), event));
757
783
  this._notifySession(sessionId);
758
784
  if (!had) this._notifyHas();
759
785
  }
@@ -797,7 +823,8 @@ var SessionStreamStore = class {
797
823
  write(sessionId, patch) {
798
824
  const had = this._events.has(sessionId);
799
825
  const wasHydrated = this._pages.has(sessionId);
800
- if (patch.events !== void 0) this._events.set(sessionId, patch.events);
826
+ if (patch.transcript !== void 0) this._events.setTranscript(sessionId, patch.transcript);
827
+ else if (patch.events !== void 0) this._events.set(sessionId, patch.events);
801
828
  else if (!had) this._events.set(sessionId, []);
802
829
  if (patch.running !== void 0) this._running.set(sessionId, patch.running);
803
830
  if (patch.page === null) this._pages.delete(sessionId);
@@ -813,12 +840,10 @@ var SessionStreamStore = class {
813
840
  */
814
841
  appendErrorEvent(sessionId, text) {
815
842
  const had = this._events.has(sessionId);
816
- const events = this._events.get(sessionId)?.slice() ?? [];
817
- events.push({
843
+ this._events.setTranscript(sessionId, appendTranscriptEvent(this._events.transcriptOrEmpty(sessionId), {
818
844
  kind: "error",
819
845
  text
820
- });
821
- this._events.set(sessionId, events);
846
+ }));
822
847
  this._notifySession(sessionId);
823
848
  if (!had) this._notifyHas();
824
849
  }
@@ -845,16 +870,16 @@ var SessionStreamStore = class {
845
870
  return;
846
871
  case "run:end": {
847
872
  this.runStateVersion++;
848
- const prior = this._events.get(signal.sessionId) ?? [];
849
- let next = finishLive(prior);
850
- if (!signal.ok && signal.error) next = [...next, {
873
+ const prior = this._events.transcriptOrEmpty(signal.sessionId);
874
+ let next = finishLiveTranscript(prior);
875
+ if (!signal.ok && signal.error) next = appendTranscriptEvent(next, {
851
876
  kind: "error",
852
877
  text: signal.error,
853
878
  ...signal.detail ? { detail: signal.detail } : {}
854
- }];
879
+ });
855
880
  const had = this._events.has(signal.sessionId);
856
881
  const wasRunning = this._running.get(signal.sessionId) === true;
857
- this._events.set(signal.sessionId, next);
882
+ this._events.setTranscript(signal.sessionId, next);
858
883
  this._running.set(signal.sessionId, false);
859
884
  const sawStart = this._runStarted.delete(signal.sessionId);
860
885
  const streamed = this._runActivity.delete(signal.sessionId);
@@ -866,10 +891,10 @@ var SessionStreamStore = class {
866
891
  return;
867
892
  }
868
893
  case "turn:end": {
869
- const prior = this._events.get(signal.sessionId) ?? [];
894
+ const prior = this._events.transcriptOrEmpty(signal.sessionId);
870
895
  const owner = signal.childId ?? PARENT_OWNER;
871
896
  const had = this._events.has(signal.sessionId);
872
- this._events.set(signal.sessionId, finalizeStreamingMarkdownForOwner(closeThinkingSegment(prior, owner), owner));
897
+ this._events.setTranscript(signal.sessionId, endTurnInTranscript(prior, owner));
873
898
  this._notifySession(signal.sessionId);
874
899
  if (!had) this._notifyHas();
875
900
  return;
@@ -898,8 +923,8 @@ var SessionStreamStore = class {
898
923
  };
899
924
  }
900
925
  const had = this._events.has(signal.sessionId);
901
- const prior = this._events.get(signal.sessionId) ?? [];
902
- this._events.set(signal.sessionId, this._append(prior, event));
926
+ const prior = this._events.transcriptOrEmpty(signal.sessionId);
927
+ this._events.setTranscript(signal.sessionId, this._append(prior, event));
903
928
  this._runActivity.add(signal.sessionId);
904
929
  if (this._batch) this._notifySoon(signal.sessionId);
905
930
  else this._notifySession(signal.sessionId);
@@ -942,7 +967,7 @@ var SessionStreamStore = class {
942
967
  if (plan.length === 0) return;
943
968
  const touched = /* @__PURE__ */ new Set();
944
969
  for (const entry of plan) {
945
- const prior = this._events.get(entry.sessionId) ?? [];
970
+ const prior = this._events.transcriptOrEmpty(entry.sessionId);
946
971
  const synthetic = {
947
972
  kind: "markdown",
948
973
  text: entry.text,
@@ -951,7 +976,7 @@ var SessionStreamStore = class {
951
976
  ...entry.depth != null ? { depth: entry.depth } : {},
952
977
  ...entry.turnId ? { turnId: entry.turnId } : {}
953
978
  };
954
- this._events.set(entry.sessionId, this._append(prior, synthetic));
979
+ this._events.setTranscript(entry.sessionId, this._append(prior, synthetic));
955
980
  touched.add(entry.sessionId);
956
981
  }
957
982
  for (const sessionId of touched) this._notifySession(sessionId);
@@ -1065,10 +1090,10 @@ var SessionStreamStore = class {
1065
1090
  }
1066
1091
  /** Drop a stalled attempt's reasoning lane: the retry (or next model) streams its own, and the saved turn never holds it. */
1067
1092
  _discardThinking(sessionId, source, turnId) {
1068
- const events = this._events.get(sessionId);
1093
+ const events = this._events.transcript(sessionId);
1069
1094
  if (!events) return;
1070
- const next = discardThinking(events, source, turnId);
1071
- if (next !== events) this._events.set(sessionId, next);
1095
+ const next = transcriptDiscardThinking(events, source, turnId);
1096
+ if (next !== events) this._events.setTranscript(sessionId, next);
1072
1097
  }
1073
1098
  /**
1074
1099
  * Append a fresh event with the kit's live rule (`applyLiveEvent`, the
@@ -1080,7 +1105,7 @@ var SessionStreamStore = class {
1080
1105
  * timing of its own).
1081
1106
  */
1082
1107
  _append(events, event) {
1083
- return applyLiveEvent(events, event, Date.now(), this._markdown);
1108
+ return applyLiveEventToTranscript(events, event, Date.now(), this._markdown);
1084
1109
  }
1085
1110
  _notifySession(sessionId) {
1086
1111
  this._pendingNotify.delete(sessionId);
@@ -0,0 +1,57 @@
1
+ import { ChatEvent } from "../host.js";
2
+ import { TranscriptEvents } from "zidane/chat/pure";
3
+ /**
4
+ * The session stream store's events: one transcript store per session
5
+ * (`TranscriptEvents`, settled exchanges and the open one). Reads as a map of
6
+ * arrays (`get`, `set`) for the store's rare whole-window writes, and as
7
+ * transcripts (`transcript`, `setTranscript`) for the streaming hot path,
8
+ * where a delta copies only the open exchange. An array read is made once per
9
+ * write, and `set` of an array keeps it as given (`get` returns it).
10
+ */
11
+ export declare class TranscriptMap<K> {
12
+ private readonly map;
13
+ /** Sessions held. */
14
+ get size(): number;
15
+ /**
16
+ * The session's events as one array (the same array until the next write).
17
+ *
18
+ * @param sessionId - The session.
19
+ */
20
+ get(sessionId: K): ChatEvent[] | undefined;
21
+ /**
22
+ * Sets the session's events; the exchanges they keep unchanged keep their chunks.
23
+ *
24
+ * @param sessionId - The session.
25
+ * @param events - The events. Never changed afterwards.
26
+ */
27
+ set(sessionId: K, events: readonly ChatEvent[]): this;
28
+ /**
29
+ * The session's transcript store, if held.
30
+ *
31
+ * @param sessionId - The session.
32
+ */
33
+ transcript(sessionId: K): TranscriptEvents<ChatEvent> | undefined;
34
+ /**
35
+ * The session's transcript store, or an empty one.
36
+ *
37
+ * @param sessionId - The session.
38
+ */
39
+ transcriptOrEmpty(sessionId: K): TranscriptEvents<ChatEvent>;
40
+ /**
41
+ * Sets the session's transcript store.
42
+ *
43
+ * @param sessionId - The session.
44
+ * @param transcript - The transcript.
45
+ */
46
+ setTranscript(sessionId: K, transcript: TranscriptEvents<ChatEvent>): this;
47
+ /**
48
+ * About how many bytes the session's rows hold: each settled exchange is measured once.
49
+ *
50
+ * @param sessionId - The session.
51
+ */
52
+ bytes(sessionId: K): number;
53
+ has(sessionId: K): boolean;
54
+ delete(sessionId: K): boolean;
55
+ clear(): void;
56
+ keys(): IterableIterator<K>;
57
+ }
@@ -0,0 +1,88 @@
1
+ import { eventsBytes } from "./event-bytes.js";
2
+ import { emptyTranscript, transcriptArray, transcriptFromArray } from "zidane/chat/pure";
3
+ // src/chat/headless/streams/transcript-map.ts
4
+ /**
5
+ * The session stream store's events: one transcript store per session
6
+ * (`TranscriptEvents`, settled exchanges and the open one). Reads as a map of
7
+ * arrays (`get`, `set`) for the store's rare whole-window writes, and as
8
+ * transcripts (`transcript`, `setTranscript`) for the streaming hot path,
9
+ * where a delta copies only the open exchange. An array read is made once per
10
+ * write, and `set` of an array keeps it as given (`get` returns it).
11
+ */
12
+ var TranscriptMap = class {
13
+ map = /* @__PURE__ */ new Map();
14
+ /** Sessions held. */
15
+ get size() {
16
+ return this.map.size;
17
+ }
18
+ /**
19
+ * The session's events as one array (the same array until the next write).
20
+ *
21
+ * @param sessionId - The session.
22
+ */
23
+ get(sessionId) {
24
+ const transcript = this.map.get(sessionId);
25
+ return transcript ? transcriptArray(transcript) : void 0;
26
+ }
27
+ /**
28
+ * Sets the session's events; the exchanges they keep unchanged keep their chunks.
29
+ *
30
+ * @param sessionId - The session.
31
+ * @param events - The events. Never changed afterwards.
32
+ */
33
+ set(sessionId, events) {
34
+ this.map.set(sessionId, transcriptFromArray(events, this.map.get(sessionId)));
35
+ return this;
36
+ }
37
+ /**
38
+ * The session's transcript store, if held.
39
+ *
40
+ * @param sessionId - The session.
41
+ */
42
+ transcript(sessionId) {
43
+ return this.map.get(sessionId);
44
+ }
45
+ /**
46
+ * The session's transcript store, or an empty one.
47
+ *
48
+ * @param sessionId - The session.
49
+ */
50
+ transcriptOrEmpty(sessionId) {
51
+ return this.map.get(sessionId) ?? emptyTranscript();
52
+ }
53
+ /**
54
+ * Sets the session's transcript store.
55
+ *
56
+ * @param sessionId - The session.
57
+ * @param transcript - The transcript.
58
+ */
59
+ setTranscript(sessionId, transcript) {
60
+ this.map.set(sessionId, transcript);
61
+ return this;
62
+ }
63
+ /**
64
+ * About how many bytes the session's rows hold: each settled exchange is measured once.
65
+ *
66
+ * @param sessionId - The session.
67
+ */
68
+ bytes(sessionId) {
69
+ const transcript = this.map.get(sessionId);
70
+ if (!transcript) return 0;
71
+ let bytes = eventsBytes(transcript.tail);
72
+ for (const chunk of transcript.chunks) bytes += eventsBytes(chunk);
73
+ return bytes;
74
+ }
75
+ has(sessionId) {
76
+ return this.map.has(sessionId);
77
+ }
78
+ delete(sessionId) {
79
+ return this.map.delete(sessionId);
80
+ }
81
+ clear() {
82
+ this.map.clear();
83
+ }
84
+ keys() {
85
+ return this.map.keys();
86
+ }
87
+ };
88
+ export { TranscriptMap };
@@ -2,8 +2,10 @@ import { Transcript, TranscriptState } from "../host.js";
2
2
  import { SessionStreamStore } from "./store.js";
3
3
  /**
4
4
  * A session's {@link TranscriptState} read off the store, reusing `prev` while
5
- * none of its parts changed (snapshots compare by identity).
5
+ * none of its parts changed (snapshots compare by identity). It carries the
6
+ * store's transcript (`transcript`); `events`, one array of it, is made on
7
+ * first read, so a reader of `transcript` never pays for a copy per delta.
6
8
  */
7
9
  export declare function transcriptSnapshot<K extends string>(store: SessionStreamStore<K>, sessionId: K, prev: TranscriptState | undefined): TranscriptState;
8
10
  /** A session's transcript as the components read it: a store over the session's slice, subscribed to that session only. */
9
- export declare function storeTranscript<K extends string>(store: SessionStreamStore<K>, sessionId: K, loadEarlier?: () => void): Transcript;
11
+ export declare function storeTranscript<K extends string>(store: SessionStreamStore<K>, sessionId: K, loadEarlier?: () => void, more?: Pick<Transcript, 'loadThrough' | 'outline'>): Transcript;
@@ -1,29 +1,41 @@
1
+ import { emptyTranscript, transcriptArray } from "zidane/chat/pure";
1
2
  // src/chat/headless/streams/transcript.ts
3
+ /** The transcript of a session the store holds nothing for: one object, so a reader's memo holds. */
4
+ const NO_TRANSCRIPT = emptyTranscript();
2
5
  /**
3
6
  * A session's {@link TranscriptState} read off the store, reusing `prev` while
4
- * none of its parts changed (snapshots compare by identity).
7
+ * none of its parts changed (snapshots compare by identity). It carries the
8
+ * store's transcript (`transcript`); `events`, one array of it, is made on
9
+ * first read, so a reader of `transcript` never pays for a copy per delta.
5
10
  */
6
11
  function transcriptSnapshot(store, sessionId, prev) {
7
- const events = store.getEventsSnapshot(sessionId);
12
+ const transcript = store.getTranscriptSnapshot(sessionId) ?? NO_TRANSCRIPT;
8
13
  const running = store.getRunningSnapshot(sessionId);
9
14
  const hydrated = store.isHydrated(sessionId);
10
15
  const page = store.getPageSnapshot(sessionId);
11
- if (prev && prev.events === events && prev.running === running && prev.hydrated === hydrated && prev.hasEarlier === page.hasMore && prev.loadingEarlier === page.loadingEarlier) return prev;
12
- return {
13
- events,
16
+ if (prev && prev.transcript === transcript && prev.running === running && prev.hydrated === hydrated && prev.hasEarlier === page.hasMore && prev.loadingEarlier === page.loadingEarlier) return prev;
17
+ const state = {
18
+ get events() {
19
+ return transcriptArray(transcript);
20
+ },
14
21
  running,
15
22
  hydrated,
16
23
  hasEarlier: page.hasMore,
17
24
  loadingEarlier: page.loadingEarlier
18
25
  };
26
+ return Object.defineProperty(state, "transcript", {
27
+ value: transcript,
28
+ enumerable: false
29
+ });
19
30
  }
20
31
  /** A session's transcript as the components read it: a store over the session's slice, subscribed to that session only. */
21
- function storeTranscript(store, sessionId, loadEarlier) {
32
+ function storeTranscript(store, sessionId, loadEarlier, more = {}) {
22
33
  let last;
23
34
  return {
24
35
  get: () => last = transcriptSnapshot(store, sessionId, last),
25
36
  subscribe: (onChange) => store.subscribeSession(sessionId, onChange),
26
- ...loadEarlier ? { loadEarlier } : {}
37
+ ...loadEarlier ? { loadEarlier } : {},
38
+ ...more
27
39
  };
28
40
  }
29
41
  export { storeTranscript, transcriptSnapshot };
@@ -1,4 +1,4 @@
1
- import { spawnParents, summarizeTools } from "zidane/chat/pure";
1
+ import { noteTranscriptPass, spawnParents, summarizeTools } from "zidane/chat/pure";
2
2
  // src/chat/headless/transcript/batch.ts
3
3
  /**
4
4
  * Group contiguous rows with the same `childId` so the renderer can
@@ -14,6 +14,7 @@ import { spawnParents, summarizeTools } from "zidane/chat/pure";
14
14
  * @param rows - The transcript rows, oldest first.
15
15
  */
16
16
  function clusterByOwner(rows) {
17
+ noteTranscriptPass("cluster", rows.length);
17
18
  const out = [];
18
19
  const parents = spawnParents(rows);
19
20
  const present = /* @__PURE__ */ new Set();
@@ -243,6 +244,7 @@ function liftExchangeToolGroups(rows) {
243
244
  * @param groupToolCalls - Lifts parent-owned tool calls into one group per exchange before batching adjacent runs. Defaults to `false`.
244
245
  */
245
246
  function batchToolRuns(rows, groupToolCalls = false) {
247
+ noteTranscriptPass("batch:tools", rows.length);
246
248
  const pre = groupToolCalls ? liftExchangeToolGroups(rows) : rows;
247
249
  const out = [];
248
250
  const used = /* @__PURE__ */ new Set();
@@ -311,6 +313,7 @@ const THINKING_CHAIN_TRANSPARENT = /* @__PURE__ */ new Set(["tool", "tool-batch"
311
313
  * @param rows - The transcript rows after {@link batchToolRuns}, oldest first.
312
314
  */
313
315
  function batchThinkingRuns(rows) {
316
+ noteTranscriptPass("batch:thinking", rows.length);
314
317
  const out = [];
315
318
  const used = /* @__PURE__ */ new Set();
316
319
  let chain = [];
@@ -366,6 +369,7 @@ const TASK_BATCH_IDS = new IdHold();
366
369
  * @param rows - The transcript rows, oldest first.
367
370
  */
368
371
  function batchTaskRuns(rows) {
372
+ noteTranscriptPass("batch:tasks", rows.length);
369
373
  const out = [];
370
374
  const used = /* @__PURE__ */ new Set();
371
375
  let burst = [];
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Media the session store holds by content hash (its blob table): a turn
3
+ * names such a block `attachment://<hash>`, on a prompt's attachment
4
+ * (`ChatAttachment.ref`) and in a tool result's stand-in line
5
+ * (`[image: image/png, ref attachment://<hash>]`). An app that serves blobs
6
+ * (`TranscriptActions.blobMediaUrl`) loads them by hash: the same bytes for
7
+ * good, so the page caches them for good. Blocks still inline keep the
8
+ * app's older addresses (by call and position, by turn).
9
+ */
10
+ /**
11
+ * The blob hash an `attachment://<hash>` handle names, or `undefined` for anything else.
12
+ *
13
+ * @param ref - A block's ref.
14
+ */
15
+ export declare function blobHashOf(ref: string | undefined): string | undefined;
@@ -0,0 +1,23 @@
1
+ // src/chat/headless/transcript/blob-media.ts
2
+ /**
3
+ * Media the session store holds by content hash (its blob table): a turn
4
+ * names such a block `attachment://<hash>`, on a prompt's attachment
5
+ * (`ChatAttachment.ref`) and in a tool result's stand-in line
6
+ * (`[image: image/png, ref attachment://<hash>]`). An app that serves blobs
7
+ * (`TranscriptActions.blobMediaUrl`) loads them by hash: the same bytes for
8
+ * good, so the page caches them for good. Blocks still inline keep the
9
+ * app's older addresses (by call and position, by turn).
10
+ */
11
+ const HANDLE = "attachment://";
12
+ const HASH = /^[0-9a-f]{32}$/;
13
+ /**
14
+ * The blob hash an `attachment://<hash>` handle names, or `undefined` for anything else.
15
+ *
16
+ * @param ref - A block's ref.
17
+ */
18
+ function blobHashOf(ref) {
19
+ if (!ref?.startsWith(HANDLE)) return void 0;
20
+ const hash = ref.slice(13).trim();
21
+ return HASH.test(hash) ? hash : void 0;
22
+ }
23
+ export { blobHashOf };
@@ -30,6 +30,16 @@ export declare function toolFailed(tool: Pick<Extract<Row, {
30
30
  export declare function refusedSpawn(tool: Pick<Extract<Row, {
31
31
  kind: 'tool';
32
32
  }>, 'name' | 'result'>): boolean;
33
+ /**
34
+ * The row the full pass puts in front of `events` when they follow other
35
+ * rows: a pass over `events` alone drops a leading separator and adds no
36
+ * turn boundary before a leading prompt, because nothing is above them.
37
+ * With it, rows derived per exchange join into the rows of the whole.
38
+ *
39
+ * @param events - The events of a part, as `collapseEvents` gets them.
40
+ * @param before - The last row the collapse made for everything above them, if any.
41
+ */
42
+ export declare function collapseSeamRow(events: readonly ChatEvent[], before: Row | undefined): Row | null;
33
43
  /**
34
44
  * Turns transcript events into rows: pairs tool calls with their results, merges streamed text, reconciles edits and spawns. Rows are cached per source event, so appending an event keeps every earlier row identical.
35
45
  *
@@ -1,7 +1,7 @@
1
1
  import { promptOriginOf } from "../prompt-origin.js";
2
2
  import { pairToolEvents } from "./pairing.js";
3
3
  import { parseBashExitMeta } from "./rows.js";
4
- import { displayNameFor, formatToolCall, isUserBashEvent, mcpJobsByCall, placeEnvironmentSetups, readEnvironmentSetup, scriptProgressByCall, scriptProgressKey } from "zidane/chat/pure";
4
+ import { displayNameFor, formatToolCall, isUserBashEvent, mcpJobsByCall, noteTranscriptPass, placeEnvironmentSetups, readEnvironmentSetup, scriptProgressByCall, scriptProgressKey } from "zidane/chat/pure";
5
5
  // src/chat/headless/transcript/collapse.ts
6
6
  /**
7
7
  * When the paired result is an `error`, flip every `applied` outcome
@@ -168,6 +168,7 @@ const lastPasses = /* @__PURE__ */ new WeakMap();
168
168
  function collapseTail(events, showEditDiffs, isStreaming) {
169
169
  const last = events.length > 0 ? lastPasses.get(events[0]) : void 0;
170
170
  if (!last || last.events.length !== events.length || last.showEditDiffs !== showEditDiffs || last.isStreaming !== isStreaming) return null;
171
+ noteTranscriptPass("collapse:tail", events.length);
171
172
  const prev = last.events;
172
173
  const { rowOf, headOf } = last;
173
174
  const changed = [];
@@ -263,6 +264,28 @@ function refusedSpawn(tool) {
263
264
  return tool.name === "spawn" && typeof tool.result === "string" && /^(?:Tool error: )?Cannot spawn/.test(tool.result);
264
265
  }
265
266
  /**
267
+ * The row the full pass puts in front of `events` when they follow other
268
+ * rows: a pass over `events` alone drops a leading separator and adds no
269
+ * turn boundary before a leading prompt, because nothing is above them.
270
+ * With it, rows derived per exchange join into the rows of the whole.
271
+ *
272
+ * @param events - The events of a part, as `collapseEvents` gets them.
273
+ * @param before - The last row the collapse made for everything above them, if any.
274
+ */
275
+ function collapseSeamRow(events, before) {
276
+ const first = events[0];
277
+ if (!first || !before || before.kind === "separator") return null;
278
+ if (first.kind === "separator") {
279
+ const sid = rowIdFor(first);
280
+ return cachedRow(first, `s-${sid}`, () => ({
281
+ kind: "separator",
282
+ id: `s-${sid}`
283
+ }));
284
+ }
285
+ if (first.kind === "user-prompt" && !first.childId) return autoSeparatorFor(first, rowIdFor(first));
286
+ return null;
287
+ }
288
+ /**
266
289
  * Turns transcript events into rows: pairs tool calls with their results, merges streamed text, reconciles edits and spawns. Rows are cached per source event, so appending an event keeps every earlier row identical.
267
290
  *
268
291
  * @param events - The transcript events, oldest first.
@@ -281,6 +304,7 @@ function collapseEvents(events, showEditDiffs, isStreaming) {
281
304
  * @param isStreaming - A run is in flight.
282
305
  */
283
306
  function collapseAll(events, showEditDiffs, isStreaming) {
307
+ noteTranscriptPass("collapse", events.length);
284
308
  const rows = [];
285
309
  const rowOf = new Int32Array(events.length).fill(-1);
286
310
  const headOf = new Int32Array(events.length);
@@ -395,7 +419,7 @@ function collapseAll(events, showEditDiffs, isStreaming) {
395
419
  const paired = pair ? events[pair.resultIndex] : void 0;
396
420
  const running = !paired || pair?.resultKind === "tool-result" && paired.streaming === true;
397
421
  const errored = pair?.resultKind === "error";
398
- const key = `ub-${sid}|${running}|${errored}|${paired ? rowIdFor(paired) : -1}|${paired?.text.length ?? -1}|${paired?.clipped ?? false}`;
422
+ const key = `ub-${sid}|${running}|${errored}|${paired ? rowIdFor(paired) : -1}|${paired?.text.length ?? -1}|${paired?.clipped?.result !== void 0}`;
399
423
  rows.push(cachedRow(event, key, () => {
400
424
  const command = typeof event.input?.command === "string" ? event.input.command : event.text;
401
425
  const result = paired ? paired.text : null;
@@ -409,7 +433,7 @@ function collapseAll(events, showEditDiffs, isStreaming) {
409
433
  exit: !running && !errored && result !== null ? parseBashExitMeta(result) : null,
410
434
  ...errored ? { errored: true } : {},
411
435
  ...event.callId ? { callId: event.callId } : {},
412
- ...paired?.clipped ? { resultClipped: true } : {}
436
+ ...paired?.clipped?.result ? { resultClipped: true } : {}
413
437
  };
414
438
  }));
415
439
  break;
@@ -426,7 +450,7 @@ function collapseAll(events, showEditDiffs, isStreaming) {
426
450
  const resuming = !paired && event.resuming === true;
427
451
  const scriptProgress = event.callId ? progressOf.get(scriptProgressKey(event.callId, event.childId)) : void 0;
428
452
  const mcpJob = event.callId ? jobOf.get(scriptProgressKey(event.callId, event.childId)) : void 0;
429
- const key = `t-${sid}|${showEditDiffs}|${okCoerced}|${paired ? rowIdFor(paired) : -1}|${paired?.text.length ?? -1}|${paired?.clipped ?? false}|${waitingFor ? "w" : ""}|${since ?? ""}|${doneMs ?? ""}|${resuming ? "r" : ""}|${scriptProgress ? progressId(scriptProgress) : ""}|${mcpJob ? progressId(mcpJob) : ""}`;
453
+ const key = `t-${sid}|${showEditDiffs}|${okCoerced}|${paired ? rowIdFor(paired) : -1}|${paired?.text.length ?? -1}|${paired?.clipped?.result !== void 0}|${waitingFor ? "w" : ""}|${since ?? ""}|${doneMs ?? ""}|${resuming ? "r" : ""}|${scriptProgress ? progressId(scriptProgress) : ""}|${mcpJob ? progressId(mcpJob) : ""}`;
430
454
  rows.push(cachedRow(event, key, () => {
431
455
  const toolName = event.tool ?? "?";
432
456
  const rawInput = event.input;
@@ -447,7 +471,9 @@ function collapseAll(events, showEditDiffs, isStreaming) {
447
471
  result,
448
472
  ok,
449
473
  ...event.callId ? { callId: event.callId } : {},
450
- ...paired?.clipped ? { resultClipped: true } : {},
474
+ ...paired?.clipped?.result ? { resultClipped: true } : {},
475
+ ...paired?.mediaRefs ? { mediaRefs: paired.mediaRefs } : {},
476
+ ...event.clipped?.input ? { inputClipped: true } : {},
451
477
  ...waitingFor ? { waitingFor } : {},
452
478
  ...resuming ? { resuming: true } : {},
453
479
  ...scriptProgress ? { scriptProgress } : {},
@@ -564,4 +590,4 @@ function collapseAll(events, showEditDiffs, isStreaming) {
564
590
  });
565
591
  return rows;
566
592
  }
567
- export { collapseAll, collapseEvents, inheritRowIdentity, refusedSpawn, toolFailed };
593
+ export { collapseAll, collapseEvents, collapseSeamRow, inheritRowIdentity, refusedSpawn, toolFailed };