zidane-ui 9.2.3 → 9.4.0

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 (354) hide show
  1. package/dist/adapters/live.d.ts +8 -0
  2. package/dist/adapters/live.js +19 -8
  3. package/dist/adapters/server-composer-host.js +22 -9
  4. package/dist/adapters/server-git-host.js +5 -2
  5. package/dist/adapters/server-host.js +158 -27
  6. package/dist/adapters/server-machines-host.js +7 -0
  7. package/dist/adapters/server-media.d.ts +9 -1
  8. package/dist/adapters/server-media.js +14 -1
  9. package/dist/adapters/server-session-host.js +49 -0
  10. package/dist/adapters/server-settings-sections.js +4 -1
  11. package/dist/adapters/sse-host.js +3 -0
  12. package/dist/adapters/sse-protocol.d.ts +10 -0
  13. package/dist/appearance/ZoomIndicator.js +5 -8
  14. package/dist/chat/HostTranscript.d.ts +0 -12
  15. package/dist/chat/HostTranscript.js +20 -1
  16. package/dist/chat/SessionStreamsProvider.d.ts +9 -1
  17. package/dist/chat/SessionStreamsProvider.js +11 -2
  18. package/dist/chat/Transcript.d.ts +21 -11
  19. package/dist/chat/Transcript.js +346 -161
  20. package/dist/chat/composer/ModelOptionsPicker.js +6 -2
  21. package/dist/chat/composer/ModelPicker.d.ts +1 -1
  22. package/dist/chat/composer/PlacePicker.d.ts +3 -1
  23. package/dist/chat/composer/PlacePicker.js +5 -1
  24. package/dist/chat/composer/use-draft-target.js +15 -3
  25. package/dist/chat/headless/block-runs.js +26 -1
  26. package/dist/chat/headless/chip-views.js +1 -1
  27. package/dist/chat/headless/draft-target.d.ts +28 -1
  28. package/dist/chat/headless/draft-target.js +22 -1
  29. package/dist/chat/headless/host.d.ts +43 -7
  30. package/dist/chat/headless/hosts.d.ts +4 -0
  31. package/dist/chat/headless/index.d.ts +27 -26
  32. package/dist/chat/headless/index.js +15 -14
  33. package/dist/chat/headless/labels.d.ts +17 -0
  34. package/dist/chat/headless/labels.js +17 -0
  35. package/dist/chat/headless/markdown-chunks.d.ts +2 -1
  36. package/dist/chat/headless/markdown-chunks.js +12 -20
  37. package/dist/chat/headless/markdown-scan.d.ts +64 -0
  38. package/dist/chat/headless/markdown-scan.js +119 -0
  39. package/dist/chat/headless/markdown-stream.d.ts +64 -0
  40. package/dist/chat/headless/markdown-stream.js +143 -0
  41. package/dist/chat/headless/output-pager.d.ts +68 -0
  42. package/dist/chat/headless/output-pager.js +113 -0
  43. package/dist/chat/headless/prompt-origin.d.ts +2 -0
  44. package/dist/chat/headless/prompt-origin.js +6 -2
  45. package/dist/chat/headless/session-list.d.ts +10 -0
  46. package/dist/chat/headless/sidebar/activity.d.ts +14 -0
  47. package/dist/chat/headless/sidebar/activity.js +32 -0
  48. package/dist/chat/headless/sidebar/directory.d.ts +19 -2
  49. package/dist/chat/headless/sidebar/directory.js +19 -51
  50. package/dist/chat/headless/sidebar/environment.d.ts +15 -4
  51. package/dist/chat/headless/sidebar/environment.js +27 -9
  52. package/dist/chat/headless/sidebar/index.d.ts +2 -2
  53. package/dist/chat/headless/sidebar/index.js +2 -2
  54. package/dist/chat/headless/sidebar/labels.d.ts +19 -2
  55. package/dist/chat/headless/sidebar/labels.js +8 -1
  56. package/dist/chat/headless/sidebar/prewarm.d.ts +68 -0
  57. package/dist/chat/headless/sidebar/prewarm.js +114 -0
  58. package/dist/chat/headless/streams/actions.d.ts +4 -2
  59. package/dist/chat/headless/streams/actions.js +2 -1
  60. package/dist/chat/headless/streams/event-bytes.d.ts +17 -0
  61. package/dist/chat/headless/streams/event-bytes.js +46 -0
  62. package/dist/chat/headless/streams/live-events.d.ts +25 -1
  63. package/dist/chat/headless/streams/live-events.js +53 -2
  64. package/dist/chat/headless/streams/selectors.d.ts +3 -0
  65. package/dist/chat/headless/streams/selectors.js +8 -1
  66. package/dist/chat/headless/streams/session-streams.d.ts +15 -3
  67. package/dist/chat/headless/streams/session-streams.js +31 -3
  68. package/dist/chat/headless/streams/store.d.ts +45 -6
  69. package/dist/chat/headless/streams/store.js +85 -31
  70. package/dist/chat/headless/streams/transcript-map.d.ts +57 -0
  71. package/dist/chat/headless/streams/transcript-map.js +85 -0
  72. package/dist/chat/headless/streams/transcript.d.ts +4 -2
  73. package/dist/chat/headless/streams/transcript.js +19 -7
  74. package/dist/chat/headless/streams/types.d.ts +2 -1
  75. package/dist/chat/headless/transcript/batch.js +5 -1
  76. package/dist/chat/headless/transcript/blob-media.d.ts +15 -0
  77. package/dist/chat/headless/transcript/blob-media.js +23 -0
  78. package/dist/chat/headless/transcript/collapse.d.ts +10 -0
  79. package/dist/chat/headless/transcript/collapse.js +35 -6
  80. package/dist/chat/headless/transcript/derive.d.ts +98 -0
  81. package/dist/chat/headless/transcript/derive.js +89 -0
  82. package/dist/chat/headless/transcript/exchange-media.d.ts +3 -1
  83. package/dist/chat/headless/transcript/exchange-media.js +8 -5
  84. package/dist/chat/headless/transcript/fold-attachments.d.ts +2 -0
  85. package/dist/chat/headless/transcript/fold-attachments.js +3 -2
  86. package/dist/chat/headless/transcript/fold.d.ts +2 -1
  87. package/dist/chat/headless/transcript/fold.js +16 -6
  88. package/dist/chat/headless/transcript/incremental.d.ts +53 -0
  89. package/dist/chat/headless/transcript/incremental.js +181 -0
  90. package/dist/chat/headless/transcript/index.d.ts +2 -2
  91. package/dist/chat/headless/transcript/index.js +2 -2
  92. package/dist/chat/headless/transcript/nesting.js +2 -1
  93. package/dist/chat/headless/transcript/rail.d.ts +50 -1
  94. package/dist/chat/headless/transcript/rail.js +165 -23
  95. package/dist/chat/headless/transcript/rows.d.ts +5 -1
  96. package/dist/chat/headless/transcript/run-failures.js +2 -1
  97. package/dist/chat/headless/transcript/seams.d.ts +78 -0
  98. package/dist/chat/headless/transcript/seams.js +116 -0
  99. package/dist/chat/headless/transcript/tool-media.d.ts +6 -7
  100. package/dist/chat/headless/transcript/tool-media.js +27 -9
  101. package/dist/chat/index.d.ts +9 -8
  102. package/dist/chat/index.js +18 -17
  103. package/dist/chat/sidebar/ProjectIcon.js +1 -1
  104. package/dist/chat/sidebar/RowChips.js +2 -2
  105. package/dist/chat/sidebar/SessionSidebar.d.ts +6 -0
  106. package/dist/chat/sidebar/SessionSidebar.js +23 -16
  107. package/dist/chat/sidebar/SidebarFilterMenu.js +0 -1
  108. package/dist/chat/sidebar/SidebarFold.js +17 -16
  109. package/dist/chat/sidebar/SidebarFooter.d.ts +8 -5
  110. package/dist/chat/sidebar/SidebarFooter.js +6 -6
  111. package/dist/chat/sidebar/SidebarSessionRow.d.ts +7 -1
  112. package/dist/chat/sidebar/SidebarSessionRow.js +11 -8
  113. package/dist/chat/sidebar/session-menu.d.ts +4 -0
  114. package/dist/chat/sidebar/session-menu.js +14 -2
  115. package/dist/chat/sidebar/sidebar-live.js +28 -4
  116. package/dist/chat/sidebar/useInboxRows.js +6 -6
  117. package/dist/chat/sidebar/useInboxTriage.js +50 -47
  118. package/dist/chat/sidebar/useSessionSearch.js +19 -18
  119. package/dist/chat/testing/contract.d.ts +5 -3
  120. package/dist/chat/testing/contract.js +66 -1
  121. package/dist/chat/transcript/DiffLines.d.ts +6 -1
  122. package/dist/chat/transcript/DiffLines.js +35 -20
  123. package/dist/chat/transcript/EditDiffBlock.d.ts +5 -1
  124. package/dist/chat/transcript/EditDiffBlock.js +89 -30
  125. package/dist/chat/transcript/FileChip.js +28 -0
  126. package/dist/chat/transcript/LazyRow.d.ts +40 -40
  127. package/dist/chat/transcript/LazyRow.js +100 -149
  128. package/dist/chat/transcript/MermaidDiagram.js +2 -1
  129. package/dist/chat/transcript/PromptEcho.js +3 -11
  130. package/dist/chat/transcript/SessionChip.d.ts +11 -0
  131. package/dist/chat/transcript/SessionChip.js +34 -0
  132. package/dist/chat/transcript/SubagentBlock.js +3 -2
  133. package/dist/chat/transcript/TranscriptRail.d.ts +25 -2
  134. package/dist/chat/transcript/TranscriptRail.js +175 -17
  135. package/dist/chat/transcript/TranscriptRow.d.ts +4 -7
  136. package/dist/chat/transcript/TranscriptRow.js +4 -3
  137. package/dist/chat/transcript/actions.d.ts +37 -1
  138. package/dist/chat/transcript/actions.js +27 -1
  139. package/dist/chat/transcript/chip-details.d.ts +11 -0
  140. package/dist/chat/transcript/chip-details.js +17 -1
  141. package/dist/chat/transcript/clipped-output.d.ts +58 -0
  142. package/dist/chat/transcript/clipped-output.js +131 -0
  143. package/dist/chat/transcript/fold-attachments.js +10 -5
  144. package/dist/chat/transcript/fold-worker.js +5 -3
  145. package/dist/chat/transcript/fold.js +13 -4
  146. package/dist/chat/transcript/index.d.ts +11 -10
  147. package/dist/chat/transcript/index.js +10 -9
  148. package/dist/chat/transcript/markdown-cache.d.ts +17 -2
  149. package/dist/chat/transcript/markdown-cache.js +48 -4
  150. package/dist/chat/transcript/markdown.js +110 -55
  151. package/dist/chat/transcript/media-gallery.d.ts +3 -2
  152. package/dist/chat/transcript/media-gallery.js +19 -19
  153. package/dist/chat/transcript/messages.js +5 -4
  154. package/dist/chat/transcript/notices.js +2 -1
  155. package/dist/chat/transcript/prompt.d.ts +1 -1
  156. package/dist/chat/transcript/prompt.js +6 -4
  157. package/dist/chat/transcript/prose.js +2 -1
  158. package/dist/chat/transcript/root-items.d.ts +96 -0
  159. package/dist/chat/transcript/root-items.js +180 -0
  160. package/dist/chat/transcript/row-mount.d.ts +184 -0
  161. package/dist/chat/transcript/row-mount.js +532 -0
  162. package/dist/chat/transcript/row-parking.d.ts +152 -0
  163. package/dist/chat/transcript/row-parking.js +171 -0
  164. package/dist/chat/transcript/row-ui-state.d.ts +37 -0
  165. package/dist/chat/transcript/row-ui-state.js +53 -0
  166. package/dist/chat/transcript/run-rows.js +3 -2
  167. package/dist/chat/transcript/script-input.d.ts +1 -1
  168. package/dist/chat/transcript/tasks.js +3 -2
  169. package/dist/chat/transcript/tool-media.d.ts +4 -2
  170. package/dist/chat/transcript/tool-media.js +15 -7
  171. package/dist/chat/transcript/tool-parts.d.ts +27 -4
  172. package/dist/chat/transcript/tool-parts.js +31 -6
  173. package/dist/chat/transcript/tool-payload.js +26 -11
  174. package/dist/chat/transcript/tool-row.d.ts +2 -1
  175. package/dist/chat/transcript/tool-row.js +38 -19
  176. package/dist/chat/transcript/use-transcript-rows.d.ts +25 -8
  177. package/dist/chat/transcript/use-transcript-rows.js +28 -46
  178. package/dist/chat/transcript/useHistoryBackfill.d.ts +42 -0
  179. package/dist/chat/transcript/useHistoryBackfill.js +170 -0
  180. package/dist/chat/transcript/useStickToBottom.js +2 -3
  181. package/dist/chat/transcript/useTranscriptFind.js +2 -4
  182. package/dist/chat/transcript/useTranscriptScroll.d.ts +7 -4
  183. package/dist/chat/transcript/useTranscriptScroll.js +12 -1
  184. package/dist/chat/transcript/useTranscriptSearch.d.ts +2 -2
  185. package/dist/chat/transcript/useTranscriptSearch.js +35 -19
  186. package/dist/chat/transcript/useTranscriptSelectionCopy.d.ts +5 -5
  187. package/dist/chat/transcript/useTranscriptSelectionCopy.js +28 -7
  188. package/dist/chat/transcript/view-scope.d.ts +26 -6
  189. package/dist/chat/transcript/view-scope.js +106 -20
  190. package/dist/code/editor/FileTree.d.ts +2 -0
  191. package/dist/code/editor/FileTree.js +1 -1
  192. package/dist/code/editor/FileView.js +16 -25
  193. package/dist/code/editor/find/useFind.js +17 -17
  194. package/dist/code/editor/useCodeDocument.js +22 -19
  195. package/dist/code/editor/useDetachCleanup.js +4 -3
  196. package/dist/code/use-highlighted-html.js +12 -13
  197. package/dist/components/IconButton.d.ts +3 -1
  198. package/dist/components/IconButton.js +7 -2
  199. package/dist/components/IconButtonTip.d.ts +3 -1
  200. package/dist/components/IconButtonTip.js +2 -1
  201. package/dist/components/RowActionsMenu.js +7 -14
  202. package/dist/components/Tooltip.d.ts +4 -1
  203. package/dist/components/Tooltip.js +8 -6
  204. package/dist/components/assign-ref.d.ts +8 -0
  205. package/dist/components/assign-ref.js +12 -0
  206. package/dist/components/floating/FloatingSurface.js +2 -2
  207. package/dist/components/floating/HoverCard.js +32 -14
  208. package/dist/components/floating/Popover.js +4 -7
  209. package/dist/components/floating/useAnchoredPosition.d.ts +5 -3
  210. package/dist/components/floating/useAnchoredPosition.js +7 -7
  211. package/dist/components/object-key.d.ts +7 -0
  212. package/dist/components/object-key.js +18 -0
  213. package/dist/components/palette/PaletteList.js +2 -7
  214. package/dist/components/tooltip-arming.d.ts +3 -0
  215. package/dist/components/tooltip-arming.js +8 -1
  216. package/dist/core.css +3 -3
  217. package/dist/dist/{index-E1Z0aPmi.d.ts → index-BheVJOLc.d.ts} +3 -1
  218. package/dist/dist/index.d.ts +2 -2
  219. package/dist/files/FilesTab.js +0 -1
  220. package/dist/files/TreeColumn.d.ts +2 -4
  221. package/dist/files/TreeColumn.js +0 -5
  222. package/dist/files/headless/host.d.ts +3 -7
  223. package/dist/files/headless/labels.d.ts +0 -1
  224. package/dist/files/headless/labels.js +0 -1
  225. package/dist/files/headless/workspace-diff.js +1 -1
  226. package/dist/files/useCodeReview.js +1 -3
  227. package/dist/files/useFilesDiagnostics.d.ts +1 -1
  228. package/dist/files/useFilesDiagnostics.js +4 -11
  229. package/dist/files/useOpenFiles.js +9 -12
  230. package/dist/files/useWorkspace.d.ts +5 -7
  231. package/dist/files/useWorkspace.js +4 -15
  232. package/dist/git/GitBar.js +5 -3
  233. package/dist/git/MoveSessionDialog.d.ts +18 -8
  234. package/dist/git/MoveSessionDialog.js +32 -53
  235. package/dist/git/MoveToDialog.d.ts +61 -0
  236. package/dist/git/MoveToDialog.js +240 -0
  237. package/dist/git/SandboxManager.js +9 -4
  238. package/dist/git/SyncChip.js +11 -4
  239. package/dist/git/TeleportSessionDialog.d.ts +69 -0
  240. package/dist/git/TeleportSessionDialog.js +440 -0
  241. package/dist/git/headless/host.d.ts +14 -0
  242. package/dist/git/headless/index.d.ts +2 -1
  243. package/dist/git/headless/index.js +2 -1
  244. package/dist/git/headless/labels.d.ts +44 -1
  245. package/dist/git/headless/labels.js +50 -0
  246. package/dist/git/headless/sandboxes.d.ts +1 -1
  247. package/dist/git/headless/sandboxes.js +4 -3
  248. package/dist/git/headless/teleport.d.ts +76 -0
  249. package/dist/git/headless/teleport.js +19 -0
  250. package/dist/git/index.d.ts +4 -2
  251. package/dist/git/index.js +4 -2
  252. package/dist/git/useEnvironmentChoices.d.ts +5 -2
  253. package/dist/git/useEnvironmentChoices.js +12 -4
  254. package/dist/hooks/useLatest.d.ts +8 -0
  255. package/dist/hooks/useLatest.js +17 -0
  256. package/dist/hooks/useMinuteTick.d.ts +6 -2
  257. package/dist/hooks/useMinuteTick.js +12 -6
  258. package/dist/hooks/useNearViewport.js +11 -8
  259. package/dist/index.d.ts +3 -2
  260. package/dist/index.js +2 -1
  261. package/dist/keybindings/KeybindingsProvider.js +3 -4
  262. package/dist/keybindings/headless/catalog.d.ts +1 -1
  263. package/dist/keybindings/headless/catalog.js +18 -0
  264. package/dist/machines/AddServerForm.js +55 -3
  265. package/dist/machines/Banners.d.ts +2 -2
  266. package/dist/machines/Banners.js +3 -3
  267. package/dist/machines/DaemonMenu.js +1 -3
  268. package/dist/machines/HostsSection.js +5 -1
  269. package/dist/machines/OrganizationPanel.d.ts +25 -0
  270. package/dist/machines/OrganizationPanel.js +266 -0
  271. package/dist/machines/PersonalLayerPanel.d.ts +32 -0
  272. package/dist/machines/PersonalLayerPanel.js +360 -0
  273. package/dist/machines/headless/fixture-host.d.ts +10 -0
  274. package/dist/machines/headless/fixture-host.js +44 -0
  275. package/dist/machines/headless/host.d.ts +21 -1
  276. package/dist/machines/headless/index.d.ts +3 -1
  277. package/dist/machines/headless/index.js +3 -1
  278. package/dist/machines/headless/labels.d.ts +55 -0
  279. package/dist/machines/headless/labels.js +58 -1
  280. package/dist/machines/headless/layer.d.ts +64 -0
  281. package/dist/machines/headless/layer.js +56 -0
  282. package/dist/machines/headless/organization.d.ts +38 -0
  283. package/dist/machines/headless/organization.js +44 -0
  284. package/dist/machines/index.d.ts +3 -1
  285. package/dist/machines/index.js +3 -1
  286. package/dist/machines/testing/contract.d.ts +25 -1
  287. package/dist/machines/testing/contract.js +97 -1
  288. package/dist/motion/grow.js +12 -13
  289. package/dist/motion/swap.js +2 -5
  290. package/dist/motion/use-flip-list.d.ts +14 -0
  291. package/dist/motion/use-flip-list.js +17 -12
  292. package/dist/palette/headless/app-sources.js +37 -0
  293. package/dist/palette/headless/labels.js +3 -0
  294. package/dist/server/sse-handler.js +25 -2
  295. package/dist/session/DiffFileTree.js +1 -4
  296. package/dist/session/OpenSessionsDialog.d.ts +46 -0
  297. package/dist/session/OpenSessionsDialog.js +170 -0
  298. package/dist/session/PlanTracker.js +1 -2
  299. package/dist/session/ProjectHome.js +10 -9
  300. package/dist/session/RemindersPanel.js +10 -12
  301. package/dist/session/SecretsPanel.js +2 -1
  302. package/dist/session/SessionHeader.js +1 -0
  303. package/dist/session/SessionPeopleStack.d.ts +23 -0
  304. package/dist/session/SessionPeopleStack.js +65 -0
  305. package/dist/session/SessionPlaceMenu.js +5 -4
  306. package/dist/session/ShareSessionDialog.d.ts +32 -0
  307. package/dist/session/ShareSessionDialog.js +342 -0
  308. package/dist/session/TypingLine.d.ts +22 -0
  309. package/dist/session/TypingLine.js +31 -0
  310. package/dist/session/headless/host.d.ts +40 -1
  311. package/dist/session/headless/index.d.ts +4 -2
  312. package/dist/session/headless/index.js +3 -1
  313. package/dist/session/headless/labels.d.ts +49 -0
  314. package/dist/session/headless/labels.js +56 -0
  315. package/dist/session/headless/people.d.ts +29 -0
  316. package/dist/session/headless/people.js +53 -0
  317. package/dist/session/headless/place.d.ts +5 -0
  318. package/dist/session/headless/place.js +5 -1
  319. package/dist/session/headless/typing.d.ts +37 -0
  320. package/dist/session/headless/typing.js +60 -0
  321. package/dist/session/index.d.ts +5 -1
  322. package/dist/session/index.js +5 -1
  323. package/dist/settings/headless/fixture-performance.js +4 -2
  324. package/dist/settings/headless/performance.d.ts +4 -0
  325. package/dist/settings/headless/search.d.ts +1 -1
  326. package/dist/settings/headless/sections-host.d.ts +7 -2
  327. package/dist/settings/section.d.ts +15 -3
  328. package/dist/settings/section.js +15 -3
  329. package/dist/settings/sections/environments/EnvironmentsSection.js +30 -6
  330. package/dist/settings/sections/keybindings/labels.d.ts +3 -0
  331. package/dist/settings/sections/keybindings/labels.js +3 -0
  332. package/dist/settings/sections/keybindings/rows.js +12 -0
  333. package/dist/settings/sections/logs/LogsSection.js +5 -8
  334. package/dist/settings/sections/performance/PerformanceSection.js +8 -1
  335. package/dist/settings/sections/performance/labels.d.ts +2 -0
  336. package/dist/settings/sections/performance/labels.js +2 -0
  337. package/dist/styles.css +65 -9
  338. package/dist/terminal/HostTerminalSurface.js +28 -30
  339. package/dist/terminal/TerminalPanel.js +4 -12
  340. package/dist/terminal/TerminalProvider.d.ts +10 -2
  341. package/dist/terminal/TerminalProvider.js +10 -2
  342. package/dist/terminal/headless/labels.d.ts +0 -1
  343. package/dist/terminal/headless/labels.js +1 -2
  344. package/dist/terminal/headless/store.js +5 -1
  345. package/dist/views/headless/answers.d.ts +8 -2
  346. package/dist/views/headless/answers.js +58 -1
  347. package/dist/views/headless/placement.d.ts +78 -0
  348. package/dist/views/headless/placement.js +154 -44
  349. package/dist/workspace/LayoutBudget.js +1 -7
  350. package/package.json +2 -2
  351. package/src/styles/chat.css +3 -1
  352. package/src/styles/palette.css +3 -3
  353. package/src/styles/transcript.css +50 -5
  354. /package/dist/dist/{index-De9AbmxS.d.ts → index-ttmMvjgM.d.ts} +0 -0
@@ -3,15 +3,17 @@ import { useExtensionItems } from "../extensions/ExtensionsProvider.js";
3
3
  import { LinkSessionScope } from "../extensions/links.js";
4
4
  import { ViewAnswers } from "../views/headless/answers.js";
5
5
  import { eventsMayHoldViews } from "../views/headless/placement.js";
6
- import { firstRowId } from "./headless/transcript/rows.js";
7
- import { rowTurnIds, stopForRow } from "./headless/transcript/select-stops.js";
6
+ import { stopForRow } from "./headless/transcript/select-stops.js";
8
7
  import { useTranscriptActions } from "./transcript/actions.js";
9
8
  import { DiagramsContext } from "./transcript/diagrams-scope.js";
10
9
  import { LiveScriptsContext } from "./transcript/fold.js";
11
10
  import { RowIconsContext } from "./transcript/frame.js";
12
- import { CvRow, TranscriptSettling } from "./transcript/LazyRow.js";
11
+ import { CvRow, LazyRow, TranscriptSettling, useForcedRows } from "./transcript/LazyRow.js";
13
12
  import { MediaGalleryProvider } from "./transcript/media-gallery.js";
14
- import { rowCvStyle, rowEstimatePx } from "./transcript/row-estimate.js";
13
+ import { endsByRow, groupRowId, matchingItems, rootItems } from "./transcript/root-items.js";
14
+ import { rowCvStyle } from "./transcript/row-estimate.js";
15
+ import { RowMountContext, RowMounter } from "./transcript/row-mount.js";
16
+ import { RowUiStateContext, createRowUiState } from "./transcript/row-ui-state.js";
15
17
  import { SelectCursor } from "./transcript/SelectCursor.js";
16
18
  import { SubagentBlock } from "./transcript/SubagentBlock.js";
17
19
  import { RailTint, useRailPublish } from "./transcript/TranscriptRail.js";
@@ -20,9 +22,61 @@ import { useSelectStops, useTranscriptRows } from "./transcript/use-transcript-r
20
22
  import { useTranscriptSelectionCopy } from "./transcript/useTranscriptSelectionCopy.js";
21
23
  import { CodemodeViewsSlot, ReplyViewPlaces, ViewsScopeContext, useViewsReady, viewsScopeOf } from "./transcript/view-scope.js";
22
24
  import { memo, useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
23
- import { jsx, jsxs } from "react/jsx-runtime";
24
- import { DEFAULT_SETTINGS, runTailActivity } from "zidane/chat/pure";
25
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
26
+ import { DEFAULT_SETTINGS, chunkFact, runTailActivity, transcriptFromArray, transcriptOfArray } from "zidane/chat/pure";
25
27
  // src/chat/Transcript.tsx
28
+ const NO_SLICE = {
29
+ rows: [],
30
+ clusters: []
31
+ };
32
+ const NO_KEYS = [];
33
+ /** The tail that mounts with its first render: `EAGER_SCREENS` views' worth of rows (estimated), never fewer than `EAGER_MIN` rows nor more than `EAGER_MAX`. */
34
+ const EAGER_SCREENS = 1.5;
35
+ const EAGER_MIN = 6;
36
+ const EAGER_MAX = 40;
37
+ /** The keys of the transcript's tail, read from the end (a few items, whatever the length). */
38
+ function tailKeys(settled, open, sizeOf) {
39
+ const budget = (typeof window === "undefined" ? 1e3 : window.innerHeight) * EAGER_SCREENS;
40
+ const out = /* @__PURE__ */ new Set();
41
+ let rows = 0;
42
+ let px = 0;
43
+ for (let i = settled.length + open.length - 1; i >= 0; i--) {
44
+ const item = i >= settled.length ? open[i - settled.length] : settled[i];
45
+ out.add(item.key);
46
+ if (item.kind === "single" || item.kind === "group") {
47
+ rows++;
48
+ px += sizeOf(item.key) ?? item.estimate;
49
+ }
50
+ if (rows >= EAGER_MAX || rows >= EAGER_MIN && px >= budget) break;
51
+ }
52
+ return out;
53
+ }
54
+ /**
55
+ * Root rows before the transcript's flat run, behind memoized fibers: a render that changes none of them (a stream
56
+ * tick) never walks them, and a render for one row (it mounts, it parks) walks its run only. React walks every child
57
+ * of a fiber it renders through, and each child it skips looks up its context providers: one run of every history
58
+ * row made each row's mount cost the whole history. The flat run after them starts where the open exchange started
59
+ * when the conversation showed, so a row never moves between the two (that would remount it).
60
+ */
61
+ const RowRun = memo(({ rows }) => /* @__PURE__ */ jsx(Fragment$1, { children: rows }), (a, b) => a.rows.length === b.rows.length && a.rows.every((row, i) => row === b.rows[i]));
62
+ RowRun.displayName = "RowRun";
63
+ /** Rows per {@link RowRun}. */
64
+ const RUN_ROWS = 64;
65
+ /** The rows in runs of {@link RUN_ROWS}, counted from the end: history prepended adds runs in front, and a row never changes runs. */
66
+ function rowRuns(rows) {
67
+ const runs = [];
68
+ for (let end = rows.length, k = 0; end > 0; end -= RUN_ROWS, k++) runs.push(/* @__PURE__ */ jsx(RowRun, { rows: rows.slice(Math.max(0, end - RUN_ROWS), end) }, `\u0000run${k}`));
69
+ return runs.reverse();
70
+ }
71
+ /** Whether a transcript can hold a view (`eventsMayHoldViews`), each settled exchange read once. */
72
+ function mayHoldViews(transcript) {
73
+ return eventsMayHoldViews(transcript.tail) || transcript.chunks.some((chunk) => chunkFact(chunk, "may-hold-views", eventsMayHoldViews));
74
+ }
75
+ /** `runTailActivity` of the open exchange: its scan stops at the exchange's prompt, so the result is the whole transcript's. */
76
+ function tailActivity(transcript) {
77
+ const tail = transcript.tail.length > 0 || transcript.chunks.length === 0 ? transcript.tail : transcript.chunks.at(-1);
78
+ return runTailActivity(tail);
79
+ }
26
80
  /** zidane's defaults for those settings. */
27
81
  const DEFAULT_TRANSCRIPT_OPTIONS = {
28
82
  showRowIcons: DEFAULT_SETTINGS.showRowIcons,
@@ -47,45 +101,9 @@ const DEFAULT_TRANSCRIPT_OPTIONS = {
47
101
  viewsSave: DEFAULT_SETTINGS.viewsSave,
48
102
  viewsOrchestration: DEFAULT_SETTINGS.viewsOrchestration
49
103
  };
50
- /**
51
- * Top-level rows at the end of the transcript that mount at once (the rest
52
- * mount on approach, `LazyRow`): enough to fill the window when the session
53
- * opens pinned to the bottom, so the first frame shows real rows. Sized by
54
- * the rows' estimated heights (`EAGER_SCREENS` windows' worth), never fewer
55
- * than `EAGER_MIN` rows nor more than `EAGER_MAX`: mounting forty rows when
56
- * eight fill the window made every conversation switch pay for the other
57
- * thirty-two in its frame. Rows above mount next, from the viewport
58
- * observers, and the ones within a viewport of the view mount at once.
59
- */
60
- const EAGER_SCREENS = 1.5;
61
- const EAGER_MIN = 6;
62
- const EAGER_MAX = 40;
63
- /**
64
- * Index of the first root cluster that mounts at once (`EAGER_SCREENS`).
65
- *
66
- * @param list - The root clusters.
67
- * @param hidden - Rows that render nothing (they take no room).
68
- */
69
- function eagerTailStart(list, hidden) {
70
- const budget = (typeof window === "undefined" ? 1e3 : window.innerHeight) * EAGER_SCREENS;
71
- let px = 0;
72
- let rows = 0;
73
- for (let i = list.length - 1; i >= 0; i--) {
74
- const cluster = list[i];
75
- if (cluster.kind === "single") {
76
- if (hidden(cluster.row)) continue;
77
- px += rowEstimatePx(cluster.row);
78
- }
79
- rows++;
80
- if (rows >= EAGER_MAX || rows >= EAGER_MIN && px >= budget) return i;
81
- }
82
- return 0;
83
- }
84
104
  /** How long after a conversation first paints its rows count as already there. */
85
105
  const SETTLE_MS = 400;
86
- /** A subagent block's id among the rows: its first row's, not its position (a prepended page shifts every position). */
87
- const groupRowId = (cluster, index) => `group-${firstRowId(cluster) ?? index}-${cluster.childId}`;
88
- /** Renders a session's events as transcript rows: messages, tool calls grouped by the display options, subagent blocks, notices, and the select-turn cursor. Rows mount lazily as they near the viewport. */
106
+ /** Renders a session's events as transcript rows: messages, tool calls grouped by the display options, subagent blocks, notices, and the select-turn cursor. Rows mount as they near the view, and stay. */
89
107
  const Transcript = memo(({ events, streaming, sessionId, options, selection, turnMenu, runStatus, liveScripts = false, className, style, children }) => {
90
108
  const o = options ? {
91
109
  ...DEFAULT_TRANSCRIPT_OPTIONS,
@@ -95,6 +113,9 @@ const Transcript = memo(({ events, streaming, sessionId, options, selection, tur
95
113
  const showFullShellOutput = Boolean(o.showFullShellOutput);
96
114
  const collapseSubagents = o.hideSubagentOutput;
97
115
  const { openSession, resume } = useTranscriptActions();
116
+ const split = useRef(void 0);
117
+ const transcript = useMemo(() => Array.isArray(events) ? transcriptOfArray(events) ?? transcriptFromArray(events, split.current) : events, [events]);
118
+ split.current = transcript;
98
119
  const settle = useRef({
99
120
  sessionId: null,
100
121
  shown: false,
@@ -105,13 +126,13 @@ const Transcript = memo(({ events, streaming, sessionId, options, selection, tur
105
126
  shown: false,
106
127
  until: 0
107
128
  };
108
- const viewsReady = useViewsReady(o.views && !settle.current.shown && eventsMayHoldViews(events), sessionId);
109
- if (!settle.current.shown && events.length > 0 && viewsReady) {
129
+ const viewsReady = useViewsReady(o.views && !settle.current.shown && mayHoldViews(transcript), sessionId);
130
+ if (!settle.current.shown && transcript.length > 0 && viewsReady) {
110
131
  settle.current.shown = true;
111
132
  settle.current.until = performance.now() + SETTLE_MS;
112
133
  }
113
134
  const settling = useCallback(() => performance.now() < settle.current.until, []);
114
- const { visibleRows, receiptByRowId, resumableId, clusters, lastStreamingRow } = useTranscriptRows(events, streaming, {
135
+ const rows = useTranscriptRows(transcript, streaming, {
115
136
  showCacheNotices: o.showCacheNotices,
116
137
  codemodeShowCalls: o.codemodeShowCalls,
117
138
  showEditDiffs,
@@ -119,26 +140,49 @@ const Transcript = memo(({ events, streaming, sessionId, options, selection, tur
119
140
  showRunReceipt: o.showRunReceipt,
120
141
  compact: o.transcriptDensity === "compact"
121
142
  });
143
+ const { receiptByRowId, resumableId, lastStreamingRow } = rows;
144
+ const parts = rows.parts ?? {
145
+ settled: NO_SLICE,
146
+ open: {
147
+ rows: rows.visibleRows,
148
+ clusters: rows.clusters
149
+ }
150
+ };
151
+ const settledClusters = parts.settled.clusters;
152
+ const openClusters = parts.open.clusters;
122
153
  const slotEntries = useExtensionItems("slot");
154
+ const turnEndsPrev = useRef(null);
123
155
  const turnEnds = useMemo(() => {
124
156
  const wanted = /* @__PURE__ */ new Set();
125
157
  for (const { item } of slotEntries) if (item.at === "transcript.turn-end" && item.turnId && (item.sessionId === void 0 || item.sessionId === sessionId)) wanted.add(item.turnId);
126
158
  if (wanted.size === 0) return null;
127
- const lastRow = /* @__PURE__ */ new Map();
128
- for (const cluster of clusters) {
129
- if (cluster.kind !== "single") continue;
130
- for (const id of rowTurnIds(cluster.row)) if (wanted.has(id)) lastRow.set(id, cluster.row.id);
131
- }
132
- const byRow = /* @__PURE__ */ new Map();
133
- for (const [turnId, rowId] of lastRow) byRow.set(rowId, [...byRow.get(rowId) ?? [], turnId]);
134
- return byRow;
159
+ const ends = endsByRow({
160
+ settled: settledClusters,
161
+ open: openClusters
162
+ }, (at, add) => {
163
+ const byRow = /* @__PURE__ */ new Map();
164
+ for (const turnId of wanted) {
165
+ const where = at(turnId);
166
+ if (!where) continue;
167
+ const entry = byRow.get(where.rowId);
168
+ if (entry) entry.turns.push(turnId);
169
+ else byRow.set(where.rowId, {
170
+ where,
171
+ turns: [turnId]
172
+ });
173
+ }
174
+ for (const { where, turns } of byRow.values()) add(where, turns);
175
+ }, turnEndsPrev.current);
176
+ turnEndsPrev.current = ends;
177
+ return ends;
135
178
  }, [
136
179
  slotEntries,
137
180
  sessionId,
138
- clusters
181
+ settledClusters,
182
+ openClusters
139
183
  ]);
140
184
  const viewInputs = o.views && o.viewsInputs;
141
- const viewEvents = o.views ? events : null;
185
+ const viewEvents = o.views ? transcript : null;
142
186
  const [viewPlaces] = useState(() => new ReplyViewPlaces());
143
187
  const [viewAnswers] = useState(() => new ViewAnswers());
144
188
  useMemo(() => {
@@ -170,33 +214,37 @@ const Transcript = memo(({ events, streaming, sessionId, options, selection, tur
170
214
  o.viewsOrchestration
171
215
  ]);
172
216
  const textless = viewEvents ? viewPlaces.textlessExchanges : null;
217
+ const textlessPrev = useRef(null);
173
218
  const textlessEnds = useMemo(() => {
174
219
  if (!textless || !sessionId) return null;
175
220
  const exchanges = textless.filter((exchange) => exchange.closed || !streaming);
176
221
  if (exchanges.length === 0) return null;
177
- const lastRow = /* @__PURE__ */ new Map();
178
- for (const cluster of clusters) {
179
- if (cluster.kind !== "single") continue;
180
- for (const id of rowTurnIds(cluster.row)) lastRow.set(id, cluster.row.id);
181
- }
182
- const byRow = /* @__PURE__ */ new Map();
183
- for (const exchange of exchanges) {
184
- let rowId;
185
- for (const turnId of exchange.turns) rowId = lastRow.get(turnId) ?? rowId;
186
- if (rowId) byRow.set(rowId, exchange.turns);
187
- }
188
- return byRow;
222
+ const ends = endsByRow({
223
+ settled: settledClusters,
224
+ open: openClusters
225
+ }, (at, add) => {
226
+ for (const exchange of exchanges) {
227
+ let where;
228
+ for (const turnId of exchange.turns) where = at(turnId) ?? where;
229
+ if (where) add(where, exchange.turns);
230
+ }
231
+ }, textlessPrev.current);
232
+ textlessPrev.current = ends;
233
+ return ends;
189
234
  }, [
190
235
  textless,
191
236
  sessionId,
192
237
  streaming,
193
- clusters
238
+ settledClusters,
239
+ openClusters
194
240
  ]);
195
241
  const selectedTurnId = selection?.selected ?? null;
196
- const stops = useSelectStops(visibleRows, events, showThinking, selectedTurnId !== null, selection?.registerStops);
242
+ const stops = useSelectStops(rows, transcript, showThinking, selectedTurnId !== null, selection?.registerStops);
197
243
  const hiddenRow = useCallback((row) => isHiddenRow(row, showThinking), [showThinking]);
198
- const rail = useRailPublish(clusters, hiddenRow, receiptByRowId, selectedTurnId);
244
+ const rail = useRailPublish(parts, hiddenRow, receiptByRowId, selectedTurnId);
199
245
  const containerRef = useRef(null);
246
+ const timelineRef = useRef(null);
247
+ const [rowUiState] = useState(createRowUiState);
200
248
  const rowCtx = useMemo(() => ({
201
249
  sessionId,
202
250
  settings: {
@@ -224,11 +272,19 @@ const Transcript = memo(({ events, streaming, sessionId, options, selection, tur
224
272
  openSession,
225
273
  resume
226
274
  ]);
227
- const slotCache = useRef(/* @__PURE__ */ new Map());
228
275
  const groupCache = useRef(/* @__PURE__ */ new WeakMap());
229
276
  const renderClustersRef = useRef(() => []);
230
277
  const showRunReceipt = o.showRunReceipt;
231
- const foldEpoch = useMemo(() => ({}), [
278
+ const foldEpoch = useMemo(() => ({
279
+ rowCtx,
280
+ selectedTurnId,
281
+ stops,
282
+ resumableId,
283
+ showThinking,
284
+ collapseSubagents,
285
+ streaming,
286
+ showRunReceipt
287
+ }), [
232
288
  rowCtx,
233
289
  selectedTurnId,
234
290
  stops,
@@ -238,8 +294,8 @@ const Transcript = memo(({ events, streaming, sessionId, options, selection, tur
238
294
  streaming,
239
295
  showRunReceipt
240
296
  ]);
241
- const renderFoldRows = useMemo(() => (list, lazy) => renderClustersRef.current(list, lazy), [foldEpoch]);
242
- const waiting = runStatus !== void 0 && streaming && runTailActivity(events) === "waiting";
297
+ const renderFoldRows = useMemo(() => (list) => renderClustersRef.current(list), [foldEpoch]);
298
+ const waiting = runStatus !== void 0 && streaming && tailActivity(transcript) === "waiting";
243
299
  const liveStatus = useMemo(() => runStatus && streaming ? {
244
300
  retry: runStatus.retry,
245
301
  waiting
@@ -248,27 +304,31 @@ const Transcript = memo(({ events, streaming, sessionId, options, selection, tur
248
304
  streaming,
249
305
  waiting
250
306
  ]);
251
- const rowProps = (row, root = false) => ({
307
+ const live = {
308
+ caret: lastStreamingRow,
309
+ receipts: receiptByRowId
310
+ };
311
+ const rowProps = (row, root = false, at = live) => ({
252
312
  row,
253
- showCaret: row === lastStreamingRow,
254
- receipt: receiptByRowId.get(row.id),
313
+ showCaret: row === at.caret,
314
+ receipt: at.receipts.get(row.id),
255
315
  resumable: row.id === resumableId,
256
316
  ctx: rowCtx,
257
317
  renderRows: row.kind === "exchange-fold" || row.kind === "message-group" ? renderFoldRows : void 0,
258
318
  status: root && row.kind === "exchange-fold" && row.live ? liveStatus : void 0
259
319
  });
260
- const groupDeps = (cluster, deps) => {
320
+ const groupDeps = (cluster, deps, at) => {
261
321
  for (const item of cluster.body) {
262
322
  if (item.kind === "group") {
263
- groupDeps(item, deps);
323
+ groupDeps(item, deps, at);
264
324
  continue;
265
325
  }
266
326
  const row = item.row;
267
- deps.push(row === lastStreamingRow, receiptByRowId.get(row.id), row.kind === "exchange-fold" || row.kind === "message-group" ? renderFoldRows : void 0);
327
+ deps.push(row === at.caret, at.receipts.get(row.id), row.kind === "exchange-fold" || row.kind === "message-group" ? renderFoldRows : void 0);
268
328
  }
269
329
  return deps;
270
330
  };
271
- const renderGroup = (cluster, ci, parentDepth) => {
331
+ const renderGroup = (cluster, ci, parentDepth, at = live) => {
272
332
  const key = groupRowId(cluster, ci);
273
333
  const deps = groupDeps(cluster, [
274
334
  key,
@@ -279,17 +339,17 @@ const Transcript = memo(({ events, streaming, sessionId, options, selection, tur
279
339
  showThinking,
280
340
  rowCtx,
281
341
  resumableId
282
- ]);
342
+ ], at);
283
343
  const hit = groupCache.current.get(cluster);
284
344
  if (hit && hit.deps.length === deps.length && hit.deps.every((d, i) => Object.is(d, deps[i]))) return hit.element;
285
- const element = buildGroup(cluster, key, parentDepth);
345
+ const element = buildGroup(cluster, key, at, parentDepth);
286
346
  groupCache.current.set(cluster, {
287
347
  deps,
288
348
  element
289
349
  });
290
350
  return element;
291
351
  };
292
- function buildGroup(cluster, key, parentDepth) {
352
+ function buildGroup(cluster, key, at, parentDepth) {
293
353
  return /* @__PURE__ */ jsx(SubagentBlock, {
294
354
  "data-row": key,
295
355
  childId: cluster.childId,
@@ -300,99 +360,216 @@ const Transcript = memo(({ events, streaming, sessionId, options, selection, tur
300
360
  defaultCollapsed: collapseSubagents,
301
361
  streaming,
302
362
  children: cluster.body.map((item, i) => {
303
- if (item.kind === "group") return renderGroup(item, i, cluster.depth);
363
+ if (item.kind === "group") return renderGroup(item, i, cluster.depth, at);
304
364
  const row = item.row;
305
365
  if (isHiddenRow(row, showThinking)) return null;
306
366
  return /* @__PURE__ */ jsx(CvRow, {
307
367
  style: rowCvStyle(row),
308
368
  "data-row": row.id,
309
- children: /* @__PURE__ */ jsx(TranscriptRow, { ...rowProps(row) })
369
+ children: /* @__PURE__ */ jsx(TranscriptRow, { ...rowProps(row, false, at) })
310
370
  }, row.id);
311
371
  })
312
372
  }, key);
313
373
  }
314
- const renderClusters = (list, lazy = false) => {
315
- const out = [];
316
- const nextSlotCache = lazy ? /* @__PURE__ */ new Map() : slotCache.current;
317
- const eagerFrom = lazy ? eagerTailStart(list, (row) => isHiddenRow(row, showThinking)) : 0;
318
- const textlessHere = lazy && sessionId ? textlessEnds : null;
319
- const renderSingle = (cluster, ci) => {
320
- if (isHiddenRow(cluster.row, showThinking)) return;
321
- const stop = stops ? stopForRow(cluster.row, stops) : null;
322
- const sel = stop !== null && stop === selectedTurnId ? "" : void 0;
323
- if (lazy) {
324
- const props = rowProps(cluster.row, true);
325
- const eager = ci >= eagerFrom;
326
- const deps = [
327
- props.row,
328
- props.showCaret,
329
- props.receipt,
330
- props.resumable,
331
- props.ctx,
332
- props.renderRows,
333
- props.status,
334
- eager,
335
- stop,
336
- sel
337
- ];
338
- const hit = slotCache.current.get(cluster.row.id);
339
- const element = hit && hit.deps.every((d, i) => Object.is(d, deps[i])) ? hit.element : /* @__PURE__ */ jsx(TranscriptRowSlot, {
340
- eager,
341
- estimatePx: rowEstimatePx(cluster.row),
342
- style: rowCvStyle(cluster.row),
343
- stop: stop ?? void 0,
344
- sel,
345
- ...props
346
- }, cluster.row.id);
347
- nextSlotCache.set(cluster.row.id, {
348
- deps,
349
- element
350
- });
351
- out.push(element);
352
- return;
353
- }
354
- out.push(/* @__PURE__ */ jsx(CvRow, {
355
- style: rowCvStyle(cluster.row),
356
- "data-stop": stop ?? void 0,
357
- "data-sel": sel,
358
- "data-row": cluster.row.id,
359
- children: /* @__PURE__ */ jsx(TranscriptRow, { ...rowProps(cluster.row) })
360
- }, cluster.row.id));
361
- };
362
- list.forEach((cluster, ci) => {
363
- if (cluster.kind === "single") {
364
- renderSingle(cluster, ci);
365
- const textless = textlessHere?.get(cluster.row.id);
366
- if (textless) out.push(/* @__PURE__ */ jsx("div", {
367
- className: "pl-2 pr-1",
368
- children: /* @__PURE__ */ jsx(CodemodeViewsSlot, {
369
- sessionId,
370
- turns: textless
371
- })
372
- }, `views-end:${cluster.row.id}`));
373
- const ends = lazy && sessionId ? turnEnds?.get(cluster.row.id) : void 0;
374
- for (const turnId of ends ?? []) out.push(/* @__PURE__ */ jsx(ExtensionSlot, {
375
- at: "transcript.turn-end",
374
+ /** A fold's or a message group's rows: the same rows, always mounted (their fold is). */
375
+ const renderClusters = (list) => list.map((cluster, ci) => {
376
+ if (cluster.kind === "group") return renderGroup(cluster, ci);
377
+ const row = cluster.row;
378
+ if (isHiddenRow(row, showThinking)) return null;
379
+ const stop = stops ? stopForRow(row, stops) : null;
380
+ return /* @__PURE__ */ jsx(CvRow, {
381
+ style: rowCvStyle(row),
382
+ "data-stop": stop ?? void 0,
383
+ "data-sel": stop !== null && stop === selectedTurnId ? "" : void 0,
384
+ "data-row": row.id,
385
+ children: /* @__PURE__ */ jsx(TranscriptRow, { ...rowProps(row) })
386
+ }, row.id);
387
+ });
388
+ const settledTextless = textlessEnds?.settled ?? null;
389
+ const settledTurnEnds = turnEnds?.settled ?? null;
390
+ const openTextless = textlessEnds?.open ?? null;
391
+ const openTurnEnds = turnEnds?.open ?? null;
392
+ const settledItems = useMemo(() => rootItems(settledClusters, hiddenRow, collapseSubagents, sessionId ? settledTextless : null, sessionId ? settledTurnEnds : null), [
393
+ settledClusters,
394
+ hiddenRow,
395
+ collapseSubagents,
396
+ sessionId,
397
+ settledTextless,
398
+ settledTurnEnds
399
+ ]);
400
+ const openItems = useMemo(() => rootItems(openClusters, hiddenRow, collapseSubagents, sessionId ? openTextless : null, sessionId ? openTurnEnds : null, settledClusters.length), [
401
+ openClusters,
402
+ hiddenRow,
403
+ collapseSubagents,
404
+ sessionId,
405
+ openTextless,
406
+ openTurnEnds,
407
+ settledClusters.length
408
+ ]);
409
+ const forced = useForcedRows();
410
+ const settledMatches = useMemo(() => matchingItems(settledItems, forced.needles), [settledItems, forced]);
411
+ const openMatches = useMemo(() => matchingItems(openItems, forced.needles), [openItems, forced]);
412
+ const selectKeys = (list) => !stops || selectedTurnId === null ? NO_KEYS : list.filter((item) => item.kind === "single" && stopForRow(item.cluster.row, stops) === selectedTurnId).map((item) => item.key);
413
+ const settledSelect = useMemo(() => selectKeys(settledItems), [
414
+ settledItems,
415
+ stops,
416
+ selectedTurnId
417
+ ]);
418
+ const openSelect = useMemo(() => selectKeys(openItems), [
419
+ openItems,
420
+ stops,
421
+ selectedTurnId
422
+ ]);
423
+ const held = useMemo(() => [
424
+ ...settledMatches,
425
+ ...openMatches,
426
+ ...settledSelect,
427
+ ...openSelect
428
+ ], [
429
+ settledMatches,
430
+ openMatches,
431
+ settledSelect,
432
+ openSelect
433
+ ]);
434
+ const [mounter] = useState(() => new RowMounter());
435
+ mounter.reset(sessionId);
436
+ const eager = useMemo(() => tailKeys(settledItems, openItems, (key) => mounter.sizeOf(key)), [
437
+ settledItems,
438
+ openItems,
439
+ mounter
440
+ ]);
441
+ const liveKeys = useMemo(() => new Set(openItems.map((item) => item.key)), [openItems]);
442
+ mounter.setTail(eager, liveKeys);
443
+ useLayoutEffect(() => mounter.hold(held, forced.all), [
444
+ mounter,
445
+ held,
446
+ forced.all
447
+ ]);
448
+ useLayoutEffect(() => () => mounter.dispose(), [mounter]);
449
+ const settledCache = useRef(/* @__PURE__ */ new Map());
450
+ const openCache = useRef(/* @__PURE__ */ new Map());
451
+ const rootElement = (item, at, out) => {
452
+ let deps;
453
+ let make;
454
+ if (item.kind === "group") {
455
+ const group = renderGroup(item.cluster, item.ci, void 0, at);
456
+ deps = [group];
457
+ make = () => /* @__PURE__ */ jsx(LazyRow, {
458
+ itemKey: item.key,
459
+ estimatePx: item.estimate,
460
+ box: true,
461
+ children: group
462
+ }, item.key);
463
+ } else if (item.kind === "views-end") {
464
+ deps = [sessionId, item.turns];
465
+ make = () => /* @__PURE__ */ jsx("div", {
466
+ className: "pl-2 pr-1",
467
+ children: /* @__PURE__ */ jsx(CodemodeViewsSlot, {
376
468
  sessionId,
377
- turnId,
378
- className: "py-1"
379
- }, `turn-end:${turnId}`));
380
- return;
381
- }
382
- out.push(renderGroup(cluster, ci));
469
+ turns: item.turns
470
+ })
471
+ }, item.key);
472
+ } else if (item.kind === "turn-end") {
473
+ deps = [sessionId, item.turnId];
474
+ make = () => /* @__PURE__ */ jsx(ExtensionSlot, {
475
+ at: "transcript.turn-end",
476
+ sessionId,
477
+ turnId: item.turnId,
478
+ className: "py-1"
479
+ }, item.key);
480
+ } else {
481
+ const row = item.cluster.row;
482
+ const stop = stops ? stopForRow(row, stops) : null;
483
+ const sel = stop !== null && stop === selectedTurnId ? "" : void 0;
484
+ const props = rowProps(row, true, at);
485
+ deps = [
486
+ props.row,
487
+ props.showCaret,
488
+ props.receipt,
489
+ props.resumable,
490
+ props.ctx,
491
+ props.renderRows,
492
+ props.status,
493
+ stop,
494
+ sel
495
+ ];
496
+ make = () => /* @__PURE__ */ jsx(TranscriptRowSlot, {
497
+ style: rowCvStyle(row),
498
+ stop: stop ?? void 0,
499
+ sel,
500
+ ...props
501
+ }, row.id);
502
+ }
503
+ const hit = openCache.current.get(item.key) ?? settledCache.current.get(item.key);
504
+ const element = hit && hit.deps.length === deps.length && hit.deps.every((d, i) => Object.is(d, deps[i])) ? hit.element : make();
505
+ out.set(item.key, {
506
+ deps,
507
+ element
383
508
  });
384
- if (lazy) slotCache.current = nextSlotCache;
385
- return out;
509
+ return element;
386
510
  };
511
+ const settledRowSet = useMemo(() => new WeakSet(parts.settled.rows), [parts.settled.rows]);
512
+ const settledCaret = lastStreamingRow && settledRowSet.has(lastStreamingRow) ? lastStreamingRow : null;
513
+ const settledReceipts = parts.settled.receipts ?? receiptByRowId;
514
+ const settledLive = useMemo(() => ({
515
+ caret: settledCaret,
516
+ receipts: settledReceipts
517
+ }), [settledCaret, settledReceipts]);
518
+ const settledEls = useMemo(() => {
519
+ const next = /* @__PURE__ */ new Map();
520
+ const els = settledItems.map((item) => rootElement(item, settledLive, next));
521
+ settledCache.current = next;
522
+ return els;
523
+ }, [
524
+ settledItems,
525
+ settledLive,
526
+ rowCtx,
527
+ stops,
528
+ selectedTurnId,
529
+ resumableId,
530
+ renderFoldRows,
531
+ liveStatus,
532
+ sessionId,
533
+ showThinking,
534
+ collapseSubagents,
535
+ streaming
536
+ ]);
537
+ const openNext = /* @__PURE__ */ new Map();
538
+ const openEls = openItems.map((item) => rootElement(item, live, openNext));
539
+ openCache.current = openNext;
540
+ const runStart = useRef({
541
+ sessionId,
542
+ key: null
543
+ });
544
+ if (runStart.current.sessionId !== sessionId) runStart.current = {
545
+ sessionId,
546
+ key: null
547
+ };
548
+ if (runStart.current.key === null && openItems.length > 0) runStart.current.key = openItems[0].key;
549
+ const runKey = runStart.current.key;
550
+ const foundAt = useMemo(() => {
551
+ if (runKey !== null) {
552
+ for (let i = settledItems.length - 1; i >= 0; i--) if (settledItems[i].key === runKey) return i;
553
+ }
554
+ return -1;
555
+ }, [settledItems, runKey]);
556
+ if (runKey !== null && foundAt < 0 && !openItems.some((item) => item.key === runKey)) runStart.current.key = openItems[0]?.key ?? null;
557
+ const runAt = foundAt < 0 ? settledItems.length : foundAt;
558
+ const prefixRuns = useMemo(() => rowRuns(runAt === settledEls.length ? settledEls : settledEls.slice(0, runAt)), [settledEls, runAt]);
559
+ const flatSettled = useMemo(() => runAt === settledEls.length ? [] : settledEls.slice(runAt), [settledEls, runAt]);
387
560
  renderClustersRef.current = renderClusters;
388
- const rootRows = renderClusters(clusters, true);
561
+ const rootRows = [
562
+ ...prefixRuns,
563
+ ...flatSettled,
564
+ ...openEls
565
+ ];
389
566
  useTranscriptSelectionCopy(containerRef);
390
567
  return /* @__PURE__ */ jsx(TranscriptSettling.Provider, {
391
568
  value: settling,
392
569
  children: /* @__PURE__ */ jsx(LiveScriptsContext.Provider, {
393
570
  value: liveScripts,
394
571
  children: /* @__PURE__ */ jsx(MediaGalleryProvider, {
395
- events,
572
+ events: transcript,
396
573
  children: /* @__PURE__ */ jsx(RowIconsContext.Provider, {
397
574
  value: o.showRowIcons,
398
575
  children: /* @__PURE__ */ jsx(DiagramsContext.Provider, {
@@ -407,17 +584,25 @@ const Transcript = memo(({ events, streaming, sessionId, options, selection, tur
407
584
  style,
408
585
  children: [
409
586
  /* @__PURE__ */ jsxs("div", {
587
+ ref: timelineRef,
410
588
  className: "zg-timeline relative pl-2 pr-1 py-1",
589
+ "data-vitems": settledItems.length + openItems.length,
411
590
  children: [
412
591
  /* @__PURE__ */ jsx(SelectCursor, {
413
592
  selected: selectedTurnId,
414
593
  layout: stops
415
594
  }),
416
595
  rail && /* @__PURE__ */ jsx(RailTint, { store: rail }),
417
- viewsReady || settle.current.shown ? rootRows : null
596
+ /* @__PURE__ */ jsx(RowUiStateContext.Provider, {
597
+ value: rowUiState,
598
+ children: /* @__PURE__ */ jsx(RowMountContext.Provider, {
599
+ value: mounter,
600
+ children: viewsReady || settle.current.shown ? rootRows : null
601
+ })
602
+ })
418
603
  ]
419
604
  }),
420
- sessionId && !streaming && events.length > 0 && /* @__PURE__ */ jsx(ExtensionSlot, {
605
+ sessionId && !streaming && transcript.length > 0 && /* @__PURE__ */ jsx(ExtensionSlot, {
421
606
  at: "transcript.turn-end",
422
607
  sessionId,
423
608
  className: "pl-2 pr-1 py-1"