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
@@ -0,0 +1,180 @@
1
+ import { firstRowId } from "../headless/transcript/rows.js";
2
+ import { rowTurnIds } from "../headless/transcript/select-stops.js";
3
+ import { rowEstimatePx } from "./row-estimate.js";
4
+ import { noteTranscriptPass } from "zidane/chat/pure";
5
+ // src/chat/transcript/root-items.ts
6
+ /** A subagent block's id among the rows: its first row's, not its position (a prepended page shifts every position). */
7
+ function groupRowId(cluster, index) {
8
+ return `group-${firstRowId(cluster) ?? index}-${cluster.childId}`;
9
+ }
10
+ /** A collapsed worker block: its header line. */
11
+ const GROUP_COLLAPSED_PX = 34;
12
+ function groupEstimate(cluster) {
13
+ let px = GROUP_COLLAPSED_PX;
14
+ for (const item of cluster.body) px += item.kind === "group" ? groupEstimate(item) : rowEstimatePx(item.row);
15
+ return px;
16
+ }
17
+ /**
18
+ * The root items, in order.
19
+ *
20
+ * @param clusters - The transcript's root clusters.
21
+ * @param hidden - Rows that render nothing (no item).
22
+ * @param collapsedGroups - Worker blocks start collapsed.
23
+ * @param textlessEnds - After which row the codemode views of an exchange with no reply text go, or null.
24
+ * @param turnEnds - After which row the extensions' items for which turns go, or null.
25
+ * @param offset - Where `clusters` start among the transcript's clusters (the open part's, after the settled ones).
26
+ */
27
+ function rootItems(clusters, hidden, collapsedGroups, textlessEnds, turnEnds, offset = 0) {
28
+ noteTranscriptPass("root-items", clusters.length);
29
+ const out = [];
30
+ clusters.forEach((cluster, at) => {
31
+ const ci = offset + at;
32
+ if (cluster.kind === "group") {
33
+ out.push({
34
+ kind: "group",
35
+ cluster,
36
+ ci,
37
+ key: groupRowId(cluster, ci),
38
+ estimate: collapsedGroups ? GROUP_COLLAPSED_PX : groupEstimate(cluster)
39
+ });
40
+ return;
41
+ }
42
+ const row = cluster.row;
43
+ if (hidden(row)) return;
44
+ out.push({
45
+ kind: "single",
46
+ cluster,
47
+ key: row.id,
48
+ estimate: rowEstimatePx(row)
49
+ });
50
+ const textless = textlessEnds?.get(row.id);
51
+ if (textless) out.push({
52
+ kind: "views-end",
53
+ rowId: row.id,
54
+ turns: textless,
55
+ key: `views-end:${row.id}`,
56
+ estimate: 0
57
+ });
58
+ for (const turnId of turnEnds?.get(row.id) ?? []) out.push({
59
+ kind: "turn-end",
60
+ turnId,
61
+ key: `turn-end:${turnId}`,
62
+ estimate: 0
63
+ });
64
+ });
65
+ return out;
66
+ }
67
+ const TEXT_CACHE = /* @__PURE__ */ new WeakMap();
68
+ /** A row's text past this is not searched for unmounted matches (it mounts once the reader scrolls to it). */
69
+ const MAX_TEXT = 2e5;
70
+ /**
71
+ * Every string a row holds, lowercased: what it shows (and some it does not, ids and paths). Cached per row object.
72
+ * A search mounts the rows whose text holds its needle; the DOM walk then finds what they really show.
73
+ *
74
+ * @param row - A row, or a block's cluster.
75
+ */
76
+ function rowSearchText(row) {
77
+ const hit = TEXT_CACHE.get(row);
78
+ if (hit !== void 0) return hit;
79
+ const parts = [];
80
+ let size = 0;
81
+ const walk = (value, depth) => {
82
+ if (size > MAX_TEXT || depth > 8) return;
83
+ if (typeof value === "string") {
84
+ parts.push(value);
85
+ size += value.length;
86
+ } else if (Array.isArray(value)) for (const v of value) walk(v, depth + 1);
87
+ else if (value && typeof value === "object") for (const v of Object.values(value)) walk(v, depth + 1);
88
+ };
89
+ walk(row, 0);
90
+ const text = parts.join("\n").toLowerCase();
91
+ TEXT_CACHE.set(row, text);
92
+ return text;
93
+ }
94
+ /** Each turn's last root row among `clusters` (single clusters only), made once per clusters array. */
95
+ const lastRows = /* @__PURE__ */ new WeakMap();
96
+ /**
97
+ * The id of the last root row holding each turn among `clusters`: once per clusters array (a settled part's, read
98
+ * every tick, is walked once).
99
+ *
100
+ * @param clusters - Root clusters.
101
+ */
102
+ function lastRowByTurn(clusters) {
103
+ let map = lastRows.get(clusters);
104
+ if (!map) {
105
+ noteTranscriptPass("turn-rows", clusters.length);
106
+ const out = /* @__PURE__ */ new Map();
107
+ for (const cluster of clusters) {
108
+ if (cluster.kind !== "single") continue;
109
+ for (const id of rowTurnIds(cluster.row)) out.set(id, cluster.row.id);
110
+ }
111
+ map = out;
112
+ lastRows.set(clusters, map);
113
+ }
114
+ return map;
115
+ }
116
+ function sameEnds(a, b) {
117
+ if (a === b) return true;
118
+ if (!a || !b || a.size !== b.size) return false;
119
+ for (const [rowId, turns] of a) {
120
+ const other = b.get(rowId);
121
+ if (!other || other.length !== turns.length || other.some((t, i) => t !== turns[i])) return false;
122
+ }
123
+ return true;
124
+ }
125
+ /**
126
+ * Places groups of turns after the last root row holding one of them, in the part that row is in.
127
+ * Each part's map is `previous`'s while it holds the same: the settled items then stay.
128
+ *
129
+ * @param parts - The settled and the open root clusters.
130
+ * @param parts.settled - The settled clusters.
131
+ * @param parts.open - The open clusters.
132
+ * @param place - Calls `at` for each group: `at(turnId)` is where a turn's last row is.
133
+ * @param previous - The last result.
134
+ */
135
+ function endsByRow(parts, place, previous) {
136
+ const settledRows = lastRowByTurn(parts.settled);
137
+ const openRows = lastRowByTurn(parts.open);
138
+ const at = (turnId) => {
139
+ const open = openRows.get(turnId);
140
+ if (open !== void 0) return {
141
+ rowId: open,
142
+ open: true
143
+ };
144
+ const settled = settledRows.get(turnId);
145
+ return settled !== void 0 ? {
146
+ rowId: settled,
147
+ open: false
148
+ } : void 0;
149
+ };
150
+ const settled = /* @__PURE__ */ new Map();
151
+ const open = /* @__PURE__ */ new Map();
152
+ place(at, (where, turns) => (where.open ? open : settled).set(where.rowId, turns));
153
+ const s = settled.size > 0 ? settled : null;
154
+ const o = open.size > 0 ? open : null;
155
+ return {
156
+ settled: previous && sameEnds(previous.settled, s) ? previous.settled : s,
157
+ open: previous && sameEnds(previous.open, o) ? previous.open : o
158
+ };
159
+ }
160
+ /** Matches past this many items are not mounted ahead (the search's own cap is 500 matches). */
161
+ const MAX_MATCH_ITEMS = 500;
162
+ /**
163
+ * The keys of the items whose data holds one of `needles` (lowercased).
164
+ *
165
+ * @param items - The root items, or their settled and open parts.
166
+ * @param needles - What the search looks for.
167
+ */
168
+ function matchingItems(items, needles) {
169
+ if (needles.length === 0) return [];
170
+ const out = [];
171
+ const all = Array.isArray(items) ? items : [...items.settled, ...items.open];
172
+ for (const item of all) {
173
+ if (item.kind !== "single" && item.kind !== "group") continue;
174
+ const text = rowSearchText(item.kind === "single" ? item.cluster.row : item.cluster);
175
+ if (needles.some((needle) => text.includes(needle))) out.push(item.key);
176
+ if (out.length >= MAX_MATCH_ITEMS) break;
177
+ }
178
+ return out;
179
+ }
180
+ export { endsByRow, groupRowId, lastRowByTurn, matchingItems, rootItems, rowSearchText };
@@ -0,0 +1,184 @@
1
+ /** A root row's state: a placeholder that never mounted, its content mounted, or a placeholder again (parked). */
2
+ export type RowPhase = 'lazy' | 'mounted' | 'parked';
3
+ /** What a row wrapper hands its transcript's mounter. */
4
+ export interface RowSlot {
5
+ /** The root item's key (the row's id). */
6
+ key: string;
7
+ /** The wrapper element. */
8
+ el: HTMLElement;
9
+ /** A `content-visibility: auto` row; false for a plain box (a worker's block). */
10
+ cv: boolean;
11
+ /** Its phase now (the mounter keeps it). */
12
+ phase: RowPhase;
13
+ /** Renders the row in a phase: `background` when mounted ahead of the view, `parkedPx` its height parked. */
14
+ set: (phase: RowPhase, background: boolean, parkedPx?: number) => void;
15
+ }
16
+ /** How a new wrapper starts. */
17
+ export interface RowStart {
18
+ /** Its content mounts with it. */
19
+ mounted: boolean;
20
+ /** It is the transcript's tail (may play the enter animation if new). */
21
+ eager: boolean;
22
+ /** It mounted before in this transcript (a wrapper made again: never new). */
23
+ seen: boolean;
24
+ }
25
+ /** One transcript's root rows: what mounts, what parks, and their heights. */
26
+ export declare class RowMounter {
27
+ private scope;
28
+ private readonly slots;
29
+ private readonly byEl;
30
+ /** The last phase of each key in this transcript: a wrapper made again starts from it. */
31
+ private readonly phases;
32
+ private eager;
33
+ private live;
34
+ private held;
35
+ private all;
36
+ private reveals;
37
+ private readonly skipped;
38
+ /** Each mounted row's height as last laid out (its ResizeObserver entry): what a parked placeholder keeps. */
39
+ private readonly boxes;
40
+ /** The rows within a view of the view, as the last range check found them. */
41
+ private near;
42
+ /** Rows within the far margin waiting to mount, in order. */
43
+ private queue;
44
+ /** The wrappers in document order (rebuilt after rows come or go). */
45
+ private order;
46
+ private orderDirty;
47
+ private mountedCount;
48
+ private timeline;
49
+ private scroller;
50
+ private ro;
51
+ private readonly cvEvents;
52
+ /** A browser (jsdom has no IntersectionObserver, and no layout): without one every row mounts. */
53
+ private readonly browser;
54
+ private checkScheduled;
55
+ private lateScheduled;
56
+ private pumpScheduled;
57
+ private lastActivity;
58
+ private direction;
59
+ private lastTop;
60
+ private parkTimer;
61
+ /** Rows mounted since the last parking pass found the transcript within budget. */
62
+ private dirty;
63
+ private parking;
64
+ private detach;
65
+ /**
66
+ * The transcript shows `scope` (a session): another one forgets this one's phases and jumps.
67
+ *
68
+ * @param scope - The session shown.
69
+ */
70
+ reset(scope: unknown): void;
71
+ private sizeKey;
72
+ /**
73
+ * The row's last true height, if it was ever measured rendered.
74
+ *
75
+ * @param key - The row's key.
76
+ */
77
+ sizeOf(key: string): number | undefined;
78
+ /**
79
+ * What the render holds as the tail (mounts with its first render) and the live exchange (never parks).
80
+ *
81
+ * @param eager - The tail's keys.
82
+ * @param live - The open exchange's keys.
83
+ */
84
+ setTail(eager: ReadonlySet<string>, live: ReadonlySet<string>): void;
85
+ /**
86
+ * How a new wrapper for `key` starts.
87
+ *
88
+ * @param key - The row's key.
89
+ */
90
+ start(key: string): RowStart;
91
+ /**
92
+ * Rows to mount wherever they are and keep mounted while held (a search's matches, the select cursor's turn).
93
+ * Call it from a layout effect: the rows render before the next paint.
94
+ *
95
+ * @param keys - The held rows.
96
+ * @param all - Every row (a search with no needle to narrow it).
97
+ */
98
+ hold(keys: readonly string[], all: boolean): void;
99
+ /**
100
+ * Mounts the row `key` now, wherever it is, and holds it a while (the last few jumps). Call it outside React's
101
+ * render and effects: it commits synchronously.
102
+ *
103
+ * @param key - The row's key.
104
+ * @returns Its wrapper, or null when this transcript has no such row.
105
+ */
106
+ reveal(key: string): HTMLElement | null;
107
+ /**
108
+ * Mounts the rows within `px` above and below the root row holding `el` (by their heights now), so a jump to
109
+ * `el` lands among rows at their real heights: mounted after it, they would move it. The rows render with the
110
+ * next commit.
111
+ *
112
+ * @param el - An element inside a root row.
113
+ * @param px - How far each way.
114
+ * @returns Whether any row was not mounted.
115
+ */
116
+ mountAround(el: Element, px: number): boolean;
117
+ /**
118
+ * A wrapper arrived (its layout effect): observe it, and queue it if it has not mounted.
119
+ *
120
+ * @param slot - The wrapper.
121
+ * @returns The stop.
122
+ */
123
+ register(slot: RowSlot): () => void;
124
+ /** Stops observing (the transcript unmounted). */
125
+ dispose(): void;
126
+ private ensure;
127
+ private mounted;
128
+ /** Moves a row to `phase` and renders it there. */
129
+ private transition;
130
+ /**
131
+ * One range check in the coming frame's animation callbacks, before its paint. From a scroll event, that is the
132
+ * scroll's own frame; from a ResizeObserver callback (after the frame's layout), the next one.
133
+ */
134
+ private scheduleCheck;
135
+ /**
136
+ * One range check in the frame after the coming one: rows committed now get their place first (a transcript
137
+ * opening at its bottom scrolls there after the coming frame's animation callbacks).
138
+ */
139
+ private checkAfterLayout;
140
+ /**
141
+ * Finds the rows near the view: those within a view of it mount now, those within the far margin queue for the
142
+ * pump. Reads the layout first (clean after a scroll), writes after.
143
+ */
144
+ private check;
145
+ private onCvState;
146
+ /** Observing again reports the row's size now: a row just rendered may have kept its placeholder's. */
147
+ private remeasure;
148
+ private onResize;
149
+ private schedulePump;
150
+ /** Mounts queued rows, nearest first, until the budget is spent; what is left waits for the next check. */
151
+ private pump;
152
+ private scheduleParking;
153
+ private whenIdle;
154
+ /** Whether a row must stay mounted now, wherever it is. */
155
+ private isHeld;
156
+ /** One parking pass: plan on a clean layout, then park the plan in idle slices while the reader holds still. */
157
+ private parkPass;
158
+ /** Counts for tests and the perf harness. */
159
+ stats(): {
160
+ mounted: number;
161
+ parked: number;
162
+ rows: number;
163
+ };
164
+ }
165
+ /** The mounter of the transcript around a row wrapper; null outside one (every row mounts). */
166
+ export declare const RowMountContext: import("react").Context<RowMounter | null>;
167
+ /**
168
+ * Mounts the transcript rows within `px` above and below the root row holding `el` (`RowMounter.mountAround`).
169
+ *
170
+ * @param scroller - The transcript's scroll container.
171
+ * @param el - An element inside a root row.
172
+ * @param px - How far each way.
173
+ * @returns Whether any row was not mounted (they render with the next commit).
174
+ */
175
+ export declare function mountAround(scroller: Element, el: Element, px: number): boolean;
176
+ /**
177
+ * The element of the transcript row `id` under `scroller`, mounting its content first if it has not mounted (a jump
178
+ * to a turn, a view put back where it was). Call it outside React's render and effects: it commits synchronously.
179
+ *
180
+ * @param scroller - The transcript's scroll container.
181
+ * @param id - The row's id (a root row's, or a worker block's).
182
+ * @returns The row's element, or null when no transcript there has it.
183
+ */
184
+ export declare function revealRow(scroller: Element, id: string): HTMLElement | null;