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
@@ -1,5 +1,6 @@
1
1
  import { useHydrated } from "../../hooks/useHydrated.js";
2
- import { holdForceMountRows, useForceMountRows } from "./LazyRow.js";
2
+ import { holdForceMountRows, useForcedRows } from "./LazyRow.js";
3
+ import { mountAround } from "./row-mount.js";
3
4
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4
5
  import { jsx } from "react/jsx-runtime";
5
6
  // src/chat/transcript/useTranscriptSearch.tsx
@@ -14,9 +15,10 @@ import { jsx } from "react/jsx-runtime";
14
15
  * re-deriving text from stream events — the DOM is the source of truth
15
16
  * for "what the user can see" (markdown rendering, tool-row formatting,
16
17
  * masking all live there). `content-visibility: auto` rows keep their
17
- * text in the DOM even when paint is skipped, and rows that mount on
18
- * approach (`LazyRow`) are all mounted while a needle is active, so the
19
- * walk still finds offscreen matches. Highlighting uses the CSS Custom Highlight API
18
+ * text in the DOM even when paint is skipped, and while a needle is
19
+ * active the transcript mounts the rows whose data holds it wherever they
20
+ * are (`holdForceMountRows`), so the walk still finds matches in rows
21
+ * that never mounted or parked. Highlighting uses the CSS Custom Highlight API
20
22
  * (`CSS.highlights`) so we never mutate the transcript's DOM — wrapping
21
23
  * matches in `<mark>` would fight React's reconciler on the next
22
24
  * streaming tick.
@@ -121,10 +123,16 @@ function releaseHighlights(owner) {
121
123
  /**
122
124
  * Jump to a match's row. `block: 'center'` keeps context visible above
123
125
  * and below; on a `content-visibility: auto` row this forces render,
124
- * which is exactly what we want before the user reads the match.
126
+ * which is exactly what we want before the user reads the match. The rows
127
+ * around it that have not mounted mount first (`mountAround`), at their
128
+ * real heights: mounting after the jump, they would push the match out of
129
+ * view. Their render lands with the next commit, so the jump waits for it.
125
130
  */
126
- function scrollToRange(range) {
127
- range.startContainer.parentElement?.scrollIntoView({ block: "center" });
131
+ function scrollToRange(range, root) {
132
+ const target = range.startContainer.parentElement;
133
+ if (!target) return;
134
+ if (root && mountAround(root, target, root.clientHeight)) queueMicrotask(() => target.isConnected && target.scrollIntoView({ block: "center" }));
135
+ else target.scrollIntoView({ block: "center" });
128
136
  }
129
137
  /**
130
138
  * `revision` is any value whose identity changes when the transcript
@@ -133,12 +141,12 @@ function scrollToRange(range) {
133
141
  * the user away from the match they're reading. Only a needle CHANGE
134
142
  * scrolls.
135
143
  *
136
- * @param container - The transcript's scroll container.
144
+ * @param containerRef - The transcript's scroll container.
137
145
  * @param query - The query as typed.
138
146
  * @param revision - Changes identity when the transcript re-renders.
139
147
  * @param options - The {@link TranscriptSearchOptions}.
140
148
  */
141
- function useTranscriptSearch(container, query, revision, { terms, revealFirstMatch = false } = {}) {
149
+ function useTranscriptSearch(containerRef, query, revision, { terms, revealFirstMatch = false } = {}) {
142
150
  const [needle, setNeedle] = useState(NO_NEEDLE);
143
151
  const [matches, setMatches] = useState({
144
152
  count: 0,
@@ -174,9 +182,10 @@ function useTranscriptSearch(container, query, revision, { terms, revealFirstMat
174
182
  * sees the freshly-rendered rows.
175
183
  */
176
184
  const prevNeedleRef = useRef("");
177
- const rowsMounted = useForceMountRows();
185
+ const forced = useForcedRows();
178
186
  const searching = needle.key !== "";
179
- useEffect(() => searching ? holdForceMountRows() : void 0, [searching]);
187
+ useEffect(() => searching ? holdForceMountRows(needle.needles) : void 0, [searching, needle]);
188
+ const rowsMounted = forced.all || needle.needles.every((n) => forced.needles.includes(n));
180
189
  /** A rescan the transcript changing asked for, waiting out a burst of stream updates. */
181
190
  const rescanTimer = useRef(null);
182
191
  useEffect(() => () => {
@@ -184,16 +193,16 @@ function useTranscriptSearch(container, query, revision, { terms, revealFirstMat
184
193
  }, []);
185
194
  useEffect(() => {
186
195
  const owner = ownerRef.current;
187
- const root = container.current;
196
+ const root = containerRef.current;
188
197
  if (searching && !rowsMounted) return;
189
198
  const needleChanged = prevNeedleRef.current !== needle.key;
190
199
  if (needleChanged && prevNeedleRef.current !== "") revealArmed.current = false;
191
- prevNeedleRef.current = needle.key;
192
200
  if (rescanTimer.current) {
193
201
  clearTimeout(rescanTimer.current);
194
202
  rescanTimer.current = null;
195
203
  }
196
204
  if (!root || !searching) {
205
+ prevNeedleRef.current = needle.key;
197
206
  if (rangesRef.current.length === 0 && !needleChanged) return;
198
207
  rangesRef.current = [];
199
208
  setMatches((prev) => prev.count === 0 && !prev.capped ? prev : {
@@ -206,6 +215,7 @@ function useTranscriptSearch(container, query, revision, { terms, revealFirstMat
206
215
  }
207
216
  const scan = () => {
208
217
  rescanTimer.current = null;
218
+ prevNeedleRef.current = needle.key;
209
219
  const ranges = collectMatches(root, needle.needles);
210
220
  const jump = needleChanged || revealArmed.current;
211
221
  const nextIndex = needleChanged ? 0 : Math.min(activeIndexRef.current, Math.max(0, ranges.length - 1));
@@ -218,16 +228,22 @@ function useTranscriptSearch(container, query, revision, { terms, revealFirstMat
218
228
  setHighlights(owner, ranges, nextIndex);
219
229
  if (jump && ranges.length > 0) {
220
230
  revealArmed.current = false;
221
- scrollToRange(ranges[nextIndex]);
231
+ scrollToRange(ranges[nextIndex], root);
222
232
  }
223
233
  };
224
- if (needleChanged) scan();
225
- else rescanTimer.current = setTimeout(scan, RESCAN_MS);
234
+ if (needleChanged) {
235
+ let live = true;
236
+ queueMicrotask(() => live && scan());
237
+ return () => {
238
+ live = false;
239
+ };
240
+ }
241
+ rescanTimer.current = setTimeout(scan, RESCAN_MS);
226
242
  }, [
227
243
  needle,
228
244
  searching,
229
245
  revision,
230
- container,
246
+ containerRef,
231
247
  rowsMounted
232
248
  ]);
233
249
  /** Highlights are registered document-wide — drop ours on unmount. */
@@ -241,8 +257,8 @@ function useTranscriptSearch(container, query, revision, { terms, revealFirstMat
241
257
  const next = (activeIndexRef.current + direction + ranges.length) % ranges.length;
242
258
  setActiveIndex(next);
243
259
  setHighlights(ownerRef.current, ranges, next);
244
- scrollToRange(ranges[next]);
245
- }, []);
260
+ scrollToRange(ranges[next], containerRef.current);
261
+ }, [containerRef]);
246
262
  return {
247
263
  count: matches.count,
248
264
  capped: matches.capped,
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Drag-select transcript copy — mirrors the TUI's OSC-52 hook. On
3
- * mouseup inside the timeline, if the live selection intersects the
4
- * transcript and is non-empty, write its plain-text contents to the
5
- * clipboard. Debounced via `lastCopiedRef` so dragging across the same
6
- * selection doesn't spam the clipboard.
2
+ * Drag-select transcript copy — mirrors the TUI's OSC-52 hook. On a
3
+ * mouseup that ends a drag begun inside the timeline, if the live
4
+ * selection intersects the transcript and is non-empty, write its
5
+ * plain-text contents to the clipboard. Debounced via `lastCopiedRef` so
6
+ * dragging across the same selection doesn't spam the clipboard.
7
7
  *
8
8
  * Web equivalent of the TUI's OSC-52 path. We don't subscribe to
9
9
  * `selectionchange` directly because that event fires per-character
@@ -1,11 +1,18 @@
1
1
  import { useEffect, useRef } from "react";
2
2
  // src/chat/transcript/useTranscriptSelectionCopy.ts
3
3
  /**
4
- * Drag-select transcript copy — mirrors the TUI's OSC-52 hook. On
5
- * mouseup inside the timeline, if the live selection intersects the
6
- * transcript and is non-empty, write its plain-text contents to the
7
- * clipboard. Debounced via `lastCopiedRef` so dragging across the same
8
- * selection doesn't spam the clipboard.
4
+ * How far the pointer moves between press and release before it counts as a
5
+ * drag. Below it, a release is a click, even when the browser widens a double
6
+ * or triple click to a word or a line: clicking a row twice to open it must
7
+ * not copy its first word.
8
+ */
9
+ const DRAG_SLOP_PX = 4;
10
+ /**
11
+ * Drag-select transcript copy — mirrors the TUI's OSC-52 hook. On a
12
+ * mouseup that ends a drag begun inside the timeline, if the live
13
+ * selection intersects the transcript and is non-empty, write its
14
+ * plain-text contents to the clipboard. Debounced via `lastCopiedRef` so
15
+ * dragging across the same selection doesn't spam the clipboard.
9
16
  *
10
17
  * Web equivalent of the TUI's OSC-52 path. We don't subscribe to
11
18
  * `selectionchange` directly because that event fires per-character
@@ -18,7 +25,17 @@ function useTranscriptSelectionCopy(containerRef) {
18
25
  useEffect(() => {
19
26
  const root = containerRef.current;
20
27
  if (!root) return;
21
- const onMouseUp = () => {
28
+ let press = null;
29
+ const onMouseDown = (event) => {
30
+ press = {
31
+ x: event.clientX,
32
+ y: event.clientY
33
+ };
34
+ };
35
+ const onMouseUp = (event) => {
36
+ const from = press;
37
+ press = null;
38
+ if (!from || Math.hypot(event.clientX - from.x, event.clientY - from.y) < DRAG_SLOP_PX) return;
22
39
  window.setTimeout(() => {
23
40
  const selection = window.getSelection();
24
41
  if (!selection || selection.isCollapsed) return;
@@ -31,8 +48,12 @@ function useTranscriptSelectionCopy(containerRef) {
31
48
  navigator.clipboard.writeText(text).catch(() => {});
32
49
  }, 0);
33
50
  };
51
+ root.addEventListener("mousedown", onMouseDown);
34
52
  root.addEventListener("mouseup", onMouseUp);
35
- return () => root.removeEventListener("mouseup", onMouseUp);
53
+ return () => {
54
+ root.removeEventListener("mousedown", onMouseDown);
55
+ root.removeEventListener("mouseup", onMouseUp);
56
+ };
36
57
  }, [containerRef]);
37
58
  }
38
59
  export { useTranscriptSelectionCopy };
@@ -10,7 +10,7 @@ import { ViewAnswer, ViewAnswers } from "../../views/headless/answers.js";
10
10
  import { ReplyViewPlace, TextlessExchange } from "../../views/headless/placement.js";
11
11
  import { ChatEvent } from "../headless/host.js";
12
12
  import { ReactNode } from "react";
13
- import { ViewsOrchestrationMode } from "zidane/chat/pure";
13
+ import { TranscriptEvents, ViewsOrchestrationMode } from "zidane/chat/pure";
14
14
  /** Props of the views chunk's fence: see `ui/src/views/TranscriptViews.tsx`. */
15
15
  export interface ViewFencePartProps {
16
16
  /** The fence body. */
@@ -143,8 +143,13 @@ export declare function viewFenceStarts(text: string): readonly number[];
143
143
  * The fences of each chunk of a reply.
144
144
  *
145
145
  * @param chunks - The reply's chunks.
146
+ * @param previous - The last call's chunks and result: a chunk still the same string is not read again (a streaming
147
+ * reply's closed chunks keep theirs), and keeps its value while its base does.
146
148
  */
147
- export declare function chunkFencesFor(chunks: readonly string[]): ChunkFences[];
149
+ export declare function chunkFencesFor(chunks: readonly string[], previous?: {
150
+ chunks: readonly string[];
151
+ fences: readonly ChunkFences[];
152
+ } | null): ChunkFences[];
148
153
  /**
149
154
  * Provides one chunk's fences. The value stays while its base and starts do: a streamed chunk
150
155
  * that grows with no new fence changes nothing below it.
@@ -163,21 +168,36 @@ export declare function ChunkFencesScope({ base, starts, children }: ChunkFences
163
168
  export declare function fenceIndexIn(chunk: ChunkFences, offset: number): number;
164
169
  /** Where each reply row's views go, read per row: a row draws again only when its own place changes. */
165
170
  export declare class ReplyViewPlaces {
166
- private map;
171
+ /** The places of the settled exchanges (or of a whole array). */
172
+ private base;
173
+ /** The places the open exchange sets, over `base`. */
174
+ private top;
175
+ private source;
167
176
  private events;
177
+ /** The folds of a transcript store's settled exchanges, per chunk list. */
178
+ private settled;
168
179
  private textless;
180
+ private textlessKey;
169
181
  private readonly changed;
170
182
  private readonly listeners;
171
183
  /**
172
184
  * Reads the events: the places (`viewPlacements`) and the exchanges with no reply text
173
185
  * (`textlessExchanges`). A stream tick changes neither, so it reads nothing. Rows rendering
174
- * after it read the places; {@link flush} tells the others.
186
+ * after it read the places; {@link flush} tells the others. A transcript store's settled
187
+ * exchanges are read once: a tick reads its open exchange.
175
188
  *
176
- * @param events - The session's events, oldest first.
189
+ * @param events - The session's events, oldest first, or its transcript store.
177
190
  */
178
- update(events: readonly ChatEvent[]): void;
191
+ update(events: readonly ChatEvent[] | TranscriptEvents<ChatEvent>): void;
192
+ private updateTranscript;
179
193
  /** The exchanges with no reply text, as of the last {@link update}. */
180
194
  get textlessExchanges(): readonly TextlessExchange[];
195
+ /** The places as one map (the array path's `previous`). */
196
+ private flat;
197
+ /**
198
+ * Sets the places, noting the rows whose place changed: every row when `whole`, else those the
199
+ * open exchange set before or sets now (the base is the same).
200
+ */
181
201
  private replace;
182
202
  /** Tells the rows whose place changed since the last flush. */
183
203
  flush(): void;
@@ -1,9 +1,9 @@
1
1
  import { lazyPart } from "../../components/lazy-part.js";
2
- import { onlyLastTextChanged, textlessExchanges, unplacedCodemodeViews, viewPlacements } from "../../views/headless/placement.js";
2
+ import { closePlacementExchange, foldPlacements, foldTextless, onlyLastTextChanged, placementFold, sameViewPlace, textlessExchanges, textlessFold, unplacedCodemodeViews, viewPlacements } from "../../views/headless/placement.js";
3
3
  import { useViewsHost, useViewsMeta } from "../../views/ViewsProvider.js";
4
4
  import { Suspense, createContext, useCallback, useContext, useEffect, useMemo, useState, useSyncExternalStore } from "react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { findViewFences, mayHoldViewFence } from "zidane/chat/pure";
6
+ import { findViewFences, mayHoldViewFence, noteTranscriptPass } from "zidane/chat/pure";
7
7
  // src/chat/transcript/view-scope.tsx
8
8
  /** Loads the views chunk. Counted by the tests that prove it never loads with views off. */
9
9
  const loadViews = () => import("../../views/TranscriptViews.js");
@@ -144,13 +144,16 @@ function viewFenceStarts(text) {
144
144
  * The fences of each chunk of a reply.
145
145
  *
146
146
  * @param chunks - The reply's chunks.
147
+ * @param previous - The last call's chunks and result: a chunk still the same string is not read again (a streaming
148
+ * reply's closed chunks keep theirs), and keeps its value while its base does.
147
149
  */
148
- function chunkFencesFor(chunks) {
150
+ function chunkFencesFor(chunks, previous) {
149
151
  let base = 0;
150
- return chunks.map((text) => {
151
- const value = {
152
+ return chunks.map((text, i) => {
153
+ const kept = previous && previous.chunks[i] === text ? previous.fences[i] : void 0;
154
+ const value = kept && kept.base === base ? kept : {
152
155
  base,
153
- starts: viewFenceStarts(text)
156
+ starts: kept ? kept.starts : viewFenceStarts(text)
154
157
  };
155
158
  base += value.starts.length;
156
159
  return value;
@@ -182,37 +185,120 @@ function ChunkFencesScope({ base, starts, children }) {
182
185
  function fenceIndexIn(chunk, offset) {
183
186
  return Math.max(0, chunk.starts.filter((start) => start <= offset).length - 1);
184
187
  }
188
+ const NO_PLACES = /* @__PURE__ */ new Map();
185
189
  /** Where each reply row's views go, read per row: a row draws again only when its own place changes. */
186
190
  var ReplyViewPlaces = class {
187
- map = /* @__PURE__ */ new Map();
191
+ /** The places of the settled exchanges (or of a whole array). */
192
+ base = NO_PLACES;
193
+ /** The places the open exchange sets, over `base`. */
194
+ top = NO_PLACES;
195
+ source = null;
188
196
  events = [];
197
+ /** The folds of a transcript store's settled exchanges, per chunk list. */
198
+ settled = null;
189
199
  textless = [];
200
+ textlessKey = null;
190
201
  changed = /* @__PURE__ */ new Set();
191
202
  listeners = /* @__PURE__ */ new Map();
192
203
  /**
193
204
  * Reads the events: the places (`viewPlacements`) and the exchanges with no reply text
194
205
  * (`textlessExchanges`). A stream tick changes neither, so it reads nothing. Rows rendering
195
- * after it read the places; {@link flush} tells the others.
206
+ * after it read the places; {@link flush} tells the others. A transcript store's settled
207
+ * exchanges are read once: a tick reads its open exchange.
196
208
  *
197
- * @param events - The session's events, oldest first.
209
+ * @param events - The session's events, oldest first, or its transcript store.
198
210
  */
199
211
  update(events) {
200
- if (events === this.events) return;
201
- if (!onlyLastTextChanged(this.events, events)) {
202
- this.replace(viewPlacements(events, this.map));
203
- this.textless = textlessExchanges(events);
212
+ if (events === this.source) return;
213
+ if (Array.isArray(events)) {
214
+ const list = events;
215
+ if (!onlyLastTextChanged(this.events, list)) {
216
+ this.replace(viewPlacements(list, this.flat()), NO_PLACES, true);
217
+ this.textless = textlessExchanges(list);
218
+ }
219
+ this.events = list;
220
+ this.settled = null;
221
+ this.textlessKey = null;
222
+ } else {
223
+ this.updateTranscript(events);
224
+ this.events = [];
225
+ }
226
+ this.source = events;
227
+ }
228
+ updateTranscript(transcript) {
229
+ let settled = this.settled;
230
+ const whole = !settled || settled.chunks !== transcript.chunks;
231
+ if (!settled || whole) {
232
+ noteTranscriptPass("views:settle", transcript.prefixLength);
233
+ const places = placementFold();
234
+ const textless = textlessFold();
235
+ for (const chunk of transcript.chunks) {
236
+ foldPlacements(places, chunk);
237
+ foldTextless(textless, chunk);
238
+ }
239
+ const map = places.places;
240
+ for (const [rowId, place] of map) {
241
+ const before = this.get(rowId);
242
+ if (before && sameViewPlace(before, place)) map.set(rowId, before);
243
+ }
244
+ settled = {
245
+ chunks: transcript.chunks,
246
+ places,
247
+ textless
248
+ };
249
+ this.settled = settled;
250
+ }
251
+ noteTranscriptPass("views:open", transcript.tail.length);
252
+ const fold = placementFold(settled.places);
253
+ foldPlacements(fold, transcript.tail);
254
+ closePlacementExchange(fold);
255
+ const top = fold.places.top;
256
+ for (const [rowId, place] of top) {
257
+ const before = this.get(rowId);
258
+ if (before && sameViewPlace(before, place)) top.set(rowId, before);
259
+ }
260
+ this.replace(settled.places.places, top, whole);
261
+ const tf = textlessFold(settled.textless);
262
+ foldTextless(tf, transcript.tail);
263
+ const open = !tf.replied && tf.turns.length > 0 ? tf.turns : null;
264
+ const key = this.textlessKey;
265
+ if (!(key !== null && key.closed === tf.out && (key.open === open || key.open !== null && open !== null && key.open.length === open.length && key.open.every((t, i) => t === open[i])))) {
266
+ this.textless = open ? [...tf.out, {
267
+ turns: open,
268
+ closed: false
269
+ }] : tf.out;
270
+ this.textlessKey = {
271
+ closed: tf.out,
272
+ open
273
+ };
204
274
  }
205
- this.events = events;
206
275
  }
207
276
  /** The exchanges with no reply text, as of the last {@link update}. */
208
277
  get textlessExchanges() {
209
278
  return this.textless;
210
279
  }
211
- replace(next) {
212
- if (next === this.map) return;
213
- for (const [rowId, place] of next) if (this.map.get(rowId) !== place) this.changed.add(rowId);
214
- for (const rowId of this.map.keys()) if (!next.has(rowId)) this.changed.add(rowId);
215
- this.map = next;
280
+ /** The places as one map (the array path's `previous`). */
281
+ flat() {
282
+ if (this.top.size === 0) return this.base;
283
+ const all = new Map(this.base);
284
+ for (const [rowId, place] of this.top) all.set(rowId, place);
285
+ return all;
286
+ }
287
+ /**
288
+ * Sets the places, noting the rows whose place changed: every row when `whole`, else those the
289
+ * open exchange set before or sets now (the base is the same).
290
+ */
291
+ replace(base, top, whole) {
292
+ const read = (rowId) => top.has(rowId) ? top.get(rowId) : base.get(rowId);
293
+ const keys = whole ? [
294
+ this.base.keys(),
295
+ this.top.keys(),
296
+ base.keys(),
297
+ top.keys()
298
+ ] : [this.top.keys(), top.keys()];
299
+ for (const list of keys) for (const rowId of list) if (this.get(rowId) !== read(rowId)) this.changed.add(rowId);
300
+ this.base = base;
301
+ this.top = top;
216
302
  }
217
303
  /** Tells the rows whose place changed since the last flush. */
218
304
  flush() {
@@ -221,7 +307,7 @@ var ReplyViewPlaces = class {
221
307
  for (const rowId of changed) for (const listener of [...this.listeners.get(rowId) ?? []]) listener();
222
308
  }
223
309
  get(rowId) {
224
- return this.map.get(rowId);
310
+ return this.top.has(rowId) ? this.top.get(rowId) : this.base.get(rowId);
225
311
  }
226
312
  subscribe(rowId, onChange) {
227
313
  let set = this.listeners.get(rowId);
@@ -28,6 +28,8 @@ export interface TreeEntry {
28
28
  kind: 'file' | 'dir';
29
29
  /** Dimmed (gitignored). */
30
30
  ignored?: boolean;
31
+ /** A folder whose contents are listed when it opens (`onExpandFolder`). */
32
+ deferred?: boolean;
31
33
  }
32
34
  /** A path's git status, painted on its row. */
33
35
  export interface TreeGitStatus {
@@ -77,7 +77,7 @@ function FileTree({ controlRef, entries, gitStatus, selectedPath, onSelect, onOp
77
77
  } }
78
78
  } : {}
79
79
  });
80
- const lazyDirs = useMemo(() => entries.filter((e) => e.ignored && e.kind === "dir" && e.path.endsWith("/")).map((e) => e.path), [entries]);
80
+ const lazyDirs = useMemo(() => entries.filter((e) => (e.ignored || e.deferred) && e.kind === "dir" && e.path.endsWith("/")).map((e) => e.path), [entries]);
81
81
  const lazyRef = useRef({
82
82
  dirs: lazyDirs,
83
83
  onExpandFolder
@@ -1,3 +1,4 @@
1
+ import { useLatest } from "../../hooks/useLatest.js";
1
2
  import { useEditorEnvironment } from "./environment.js";
2
3
  import { DIFFS_HOST_STYLE, DIFFS_UNSAFE_CSS, PREFERRED_HIGHLIGHTER, VIRTUALIZER_CONFIG } from "./pierre-theme.js";
3
4
  import { revealOnHighlight } from "./reveal.js";
@@ -21,7 +22,7 @@ function FileViewInner({ name, contents, wrap = false, hideHeader = false, selec
21
22
  const { shikiTheme: theme, appearance } = useEditorEnvironment();
22
23
  const selectable = onSelectionEnd !== void 0;
23
24
  const host = useDetachCleanup();
24
- const latest = useRef({
25
+ const latest = useLatest({
25
26
  onSelectionEnd,
26
27
  onGutterAction,
27
28
  onTokenEnter,
@@ -32,48 +33,38 @@ function FileViewInner({ name, contents, wrap = false, hideHeader = false, selec
32
33
  edit,
33
34
  wrap
34
35
  });
35
- latest.current = {
36
- onSelectionEnd,
37
- onGutterAction,
38
- onTokenEnter,
39
- onTokenLeave,
40
- onTokenClick,
41
- onHighlighted,
42
- renderAnnotation,
43
- edit,
44
- wrap
45
- };
46
36
  const highlightedOnce = useRef(false);
47
37
  const words = useMemo(() => wordHover({
48
- enter: (t, e) => latest.current.onTokenEnter?.(t, e),
49
- leave: () => latest.current.onTokenLeave?.()
50
- }), []);
38
+ enter: (t, e) => latest().onTokenEnter?.(t, e),
39
+ leave: () => latest().onTokenLeave?.()
40
+ }), [latest]);
51
41
  const stable = useMemo(() => ({
52
- onLineSelectionEnd: (r) => latest.current.onSelectionEnd?.(r),
53
- onGutterUtilityClick: (r) => latest.current.onGutterAction?.(r),
42
+ onLineSelectionEnd: (r) => latest().onSelectionEnd?.(r),
43
+ onGutterUtilityClick: (r) => latest().onGutterAction?.(r),
54
44
  onTokenEnter: (t, e) => words.enter(t, e),
55
45
  onTokenLeave: () => words.leave(),
56
46
  onTokenClick: (t, e) => {
57
47
  const token = words.token(t, e.clientX, e.clientY);
58
- if (token) latest.current.onTokenClick?.(token, e);
48
+ if (token) latest().onTokenClick?.(token, e);
59
49
  },
60
- renderAnnotation: (a) => latest.current.renderAnnotation?.(a) ?? null,
61
- onEditChange: (e) => latest.current.edit?.onChange(e.file.contents, e.changes.map((c) => ({
50
+ renderAnnotation: (a) => latest().renderAnnotation?.(a) ?? null,
51
+ onEditChange: (e) => latest().edit?.onChange(e.file.contents, e.changes.map((c) => ({
62
52
  range: c.range,
63
53
  text: c.text
64
54
  }))),
65
- onEditComplete: (e) => latest.current.edit?.onComplete?.(e) ?? "reject",
55
+ onEditComplete: (e) => latest().edit?.onComplete?.(e) ?? "reject",
66
56
  onPostRender: (node, instance, phase) => {
67
57
  const highlighted = phase !== "unmount" && isHighlighted(instance, node);
68
58
  revealOnHighlight(node, highlighted, phase, phase !== "unmount" && colorsFile(instance));
69
- scrollReachOnRender(node, !latest.current.wrap, phase);
70
- if (phase === "unmount" || highlightedOnce.current || !latest.current.onHighlighted) return;
59
+ const current = latest();
60
+ scrollReachOnRender(node, !current.wrap, phase);
61
+ if (phase === "unmount" || highlightedOnce.current || !current.onHighlighted) return;
71
62
  if (highlighted) {
72
63
  highlightedOnce.current = true;
73
- latest.current.onHighlighted();
64
+ current.onHighlighted();
74
65
  }
75
66
  }
76
- }), [words]);
67
+ }), [words, latest]);
77
68
  const hasTokenHandlers = onTokenEnter !== void 0;
78
69
  const hasTokenClick = onTokenClick !== void 0;
79
70
  const hasGutter = onGutterAction !== void 0;
@@ -1,3 +1,4 @@
1
+ import { useLatest } from "../../../hooks/useLatest.js";
1
2
  import { clearFind, paintFind, rowOf } from "./find-highlight.js";
2
3
  import { findAll } from "./find-model.js";
3
4
  import { settleScroll } from "./settle-scroll.js";
@@ -23,23 +24,16 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
23
24
  const [needle, setNeedle] = useState("");
24
25
  const [opts, setOpts] = useState({ caseSensitive: false });
25
26
  const [index, setIndex] = useState(0);
26
- const latest = useRef({
27
- parts,
27
+ const latest = useLatest({
28
28
  surfaces,
29
29
  scroller,
30
30
  fallback
31
31
  });
32
- latest.current = {
33
- parts,
34
- surfaces,
35
- scroller,
36
- fallback
37
- };
38
32
  useEffect(() => {
39
33
  const t = window.setTimeout(setNeedle, QUERY_DEBOUNCE_MS, query);
40
34
  return () => window.clearTimeout(t);
41
35
  }, [query]);
42
- const { matches, capped } = useMemo(() => open && needle ? findAll(latest.current.parts(), needle, opts) : {
36
+ const { matches, capped } = useMemo(() => open && needle ? findAll(parts(), needle, opts) : {
43
37
  matches: [],
44
38
  capped: false
45
39
  }, [
@@ -69,13 +63,14 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
69
63
  cancelAnimationFrame(frame.current);
70
64
  frame.current = requestAnimationFrame(() => {
71
65
  if (!open || !needle) return clearFind(me.current);
72
- paintFind(me.current, latest.current.surfaces(), needle, opts, current);
66
+ paintFind(me.current, latest().surfaces(), needle, opts, current);
73
67
  });
74
68
  }, [
75
69
  open,
76
70
  needle,
77
71
  opts,
78
- current
72
+ current,
73
+ latest
79
74
  ]);
80
75
  useEffect(() => {
81
76
  paint();
@@ -83,14 +78,14 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
83
78
  useEffect(() => () => clearFind(me.current), []);
84
79
  useEffect(() => {
85
80
  if (!open) return;
86
- const root = latest.current.scroller();
81
+ const root = latest().scroller();
87
82
  const watched = /* @__PURE__ */ new WeakSet();
88
83
  const observer = new MutationObserver(() => {
89
84
  watch();
90
85
  paint();
91
86
  });
92
87
  function watch() {
93
- for (const s of latest.current.surfaces()) {
88
+ for (const s of latest().surfaces()) {
94
89
  if (watched.has(s.root)) continue;
95
90
  watched.add(s.root);
96
91
  observer.observe(s.root, {
@@ -110,7 +105,11 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
110
105
  observer.disconnect();
111
106
  root?.removeEventListener("scroll", onScroll);
112
107
  };
113
- }, [open, paint]);
108
+ }, [
109
+ open,
110
+ paint,
111
+ latest
112
+ ]);
114
113
  const stop = useRef(null);
115
114
  const currentRef = useRef(current);
116
115
  useLayoutEffect(() => {
@@ -119,10 +118,10 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
119
118
  const currentKey = current ? `${current.part}\0${current.side}\0${current.line}\0${current.start}` : "";
120
119
  useEffect(() => {
121
120
  stop.current?.();
122
- const root = latest.current.scroller();
121
+ const root = latest().scroller();
123
122
  const target = currentRef.current;
124
123
  if (!open || !target || !root) return;
125
- stop.current = settleScroll(root, () => rowOf(latest.current.surfaces(), target) ?? latest.current.fallback(target, root), {
124
+ stop.current = settleScroll(root, () => rowOf(latest().surfaces(), target) ?? latest().fallback(target, root), {
126
125
  offset: (r) => r.clientHeight * LAND_AT,
127
126
  smooth
128
127
  });
@@ -131,7 +130,8 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
131
130
  open,
132
131
  currentKey,
133
132
  jumps,
134
- smooth
133
+ smooth,
134
+ latest
135
135
  ]);
136
136
  const step = useCallback((direction) => {
137
137
  if (matches.length === 0) return;