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,181 @@
1
+ import { deriveRowsPart, resumableRowId } from "./derive.js";
2
+ import { BlockPlan, tailTies } from "./seams.js";
3
+ import { noteTranscriptPass, transcriptFromArray, transcriptOfArray } from "zidane/chat/pure";
4
+ // src/chat/headless/transcript/incremental.ts
5
+ const seamOf = (row) => !row ? "none" : row.kind === "separator" ? "separator" : "other";
6
+ function optionsKey(o) {
7
+ return `${+o.showCacheNotices}${+o.codemodeShowCalls}${+o.showEditDiffs}${+o.groupToolCalls}${+o.showRunReceipt}${+o.compact}`;
8
+ }
9
+ /** A settled block's rows, per its first chunk. */
10
+ const blocks = /* @__PURE__ */ new WeakMap();
11
+ function sameChunks(a, b) {
12
+ if (a.length !== b.length) return false;
13
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
14
+ return true;
15
+ }
16
+ function eventsOf(chunks, tail) {
17
+ if (chunks.length === 0) return tail ?? [];
18
+ if (chunks.length === 1 && !tail) return chunks[0];
19
+ const all = tail ? [...chunks, tail] : chunks;
20
+ noteTranscriptPass("join:events", all.reduce((n, c) => n + c.length, 0));
21
+ return all.flat();
22
+ }
23
+ function settledBlock(chunks, streaming, options, optsKey, before) {
24
+ const key = `${optsKey}|${+streaming}|${seamOf(before)}`;
25
+ const hit = blocks.get(chunks[0]);
26
+ if (hit && hit.key === key && sameChunks(hit.chunks, chunks)) return hit.part;
27
+ const part = deriveRowsPart(eventsOf(chunks), streaming, options, false, before);
28
+ blocks.set(chunks[0], {
29
+ chunks,
30
+ key,
31
+ part
32
+ });
33
+ return part;
34
+ }
35
+ const EMPTY_RECEIPTS = /* @__PURE__ */ new Map();
36
+ /** Two receipt maps read as one (the settled part's, merged once, and the open part's). */
37
+ var JoinedMap = class {
38
+ a;
39
+ b;
40
+ constructor(a, b) {
41
+ this.a = a;
42
+ this.b = b;
43
+ }
44
+ get size() {
45
+ return this.a.size + this.b.size;
46
+ }
47
+ get(key) {
48
+ return this.b.get(key) ?? this.a.get(key);
49
+ }
50
+ has(key) {
51
+ return this.b.has(key) || this.a.has(key);
52
+ }
53
+ forEach(callback) {
54
+ for (const [key, value] of this) callback(value, key, this);
55
+ }
56
+ *entries() {
57
+ yield* this.a.entries();
58
+ yield* this.b.entries();
59
+ }
60
+ *keys() {
61
+ for (const [key] of this.entries()) yield key;
62
+ }
63
+ *values() {
64
+ for (const [, value] of this.entries()) yield value;
65
+ }
66
+ [Symbol.iterator]() {
67
+ return this.entries();
68
+ }
69
+ };
70
+ const NO_SETTLED = {
71
+ chunks: [],
72
+ count: 0,
73
+ key: "",
74
+ slice: {
75
+ rows: [],
76
+ clusters: []
77
+ },
78
+ receipts: EMPTY_RECEIPTS,
79
+ lastCollapsed: void 0,
80
+ lastStreaming: null
81
+ };
82
+ function joinSettled(parts, base) {
83
+ const rows = parts.flatMap((p) => p.rows);
84
+ noteTranscriptPass("join:settled", rows.length);
85
+ const receipts = /* @__PURE__ */ new Map();
86
+ let lastStreaming = null;
87
+ for (const part of parts) {
88
+ part.receipts.forEach((receipt, id) => receipts.set(id, receipt));
89
+ lastStreaming = part.lastStreaming ?? lastStreaming;
90
+ }
91
+ return {
92
+ ...base,
93
+ slice: {
94
+ rows,
95
+ clusters: parts.flatMap((p) => p.clusters),
96
+ receipts
97
+ },
98
+ receipts,
99
+ lastCollapsed: parts.at(-1)?.lastCollapsed,
100
+ lastStreaming
101
+ };
102
+ }
103
+ /** A deriver for one transcript view (it keeps the settled exchanges' rows of the transcript it last derived). */
104
+ function createTranscriptRowsDeriver() {
105
+ const plan = new BlockPlan();
106
+ let settled = NO_SETTLED;
107
+ let last = null;
108
+ const settle = (transcript, count, streaming, options, optsKey) => {
109
+ const key = `${optsKey}|${+streaming}`;
110
+ if (settled.count === count && settled.key === key && sameChunks(settled.chunks, transcript.chunks)) return settled;
111
+ if (count === 0) return {
112
+ ...NO_SETTLED,
113
+ chunks: transcript.chunks,
114
+ key
115
+ };
116
+ const parts = [];
117
+ let before;
118
+ for (let b = 0; b < count; b++) {
119
+ const block = plan.blocks[b];
120
+ const part = settledBlock(transcript.chunks.slice(block.start, block.end), streaming, options, optsKey, before);
121
+ parts.push(part);
122
+ before = part.lastCollapsed;
123
+ }
124
+ return joinSettled(parts, {
125
+ chunks: transcript.chunks,
126
+ count,
127
+ key
128
+ });
129
+ };
130
+ const derive = (source, streaming, options) => {
131
+ const transcript = Array.isArray(source) ? transcriptOfArray(source) ?? transcriptFromArray(source, last?.transcript) : source;
132
+ const optsKey = optionsKey(options);
133
+ if (last && last.transcript === transcript && last.streaming === streaming && last.key === optsKey) return last.result;
134
+ plan.update(transcript.chunks);
135
+ const count = plan.joinFrom(tailTies(transcript.tail));
136
+ settled = settle(transcript, count, streaming, options, optsKey);
137
+ const from = count < plan.blocks.length ? plan.blocks[count].start : transcript.chunks.length;
138
+ const events = eventsOf(transcript.chunks.slice(from), transcript.tail);
139
+ const open = deriveRowsPart(events, streaming, options, true, settled.lastCollapsed);
140
+ const prior = settled.slice;
141
+ const receiptByRowId = settled.receipts.size === 0 ? open.receipts : open.receipts.size === 0 ? settled.receipts : new JoinedMap(settled.receipts, open.receipts);
142
+ let visibleRows;
143
+ let clusters;
144
+ const result = {
145
+ get visibleRows() {
146
+ if (!visibleRows) {
147
+ if (prior.rows.length > 0) noteTranscriptPass("join:rows", prior.rows.length + open.rows.length);
148
+ visibleRows = prior.rows.length > 0 ? prior.rows.concat(open.rows) : open.rows;
149
+ }
150
+ return visibleRows;
151
+ },
152
+ receiptByRowId,
153
+ resumableId: resumableRowId([prior.rows, open.rows], streaming),
154
+ get clusters() {
155
+ if (!clusters) {
156
+ if (prior.clusters.length > 0) noteTranscriptPass("join:clusters", prior.clusters.length + open.clusters.length);
157
+ clusters = prior.clusters.length > 0 ? prior.clusters.concat(open.clusters) : open.clusters;
158
+ }
159
+ return clusters;
160
+ },
161
+ lastStreamingRow: open.lastStreaming ?? settled.lastStreaming,
162
+ parts: {
163
+ settled: prior,
164
+ open: {
165
+ rows: open.rows,
166
+ clusters: open.clusters,
167
+ receipts: open.receipts
168
+ }
169
+ }
170
+ };
171
+ last = {
172
+ transcript,
173
+ streaming,
174
+ key: optsKey,
175
+ result
176
+ };
177
+ return result;
178
+ };
179
+ return { derive };
180
+ }
181
+ export { createTranscriptRowsDeriver };
@@ -6,7 +6,8 @@ import { dockRunReceipts, dotVariantFor, findLastStreamingRow, foldExchanges, fo
6
6
  import { FoldActionItem, FoldActionState, foldActionItems, toolAction } from "./fold-actions.js";
7
7
  import { nestToolCalls, nestedCallVisible } from "./nesting.js";
8
8
  import { PairingResult, ToolPairing, pairToolEvents } from "./pairing.js";
9
+ import { EMPTY_RAIL, RailExchange, RailModel, TranscriptRailState, TranscriptRailStore, computeRailModel, computeRailModelParts, createTranscriptRailStore, dataRowSelector, plainPreview, railWithOutline, sameRail } from "./rail.js";
9
10
  import { BashExitMeta, Cluster, DotVariant, ExchangeFoldStats, GroupCluster, Owned, Row, SpawnMeta, TaskInfo, ToolRowModel, firstRowId, parseBashExitMeta } from "./rows.js";
10
11
  import { RunFailure, failureTooltip, markRunFailures } from "./run-failures.js";
11
12
  import { SelectStops, computeSelectStops, rowTurnIds, stopForRow } from "./select-stops.js";
12
- export { type AuthCardPlan, type AuthFixes, type AuthSettingsTarget, type BashExitMeta, type Cluster, type DotVariant, type ExchangeFoldStats, type ExchangeMedium, type FoldActionItem, type FoldActionState, type GroupCluster, type MediaRef, type Owned, type PairingResult, type Row, type RunFailure, type SelectStops, type SpawnMeta, type TaskInfo, type ToolPairing, type ToolRowModel, authFailureDetails, batchTaskRuns, batchThinkingRuns, batchToolRuns, clusterByOwner, collapseEvents, computeSelectStops, createAuthFixes, dockRunReceipts, dotVariantFor, exchangesMedia, failureTooltip, findLastStreamingRow, firstRowId, foldActionItems, foldExchanges, foldWorkerRows, inheritRowIdentity, isAuthFixed, markRunFailures, mediaRefsOf, mediumKey, nestToolCalls, nestedCallVisible, pairToolEvents, parseBashExitMeta, planAuthCard, refusedSpawn, rowTurnIds, stopForRow, toolAction, toolFailed };
13
+ export { type AuthCardPlan, type AuthFixes, type AuthSettingsTarget, type BashExitMeta, type Cluster, type DotVariant, EMPTY_RAIL, type ExchangeFoldStats, type ExchangeMedium, type FoldActionItem, type FoldActionState, type GroupCluster, type MediaRef, type Owned, type PairingResult, type RailExchange, type RailModel, type Row, type RunFailure, type SelectStops, type SpawnMeta, type TaskInfo, type ToolPairing, type ToolRowModel, type TranscriptRailState, type TranscriptRailStore, authFailureDetails, batchTaskRuns, batchThinkingRuns, batchToolRuns, clusterByOwner, collapseEvents, computeRailModel, computeRailModelParts, computeSelectStops, createAuthFixes, createTranscriptRailStore, dataRowSelector, dockRunReceipts, dotVariantFor, exchangesMedia, failureTooltip, findLastStreamingRow, firstRowId, foldActionItems, foldExchanges, foldWorkerRows, inheritRowIdentity, isAuthFixed, markRunFailures, mediaRefsOf, mediumKey, nestToolCalls, nestedCallVisible, pairToolEvents, parseBashExitMeta, plainPreview, planAuthCard, railWithOutline, refusedSpawn, rowTurnIds, sameRail, stopForRow, toolAction, toolFailed };
@@ -6,7 +6,8 @@ import { dockRunReceipts, dotVariantFor, findLastStreamingRow, foldExchanges, fo
6
6
  import { foldActionItems, toolAction } from "./fold-actions.js";
7
7
  import { nestToolCalls, nestedCallVisible } from "./nesting.js";
8
8
  import { pairToolEvents } from "./pairing.js";
9
+ import { EMPTY_RAIL, computeRailModel, computeRailModelParts, createTranscriptRailStore, dataRowSelector, plainPreview, railWithOutline, sameRail } from "./rail.js";
9
10
  import { firstRowId, parseBashExitMeta } from "./rows.js";
10
11
  import { failureTooltip, markRunFailures } from "./run-failures.js";
11
12
  import { computeSelectStops, rowTurnIds, stopForRow } from "./select-stops.js";
12
- export { authFailureDetails, batchTaskRuns, batchThinkingRuns, batchToolRuns, clusterByOwner, collapseEvents, computeSelectStops, createAuthFixes, dockRunReceipts, dotVariantFor, exchangesMedia, failureTooltip, findLastStreamingRow, firstRowId, foldActionItems, foldExchanges, foldWorkerRows, inheritRowIdentity, isAuthFixed, markRunFailures, mediaRefsOf, mediumKey, nestToolCalls, nestedCallVisible, pairToolEvents, parseBashExitMeta, planAuthCard, refusedSpawn, rowTurnIds, stopForRow, toolAction, toolFailed };
13
+ export { EMPTY_RAIL, authFailureDetails, batchTaskRuns, batchThinkingRuns, batchToolRuns, clusterByOwner, collapseEvents, computeRailModel, computeRailModelParts, computeSelectStops, createAuthFixes, createTranscriptRailStore, dataRowSelector, dockRunReceipts, dotVariantFor, exchangesMedia, failureTooltip, findLastStreamingRow, firstRowId, foldActionItems, foldExchanges, foldWorkerRows, inheritRowIdentity, isAuthFixed, markRunFailures, mediaRefsOf, mediumKey, nestToolCalls, nestedCallVisible, pairToolEvents, parseBashExitMeta, plainPreview, planAuthCard, railWithOutline, refusedSpawn, rowTurnIds, sameRail, stopForRow, toolAction, toolFailed };
@@ -1,5 +1,5 @@
1
1
  import { sameMembers } from "./batch.js";
2
- import { nestedCallShown } from "zidane/chat/pure";
2
+ import { nestedCallShown, noteTranscriptPass } from "zidane/chat/pure";
3
3
  // src/chat/headless/transcript/nesting.ts
4
4
  /**
5
5
  * Whether a nested call's events show: core's `nestedCallShown` (a subagent,
@@ -23,6 +23,7 @@ const callKey = (owner, callId) => `${owner ?? ""}\u0000${callId}`;
23
23
  * @param rows - Rows from {@link collapseEvents}, oldest first.
24
24
  */
25
25
  function nestToolCalls(rows) {
26
+ noteTranscriptPass("nest", rows.length);
26
27
  const calls = /* @__PURE__ */ new Map();
27
28
  for (const row of rows) if (row.kind === "tool" && row.callId) calls.set(callKey(row.childId, row.callId), row);
28
29
  const childrenOf = /* @__PURE__ */ new Map();
@@ -0,0 +1,142 @@
1
+ /**
2
+ * The prompt rail's model: one exchange per prompt the user typed, from the
3
+ * root clusters a transcript paints. An exchange runs from its prompt to the
4
+ * row before the next one, so its span is the prompt and the run that
5
+ * answered it (work, replies, notices). Synthetic prompts (a command's echo,
6
+ * a context note) start no exchange: they read as part of the one they sit
7
+ * in. Rows before the first prompt and subagent blocks belong to none.
8
+ *
9
+ * Pure and cheap: one pass over the root clusters, plus the rows of the
10
+ * exchange's last reply for its excerpt. Previews are cached per row object
11
+ * (a row that did not change keeps its object), so a streamed token costs
12
+ * the preview of the one row it changed.
13
+ */
14
+ import { Readable } from "../store.js";
15
+ import { Cluster, Row } from "./rows.js";
16
+ import { PromptOutlineEntry, RunReceipt } from "zidane/chat/pure";
17
+ /** One exchange on the rail: a typed prompt and the run that answered it. */
18
+ export interface RailExchange {
19
+ /** The prompt row's id: the exchange's id and the row a jump lands on. */
20
+ id: string;
21
+ /** The prompt, on one line. */
22
+ prompt: string;
23
+ /** The exchange's last reply, as plain text on one line; `null` before it wrote any. */
24
+ answer: string | null;
25
+ /** The first painted root row of the exchange (its prompt), where its highlight starts. */
26
+ firstRowId: string;
27
+ /** The last painted root row of the exchange, where its highlight ends. */
28
+ lastRowId: string;
29
+ /** The receipt of the run that answered (model, duration), when it docked one. */
30
+ receipt?: RunReceipt;
31
+ /**
32
+ * A prompt of the session's outline whose history is not loaded yet: no rows (`firstRowId` and `lastRowId` are
33
+ * empty), its turn and where it sits. A jump loads up to `index` first.
34
+ */
35
+ unloaded?: {
36
+ turnId: string;
37
+ index: number;
38
+ };
39
+ }
40
+ /** The rail's exchanges and how any turn maps to the exchange that holds it. */
41
+ export interface RailModel {
42
+ /** The exchanges, oldest first. */
43
+ exchanges: readonly RailExchange[];
44
+ /** Any turn id a root row carries → the id of the exchange holding that row. */
45
+ exchangeOfTurn: ReadonlyMap<string, string>;
46
+ }
47
+ /**
48
+ * The selector of a transcript row's element by its id (`data-row`), quoted for an attribute value.
49
+ *
50
+ * @param id - The row's id.
51
+ */
52
+ export declare function dataRowSelector(id: string): string;
53
+ /** The empty model: no exchange. */
54
+ export declare const EMPTY_RAIL: RailModel;
55
+ /**
56
+ * Markdown as one line of plain text: no fences, marks, link targets or heading hashes.
57
+ *
58
+ * @param text - Markdown source.
59
+ */
60
+ export declare function plainPreview(text: string): string;
61
+ /**
62
+ * Works out the rail's exchanges from the root clusters a transcript paints.
63
+ *
64
+ * @param clusters - The transcript's root clusters, oldest first.
65
+ * @param options - `isHidden`: rows that paint nothing (never a first or last row). `receipts`: the receipts docked on reply rows.
66
+ * @param options.isHidden - Whether a row paints nothing.
67
+ * @param options.receipts - The run receipts, by the id of the reply row they dock on.
68
+ */
69
+ export declare function computeRailModel(clusters: readonly Cluster[], { isHidden, receipts }?: {
70
+ isHidden?: (row: Row) => boolean;
71
+ receipts?: ReadonlyMap<string, RunReceipt>;
72
+ }): RailModel;
73
+ /**
74
+ * {@link computeRailModel} over the two parts an incremental transcript paints: the settled
75
+ * clusters fold once (per clusters array), each stream tick folds the open ones. The settled
76
+ * exchanges' rail entries keep their objects, and the turn map reads through to theirs.
77
+ *
78
+ * @param parts - The settled and the open root clusters.
79
+ * @param parts.settled - The settled exchanges' clusters and receipts.
80
+ * @param parts.settled.clusters - The settled root clusters (one fold per array).
81
+ * @param parts.settled.receipts - The receipts docked on them.
82
+ * @param parts.open - The open exchange's clusters.
83
+ * @param parts.open.clusters - The open root clusters.
84
+ * @param options - As {@link computeRailModel}'s; `receipts` holds both parts'.
85
+ * @param options.isHidden - Whether a row paints nothing.
86
+ * @param options.receipts - The run receipts, by the id of the reply row they dock on.
87
+ */
88
+ export declare function computeRailModelParts(parts: {
89
+ settled: {
90
+ clusters: readonly Cluster[];
91
+ receipts?: ReadonlyMap<string, RunReceipt>;
92
+ };
93
+ open: {
94
+ clusters: readonly Cluster[];
95
+ };
96
+ }, { isHidden, receipts }?: {
97
+ isHidden?: (row: Row) => boolean;
98
+ receipts?: ReadonlyMap<string, RunReceipt>;
99
+ }): RailModel;
100
+ /**
101
+ * The rail with the session's whole outline: the outline's prompts before the first loaded one (their history is
102
+ * not loaded yet) as unloaded exchanges, then the loaded exchanges. The same array when there are none to add.
103
+ *
104
+ * @param model - The loaded exchanges.
105
+ * @param outline - The session's prompts, oldest first, or `null` when there is none (all loaded, or the host can't say).
106
+ */
107
+ export declare function railWithOutline(model: RailModel, outline: readonly PromptOutlineEntry[] | null): readonly RailExchange[];
108
+ /**
109
+ * Whether two exchange lists show the same rail: same exchanges, same text, same span and receipt.
110
+ *
111
+ * @param a - One list.
112
+ * @param b - The other.
113
+ */
114
+ export declare function sameRail(a: readonly RailExchange[], b: readonly RailExchange[]): boolean;
115
+ /** What a {@link TranscriptRailStore} holds: the transcript's exchanges and what the reader points at. */
116
+ export interface TranscriptRailState extends RailModel {
117
+ /** The exchange under the pointer on the rail (its rows tint), or `null`. */
118
+ hovered: string | null;
119
+ /** The exchange holding select-turn mode's cursor, or `null` outside the mode. */
120
+ selected: string | null;
121
+ /** The session's whole prompt outline while part of its history is not loaded; `null` otherwise. */
122
+ outline: readonly PromptOutlineEntry[] | null;
123
+ /** Loads the history up to a turn position (`Transcript.loadThrough`); `null`: unloaded prompts can't be reached. */
124
+ loadThrough: ((index: number) => Promise<boolean>) | null;
125
+ }
126
+ /**
127
+ * The bridge between a transcript and its rail: the transcript publishes its
128
+ * exchanges and the cursor's exchange, the rail publishes what it hovers.
129
+ * Each write notifies only when it changes something.
130
+ */
131
+ export interface TranscriptRailStore extends Readable<TranscriptRailState> {
132
+ /** The transcript's exchanges (`EMPTY_RAIL` once it unmounts). */
133
+ publish: (model: RailModel) => void;
134
+ /** The exchange the rail hovers, or `null`. */
135
+ hover: (id: string | null) => void;
136
+ /** The exchange holding select-turn mode's cursor, or `null`. */
137
+ select: (id: string | null) => void;
138
+ /** The session's outline (`null`: none, all is loaded) and how to load up to one of its prompts. */
139
+ publishOutline: (outline: readonly PromptOutlineEntry[] | null, loadThrough: ((index: number) => Promise<boolean>) | null) => void;
140
+ }
141
+ /** A rail store with no exchange: one per transcript view (the provider makes it). */
142
+ export declare function createTranscriptRailStore(): TranscriptRailStore;
@@ -0,0 +1,290 @@
1
+ import { writable } from "../store.js";
2
+ import { rowTurnIds } from "./select-stops.js";
3
+ import { noteTranscriptPass } from "zidane/chat/pure";
4
+ // src/chat/headless/transcript/rail.ts
5
+ /** The longest text an exchange keeps for its preview: the card clamps its lines, this bounds the work. */
6
+ const PREVIEW_CHARS = 320;
7
+ /**
8
+ * The most source a preview reads. Markdown marks and fences take room the plain text does not, hence the margin; a
9
+ * reply that opens with a longer code block previews only what follows it within this window.
10
+ */
11
+ const PREVIEW_SOURCE_CHARS = PREVIEW_CHARS * 4;
12
+ /**
13
+ * The selector of a transcript row's element by its id (`data-row`), quoted for an attribute value.
14
+ *
15
+ * @param id - The row's id.
16
+ */
17
+ function dataRowSelector(id) {
18
+ return `[data-row="${id.replace(/["\\]/g, (c) => `\\${c}`)}"]`;
19
+ }
20
+ /** The empty model: no exchange. */
21
+ const EMPTY_RAIL = {
22
+ exchanges: [],
23
+ exchangeOfTurn: /* @__PURE__ */ new Map()
24
+ };
25
+ /**
26
+ * Markdown as one line of plain text: no fences, marks, link targets or heading hashes.
27
+ *
28
+ * @param text - Markdown source.
29
+ */
30
+ function plainPreview(text) {
31
+ const plain = text.slice(0, PREVIEW_SOURCE_CHARS).replace(/```[\s\S]*?(?:```|$)/g, " ").replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/^\s{0,3}(?:#{1,6}|[>\-*+]|\d+[.)])\s+/gm, "").replace(/(\*\*|__|~~|`)/g, "").replace(/\s+/g, " ").trim();
32
+ return plain.length > PREVIEW_CHARS ? `${plain.slice(0, PREVIEW_CHARS).trimEnd()}…` : plain;
33
+ }
34
+ const previews = /* @__PURE__ */ new WeakMap();
35
+ /** A text row's {@link plainPreview}, once per row object. */
36
+ function previewOf(row) {
37
+ let preview = previews.get(row);
38
+ if (preview === void 0) {
39
+ preview = plainPreview(row.text);
40
+ previews.set(row, preview);
41
+ }
42
+ return preview;
43
+ }
44
+ /** The rows a root row stands for, deepest last: what a fold or a message group holds. */
45
+ function* rowsWithin(row) {
46
+ yield row;
47
+ if (row.kind === "exchange-fold") for (const r of row.rows) yield* rowsWithin(r);
48
+ if (row.kind === "message-group") {
49
+ for (const r of row.messages) yield* rowsWithin(r);
50
+ for (const r of row.between) yield* rowsWithin(r);
51
+ yield* rowsWithin(row.current);
52
+ }
53
+ }
54
+ /**
55
+ * Works out the rail's exchanges from the root clusters a transcript paints.
56
+ *
57
+ * @param clusters - The transcript's root clusters, oldest first.
58
+ * @param options - `isHidden`: rows that paint nothing (never a first or last row). `receipts`: the receipts docked on reply rows.
59
+ * @param options.isHidden - Whether a row paints nothing.
60
+ * @param options.receipts - The run receipts, by the id of the reply row they dock on.
61
+ */
62
+ function computeRailModel(clusters, { isHidden = () => false, receipts } = {}) {
63
+ const fold = railFold();
64
+ foldRail(fold, clusters, isHidden, receipts);
65
+ closeRail(fold, receipts);
66
+ return {
67
+ exchanges: fold.exchanges,
68
+ exchangeOfTurn: fold.exchangeOfTurn
69
+ };
70
+ }
71
+ /** Two turn maps read as one: the settled exchanges' and the open part's (which wins). */
72
+ var LayeredTurns = class {
73
+ base;
74
+ top = /* @__PURE__ */ new Map();
75
+ constructor(base) {
76
+ this.base = base;
77
+ }
78
+ get size() {
79
+ let n = this.base.size;
80
+ for (const key of this.top.keys()) n += this.base.has(key) ? 0 : 1;
81
+ return n;
82
+ }
83
+ get(key) {
84
+ return this.top.has(key) ? this.top.get(key) : this.base.get(key);
85
+ }
86
+ has(key) {
87
+ return this.top.has(key) || this.base.has(key);
88
+ }
89
+ set(key, value) {
90
+ this.top.set(key, value);
91
+ return this;
92
+ }
93
+ forEach(callback) {
94
+ for (const [key, value] of this) callback(value, key, this);
95
+ }
96
+ *entries() {
97
+ for (const [key, value] of this.base) if (!this.top.has(key)) yield [key, value];
98
+ yield* this.top.entries();
99
+ }
100
+ *keys() {
101
+ for (const [key] of this.entries()) yield key;
102
+ }
103
+ *values() {
104
+ for (const [, value] of this.entries()) yield value;
105
+ }
106
+ [Symbol.iterator]() {
107
+ return this.entries();
108
+ }
109
+ };
110
+ function railFold(base) {
111
+ if (!base) return {
112
+ exchanges: [],
113
+ shared: false,
114
+ exchangeOfTurn: /* @__PURE__ */ new Map(),
115
+ current: null,
116
+ lastReply: null
117
+ };
118
+ return {
119
+ exchanges: base.exchanges,
120
+ shared: true,
121
+ exchangeOfTurn: new LayeredTurns(base.exchangeOfTurn),
122
+ current: base.current ? { ...base.current } : null,
123
+ lastReply: base.lastReply
124
+ };
125
+ }
126
+ function closeRail(fold, receipts) {
127
+ const current = fold.current;
128
+ if (!current) return;
129
+ const lastReply = fold.lastReply;
130
+ if (lastReply && lastReply.kind === "markdown") {
131
+ current.answer = previewOf(lastReply) || null;
132
+ const receipt = receipts?.get(lastReply.id);
133
+ if (receipt) current.receipt = receipt;
134
+ }
135
+ if (fold.shared) {
136
+ fold.exchanges = [...fold.exchanges];
137
+ fold.shared = false;
138
+ }
139
+ fold.exchanges.push(current);
140
+ fold.current = null;
141
+ fold.lastReply = null;
142
+ }
143
+ function foldRail(fold, clusters, isHidden, receipts) {
144
+ noteTranscriptPass("rail", clusters.length);
145
+ for (const cluster of clusters) {
146
+ if (cluster.kind !== "single") continue;
147
+ const row = cluster.row;
148
+ if (isHidden(row)) continue;
149
+ if (row.kind === "user-prompt" && !row.synthetic && row.childId === void 0) {
150
+ closeRail(fold, receipts);
151
+ fold.current = {
152
+ id: row.id,
153
+ prompt: previewOf(row),
154
+ answer: null,
155
+ firstRowId: row.id,
156
+ lastRowId: row.id
157
+ };
158
+ }
159
+ const current = fold.current;
160
+ if (!current) continue;
161
+ current.lastRowId = row.id;
162
+ for (const id of rowTurnIds(row)) if (!fold.exchangeOfTurn.has(id)) fold.exchangeOfTurn.set(id, current.id);
163
+ for (const inner of rowsWithin(row)) if (inner.kind === "markdown" && inner.text.trim() !== "") fold.lastReply = inner;
164
+ }
165
+ }
166
+ /** The settled clusters' fold, per clusters array (its rows keep their identity while only the open exchange changes). */
167
+ const settledRails = /* @__PURE__ */ new WeakMap();
168
+ /**
169
+ * {@link computeRailModel} over the two parts an incremental transcript paints: the settled
170
+ * clusters fold once (per clusters array), each stream tick folds the open ones. The settled
171
+ * exchanges' rail entries keep their objects, and the turn map reads through to theirs.
172
+ *
173
+ * @param parts - The settled and the open root clusters.
174
+ * @param parts.settled - The settled exchanges' clusters and receipts.
175
+ * @param parts.settled.clusters - The settled root clusters (one fold per array).
176
+ * @param parts.settled.receipts - The receipts docked on them.
177
+ * @param parts.open - The open exchange's clusters.
178
+ * @param parts.open.clusters - The open root clusters.
179
+ * @param options - As {@link computeRailModel}'s; `receipts` holds both parts'.
180
+ * @param options.isHidden - Whether a row paints nothing.
181
+ * @param options.receipts - The run receipts, by the id of the reply row they dock on.
182
+ */
183
+ function computeRailModelParts(parts, { isHidden = () => false, receipts } = {}) {
184
+ const { settled, open } = parts;
185
+ let hit = settledRails.get(settled.clusters);
186
+ const settledReceipts = settled.receipts ?? receipts;
187
+ if (!hit || hit.isHidden !== isHidden || hit.receipts !== settledReceipts) {
188
+ const fold = railFold();
189
+ foldRail(fold, settled.clusters, isHidden, settledReceipts);
190
+ hit = {
191
+ isHidden,
192
+ receipts: settledReceipts,
193
+ fold
194
+ };
195
+ settledRails.set(settled.clusters, hit);
196
+ }
197
+ const fold = railFold(hit.fold);
198
+ foldRail(fold, open.clusters, isHidden, receipts);
199
+ closeRail(fold, receipts);
200
+ return {
201
+ exchanges: fold.exchanges,
202
+ exchangeOfTurn: fold.exchangeOfTurn
203
+ };
204
+ }
205
+ /**
206
+ * The rail with the session's whole outline: the outline's prompts before the first loaded one (their history is
207
+ * not loaded yet) as unloaded exchanges, then the loaded exchanges. The same array when there are none to add.
208
+ *
209
+ * @param model - The loaded exchanges.
210
+ * @param outline - The session's prompts, oldest first, or `null` when there is none (all loaded, or the host can't say).
211
+ */
212
+ function railWithOutline(model, outline) {
213
+ if (!outline || outline.length === 0) return model.exchanges;
214
+ const unloaded = [];
215
+ for (const prompt of outline) {
216
+ if (model.exchangeOfTurn.has(prompt.turnId)) break;
217
+ unloaded.push({
218
+ id: `outline:${prompt.turnId}`,
219
+ prompt: prompt.text,
220
+ answer: null,
221
+ firstRowId: "",
222
+ lastRowId: "",
223
+ unloaded: {
224
+ turnId: prompt.turnId,
225
+ index: prompt.index
226
+ }
227
+ });
228
+ }
229
+ if (unloaded.length === outline.length && model.exchanges.length > 0) return model.exchanges;
230
+ return unloaded.length > 0 ? [...unloaded, ...model.exchanges] : model.exchanges;
231
+ }
232
+ /**
233
+ * Whether two exchange lists show the same rail: same exchanges, same text, same span and receipt.
234
+ *
235
+ * @param a - One list.
236
+ * @param b - The other.
237
+ */
238
+ function sameRail(a, b) {
239
+ if (a === b) return true;
240
+ if (a.length !== b.length) return false;
241
+ return a.every((x, i) => {
242
+ const y = b[i];
243
+ return x.id === y.id && x.prompt === y.prompt && x.answer === y.answer && x.firstRowId === y.firstRowId && x.lastRowId === y.lastRowId && x.receipt === y.receipt;
244
+ });
245
+ }
246
+ /** Whether two turn maps send every turn to the same exchange. */
247
+ function sameTurns(a, b) {
248
+ if (a === b) return true;
249
+ if (a instanceof LayeredTurns && b instanceof LayeredTurns && a.base === b.base) {
250
+ if (a.top.size !== b.top.size) return false;
251
+ for (const [turn, exchange] of a.top) if (b.top.get(turn) !== exchange) return false;
252
+ return true;
253
+ }
254
+ if (a.size !== b.size) return false;
255
+ for (const [turn, exchange] of a) if (b.get(turn) !== exchange) return false;
256
+ return true;
257
+ }
258
+ /** A rail store with no exchange: one per transcript view (the provider makes it). */
259
+ function createTranscriptRailStore() {
260
+ const state = writable({
261
+ ...EMPTY_RAIL,
262
+ hovered: null,
263
+ selected: null,
264
+ outline: null,
265
+ loadThrough: null
266
+ });
267
+ return {
268
+ get: state.get,
269
+ subscribe: state.subscribe,
270
+ publish: (model) => state.set((prev) => sameRail(prev.exchanges, model.exchanges) && sameTurns(prev.exchangeOfTurn, model.exchangeOfTurn) ? prev : {
271
+ ...prev,
272
+ ...model,
273
+ hovered: model.exchanges.some((e) => e.id === prev.hovered) ? prev.hovered : null
274
+ }),
275
+ hover: (id) => state.set((prev) => prev.hovered === id ? prev : {
276
+ ...prev,
277
+ hovered: id
278
+ }),
279
+ select: (id) => state.set((prev) => prev.selected === id ? prev : {
280
+ ...prev,
281
+ selected: id
282
+ }),
283
+ publishOutline: (outline, loadThrough) => state.set((prev) => prev.outline === outline && prev.loadThrough === loadThrough ? prev : {
284
+ ...prev,
285
+ outline,
286
+ loadThrough
287
+ })
288
+ };
289
+ }
290
+ export { EMPTY_RAIL, computeRailModel, computeRailModelParts, createTranscriptRailStore, dataRowSelector, plainPreview, railWithOutline, sameRail };
@@ -106,6 +106,12 @@ export type Row = (Owned & {
106
106
  resume: 'continue' | 'retry';
107
107
  prompt?: string;
108
108
  };
109
+ /**
110
+ * The broken environment this error stopped on (`detail.environment`) was
111
+ * set up again, or answered again, later in the transcript (`markRunFailures`):
112
+ * it reads as one quiet line, the error kept for its tooltip.
113
+ */
114
+ repaired?: true;
109
115
  }) | (Owned & {
110
116
  /**
111
117
  * Orchestration: a worker session (created/steered by the pinned
@@ -225,8 +231,12 @@ export type Row = (Owned & {
225
231
  ok: boolean | null;
226
232
  /** Wire id of the call — the key for the lazy full-result fetch. */
227
233
  callId?: string;
228
- /** True when `result` was clipped main-side (expand offers a full fetch). */
234
+ /** True when the host clipped `result` for the wire (`clipped.result`; expand offers a full fetch). */
229
235
  resultClipped?: boolean;
236
+ /** Per media block of the result, the blob it is held as (`StreamEvent.mediaRefs`): its address by hash. */
237
+ mediaRefs?: readonly (string | null)[];
238
+ /** True when the host clipped `rawInput` for the wire (`clipped.input`; expand offers the whole input). */
239
+ inputClipped?: boolean;
230
240
  /**
231
241
  * Timing, from the host: `startedAt` while the call is unpaired (its
232
242
  * `tool` event's), `durationMs` once its result landed (its