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,7 +1,7 @@
1
- import { SecretTimeLeft } from "../secrets.js";
2
1
  import { u as AuthFailure } from "../../../dist/timeout-CmTx6V9y.js";
3
2
  import "../../../dist/index.js";
4
- import { $L as SecretTtl, HM as McpJobView, iM as TaskOutcomeCounts, rM as TaskOutcome } from "../../../dist/index-E1Z0aPmi.js";
3
+ import { AM as TaskOutcomeCounts, kM as TaskOutcome, kR as SecretTtl, mN as McpJobView } from "../../../dist/index-BheVJOLc.js";
4
+ import { SecretTimeLeft } from "../secrets.js";
5
5
  import "../index.js";
6
6
  /** The default English strings of the session sidebar, merged over the chat layer's. */
7
7
  export declare const DEFAULT_SIDEBAR_LABELS: {
@@ -69,6 +69,9 @@ export declare const DEFAULT_SIDEBAR_LABELS: {
69
69
  environmentNotAnswering: (where: string, error?: string) => string;
70
70
  environmentPaused: (where: string) => string;
71
71
  environmentResuming: (where: string) => string;
72
+ environmentPausing: (where: string) => string;
73
+ environmentDeletingSandbox: (where: string) => string;
74
+ environmentRunningAction: (where: string, action?: string) => string;
72
75
  environmentRemoved: (where: string) => string;
73
76
  menuRename: string;
74
77
  menuAddFavorite: string;
@@ -83,6 +86,10 @@ export declare const DEFAULT_SIDEBAR_LABELS: {
83
86
  menuRetryEnvironment: string;
84
87
  menuWakeEnvironment: string;
85
88
  menuMoveTo: string;
89
+ menuTeleportTo: string;
90
+ menuShare: string;
91
+ /** The open session was teleported to a host this app does not know. */
92
+ sessionMovedTo: (host: string) => string;
86
93
  menuMoveToSpace: string;
87
94
  menuDelete: string;
88
95
  newSessionIn: (project: string) => string;
@@ -310,6 +317,16 @@ export declare const DEFAULT_SIDEBAR_LABELS: {
310
317
  modelVerdictTitle: (approved: boolean, model: string, confidence: string | null) => string;
311
318
  loadFullOutput: string;
312
319
  loadingFullOutput: string;
320
+ loadMoreOutput: string;
321
+ loadAllOutput: string;
322
+ loadingOutput: string;
323
+ outputLoaded: (loaded: string, total: string) => string;
324
+ outputLoadFailed: string;
325
+ loadFullInput: string;
326
+ loadingFullInput: string;
327
+ loadFullDiff: string;
328
+ loadingFullDiff: string;
329
+ diffNotShown: (hunks: number, size: string) => string;
313
330
  showOutput: string;
314
331
  inputCaption: string;
315
332
  outputCaption: string;
@@ -76,8 +76,11 @@ const DEFAULT_SIDEBAR_LABELS = {
76
76
  environmentGone: (where, error) => `${where}. Gone${error ? `: ${error}` : "."}`,
77
77
  /** It broke after setup: not answering, and the host stopped reconnecting (`unreachable`). */
78
78
  environmentNotAnswering: (where, error) => `${where}. Not answering${error ? `: ${error}` : "."}`,
79
- environmentPaused: (where) => `${where}. Paused while idle, resumes on your next prompt.`,
79
+ environmentPaused: (where) => `${where}. Paused, resumes on your next prompt.`,
80
80
  environmentResuming: (where) => `${where}. Resuming…`,
81
+ environmentPausing: (where) => `${where}. Pausing…`,
82
+ environmentDeletingSandbox: (where) => `${where}. Deleting the sandbox…`,
83
+ environmentRunningAction: (where, action) => `${where}. ${action ? `${action}…` : "Working…"}`,
81
84
  environmentRemoved: (where) => `${where}. Sandbox deleted, a new one is set up on your next prompt.`,
82
85
  menuRename: "Rename",
83
86
  menuAddFavorite: "Add to favorites",
@@ -92,6 +95,10 @@ const DEFAULT_SIDEBAR_LABELS = {
92
95
  menuRetryEnvironment: "Retry environment setup",
93
96
  menuWakeEnvironment: "Wake up environment",
94
97
  menuMoveTo: "Move to…",
98
+ menuTeleportTo: "Teleport to…",
99
+ menuShare: "Share…",
100
+ /** The open session was teleported to a host this app does not know. */
101
+ sessionMovedTo: (host) => `This session moved to ${host}.`,
95
102
  menuMoveToSpace: "Move to space",
96
103
  menuDelete: "Delete",
97
104
  newSessionIn: (project) => `New session in ${project}`,
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Prewarm: the transcripts around the open session load in idle time, so
3
+ * opening the next one shows it at once.
4
+ *
5
+ * A load is a tail page (`loadEvents`, the page an open shows), but on a
6
+ * host's cache miss it costs a replay of the whole session. So the window
7
+ * reads ahead only when what it would read changes:
8
+ *
9
+ * - Only the open session and the order of the sessions around it count.
10
+ * A row's other fields (a title, a status, a count: every
11
+ * `sessions:changed`) leave the window as it is and read nothing.
12
+ * - A change waits {@link PREWARM_DELAY_MS} for the next: a burst of
13
+ * reorders or a run of selections reads once, for where it ended.
14
+ * - A load in flight is never asked again: a later window takes its page
15
+ * when it lands.
16
+ *
17
+ * What the window holds is bounded by bytes, not by sessions: nearest first,
18
+ * the prewarmed transcripts are kept while their rows fit in `maxBytes`
19
+ * (`eventBytes`), and the reading stops when one no longer fits. The open
20
+ * session and the pinned ones are always kept and never counted.
21
+ */
22
+ /** The stream store as prewarm reads and fills it. */
23
+ export interface PrewarmStreams<K extends string, P> {
24
+ /** The session's transcript is cached. */
25
+ hasEvents: (sessionId: K) => boolean;
26
+ /** Cache a loaded transcript page. */
27
+ setEventsPage: (sessionId: K, page: P) => void;
28
+ /** Drop every cached transcript except these. */
29
+ evictExcept: (keep: ReadonlySet<K>) => void;
30
+ /** About how many bytes the session's cached rows hold. Absent: the window is bounded by its sessions only. */
31
+ eventBytes?: (sessionId: K) => number;
32
+ }
33
+ export interface PrewarmOptions<K extends string, P> {
34
+ streams: PrewarmStreams<K, P>;
35
+ /** Load a session's tail page, as a read ahead of the user. */
36
+ loadEvents: (sessionId: K, options: {
37
+ prewarm: true;
38
+ }) => Promise<P>;
39
+ /** Schedules one read in idle time. */
40
+ idle: {
41
+ request: (run: () => void) => number;
42
+ cancel: (handle: number) => void;
43
+ };
44
+ /** Sessions kept besides the window (side chats on screen). */
45
+ pinned?: () => Iterable<K>;
46
+ /** Wait for a change to settle before reading. Default {@link PREWARM_DELAY_MS}. */
47
+ delayMs?: number;
48
+ /** Bytes of prewarmed rows kept. Default {@link PREWARM_MAX_BYTES}. */
49
+ maxBytes?: number;
50
+ }
51
+ export interface Prewarmer<K extends string> {
52
+ /** The sessions as listed and the open one, after any change: reads ahead when the window moved. */
53
+ update: (sessions: readonly {
54
+ id: K;
55
+ }[], activeSessionId: K | null) => void;
56
+ stop: () => void;
57
+ }
58
+ /** Every session is in the window up to this many. */
59
+ export declare const PREWARM_FULL_THRESHOLD = 12;
60
+ /** Past it, this many on each side of the open session. */
61
+ export declare const PREWARM_WINDOW_RADIUS = 6;
62
+ export declare const PREWARM_DELAY_MS = 200;
63
+ export declare const PREWARM_MAX_BYTES: number;
64
+ /** The sessions around the open one (the first when none is open), nearest first, the one below before the one above. */
65
+ export declare function prewarmWindow<K extends string>(sessions: readonly {
66
+ id: K;
67
+ }[], activeSessionId: K | null): K[];
68
+ export declare function createPrewarmer<K extends string, P>(options: PrewarmOptions<K, P>): Prewarmer<K>;
@@ -0,0 +1,114 @@
1
+ // src/chat/headless/sidebar/prewarm.ts
2
+ /** Every session is in the window up to this many. */
3
+ const PREWARM_FULL_THRESHOLD = 12;
4
+ /** Past it, this many on each side of the open session. */
5
+ const PREWARM_WINDOW_RADIUS = 6;
6
+ const PREWARM_DELAY_MS = 200;
7
+ const PREWARM_MAX_BYTES = 25165824;
8
+ /** The sessions around the open one (the first when none is open), nearest first, the one below before the one above. */
9
+ function prewarmWindow(sessions, activeSessionId) {
10
+ const anchor = activeSessionId ? sessions.findIndex((s) => s.id === activeSessionId) : -1;
11
+ const center = anchor === -1 ? 0 : anchor;
12
+ const radius = sessions.length <= 12 ? sessions.length : 6;
13
+ const out = [];
14
+ for (let d = 0; d <= radius; d++) {
15
+ const below = sessions[center + d];
16
+ if (below) out.push(below.id);
17
+ const above = d > 0 ? sessions[center - d] : void 0;
18
+ if (above) out.push(above.id);
19
+ }
20
+ return out;
21
+ }
22
+ function createPrewarmer(options) {
23
+ const { streams, idle } = options;
24
+ const delayMs = options.delayMs ?? 200;
25
+ const maxBytes = options.maxBytes ?? 25165824;
26
+ let windowKey = null;
27
+ let candidates = [];
28
+ let active = null;
29
+ let timer;
30
+ let stopPump = null;
31
+ /** What the last fit kept: a load landing after the window moved is taken only if it is still in. */
32
+ let kept = /* @__PURE__ */ new Set();
33
+ const inFlight = /* @__PURE__ */ new Set();
34
+ /** Keep the open and pinned sessions, then the window nearest first while its loaded rows fit; evict the rest. */
35
+ const fit = () => {
36
+ const keep = new Set(options.pinned?.() ?? []);
37
+ if (active) keep.add(active);
38
+ const toLoad = [];
39
+ let used = 0;
40
+ for (const id of candidates) {
41
+ if (!streams.hasEvents(id)) {
42
+ keep.add(id);
43
+ toLoad.push(id);
44
+ continue;
45
+ }
46
+ if (keep.has(id)) continue;
47
+ used += streams.eventBytes?.(id) ?? 0;
48
+ if (used > maxBytes) break;
49
+ keep.add(id);
50
+ }
51
+ kept = keep;
52
+ streams.evictExcept(keep);
53
+ return toLoad;
54
+ };
55
+ const run = () => {
56
+ stopPump?.();
57
+ stopPump = null;
58
+ if (candidates.length === 0) return;
59
+ const targets = fit();
60
+ let cancelled = false;
61
+ let handle;
62
+ const pump = (index) => {
63
+ if (cancelled || index >= targets.length) return;
64
+ handle = idle.request(() => {
65
+ if (cancelled) return;
66
+ const id = targets[index];
67
+ if (streams.hasEvents(id) || inFlight.has(id) || !kept.has(id)) {
68
+ pump(index + 1);
69
+ return;
70
+ }
71
+ inFlight.add(id);
72
+ options.loadEvents(id, { prewarm: true }).then((page) => {
73
+ if (!kept.has(id) || streams.hasEvents(id)) return;
74
+ streams.setEventsPage(id, page);
75
+ fit();
76
+ if (!kept.has(id)) cancelled = true;
77
+ }).catch(() => {}).finally(() => {
78
+ inFlight.delete(id);
79
+ pump(index + 1);
80
+ });
81
+ });
82
+ };
83
+ pump(0);
84
+ stopPump = () => {
85
+ cancelled = true;
86
+ if (handle !== void 0) idle.cancel(handle);
87
+ };
88
+ };
89
+ return {
90
+ update(sessions, activeSessionId) {
91
+ const next = prewarmWindow(sessions, activeSessionId);
92
+ const key = `${activeSessionId ?? ""}\n${next.join("\n")}`;
93
+ if (key === windowKey) return;
94
+ windowKey = key;
95
+ candidates = next;
96
+ active = activeSessionId;
97
+ stopPump?.();
98
+ stopPump = null;
99
+ if (timer !== void 0) clearTimeout(timer);
100
+ timer = setTimeout(() => {
101
+ timer = void 0;
102
+ run();
103
+ }, delayMs);
104
+ },
105
+ stop() {
106
+ if (timer !== void 0) clearTimeout(timer);
107
+ timer = void 0;
108
+ stopPump?.();
109
+ stopPump = null;
110
+ windowKey = null;
111
+ }
112
+ };
113
+ }
114
+ export { PREWARM_DELAY_MS, PREWARM_FULL_THRESHOLD, PREWARM_MAX_BYTES, PREWARM_WINDOW_RADIUS, createPrewarmer, prewarmWindow };
@@ -29,6 +29,8 @@ export interface SessionStreamActions<K extends string = string> {
29
29
  appendErrorEvent: (sessionId: K, text: string) => void;
30
30
  /** Whether the store holds any record for the session (no subscription). */
31
31
  hasEvents: (sessionId: K) => boolean;
32
+ /** About how many bytes the session's rows hold (no subscription). */
33
+ eventBytes: (sessionId: K) => number;
32
34
  /** Seeds a run seen only through the session list. */
33
35
  markRunning: (sessionId: K) => void;
34
36
  /** Confirms the session is idle (a run that ended while nobody listened). */
@@ -41,8 +43,8 @@ export interface SessionStreamActions<K extends string = string> {
41
43
  setEventsPage: (sessionId: K, page: SessionStreamPage) => void;
42
44
  /** Brings the session's window back in step after its signals may have gone missing (the reconnect ladder's last steps). */
43
45
  resync: (sessionId: K) => void;
44
- /** Seeds the session's `SYSTEM.md` override. */
45
- seedSystemMd: (sessionId: K, file: SystemMdFile | null) => void;
46
+ /** Seeds the session's `SYSTEM.md` override from `read`, unless a signal lands first. */
47
+ seedSystemMd: (sessionId: K, read: () => Promise<SystemMdFile | null | undefined>) => Promise<void>;
46
48
  /** Names the session the user reads: its run-end compaction waits until it is backgrounded. */
47
49
  noteActiveSession: (sessionId: K | null) => void;
48
50
  /** Fetches and splices the page before the window. `false` when no fetch started. */
@@ -13,7 +13,7 @@ function createSessionStreamActions(streams) {
13
13
  evictExcept: (keep) => streams.evictExcept(keep),
14
14
  setEventsPage: (sessionId, page) => streams.setEventsPage(sessionId, page),
15
15
  resync: (sessionId) => streams.resync(sessionId),
16
- seedSystemMd: (sessionId, file) => store.seedSystemMd(sessionId, file),
16
+ seedSystemMd: (sessionId, read) => store.seedSystemMd(sessionId, read),
17
17
  loadEarlier: (sessionId, options) => streams.loadEarlier(sessionId, options),
18
18
  appendUserPrompt: (sessionId, text, refs, attachments, clientMessageId) => store.appendUserPrompt(sessionId, text, refs, attachments, clientMessageId),
19
19
  dropPendingEcho: (sessionId, text) => store.dropPendingEcho(sessionId, text),
@@ -22,6 +22,7 @@ function createSessionStreamActions(streams) {
22
22
  renamePromptPreviews: (sessionId, from, to) => store.renamePromptPreviews(sessionId, from, to),
23
23
  appendErrorEvent: (sessionId, text) => store.appendErrorEvent(sessionId, text),
24
24
  hasEvents: (sessionId) => store.hasEvents(sessionId),
25
+ eventBytes: (sessionId) => store.eventBytes(sessionId),
25
26
  markRunning: (sessionId) => store.markRunning(sessionId),
26
27
  confirmIdle: (sessionId) => streams.confirmIdle(sessionId),
27
28
  noteActiveSession: (sessionId) => streams.noteActiveSession(sessionId)
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The approximate size of `events`, measured once per array.
3
+ *
4
+ * @param events - A session's rows.
5
+ */
6
+ export declare function eventsBytes(events: readonly unknown[]): number;
7
+ /**
8
+ * The approximate size of a transcript store's rows: each settled exchange is measured once.
9
+ *
10
+ * @param transcript - The open exchange (`tail`) and the settled ones (`chunks`).
11
+ * @param transcript.tail - The open exchange.
12
+ * @param transcript.chunks - The settled exchanges.
13
+ */
14
+ export declare function transcriptBytes(transcript: {
15
+ tail: readonly unknown[];
16
+ chunks: readonly (readonly unknown[])[];
17
+ }): number;
@@ -0,0 +1,46 @@
1
+ // src/chat/headless/streams/event-bytes.ts
2
+ /**
3
+ * About how many bytes a transcript's rows hold, as JSON would spell them:
4
+ * what the prewarm window budgets by (`sidebar/prewarm.ts`). Strings count
5
+ * their length, so it is a size, not an exact one. A rows array is never
6
+ * changed in place (the store replaces it), so its size is kept per array.
7
+ */
8
+ const sizes = /* @__PURE__ */ new WeakMap();
9
+ function approxBytes(value) {
10
+ if (typeof value === "string") return value.length + 2;
11
+ if (value === null || typeof value !== "object") return typeof value === "undefined" || typeof value === "function" ? 0 : 8;
12
+ if (Array.isArray(value)) {
13
+ let bytes = 2;
14
+ for (const item of value) bytes += approxBytes(item) + 1;
15
+ return bytes;
16
+ }
17
+ let bytes = 2;
18
+ for (const key in value) bytes += key.length + 4 + approxBytes(value[key]);
19
+ return bytes;
20
+ }
21
+ /**
22
+ * The approximate size of `events`, measured once per array.
23
+ *
24
+ * @param events - A session's rows.
25
+ */
26
+ function eventsBytes(events) {
27
+ let bytes = sizes.get(events);
28
+ if (bytes === void 0) {
29
+ bytes = approxBytes(events);
30
+ sizes.set(events, bytes);
31
+ }
32
+ return bytes;
33
+ }
34
+ /**
35
+ * The approximate size of a transcript store's rows: each settled exchange is measured once.
36
+ *
37
+ * @param transcript - The open exchange (`tail`) and the settled ones (`chunks`).
38
+ * @param transcript.tail - The open exchange.
39
+ * @param transcript.chunks - The settled exchanges.
40
+ */
41
+ function transcriptBytes(transcript) {
42
+ let bytes = eventsBytes(transcript.tail);
43
+ for (const chunk of transcript.chunks) bytes += eventsBytes(chunk);
44
+ return bytes;
45
+ }
46
+ export { eventsBytes, transcriptBytes };
@@ -15,7 +15,7 @@
15
15
  * the run's end closes every lane still open.
16
16
  */
17
17
  import { ChatEvent } from "../host.js";
18
- import { MarkdownDeltaOptions } from "zidane/chat/pure";
18
+ import { MarkdownDeltaOptions, TranscriptEvents } from "zidane/chat/pure";
19
19
  import { Owner, StreamEvent } from "zidane/chat";
20
20
  /** A live transcript event with the live timings (`ChatEvent`'s, the desktop app's `GuiStreamEvent`'s). */
21
21
  type TimedEvent = Omit<StreamEvent, 'attachments'> & Pick<ChatEvent, 'thinkingStartedAt' | 'thinkingMs' | 'receivedAt'>;
@@ -49,4 +49,28 @@ export declare function applyLiveEvent<E extends TimedEvent = ChatEvent>(events:
49
49
  * @param now - Epoch milliseconds the open lanes close at. Defaults to the current time.
50
50
  */
51
51
  export declare function finishLive<E extends TimedEvent = ChatEvent>(events: readonly E[], now?: number): E[];
52
+ /**
53
+ * {@link applyLiveEvent} on a transcript store: a delta costs the open exchange, not the session.
54
+ *
55
+ * @param transcript - The transcript so far.
56
+ * @param event - The live event to fold in.
57
+ * @param now - Epoch milliseconds stamped on tool rows and thinking lanes. Defaults to the current time.
58
+ * @param markdown - How streamed markdown merges.
59
+ */
60
+ export declare function applyLiveEventToTranscript<E extends TimedEvent = ChatEvent>(transcript: TranscriptEvents<E>, event: E, now?: number, markdown?: MarkdownDeltaOptions): TranscriptEvents<E>;
61
+ /**
62
+ * A turn of `owner` ended (`turn:end`): its thinking lane closes and its streaming markdown is final.
63
+ *
64
+ * @param transcript - The transcript so far.
65
+ * @param owner - The owner whose turn ended.
66
+ * @param now - Epoch milliseconds the lane closes at. Defaults to the current time.
67
+ */
68
+ export declare function endTurnInTranscript<E extends TimedEvent = ChatEvent>(transcript: TranscriptEvents<E>, owner: Owner, now?: number): TranscriptEvents<E>;
69
+ /**
70
+ * {@link finishLive} on a transcript store: only the exchanges still live are visited.
71
+ *
72
+ * @param transcript - The transcript so far.
73
+ * @param now - Epoch milliseconds the open lanes close at. Defaults to the current time.
74
+ */
75
+ export declare function finishLiveTranscript<E extends TimedEvent = ChatEvent>(transcript: TranscriptEvents<E>, now?: number): TranscriptEvents<E>;
52
76
  export {};
@@ -1,4 +1,4 @@
1
- import { appendMarkdownDelta, appendThinkingLines, finalizeStreamingMarkdown, mergeTargetIndex, ownerOf, readEnvironmentSetup, upsertEnvironmentSetup, upsertToolProgress } from "zidane/chat/pure";
1
+ import { appendMarkdownDelta, appendThinkingLines, appendTranscriptEvent, chunkFact, finalizeStreamingMarkdown, mapTranscript, mergeTargetIndex, ownerOf, readEnvironmentSetup, transcriptFinalizeStreamingMarkdownForOwner, transcriptMarkdownDelta, transcriptThinkingLines, transcriptUpsertEnvironmentSetup, transcriptUpsertToolProgress, upsertEnvironmentSetup, upsertToolProgress, withTranscriptTail } from "zidane/chat/pure";
2
2
  // src/chat/headless/streams/live-events.ts
3
3
  const rows = (events) => events;
4
4
  const timed = (events) => events;
@@ -75,4 +75,55 @@ function finishLive(events, now = Date.now()) {
75
75
  const settled = events.some((e) => e.thinkingStartedAt !== void 0 && e.thinkingMs === void 0) ? events.map((e) => e.thinkingStartedAt !== void 0 && e.thinkingMs === void 0 ? closed(e, e.thinkingStartedAt, now) : e) : events;
76
76
  return timed(finalizeStreamingMarkdown(rows(settled)));
77
77
  }
78
- export { applyLiveEvent, closeThinkingSegment, finishLive };
78
+ const asStream = (transcript) => transcript;
79
+ const asTimed = (transcript) => transcript;
80
+ /**
81
+ * {@link applyLiveEvent} on a transcript store: a delta costs the open exchange, not the session.
82
+ *
83
+ * @param transcript - The transcript so far.
84
+ * @param event - The live event to fold in.
85
+ * @param now - Epoch milliseconds stamped on tool rows and thinking lanes. Defaults to the current time.
86
+ * @param markdown - How streamed markdown merges.
87
+ */
88
+ function applyLiveEventToTranscript(transcript, event, now = Date.now(), markdown) {
89
+ const stream = asStream(transcript);
90
+ const plain = event;
91
+ if (event.kind === "tool-progress") return asTimed(transcriptUpsertToolProgress(stream, plain));
92
+ if (readEnvironmentSetup(event)) return asTimed(transcriptUpsertEnvironmentSetup(stream, plain));
93
+ const owner = ownerOf(plain);
94
+ if (event.kind === "thinking") return asTimed(transcriptThinkingLines(stream, event.text, owner, event.depth, event.turnId, { onLaneOpen: (row) => ({
95
+ ...row,
96
+ thinkingStartedAt: now
97
+ }) }));
98
+ const open = withTranscriptTail(transcript, closeThinkingSegment(transcript.tail, owner, now));
99
+ if (event.kind === "markdown" && event.streaming) return asTimed(transcriptMarkdownDelta(asStream(open), event.text, owner, event.depth, event.turnId, markdown));
100
+ if ((event.kind === "tool" || event.kind === "tool-result") && !event.receivedAt) return appendTranscriptEvent(open, {
101
+ ...event,
102
+ receivedAt: now
103
+ });
104
+ return appendTranscriptEvent(open, event);
105
+ }
106
+ /**
107
+ * A turn of `owner` ended (`turn:end`): its thinking lane closes and its streaming markdown is final.
108
+ *
109
+ * @param transcript - The transcript so far.
110
+ * @param owner - The owner whose turn ended.
111
+ * @param now - Epoch milliseconds the lane closes at. Defaults to the current time.
112
+ */
113
+ function endTurnInTranscript(transcript, owner, now = Date.now()) {
114
+ const closed = withTranscriptTail(transcript, closeThinkingSegment(transcript.tail, owner, now));
115
+ return asTimed(transcriptFinalizeStreamingMarkdownForOwner(asStream(closed), owner));
116
+ }
117
+ function isLive(events) {
118
+ return events.some((e) => e.thinkingStartedAt !== void 0 && e.thinkingMs === void 0 || e.kind === "markdown" && e.streaming === true);
119
+ }
120
+ /**
121
+ * {@link finishLive} on a transcript store: only the exchanges still live are visited.
122
+ *
123
+ * @param transcript - The transcript so far.
124
+ * @param now - Epoch milliseconds the open lanes close at. Defaults to the current time.
125
+ */
126
+ function finishLiveTranscript(transcript, now = Date.now()) {
127
+ return mapTranscript(transcript, (events) => finishLive(events, now), (chunk) => chunkFact(chunk, "live", isLive));
128
+ }
129
+ export { applyLiveEvent, applyLiveEventToTranscript, closeThinkingSegment, endTurnInTranscript, finishLive, finishLiveTranscript };
@@ -8,11 +8,14 @@
8
8
  import { ChatEvent } from "../host.js";
9
9
  import { SessionStreamStore } from "./store.js";
10
10
  import { SessionFallbackModel, SessionPageState, SessionRetryState } from "./types.js";
11
+ import { TranscriptEvents } from "zidane/chat/pure";
11
12
  import { SystemMdFile } from "zidane/chat";
12
13
  /** One session's read of the store. Module-level reads keep the subscription stable. */
13
14
  export type SessionStreamRead<T, K extends string = string> = (store: SessionStreamStore<K>, sessionId: K | null) => T;
14
15
  /** The session's events. */
15
16
  export declare function readSessionEvents<K extends string>(store: SessionStreamStore<K>, id: K | null): readonly ChatEvent[];
17
+ /** The session's events as the store holds them (settled exchanges and the open one): no array is made. */
18
+ export declare function readSessionTranscript<K extends string>(store: SessionStreamStore<K>, id: K | null): TranscriptEvents<ChatEvent>;
16
19
  /** The session's scrollback state. */
17
20
  export declare function readSessionPage<K extends string>(store: SessionStreamStore<K>, id: K | null): SessionPageState;
18
21
  /** Whether a run is in flight. */
@@ -1,8 +1,15 @@
1
+ import { emptyTranscript } from "zidane/chat/pure";
1
2
  // src/chat/headless/streams/selectors.ts
2
3
  /** The session's events. */
3
4
  function readSessionEvents(store, id) {
4
5
  return store.getEventsSnapshot(id);
5
6
  }
7
+ /** A session the store holds nothing for: one transcript, so a reader's memo holds. */
8
+ const NO_TRANSCRIPT = emptyTranscript();
9
+ /** The session's events as the store holds them (settled exchanges and the open one): no array is made. */
10
+ function readSessionTranscript(store, id) {
11
+ return (id ? store.getTranscriptSnapshot(id) : void 0) ?? NO_TRANSCRIPT;
12
+ }
6
13
  /** The session's scrollback state. */
7
14
  function readSessionPage(store, id) {
8
15
  return store.getPageSnapshot(id);
@@ -49,4 +56,4 @@ function stableSelection(select) {
49
56
  return next;
50
57
  };
51
58
  }
52
- export { readSessionEvents, readSessionFallback, readSessionPage, readSessionRetry, readSessionRunning, readSessionSystemMd, selectEditEvents, stableSelection };
59
+ export { readSessionEvents, readSessionFallback, readSessionPage, readSessionRetry, readSessionRunning, readSessionSystemMd, readSessionTranscript, selectEditEvents, stableSelection };
@@ -10,7 +10,7 @@ import { ChatEvent, Transcript } from "../host.js";
10
10
  import { FrameScheduler } from "./scheduler.js";
11
11
  import { OtherStreamSignal, SessionStreamPage, SessionStreamSignal } from "./types.js";
12
12
  import { SessionStreamStore } from "./store.js";
13
- import { HistoryChange, HistorySince, MarkdownDeltaOptions } from "zidane/chat/pure";
13
+ import { HistoryChange, HistorySince, MarkdownDeltaOptions, PromptOutline } from "zidane/chat/pure";
14
14
  /** Options for {@link createSessionStreams}. */
15
15
  export interface SessionStreamsOptions<K extends string = string> {
16
16
  /** Pace streamed markdown at a steady speed. A function is read on every signal, so a setting can flip it live (call {@link SessionStreams.drainSmoothing} when it turns off). Default: `false`. */
@@ -21,8 +21,10 @@ export interface SessionStreamsOptions<K extends string = string> {
21
21
  markdown?: MarkdownDeltaOptions;
22
22
  /** Loads a session's persisted tail page. Run-end compaction and a history rewrite's fetch need it; without it neither happens. */
23
23
  loadTail?: (sessionId: K) => Promise<SessionStreamPage>;
24
- /** Loads the page before `beforeSeq`. {@link SessionStreams.loadEarlier} needs it. */
25
- loadBefore?: (sessionId: K, beforeSeq: number) => Promise<SessionStreamPage>;
24
+ /** Loads the page before `beforeSeq`, `limit` turns when given. {@link SessionStreams.loadEarlier} needs it. */
25
+ loadBefore?: (sessionId: K, beforeSeq: number, limit?: number) => Promise<SessionStreamPage>;
26
+ /** Reads the session's prompt outline (`Transcript.outline`). Absent: transcripts offer none. */
27
+ loadOutline?: (sessionId: K) => Promise<PromptOutline | null>;
26
28
  /**
27
29
  * The reconnect ladder's second step (`sessions.historySince`). Reads the rows
28
30
  * of the turns appended after `afterPos` of numbering `historyId`. Returns
@@ -37,7 +39,11 @@ export interface SessionStreamsOptions<K extends string = string> {
37
39
  export interface LoadEarlierOptions {
38
40
  /** Called once the fetch settles: `true` when the older page was spliced in. */
39
41
  onSettled?: (prepended: boolean) => void;
42
+ /** Turns in the page; default the host's page size. */
43
+ limit?: number;
40
44
  }
45
+ /** The most turns {@link SessionStreams.loadThrough} asks for in one page: a host's page ceiling. */
46
+ export declare const LOAD_THROUGH_MAX_TURNS = 1000;
41
47
  /** The session stream store with pacing, scrollback and compaction. Created by {@link createSessionStreams}. */
42
48
  export interface SessionStreams<K extends string = string> {
43
49
  /** The store: per-session snapshots (`get…Snapshot`), per-session subscriptions and the direct writes. */
@@ -85,6 +91,12 @@ export interface SessionStreams<K extends string = string> {
85
91
  * (reset, re-hydration) is dropped and reported as `onSettled(false)`.
86
92
  */
87
93
  loadEarlier: (sessionId: K, options?: LoadEarlierOptions) => boolean;
94
+ /**
95
+ * Loads the earlier pages up to turn position `index`, the gap at once (a page of at most
96
+ * {@link LOAD_THROUGH_MAX_TURNS}, again while it is not in). Resolves `true` once the window starts at or
97
+ * before it, `false` when it can't get there (no more history, a rewrite, a failed read).
98
+ */
99
+ loadThrough: (sessionId: K, index: number) => Promise<boolean>;
88
100
  /** The session the user is looking at: run-end compaction skips it and catches up once it is backgrounded. */
89
101
  noteActiveSession: (sessionId: K | null) => void;
90
102
  /** Reveals every waiting smoothed delta at once and stops the ticker (smoothing was turned off). */
@@ -13,6 +13,8 @@ import { climbReconnectLadder, cursorValid } from "zidane/chat/pure";
13
13
  * walk starts eating the frame budget.
14
14
  */
15
15
  const EVENT_WINDOW_COMPACT_THRESHOLD = 2e3;
16
+ /** The most turns {@link SessionStreams.loadThrough} asks for in one page: a host's page ceiling. */
17
+ const LOAD_THROUGH_MAX_TURNS = 1e3;
16
18
  /**
17
19
  * Creates the session stream store with smooth streaming, lazy scrollback and
18
20
  * run-end compaction. Feed it a client's live signals with `apply`.
@@ -184,7 +186,10 @@ function createSessionStreams(options = {}) {
184
186
  transcript(sessionId) {
185
187
  let transcript = transcripts.get(sessionId);
186
188
  if (!transcript) {
187
- transcript = storeTranscript(store, sessionId, options.loadBefore ? () => void streams.loadEarlier(sessionId) : void 0);
189
+ transcript = storeTranscript(store, sessionId, options.loadBefore ? () => void streams.loadEarlier(sessionId) : void 0, {
190
+ ...options.loadBefore ? { loadThrough: (index) => streams.loadThrough(sessionId, index) } : {},
191
+ ...options.loadOutline ? { outline: () => options.loadOutline(sessionId) } : {}
192
+ });
188
193
  transcripts.set(sessionId, transcript);
189
194
  }
190
195
  return transcript;
@@ -228,7 +233,7 @@ function createSessionStreams(options = {}) {
228
233
  store.setLoadingEarlier(sessionId, true);
229
234
  const issued = store.getPageSnapshot(sessionId);
230
235
  const current = () => store.getPageSnapshot(sessionId) === issued;
231
- loadBefore(sessionId, page.firstSeq).then((older) => {
236
+ (opts?.limit !== void 0 ? loadBefore(sessionId, page.firstSeq, opts.limit) : loadBefore(sessionId, page.firstSeq)).then((older) => {
232
237
  if (!current()) {
233
238
  opts?.onSettled?.(false);
234
239
  return;
@@ -247,6 +252,29 @@ function createSessionStreams(options = {}) {
247
252
  });
248
253
  return true;
249
254
  },
255
+ loadThrough(sessionId, index) {
256
+ return new Promise((resolve) => {
257
+ const step = () => {
258
+ const page = store.getPageSnapshot(sessionId);
259
+ if (store.isHydrated(sessionId) && page.firstSeq <= index) return resolve(true);
260
+ if (!page.hasMore || page.firstSeq <= 0) return resolve(false);
261
+ if (page.loadingEarlier) {
262
+ const off = store.subscribeSession(sessionId, () => {
263
+ if (store.getPageSnapshot(sessionId).loadingEarlier) return;
264
+ off();
265
+ step();
266
+ });
267
+ return;
268
+ }
269
+ const limit = Math.min(Math.max(page.firstSeq - index, 1), LOAD_THROUGH_MAX_TURNS);
270
+ if (!streams.loadEarlier(sessionId, {
271
+ limit,
272
+ onSettled: (ok) => ok ? step() : resolve(false)
273
+ })) resolve(false);
274
+ };
275
+ step();
276
+ });
277
+ },
250
278
  noteActiveSession(sessionId) {
251
279
  activeSession = sessionId;
252
280
  for (const deferred of [...deferredCompact]) {
@@ -268,4 +296,4 @@ function createSessionStreams(options = {}) {
268
296
  };
269
297
  return streams;
270
298
  }
271
- export { createSessionStreams };
299
+ export { LOAD_THROUGH_MAX_TURNS, createSessionStreams };