zidane-ui 9.1.1 → 9.1.3

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 (1071) hide show
  1. package/README.md +2 -0
  2. package/dist/adapters/index.js +1 -1
  3. package/dist/adapters/server-transcript-members.d.ts +1 -1
  4. package/dist/adapters/server-transcript-members.js +19 -1
  5. package/dist/app/ModalProvider.d.ts +3 -1
  6. package/dist/app/ModalProvider.js +15 -9
  7. package/dist/approvals/headless/index.js +1 -1
  8. package/dist/chat/HostTranscript.d.ts +3 -1
  9. package/dist/chat/HostTranscript.js +5 -3
  10. package/dist/chat/Transcript.js +1 -1
  11. package/dist/chat/composer/ComposerEditor.js +1 -1
  12. package/dist/chat/composer/index.js +1 -1
  13. package/dist/chat/composer/use-composer-stores.js +1 -1
  14. package/dist/chat/headless/block-runs.d.ts +57 -0
  15. package/dist/chat/headless/block-runs.js +123 -0
  16. package/dist/chat/headless/composer/index.js +2 -2
  17. package/dist/chat/headless/fixture-transcript.d.ts +6 -1
  18. package/dist/chat/headless/fixture-transcript.js +49 -0
  19. package/dist/chat/headless/host.d.ts +3 -0
  20. package/dist/chat/headless/index.d.ts +2 -1
  21. package/dist/chat/headless/index.js +12 -11
  22. package/dist/chat/headless/labels.d.ts +42 -0
  23. package/dist/chat/headless/labels.js +42 -0
  24. package/dist/chat/headless/session-list.d.ts +27 -0
  25. package/dist/chat/headless/sidebar/index.js +1 -1
  26. package/dist/chat/headless/sidebar/labels.d.ts +27 -0
  27. package/dist/chat/headless/streams/index.js +1 -1
  28. package/dist/chat/headless/streams/live-events.js +2 -1
  29. package/dist/chat/headless/streams/session-streams.js +2 -2
  30. package/dist/chat/headless/streams/store.js +2 -2
  31. package/dist/chat/headless/transcript/batch.d.ts +21 -1
  32. package/dist/chat/headless/transcript/batch.js +55 -10
  33. package/dist/chat/headless/transcript/collapse.js +18 -3
  34. package/dist/chat/headless/transcript/fold.js +26 -10
  35. package/dist/chat/headless/transcript/index.js +1 -1
  36. package/dist/chat/headless/transcript/rows.d.ts +7 -1
  37. package/dist/chat/index.d.ts +6 -1
  38. package/dist/chat/index.js +7 -2
  39. package/dist/chat/testing/contract.d.ts +6 -1
  40. package/dist/chat/testing/contract.js +30 -3
  41. package/dist/chat/transcript/AnsiText.d.ts +27 -0
  42. package/dist/chat/transcript/AnsiText.js +73 -0
  43. package/dist/chat/transcript/CodemodeScript.d.ts +33 -0
  44. package/dist/chat/transcript/CodemodeScript.js +212 -0
  45. package/dist/chat/transcript/LiveOutput.d.ts +21 -0
  46. package/dist/chat/transcript/LiveOutput.js +42 -0
  47. package/dist/chat/transcript/TranscriptRow.js +19 -2
  48. package/dist/chat/transcript/actions.d.ts +6 -0
  49. package/dist/chat/transcript/index.d.ts +6 -1
  50. package/dist/chat/transcript/index.js +6 -1
  51. package/dist/chat/transcript/markdown.js +9 -0
  52. package/dist/chat/transcript/renderers.d.ts +7 -0
  53. package/dist/chat/transcript/script-input.d.ts +17 -0
  54. package/dist/chat/transcript/script-input.js +16 -0
  55. package/dist/chat/transcript/shell-block-scope.d.ts +29 -0
  56. package/dist/chat/transcript/shell-block-scope.js +18 -0
  57. package/dist/chat/transcript/shell-block.d.ts +27 -0
  58. package/dist/chat/transcript/shell-block.js +306 -0
  59. package/dist/chat/transcript/tool-parts.d.ts +18 -6
  60. package/dist/chat/transcript/tool-parts.js +15 -5
  61. package/dist/chat/transcript/tool-payload.js +6 -3
  62. package/dist/chat/transcript/tool-row.js +155 -96
  63. package/dist/chat/transcript/user-bash.js +3 -2
  64. package/dist/code/HighlightedCode.js +3 -69
  65. package/dist/code/highlight-lines.d.ts +24 -0
  66. package/dist/code/highlight-lines.js +41 -0
  67. package/dist/code/use-highlighted-html.d.ts +5 -0
  68. package/dist/code/use-highlighted-html.js +75 -0
  69. package/dist/core.css +6 -2
  70. package/dist/dist/{index-CGbOWa7y.d.ts → index-WlE93Q6d.d.ts} +101 -3
  71. package/dist/extensions/ExtensionSettingsSidebar.js +19 -3
  72. package/dist/extensions/kit.d.ts +1 -1
  73. package/dist/git/BranchMenu.d.ts +1 -7
  74. package/dist/git/BranchMenu.js +17 -40
  75. package/dist/git/headless/labels.d.ts +0 -2
  76. package/dist/git/headless/labels.js +0 -2
  77. package/dist/index.d.ts +4 -3
  78. package/dist/index.js +2 -1
  79. package/dist/onboarding/index.js +1 -1
  80. package/dist/onboarding/steps/ConnectStep.js +1 -1
  81. package/dist/onboarding/steps/ExtensionsStep.js +1 -1
  82. package/dist/onboarding/steps/ReadyStep.js +1 -1
  83. package/dist/onboarding/steps/connect/ProviderPanel.js +1 -1
  84. package/dist/session/headless/index.js +2 -2
  85. package/dist/settings/SettingsShell.d.ts +3 -1
  86. package/dist/settings/SettingsShell.js +15 -8
  87. package/dist/settings/headless/catalog.js +5 -0
  88. package/dist/settings/headless/layout.js +2 -1
  89. package/dist/settings/headless/registry.d.ts +2 -0
  90. package/dist/settings/headless/search.d.ts +1 -1
  91. package/dist/settings/sections/environments/EnvironmentsSection.js +1 -1
  92. package/dist/settings/sections/extensions/ExtensionsSection.js +2 -2
  93. package/dist/settings/sections/models/ModelRows.js +1 -1
  94. package/dist/settings/sections/models/model-test.js +1 -1
  95. package/dist/styles.css +291 -2
  96. package/dist/terminal/TerminalProvider.d.ts +3 -1
  97. package/dist/terminal/TerminalProvider.js +5 -1
  98. package/dist/terminal/headless/store.d.ts +10 -0
  99. package/dist/terminal/headless/store.js +16 -0
  100. package/dist/terminal/index.d.ts +2 -2
  101. package/dist/terminal/index.js +2 -2
  102. package/dist/theme/runtime-icons.d.ts +50 -0
  103. package/dist/theme/runtime-icons.js +95 -0
  104. package/package.json +3 -6
  105. package/src/styles/primitives.css +5 -2
  106. package/src/styles/transcript.css +281 -0
  107. package/src/adapters/browser-appearance-host.ts +0 -51
  108. package/src/adapters/browser-keybindings-host.ts +0 -48
  109. package/src/adapters/browser-workspace-host.ts +0 -92
  110. package/src/adapters/closable-client.ts +0 -34
  111. package/src/adapters/extension-modules.ts +0 -360
  112. package/src/adapters/index.ts +0 -35
  113. package/src/adapters/live-events.ts +0 -6
  114. package/src/adapters/live.ts +0 -270
  115. package/src/adapters/run-host.ts +0 -238
  116. package/src/adapters/server-approvals-host.ts +0 -102
  117. package/src/adapters/server-client.ts +0 -15
  118. package/src/adapters/server-composer-host.ts +0 -459
  119. package/src/adapters/server-extensions-host.ts +0 -979
  120. package/src/adapters/server-files-host.ts +0 -287
  121. package/src/adapters/server-git-host.ts +0 -289
  122. package/src/adapters/server-host.ts +0 -489
  123. package/src/adapters/server-machines-host.ts +0 -283
  124. package/src/adapters/server-oauth-flow.ts +0 -133
  125. package/src/adapters/server-onboarding-host.ts +0 -363
  126. package/src/adapters/server-palette-host.ts +0 -134
  127. package/src/adapters/server-session-host.ts +0 -241
  128. package/src/adapters/server-settings-accounts.ts +0 -212
  129. package/src/adapters/server-settings-host.ts +0 -120
  130. package/src/adapters/server-settings-models.ts +0 -46
  131. package/src/adapters/server-settings-performance.ts +0 -58
  132. package/src/adapters/server-settings-sections.ts +0 -222
  133. package/src/adapters/server-sidebar-host.ts +0 -59
  134. package/src/adapters/server-terminal-host.ts +0 -124
  135. package/src/adapters/server-transcript-members.ts +0 -131
  136. package/src/adapters/sse-host.ts +0 -264
  137. package/src/adapters/sse-parser.ts +0 -82
  138. package/src/adapters/sse-protocol.ts +0 -118
  139. package/src/adapters/stream-pacer.ts +0 -122
  140. package/src/adapters/worker-host.ts +0 -192
  141. package/src/adapters/worker-protocol.ts +0 -97
  142. package/src/app/AppHostProvider.tsx +0 -135
  143. package/src/app/ModalProvider.tsx +0 -731
  144. package/src/app/headless/app-host.ts +0 -61
  145. package/src/app/headless/index.ts +0 -6
  146. package/src/app/headless/resource.ts +0 -444
  147. package/src/app/index.ts +0 -9
  148. package/src/app/testing/index.ts +0 -90
  149. package/src/app/useConfirm.tsx +0 -65
  150. package/src/app/useResource.ts +0 -30
  151. package/src/appearance/AppearanceProvider.tsx +0 -383
  152. package/src/appearance/apply.ts +0 -69
  153. package/src/appearance/headless/fixture-host.ts +0 -111
  154. package/src/appearance/headless/fonts.ts +0 -224
  155. package/src/appearance/headless/host.ts +0 -65
  156. package/src/appearance/headless/index.ts +0 -12
  157. package/src/appearance/headless/prefs.ts +0 -252
  158. package/src/appearance/headless/storage.ts +0 -127
  159. package/src/appearance/headless/zoom-commands.ts +0 -21
  160. package/src/appearance/index.ts +0 -11
  161. package/src/appearance/testing/contract.ts +0 -210
  162. package/src/appearance/testing/index.ts +0 -6
  163. package/src/approvals/ApprovalBar.tsx +0 -234
  164. package/src/approvals/ApprovalConcern.tsx +0 -33
  165. package/src/approvals/ApprovalShell.tsx +0 -69
  166. package/src/approvals/ApprovalsProvider.tsx +0 -110
  167. package/src/approvals/FileEditApproval.tsx +0 -310
  168. package/src/approvals/HunkPreviews.tsx +0 -225
  169. package/src/approvals/SafelistPanel.tsx +0 -149
  170. package/src/approvals/headless/fixture-host.ts +0 -73
  171. package/src/approvals/headless/fixtures.ts +0 -86
  172. package/src/approvals/headless/heads.ts +0 -81
  173. package/src/approvals/headless/host.ts +0 -80
  174. package/src/approvals/headless/index.ts +0 -12
  175. package/src/approvals/headless/labels.ts +0 -67
  176. package/src/approvals/headless/pending.ts +0 -91
  177. package/src/approvals/headless/preview.ts +0 -94
  178. package/src/approvals/headless/safelist.ts +0 -63
  179. package/src/approvals/index.ts +0 -13
  180. package/src/approvals/key-scope.ts +0 -33
  181. package/src/approvals/testing/contract.ts +0 -230
  182. package/src/approvals/testing/index.ts +0 -7
  183. package/src/brands/marks.ts +0 -298
  184. package/src/chat/ChatProvider.tsx +0 -60
  185. package/src/chat/DaemonOrb.tsx +0 -107
  186. package/src/chat/HostBadge.tsx +0 -71
  187. package/src/chat/HostStatusDot.tsx +0 -53
  188. package/src/chat/HostTranscript.tsx +0 -101
  189. package/src/chat/PdfPreview.tsx +0 -65
  190. package/src/chat/RunEstimateChip.tsx +0 -168
  191. package/src/chat/SessionFilterMenu.tsx +0 -397
  192. package/src/chat/SessionGroupHeader.tsx +0 -177
  193. package/src/chat/SessionHostHeader.tsx +0 -66
  194. package/src/chat/SessionList.tsx +0 -413
  195. package/src/chat/SessionListRow.tsx +0 -296
  196. package/src/chat/SessionStreamsProvider.tsx +0 -253
  197. package/src/chat/StatusDot.tsx +0 -128
  198. package/src/chat/TextPreview.tsx +0 -121
  199. package/src/chat/Throbber.tsx +0 -270
  200. package/src/chat/Transcript.tsx +0 -523
  201. package/src/chat/composer/AgentPicker.tsx +0 -155
  202. package/src/chat/composer/AgentPickerDialog.tsx +0 -99
  203. package/src/chat/composer/ApprovalDock.tsx +0 -64
  204. package/src/chat/composer/ArchivedBanner.tsx +0 -44
  205. package/src/chat/composer/AttachmentTiles.tsx +0 -211
  206. package/src/chat/composer/Composer.tsx +0 -500
  207. package/src/chat/composer/ComposerBadges.tsx +0 -339
  208. package/src/chat/composer/ComposerControls.tsx +0 -243
  209. package/src/chat/composer/ComposerEditor.tsx +0 -101
  210. package/src/chat/composer/ComposerHostProvider.tsx +0 -46
  211. package/src/chat/composer/ComposerShell.tsx +0 -129
  212. package/src/chat/composer/ContextBreakdown.tsx +0 -382
  213. package/src/chat/composer/ContextOrb.tsx +0 -176
  214. package/src/chat/composer/ConversationBadges.tsx +0 -168
  215. package/src/chat/composer/DockCard.tsx +0 -126
  216. package/src/chat/composer/EffortPickerDialog.tsx +0 -184
  217. package/src/chat/composer/HostComposer.tsx +0 -135
  218. package/src/chat/composer/HostContextOrb.tsx +0 -94
  219. package/src/chat/composer/HostModelChainList.tsx +0 -102
  220. package/src/chat/composer/HostPicker.tsx +0 -97
  221. package/src/chat/composer/HostPickers.tsx +0 -320
  222. package/src/chat/composer/ImageModelList.tsx +0 -151
  223. package/src/chat/composer/ModelChainList.tsx +0 -442
  224. package/src/chat/composer/ModelChainParts.tsx +0 -247
  225. package/src/chat/composer/ModelChainRow.tsx +0 -191
  226. package/src/chat/composer/ModelChainRows.tsx +0 -223
  227. package/src/chat/composer/ModelChainTooltip.tsx +0 -121
  228. package/src/chat/composer/ModelFacts.tsx +0 -204
  229. package/src/chat/composer/ModelOptionsPicker.tsx +0 -257
  230. package/src/chat/composer/ModelPicker.tsx +0 -513
  231. package/src/chat/composer/ModelPickerDialog.tsx +0 -99
  232. package/src/chat/composer/ModelProviderPills.tsx +0 -141
  233. package/src/chat/composer/PickerPill.tsx +0 -41
  234. package/src/chat/composer/ProjectMenu.tsx +0 -187
  235. package/src/chat/composer/PromptHistoryProvider.tsx +0 -214
  236. package/src/chat/composer/RetryPill.tsx +0 -47
  237. package/src/chat/composer/RunStatusChip.tsx +0 -150
  238. package/src/chat/composer/ScopeToggle.tsx +0 -94
  239. package/src/chat/composer/SelectTurnHint.tsx +0 -40
  240. package/src/chat/composer/SendButton.tsx +0 -89
  241. package/src/chat/composer/ServerScopeToggle.tsx +0 -188
  242. package/src/chat/composer/attachment-ingest.ts +0 -413
  243. package/src/chat/composer/attachments.tsx +0 -176
  244. package/src/chat/composer/badge-order.ts +0 -65
  245. package/src/chat/composer/composer-bus.ts +0 -317
  246. package/src/chat/composer/index.ts +0 -63
  247. package/src/chat/composer/load-composer-editor.ts +0 -25
  248. package/src/chat/composer/model-catalog.ts +0 -424
  249. package/src/chat/composer/model-list-layout.ts +0 -118
  250. package/src/chat/composer/prompt-history-nav.ts +0 -60
  251. package/src/chat/composer/scope-side.ts +0 -7
  252. package/src/chat/composer/suggestion-extension.ts +0 -113
  253. package/src/chat/composer/suggestions.tsx +0 -115
  254. package/src/chat/composer/use-agent-profiles.ts +0 -97
  255. package/src/chat/composer/use-cache-hints.ts +0 -93
  256. package/src/chat/composer/use-composer-stores.ts +0 -140
  257. package/src/chat/composer/use-draft-target.ts +0 -317
  258. package/src/chat/composer/use-new-session-defaults.ts +0 -201
  259. package/src/chat/composer/use-provider-ready-poll.ts +0 -35
  260. package/src/chat/composer/use-run-meter.ts +0 -140
  261. package/src/chat/composer/use-send-prompt.ts +0 -188
  262. package/src/chat/composer/use-session-meters.ts +0 -109
  263. package/src/chat/composer/use-sustained-work.ts +0 -74
  264. package/src/chat/composer/useAttachmentIngest.ts +0 -116
  265. package/src/chat/composer/useModelListSpy.ts +0 -19
  266. package/src/chat/headless/badge-refs.ts +0 -76
  267. package/src/chat/headless/chip-labels.ts +0 -40
  268. package/src/chat/headless/chip-settle.ts +0 -53
  269. package/src/chat/headless/chip-views.ts +0 -215
  270. package/src/chat/headless/composer/attachment-dedupe.ts +0 -50
  271. package/src/chat/headless/composer/commands.ts +0 -16
  272. package/src/chat/headless/composer/composer-sources.ts +0 -150
  273. package/src/chat/headless/composer/conversation-badges.ts +0 -227
  274. package/src/chat/headless/composer/draft-sync.ts +0 -199
  275. package/src/chat/headless/composer/editor-markdown.ts +0 -137
  276. package/src/chat/headless/composer/ghost-autocomplete.ts +0 -381
  277. package/src/chat/headless/composer/host-chrome.ts +0 -197
  278. package/src/chat/headless/composer/host.ts +0 -250
  279. package/src/chat/headless/composer/index.ts +0 -17
  280. package/src/chat/headless/composer/labels-chrome.ts +0 -83
  281. package/src/chat/headless/composer/labels-editor.ts +0 -44
  282. package/src/chat/headless/composer/labels.ts +0 -18
  283. package/src/chat/headless/composer/live-cost.ts +0 -67
  284. package/src/chat/headless/composer/model-knobs.ts +0 -179
  285. package/src/chat/headless/composer/model-names.ts +0 -145
  286. package/src/chat/headless/composer/model-picker-prefs.ts +0 -90
  287. package/src/chat/headless/composer/models.ts +0 -86
  288. package/src/chat/headless/composer/new-session-defaults.ts +0 -68
  289. package/src/chat/headless/composer/prompt-suggestions.ts +0 -72
  290. package/src/chat/headless/composer/remember-model-pick.ts +0 -132
  291. package/src/chat/headless/composer/run-meter.ts +0 -228
  292. package/src/chat/headless/composer-modes.ts +0 -170
  293. package/src/chat/headless/draft-scope.ts +0 -136
  294. package/src/chat/headless/draft-target.ts +0 -87
  295. package/src/chat/headless/extension-sources.ts +0 -64
  296. package/src/chat/headless/file-chip.ts +0 -175
  297. package/src/chat/headless/fixture-host.ts +0 -294
  298. package/src/chat/headless/fixture-transcript.ts +0 -125
  299. package/src/chat/headless/fixtures/demo-transcript-all-kinds.ts +0 -233
  300. package/src/chat/headless/fixtures/demo-transcript.ts +0 -244
  301. package/src/chat/headless/host.ts +0 -264
  302. package/src/chat/headless/hosts.ts +0 -55
  303. package/src/chat/headless/index.ts +0 -31
  304. package/src/chat/headless/labels.ts +0 -373
  305. package/src/chat/headless/markdown-chunks.ts +0 -134
  306. package/src/chat/headless/path-resolver.ts +0 -178
  307. package/src/chat/headless/prompt-origin.ts +0 -90
  308. package/src/chat/headless/reference-store.ts +0 -285
  309. package/src/chat/headless/send-flow.ts +0 -347
  310. package/src/chat/headless/session-list.ts +0 -400
  311. package/src/chat/headless/sidebar/activity.ts +0 -179
  312. package/src/chat/headless/sidebar/badges.ts +0 -190
  313. package/src/chat/headless/sidebar/compaction.ts +0 -98
  314. package/src/chat/headless/sidebar/directory.ts +0 -1046
  315. package/src/chat/headless/sidebar/dot-state.ts +0 -36
  316. package/src/chat/headless/sidebar/environment.ts +0 -70
  317. package/src/chat/headless/sidebar/estimates.ts +0 -146
  318. package/src/chat/headless/sidebar/host.ts +0 -41
  319. package/src/chat/headless/sidebar/index.ts +0 -18
  320. package/src/chat/headless/sidebar/labels.ts +0 -161
  321. package/src/chat/headless/sidebar/notifications.ts +0 -61
  322. package/src/chat/headless/sidebar/pinned-projects.ts +0 -51
  323. package/src/chat/headless/sidebar/pinned-sessions.ts +0 -27
  324. package/src/chat/headless/sidebar/project-icons.ts +0 -116
  325. package/src/chat/headless/sidebar/query.ts +0 -621
  326. package/src/chat/headless/sidebar/rows.ts +0 -427
  327. package/src/chat/headless/sidebar/types.ts +0 -96
  328. package/src/chat/headless/sidebar/view.ts +0 -367
  329. package/src/chat/headless/site-icons.ts +0 -51
  330. package/src/chat/headless/smooth-stream.ts +0 -76
  331. package/src/chat/headless/store.ts +0 -62
  332. package/src/chat/headless/streams/actions.ts +0 -85
  333. package/src/chat/headless/streams/index.ts +0 -25
  334. package/src/chat/headless/streams/live-events.ts +0 -124
  335. package/src/chat/headless/streams/merge.ts +0 -60
  336. package/src/chat/headless/streams/pacer.ts +0 -189
  337. package/src/chat/headless/streams/prompt-previews.ts +0 -64
  338. package/src/chat/headless/streams/scheduler.ts +0 -36
  339. package/src/chat/headless/streams/selectors.ts +0 -76
  340. package/src/chat/headless/streams/session-streams.ts +0 -407
  341. package/src/chat/headless/streams/store.ts +0 -1107
  342. package/src/chat/headless/streams/transcript.ts +0 -41
  343. package/src/chat/headless/streams/types.ts +0 -84
  344. package/src/chat/headless/transcript/batch.ts +0 -429
  345. package/src/chat/headless/transcript/collapse.ts +0 -789
  346. package/src/chat/headless/transcript/fold-actions.ts +0 -269
  347. package/src/chat/headless/transcript/fold-attachments.ts +0 -78
  348. package/src/chat/headless/transcript/fold.ts +0 -382
  349. package/src/chat/headless/transcript/index.ts +0 -41
  350. package/src/chat/headless/transcript/nesting.ts +0 -73
  351. package/src/chat/headless/transcript/pairing.ts +0 -124
  352. package/src/chat/headless/transcript/rows.ts +0 -377
  353. package/src/chat/headless/transcript/run-failures.ts +0 -72
  354. package/src/chat/headless/transcript/select-stops.ts +0 -151
  355. package/src/chat/headless/transcript/tool-media.ts +0 -42
  356. package/src/chat/headless/transcript-host.ts +0 -180
  357. package/src/chat/headless/transcript-labels.ts +0 -12
  358. package/src/chat/headless/turn-labels.ts +0 -28
  359. package/src/chat/headless/turn-prompt.ts +0 -32
  360. package/src/chat/index.ts +0 -31
  361. package/src/chat/interactions/HostInteractions.tsx +0 -76
  362. package/src/chat/interactions/InboxPanel.tsx +0 -226
  363. package/src/chat/interactions/InteractionCard.tsx +0 -111
  364. package/src/chat/interactions/PlanCard.tsx +0 -186
  365. package/src/chat/interactions/QuestionField.tsx +0 -336
  366. package/src/chat/interactions/QuestionForm.tsx +0 -283
  367. package/src/chat/interactions/card-ui.tsx +0 -86
  368. package/src/chat/interactions/hooks.ts +0 -49
  369. package/src/chat/interactions/index.ts +0 -8
  370. package/src/chat/provider-color.ts +0 -71
  371. package/src/chat/rich-composer/MentionList.tsx +0 -238
  372. package/src/chat/rich-composer/RichComposer.tsx +0 -1071
  373. package/src/chat/rich-composer/badge-decorations.ts +0 -157
  374. package/src/chat/rich-composer/composer-controls.tsx +0 -102
  375. package/src/chat/rich-composer/composer-extensions.ts +0 -388
  376. package/src/chat/rich-composer/composer-keys.ts +0 -416
  377. package/src/chat/rich-composer/ghost-plugin.ts +0 -89
  378. package/src/chat/rich-composer/index.ts +0 -3
  379. package/src/chat/rich-composer/mention-popover.ts +0 -336
  380. package/src/chat/rich-composer/slash-completion.ts +0 -143
  381. package/src/chat/rich-composer/use-composer-bus.ts +0 -57
  382. package/src/chat/rich-composer/use-composer-editor.ts +0 -216
  383. package/src/chat/rich-composer/use-composer-sources.ts +0 -90
  384. package/src/chat/rich-composer/use-draft-mirror.ts +0 -398
  385. package/src/chat/rich-composer/use-editor-handover.ts +0 -45
  386. package/src/chat/rich-composer/use-extension-composer.ts +0 -80
  387. package/src/chat/rich-composer/use-ghost-lifecycle.ts +0 -265
  388. package/src/chat/rich-composer/use-prompt-ghost.ts +0 -90
  389. package/src/chat/rich-composer/use-staged-attachments.ts +0 -65
  390. package/src/chat/sidebar/MainSessionRow.tsx +0 -102
  391. package/src/chat/sidebar/ProjectIcon.tsx +0 -399
  392. package/src/chat/sidebar/RowChips.tsx +0 -98
  393. package/src/chat/sidebar/SessionSidebar.tsx +0 -1039
  394. package/src/chat/sidebar/SidebarDecoration.tsx +0 -93
  395. package/src/chat/sidebar/SidebarFilterMenu.tsx +0 -270
  396. package/src/chat/sidebar/SidebarFooter.tsx +0 -244
  397. package/src/chat/sidebar/SidebarFrame.tsx +0 -154
  398. package/src/chat/sidebar/SidebarGroupHeader.tsx +0 -263
  399. package/src/chat/sidebar/SidebarHostProvider.tsx +0 -51
  400. package/src/chat/sidebar/SidebarRowView.tsx +0 -151
  401. package/src/chat/sidebar/SidebarSearchRow.tsx +0 -66
  402. package/src/chat/sidebar/SidebarSessionRow.tsx +0 -317
  403. package/src/chat/sidebar/SidebarToggleButton.tsx +0 -48
  404. package/src/chat/sidebar/SpaceSwitcher.tsx +0 -341
  405. package/src/chat/sidebar/SpacesSection.tsx +0 -259
  406. package/src/chat/sidebar/collapsed.ts +0 -61
  407. package/src/chat/sidebar/index.ts +0 -109
  408. package/src/chat/sidebar/session-menu.ts +0 -441
  409. package/src/chat/sidebar/sidebar-focus-hold.ts +0 -56
  410. package/src/chat/sidebar/sidebar-live.tsx +0 -666
  411. package/src/chat/sidebar/use-main-session.ts +0 -32
  412. package/src/chat/sidebar/useAgentNames.ts +0 -12
  413. package/src/chat/sidebar/useCompactionProgress.ts +0 -24
  414. package/src/chat/sidebar/usePinnedProjects.ts +0 -36
  415. package/src/chat/sidebar/useSaveViewAsSpace.ts +0 -42
  416. package/src/chat/sidebar/useSessionActivity.ts +0 -24
  417. package/src/chat/sidebar/useSessionBadges.ts +0 -26
  418. package/src/chat/sidebar/useSessionDirectoryView.ts +0 -128
  419. package/src/chat/sidebar/useSessionSearch.ts +0 -94
  420. package/src/chat/sidebar/useSidebarKeyboardNav.ts +0 -167
  421. package/src/chat/sidebar/useSidebarLabels.ts +0 -10
  422. package/src/chat/testing/composer.contract.ts +0 -508
  423. package/src/chat/testing/contract.ts +0 -634
  424. package/src/chat/testing/fixture-composer-chrome.ts +0 -159
  425. package/src/chat/testing/fixture-composer-host.ts +0 -147
  426. package/src/chat/testing/fixture-sidebar-host.ts +0 -99
  427. package/src/chat/testing/index.ts +0 -12
  428. package/src/chat/testing/sidebar.contract.ts +0 -196
  429. package/src/chat/transcript/BadgeMenu.tsx +0 -241
  430. package/src/chat/transcript/CardMarkdown.tsx +0 -102
  431. package/src/chat/transcript/ChipCard.tsx +0 -187
  432. package/src/chat/transcript/ChipCards.tsx +0 -100
  433. package/src/chat/transcript/DiffLines.tsx +0 -122
  434. package/src/chat/transcript/EarlierHistory.tsx +0 -136
  435. package/src/chat/transcript/EditDiffBlock.tsx +0 -176
  436. package/src/chat/transcript/FileChip.tsx +0 -361
  437. package/src/chat/transcript/ImageGenerationBlock.tsx +0 -239
  438. package/src/chat/transcript/InlineChipText.tsx +0 -57
  439. package/src/chat/transcript/InteractionToolBody.tsx +0 -211
  440. package/src/chat/transcript/LazyRow.tsx +0 -311
  441. package/src/chat/transcript/MermaidDiagram.tsx +0 -484
  442. package/src/chat/transcript/PromptEcho.tsx +0 -171
  443. package/src/chat/transcript/PromptOriginLabel.tsx +0 -44
  444. package/src/chat/transcript/ProseMarkdown.tsx +0 -168
  445. package/src/chat/transcript/ReferenceText.tsx +0 -198
  446. package/src/chat/transcript/SelectCursor.tsx +0 -118
  447. package/src/chat/transcript/SelectTurnHint.tsx +0 -81
  448. package/src/chat/transcript/SelectTurnProvider.tsx +0 -150
  449. package/src/chat/transcript/SubagentBlock.tsx +0 -224
  450. package/src/chat/transcript/TranscriptRow.tsx +0 -362
  451. package/src/chat/transcript/TranscriptSearch.tsx +0 -171
  452. package/src/chat/transcript/TurnMenu.tsx +0 -217
  453. package/src/chat/transcript/actions.tsx +0 -77
  454. package/src/chat/transcript/badges.tsx +0 -155
  455. package/src/chat/transcript/chip-details.ts +0 -169
  456. package/src/chat/transcript/chip-resolve.ts +0 -56
  457. package/src/chat/transcript/extension-renderers.tsx +0 -148
  458. package/src/chat/transcript/fold-attachments.tsx +0 -221
  459. package/src/chat/transcript/fold-status.tsx +0 -112
  460. package/src/chat/transcript/fold-worker.tsx +0 -160
  461. package/src/chat/transcript/fold.tsx +0 -522
  462. package/src/chat/transcript/frame.tsx +0 -326
  463. package/src/chat/transcript/index.ts +0 -66
  464. package/src/chat/transcript/markdown-cache.ts +0 -84
  465. package/src/chat/transcript/markdown-context.ts +0 -52
  466. package/src/chat/transcript/markdown.tsx +0 -351
  467. package/src/chat/transcript/messages.tsx +0 -169
  468. package/src/chat/transcript/notices.tsx +0 -508
  469. package/src/chat/transcript/prompt-lines.tsx +0 -55
  470. package/src/chat/transcript/prompt.tsx +0 -258
  471. package/src/chat/transcript/prose.tsx +0 -171
  472. package/src/chat/transcript/recent-map.ts +0 -32
  473. package/src/chat/transcript/references.ts +0 -108
  474. package/src/chat/transcript/remark-references.ts +0 -157
  475. package/src/chat/transcript/remark-refs.ts +0 -176
  476. package/src/chat/transcript/renderer-slots.tsx +0 -35
  477. package/src/chat/transcript/renderers.tsx +0 -251
  478. package/src/chat/transcript/row-estimate.ts +0 -158
  479. package/src/chat/transcript/run-rows.tsx +0 -291
  480. package/src/chat/transcript/site-icons.ts +0 -27
  481. package/src/chat/transcript/thumbnails.ts +0 -146
  482. package/src/chat/transcript/tool-batch.tsx +0 -102
  483. package/src/chat/transcript/tool-details.tsx +0 -31
  484. package/src/chat/transcript/tool-media.tsx +0 -132
  485. package/src/chat/transcript/tool-parts.tsx +0 -358
  486. package/src/chat/transcript/tool-payload.tsx +0 -76
  487. package/src/chat/transcript/tool-row.tsx +0 -496
  488. package/src/chat/transcript/turn-commands.ts +0 -101
  489. package/src/chat/transcript/use-transcript-rows.ts +0 -195
  490. package/src/chat/transcript/useComposerSearch.ts +0 -106
  491. package/src/chat/transcript/useSelectTurnKeys.ts +0 -204
  492. package/src/chat/transcript/useSettledReveal.ts +0 -57
  493. package/src/chat/transcript/useStickToBottom.ts +0 -600
  494. package/src/chat/transcript/useTranscriptFind.ts +0 -70
  495. package/src/chat/transcript/useTranscriptFindKey.ts +0 -52
  496. package/src/chat/transcript/useTranscriptScroll.ts +0 -163
  497. package/src/chat/transcript/useTranscriptSearch.tsx +0 -382
  498. package/src/chat/transcript/useTranscriptSelectionCopy.ts +0 -63
  499. package/src/chat/transcript/useWheelHoverPause.ts +0 -79
  500. package/src/chat/transcript/user-bash.tsx +0 -134
  501. package/src/chat/transcript-options.ts +0 -51
  502. package/src/chat/useChatLabels.ts +0 -14
  503. package/src/code/CodeHighlightProvider.tsx +0 -87
  504. package/src/code/HighlightedCode.tsx +0 -156
  505. package/src/code/code-themes.ts +0 -187
  506. package/src/code/editor/CodeCompletion.tsx +0 -719
  507. package/src/code/editor/CodeEditor.tsx +0 -480
  508. package/src/code/editor/CodeHover.tsx +0 -429
  509. package/src/code/editor/DiagnosticAnnotation.tsx +0 -73
  510. package/src/code/editor/DiagnosticsChip.tsx +0 -85
  511. package/src/code/editor/DiffView.tsx +0 -197
  512. package/src/code/editor/EditorColumn.tsx +0 -256
  513. package/src/code/editor/FileIcon.tsx +0 -89
  514. package/src/code/editor/FileTabPill.tsx +0 -101
  515. package/src/code/editor/FileTree.tsx +0 -414
  516. package/src/code/editor/FileView.tsx +0 -462
  517. package/src/code/editor/HighlightWorkers.tsx +0 -84
  518. package/src/code/editor/LanguageEditor.tsx +0 -210
  519. package/src/code/editor/_vendor/tree-icon-colors.ts +0 -72
  520. package/src/code/editor/diagnostics.ts +0 -140
  521. package/src/code/editor/edit-session.ts +0 -32
  522. package/src/code/editor/environment.tsx +0 -88
  523. package/src/code/editor/find/FindBar.tsx +0 -126
  524. package/src/code/editor/find/find-highlight.ts +0 -138
  525. package/src/code/editor/find/find-model.ts +0 -123
  526. package/src/code/editor/find/settle-scroll.ts +0 -77
  527. package/src/code/editor/find/useFind.ts +0 -203
  528. package/src/code/editor/fs-adapter.ts +0 -37
  529. package/src/code/editor/index.ts +0 -36
  530. package/src/code/editor/language.ts +0 -31
  531. package/src/code/editor/patch-parse.ts +0 -176
  532. package/src/code/editor/patch-parse.worker.ts +0 -12
  533. package/src/code/editor/pierre-theme.ts +0 -155
  534. package/src/code/editor/prime-diff.ts +0 -37
  535. package/src/code/editor/reveal.ts +0 -58
  536. package/src/code/editor/scroll-reach.ts +0 -28
  537. package/src/code/editor/useCodeDocument.ts +0 -226
  538. package/src/code/editor/useDefinition.ts +0 -159
  539. package/src/code/editor/useDetachCleanup.ts +0 -36
  540. package/src/code/editor/useFileDocument.ts +0 -87
  541. package/src/code/editor/useRevealLine.ts +0 -92
  542. package/src/code/editor/word-at.ts +0 -145
  543. package/src/code/highlight.worker.ts +0 -16
  544. package/src/code/highlighter.ts +0 -181
  545. package/src/code/highlights.ts +0 -51
  546. package/src/code/mermaid-lexer.ts +0 -331
  547. package/src/code/shiki-theme.ts +0 -46
  548. package/src/components/BrandMark.tsx +0 -118
  549. package/src/components/Breadcrumb.tsx +0 -105
  550. package/src/components/BrowserChrome.tsx +0 -189
  551. package/src/components/BrowserSignIn.tsx +0 -210
  552. package/src/components/ChoiceCards.tsx +0 -170
  553. package/src/components/CodeFrame.tsx +0 -225
  554. package/src/components/ConfirmDialog.tsx +0 -119
  555. package/src/components/CopyButton.tsx +0 -85
  556. package/src/components/EditableTitle.tsx +0 -199
  557. package/src/components/ErrorBoundary.tsx +0 -208
  558. package/src/components/Form.tsx +0 -593
  559. package/src/components/Highlighted.tsx +0 -68
  560. package/src/components/HowItWorks.tsx +0 -123
  561. package/src/components/IconButton.tsx +0 -101
  562. package/src/components/IconToggle.tsx +0 -71
  563. package/src/components/Keycap.tsx +0 -334
  564. package/src/components/Lightbox.tsx +0 -257
  565. package/src/components/LoadError.tsx +0 -45
  566. package/src/components/MediaNav.tsx +0 -85
  567. package/src/components/Menu.tsx +0 -435
  568. package/src/components/Overlay.tsx +0 -327
  569. package/src/components/PanelEmpty.tsx +0 -80
  570. package/src/components/PanelRows.tsx +0 -107
  571. package/src/components/PreviewWindow.tsx +0 -53
  572. package/src/components/ReorderTabs.tsx +0 -103
  573. package/src/components/RowActionsMenu.tsx +0 -383
  574. package/src/components/SegmentSpinner.tsx +0 -88
  575. package/src/components/Segmented.tsx +0 -126
  576. package/src/components/StepFrame.tsx +0 -151
  577. package/src/components/Stepper.tsx +0 -157
  578. package/src/components/Surface.tsx +0 -191
  579. package/src/components/SwatchPicker.tsx +0 -147
  580. package/src/components/SwitchGlyph.tsx +0 -56
  581. package/src/components/TabPill.tsx +0 -188
  582. package/src/components/ThemeThumb.tsx +0 -52
  583. package/src/components/ToggleCard.tsx +0 -120
  584. package/src/components/Tooltip.tsx +0 -288
  585. package/src/components/ZoomableImage.tsx +0 -322
  586. package/src/components/button.ts +0 -120
  587. package/src/components/floating/FloatingSurface.tsx +0 -158
  588. package/src/components/floating/HoverCard.tsx +0 -143
  589. package/src/components/floating/Popover.tsx +0 -166
  590. package/src/components/floating/useAnchoredPosition.ts +0 -186
  591. package/src/components/floating/usePopover.ts +0 -158
  592. package/src/components/image-clipboard.ts +0 -70
  593. package/src/components/keyboard-layout.ts +0 -115
  594. package/src/components/palette/PaletteList.tsx +0 -432
  595. package/src/components/palette/PalettePanel.tsx +0 -338
  596. package/src/components/palette/palette-layout.ts +0 -86
  597. package/src/components/report-error.ts +0 -142
  598. package/src/components/zoom.ts +0 -133
  599. package/src/extensions/ExtensionComponent.tsx +0 -167
  600. package/src/extensions/ExtensionDialogHost.tsx +0 -445
  601. package/src/extensions/ExtensionRenderer.tsx +0 -100
  602. package/src/extensions/ExtensionScreen.tsx +0 -122
  603. package/src/extensions/ExtensionSettingsPage.tsx +0 -112
  604. package/src/extensions/ExtensionSettingsPages.tsx +0 -44
  605. package/src/extensions/ExtensionSettingsSidebar.tsx +0 -373
  606. package/src/extensions/ExtensionSlot.tsx +0 -213
  607. package/src/extensions/ExtensionWebview.tsx +0 -104
  608. package/src/extensions/ExtensionsProvider.tsx +0 -124
  609. package/src/extensions/SettingsWireForm.tsx +0 -182
  610. package/src/extensions/headless/dialog-queue.ts +0 -92
  611. package/src/extensions/headless/effect-channel.ts +0 -50
  612. package/src/extensions/headless/effect-router.ts +0 -107
  613. package/src/extensions/headless/fixture-host.ts +0 -381
  614. package/src/extensions/headless/host.ts +0 -398
  615. package/src/extensions/headless/index.ts +0 -17
  616. package/src/extensions/headless/labels.ts +0 -64
  617. package/src/extensions/headless/links.ts +0 -56
  618. package/src/extensions/headless/select.ts +0 -249
  619. package/src/extensions/headless/webview-bridge.ts +0 -127
  620. package/src/extensions/headless/wire.ts +0 -175
  621. package/src/extensions/hooks.ts +0 -209
  622. package/src/extensions/index.ts +0 -25
  623. package/src/extensions/kit.ts +0 -79
  624. package/src/extensions/links.tsx +0 -165
  625. package/src/extensions/testing/contract.ts +0 -382
  626. package/src/extensions/testing/index.ts +0 -6
  627. package/src/extensions/useExtensionsLabels.ts +0 -14
  628. package/src/files/CodeViewer.tsx +0 -289
  629. package/src/files/DiffFileViewer.tsx +0 -143
  630. package/src/files/DiffsTab.tsx +0 -581
  631. package/src/files/EditorColumn.tsx +0 -453
  632. package/src/files/EditorEnvironmentRoot.tsx +0 -63
  633. package/src/files/FilesDiagnosticsChip.tsx +0 -32
  634. package/src/files/FilesProvider.tsx +0 -58
  635. package/src/files/FilesTab.tsx +0 -441
  636. package/src/files/MediaDiff.tsx +0 -61
  637. package/src/files/MediaView.tsx +0 -170
  638. package/src/files/ReviewDraft.tsx +0 -88
  639. package/src/files/ReviewableDiff.tsx +0 -72
  640. package/src/files/SearchPanel.tsx +0 -325
  641. package/src/files/TreeColumn.tsx +0 -229
  642. package/src/files/code-excerpt.ts +0 -265
  643. package/src/files/code-menu.ts +0 -53
  644. package/src/files/drafts-store.ts +0 -192
  645. package/src/files/file-actions.ts +0 -152
  646. package/src/files/headless/editor-prefs.ts +0 -230
  647. package/src/files/headless/entries.ts +0 -172
  648. package/src/files/headless/fixture-host.ts +0 -260
  649. package/src/files/headless/host.ts +0 -387
  650. package/src/files/headless/index.ts +0 -14
  651. package/src/files/headless/labels.ts +0 -123
  652. package/src/files/headless/lsp-edits.ts +0 -58
  653. package/src/files/headless/media.ts +0 -57
  654. package/src/files/headless/name-match.ts +0 -38
  655. package/src/files/headless/search.ts +0 -23
  656. package/src/files/headless/view.ts +0 -114
  657. package/src/files/headless/workspace-diff.ts +0 -82
  658. package/src/files/index.ts +0 -25
  659. package/src/files/lazy-tabs.tsx +0 -41
  660. package/src/files/session-patch.ts +0 -45
  661. package/src/files/tab-hooks.ts +0 -37
  662. package/src/files/testing/contract.ts +0 -279
  663. package/src/files/testing/demo.ts +0 -36
  664. package/src/files/testing/index.ts +0 -7
  665. package/src/files/useCodeReview.tsx +0 -177
  666. package/src/files/useDiagnostics.ts +0 -59
  667. package/src/files/useDiagnosticsRun.ts +0 -86
  668. package/src/files/useEntryActions.ts +0 -280
  669. package/src/files/useFilesDiagnostics.ts +0 -51
  670. package/src/files/useFilesLabels.ts +0 -14
  671. package/src/files/useFolderChanges.ts +0 -38
  672. package/src/files/useLsp.ts +0 -181
  673. package/src/files/useOpenFiles.ts +0 -402
  674. package/src/files/useWorkspace.ts +0 -148
  675. package/src/files/working-tree-diff.ts +0 -142
  676. package/src/git/BranchMenu.tsx +0 -988
  677. package/src/git/GitBar.tsx +0 -297
  678. package/src/git/GitProvider.tsx +0 -50
  679. package/src/git/ImportRepoDialog.tsx +0 -390
  680. package/src/git/MoveSessionDialog.tsx +0 -396
  681. package/src/git/RemoteFolderPicker.tsx +0 -475
  682. package/src/git/SyncChip.tsx +0 -275
  683. package/src/git/WherePicker.tsx +0 -358
  684. package/src/git/headless/environment.ts +0 -132
  685. package/src/git/headless/host.ts +0 -353
  686. package/src/git/headless/index.ts +0 -14
  687. package/src/git/headless/labels.ts +0 -230
  688. package/src/git/headless/move.ts +0 -101
  689. package/src/git/headless/remote-clone.ts +0 -44
  690. package/src/git/headless/status-reads.ts +0 -77
  691. package/src/git/headless/switcher.ts +0 -215
  692. package/src/git/headless/sync.ts +0 -71
  693. package/src/git/index.ts +0 -17
  694. package/src/git/testing/contract.ts +0 -551
  695. package/src/git/testing/index.ts +0 -537
  696. package/src/git/useEnvironmentChoices.ts +0 -50
  697. package/src/git/useGitBar.ts +0 -180
  698. package/src/hooks/keyed-store.ts +0 -65
  699. package/src/hooks/useDisplayPath.tsx +0 -93
  700. package/src/hooks/useHydrated.ts +0 -16
  701. package/src/hooks/useMinuteTick.ts +0 -49
  702. package/src/hooks/useNearViewport.ts +0 -111
  703. package/src/hooks/usePersistedState.ts +0 -98
  704. package/src/hooks/useResizeDrag.ts +0 -240
  705. package/src/hooks/useTabDrag.ts +0 -88
  706. package/src/index.ts +0 -119
  707. package/src/keybindings/KeyCommands.tsx +0 -123
  708. package/src/keybindings/KeyHint.tsx +0 -78
  709. package/src/keybindings/KeybindingsProvider.tsx +0 -231
  710. package/src/keybindings/headless/catalog.ts +0 -360
  711. package/src/keybindings/headless/commands.ts +0 -77
  712. package/src/keybindings/headless/fixture-host.ts +0 -51
  713. package/src/keybindings/headless/host.ts +0 -29
  714. package/src/keybindings/headless/index.ts +0 -13
  715. package/src/keybindings/headless/key-scope.ts +0 -91
  716. package/src/keybindings/headless/labels.ts +0 -14
  717. package/src/keybindings/headless/overrides.ts +0 -64
  718. package/src/keybindings/index.ts +0 -15
  719. package/src/keybindings/load-once.ts +0 -11
  720. package/src/keybindings/match.ts +0 -48
  721. package/src/keybindings/press.ts +0 -80
  722. package/src/keybindings/testing/contract.ts +0 -139
  723. package/src/keybindings/testing/index.ts +0 -6
  724. package/src/keybindings/useHelpKey.ts +0 -35
  725. package/src/keybindings/useKeybindingsLabels.ts +0 -14
  726. package/src/labels.tsx +0 -175
  727. package/src/machines/AddServerForm.tsx +0 -151
  728. package/src/machines/Banners.tsx +0 -172
  729. package/src/machines/DaemonMenu.tsx +0 -413
  730. package/src/machines/HostCapabilities.tsx +0 -245
  731. package/src/machines/HostSignIn.tsx +0 -63
  732. package/src/machines/HostSyncPanel.tsx +0 -275
  733. package/src/machines/HostsSection.tsx +0 -312
  734. package/src/machines/MachinesProvider.tsx +0 -164
  735. package/src/machines/ServerCard.tsx +0 -347
  736. package/src/machines/ServerMachinesPanel.tsx +0 -547
  737. package/src/machines/ServerUpdatePanel.tsx +0 -160
  738. package/src/machines/SyncAccounts.tsx +0 -148
  739. package/src/machines/SyncMarker.tsx +0 -87
  740. package/src/machines/SyncOutcomeBadge.tsx +0 -84
  741. package/src/machines/TokensPanel.tsx +0 -249
  742. package/src/machines/headless/fixture-host.ts +0 -519
  743. package/src/machines/headless/fixtures.ts +0 -164
  744. package/src/machines/headless/host.ts +0 -381
  745. package/src/machines/headless/index.ts +0 -13
  746. package/src/machines/headless/labels.ts +0 -364
  747. package/src/machines/headless/messages.ts +0 -209
  748. package/src/machines/headless/presence.ts +0 -110
  749. package/src/machines/headless/settings-focus.ts +0 -25
  750. package/src/machines/headless/stores.ts +0 -137
  751. package/src/machines/headless/sync.ts +0 -207
  752. package/src/machines/index.ts +0 -29
  753. package/src/machines/settings-section.tsx +0 -37
  754. package/src/machines/testing/contract.ts +0 -617
  755. package/src/machines/testing/index.ts +0 -7
  756. package/src/machines/testing/sync.contract.ts +0 -260
  757. package/src/motion/SwapIcon.tsx +0 -29
  758. package/src/motion/collapse.ts +0 -21
  759. package/src/motion/grow.tsx +0 -86
  760. package/src/motion/layout-animating.ts +0 -50
  761. package/src/motion/presence.ts +0 -191
  762. package/src/motion/provider.tsx +0 -63
  763. package/src/motion/reduced.ts +0 -36
  764. package/src/motion/roll.tsx +0 -131
  765. package/src/motion/shimmer.ts +0 -15
  766. package/src/motion/size.tsx +0 -192
  767. package/src/motion/springs.ts +0 -413
  768. package/src/motion/swap.tsx +0 -216
  769. package/src/motion/title-text.tsx +0 -74
  770. package/src/onboarding/ConnectProviderCard.tsx +0 -49
  771. package/src/onboarding/OnboardingFlow.tsx +0 -176
  772. package/src/onboarding/OnboardingProvider.tsx +0 -209
  773. package/src/onboarding/OnboardingStepFrame.tsx +0 -80
  774. package/src/onboarding/conversation.tsx +0 -196
  775. package/src/onboarding/demos/autonomy.tsx +0 -154
  776. package/src/onboarding/demos/extensions.tsx +0 -183
  777. package/src/onboarding/demos/features.tsx +0 -488
  778. package/src/onboarding/demos/how-it-works.tsx +0 -698
  779. package/src/onboarding/demos/index.ts +0 -11
  780. package/src/onboarding/demos/parts.tsx +0 -133
  781. package/src/onboarding/demos/tour.tsx +0 -217
  782. package/src/onboarding/headless/controller.ts +0 -110
  783. package/src/onboarding/headless/fixture-host.ts +0 -269
  784. package/src/onboarding/headless/fixtures.ts +0 -486
  785. package/src/onboarding/headless/host.ts +0 -176
  786. package/src/onboarding/headless/index.ts +0 -8
  787. package/src/onboarding/headless/labels.ts +0 -282
  788. package/src/onboarding/index.ts +0 -21
  789. package/src/onboarding/marks.tsx +0 -107
  790. package/src/onboarding/preview-attachments.ts +0 -39
  791. package/src/onboarding/skills/SkillSourceBrowser.tsx +0 -128
  792. package/src/onboarding/skills/parts.tsx +0 -464
  793. package/src/onboarding/sources/SourceBrowser.tsx +0 -400
  794. package/src/onboarding/steps/AutonomyStep.tsx +0 -128
  795. package/src/onboarding/steps/ConnectStep.tsx +0 -104
  796. package/src/onboarding/steps/ConnectorsStep.tsx +0 -222
  797. package/src/onboarding/steps/ConversationStep.tsx +0 -132
  798. package/src/onboarding/steps/ExtensionsStep.tsx +0 -113
  799. package/src/onboarding/steps/FeatureExample.tsx +0 -46
  800. package/src/onboarding/steps/FeaturesStep.tsx +0 -88
  801. package/src/onboarding/steps/ImportStep.tsx +0 -156
  802. package/src/onboarding/steps/LookStep.tsx +0 -276
  803. package/src/onboarding/steps/ReadyStep.tsx +0 -278
  804. package/src/onboarding/steps/SkillsStep.tsx +0 -45
  805. package/src/onboarding/steps/StepSection.tsx +0 -63
  806. package/src/onboarding/steps/Tradeoff.tsx +0 -45
  807. package/src/onboarding/steps/WelcomeStep.tsx +0 -147
  808. package/src/onboarding/steps/connect/KeyForm.tsx +0 -112
  809. package/src/onboarding/steps/connect/ProviderPanel.tsx +0 -149
  810. package/src/onboarding/steps/connect/ProviderReady.tsx +0 -171
  811. package/src/onboarding/steps/connect/ready-text.ts +0 -17
  812. package/src/onboarding/steps/index.ts +0 -12
  813. package/src/onboarding/steps/tasks.tsx +0 -84
  814. package/src/onboarding/testing/contract.ts +0 -472
  815. package/src/onboarding/testing/index.ts +0 -7
  816. package/src/onboarding/tutorials.tsx +0 -45
  817. package/src/onboarding/useSignIn.ts +0 -58
  818. package/src/palette/CommandPalette.tsx +0 -59
  819. package/src/palette/PaletteDialog.tsx +0 -186
  820. package/src/palette/PaletteProvider.tsx +0 -149
  821. package/src/palette/PaletteRows.tsx +0 -208
  822. package/src/palette/app-sources.ts +0 -62
  823. package/src/palette/headless/app-sources.ts +0 -515
  824. package/src/palette/headless/gather.ts +0 -50
  825. package/src/palette/headless/host.ts +0 -129
  826. package/src/palette/headless/index.ts +0 -15
  827. package/src/palette/headless/labels.ts +0 -124
  828. package/src/palette/headless/rank-protocol.ts +0 -23
  829. package/src/palette/headless/recents.ts +0 -35
  830. package/src/palette/headless/session-sources.ts +0 -218
  831. package/src/palette/headless/sources.ts +0 -313
  832. package/src/palette/headless/store.ts +0 -105
  833. package/src/palette/index.ts +0 -17
  834. package/src/palette/rank.worker.ts +0 -30
  835. package/src/palette/setup.ts +0 -19
  836. package/src/palette/testing/contract.ts +0 -250
  837. package/src/palette/testing/index.ts +0 -152
  838. package/src/palette/useConversationSearch.ts +0 -115
  839. package/src/palette/usePaletteController.ts +0 -229
  840. package/src/palette/useRankedItems.ts +0 -122
  841. package/src/path.ts +0 -199
  842. package/src/server/demo-tools.ts +0 -34
  843. package/src/server/environment.ts +0 -118
  844. package/src/server/index.ts +0 -7
  845. package/src/server/scripted-provider.ts +0 -174
  846. package/src/server/sse-handler.ts +0 -457
  847. package/src/server/testing/index.ts +0 -7
  848. package/src/session/ArtifactRowChips.tsx +0 -260
  849. package/src/session/ArtifactsPanel.tsx +0 -426
  850. package/src/session/DiffFileTree.tsx +0 -173
  851. package/src/session/PanelAttention.tsx +0 -131
  852. package/src/session/ProjectHome.tsx +0 -733
  853. package/src/session/ProviderUsageProvider.tsx +0 -113
  854. package/src/session/QueueTab.tsx +0 -669
  855. package/src/session/RunningWorkDialog.tsx +0 -178
  856. package/src/session/SessionCacheFacts.tsx +0 -190
  857. package/src/session/SessionDetailsDialog.tsx +0 -627
  858. package/src/session/SessionHeader.tsx +0 -242
  859. package/src/session/SessionProvider.tsx +0 -98
  860. package/src/session/SessionShell.tsx +0 -77
  861. package/src/session/SideChat.tsx +0 -320
  862. package/src/session/TodoList.tsx +0 -123
  863. package/src/session/TodosPanel.tsx +0 -279
  864. package/src/session/TurnDetailsDialog.tsx +0 -299
  865. package/src/session/UsagePanel.tsx +0 -358
  866. package/src/session/WelcomeScreen.tsx +0 -88
  867. package/src/session/headless/artifacts.ts +0 -101
  868. package/src/session/headless/diff-tree.ts +0 -167
  869. package/src/session/headless/fixture-host.ts +0 -362
  870. package/src/session/headless/home-layout.ts +0 -276
  871. package/src/session/headless/host.ts +0 -263
  872. package/src/session/headless/index.ts +0 -23
  873. package/src/session/headless/keyed.ts +0 -72
  874. package/src/session/headless/labels.ts +0 -337
  875. package/src/session/headless/queue-attachments.ts +0 -73
  876. package/src/session/headless/queue.ts +0 -122
  877. package/src/session/headless/running-work.ts +0 -85
  878. package/src/session/headless/session-actions.ts +0 -198
  879. package/src/session/headless/session-diffs.ts +0 -136
  880. package/src/session/headless/side.ts +0 -63
  881. package/src/session/headless/todos.ts +0 -62
  882. package/src/session/headless/usage-format.ts +0 -19
  883. package/src/session/headless/usage.ts +0 -407
  884. package/src/session/index.ts +0 -31
  885. package/src/session/modal-shell.tsx +0 -24
  886. package/src/session/testing/contract.ts +0 -588
  887. package/src/session/testing/demo.ts +0 -224
  888. package/src/session/testing/index.ts +0 -7
  889. package/src/session/useSessionLabels.ts +0 -14
  890. package/src/session/useUsageSummary.ts +0 -82
  891. package/src/settings/SettingsHeadingText.tsx +0 -54
  892. package/src/settings/SettingsHostSwitcher.tsx +0 -93
  893. package/src/settings/SettingsNav.tsx +0 -198
  894. package/src/settings/SettingsProvider.tsx +0 -127
  895. package/src/settings/SettingsRowsPage.tsx +0 -218
  896. package/src/settings/SettingsShell.tsx +0 -337
  897. package/src/settings/SettingsTutorial.tsx +0 -55
  898. package/src/settings/headless/catalog.ts +0 -570
  899. package/src/settings/headless/claude-import.ts +0 -61
  900. package/src/settings/headless/enabled.ts +0 -44
  901. package/src/settings/headless/fixture-accounts.ts +0 -260
  902. package/src/settings/headless/fixture-host.ts +0 -162
  903. package/src/settings/headless/fixture-models.ts +0 -51
  904. package/src/settings/headless/fixture-performance.ts +0 -350
  905. package/src/settings/headless/fixture-sections.ts +0 -391
  906. package/src/settings/headless/host.ts +0 -127
  907. package/src/settings/headless/index.ts +0 -22
  908. package/src/settings/headless/labels.ts +0 -63
  909. package/src/settings/headless/layout-sections.ts +0 -41
  910. package/src/settings/headless/layout.ts +0 -732
  911. package/src/settings/headless/mcp.ts +0 -319
  912. package/src/settings/headless/models.ts +0 -51
  913. package/src/settings/headless/page-counts.ts +0 -40
  914. package/src/settings/headless/performance.ts +0 -524
  915. package/src/settings/headless/providers.ts +0 -117
  916. package/src/settings/headless/registry.ts +0 -62
  917. package/src/settings/headless/resource.ts +0 -75
  918. package/src/settings/headless/search.ts +0 -142
  919. package/src/settings/headless/sections-host.ts +0 -340
  920. package/src/settings/index.ts +0 -32
  921. package/src/settings/rows.tsx +0 -152
  922. package/src/settings/section.tsx +0 -165
  923. package/src/settings/sections/appearance/AppearanceSection.tsx +0 -667
  924. package/src/settings/sections/appearance/labels.ts +0 -77
  925. package/src/settings/sections/claude-import/ClaudeImportDialog.tsx +0 -258
  926. package/src/settings/sections/claude-import/labels.ts +0 -42
  927. package/src/settings/sections/claude-import/use-claude-import-available.ts +0 -35
  928. package/src/settings/sections/descriptors.tsx +0 -261
  929. package/src/settings/sections/editor/EditorSection.tsx +0 -521
  930. package/src/settings/sections/editor/labels.ts +0 -84
  931. package/src/settings/sections/enabled-list/EnabledListSection.tsx +0 -112
  932. package/src/settings/sections/enabled-list/labels.ts +0 -37
  933. package/src/settings/sections/environments/EnvironmentsSection.tsx +0 -549
  934. package/src/settings/sections/environments/labels.ts +0 -31
  935. package/src/settings/sections/extensions/ChangeOriginDialog.tsx +0 -218
  936. package/src/settings/sections/extensions/CreateExtensionDialog.tsx +0 -210
  937. package/src/settings/sections/extensions/ExtensionConfigRows.tsx +0 -508
  938. package/src/settings/sections/extensions/ExtensionOptionsSection.tsx +0 -356
  939. package/src/settings/sections/extensions/ExtensionPicksBar.tsx +0 -112
  940. package/src/settings/sections/extensions/ExtensionSourceBrowser.tsx +0 -244
  941. package/src/settings/sections/extensions/ExtensionsSection.tsx +0 -665
  942. package/src/settings/sections/extensions/create-labels.ts +0 -31
  943. package/src/settings/sections/extensions/labels.ts +0 -64
  944. package/src/settings/sections/extensions/options-labels.ts +0 -34
  945. package/src/settings/sections/host-catalog/HostCatalogSection.tsx +0 -457
  946. package/src/settings/sections/host-catalog/labels.ts +0 -44
  947. package/src/settings/sections/index.ts +0 -60
  948. package/src/settings/sections/instructions/InstructionsSection.tsx +0 -385
  949. package/src/settings/sections/instructions/labels.ts +0 -33
  950. package/src/settings/sections/keybindings/KeybindingsSection.tsx +0 -124
  951. package/src/settings/sections/keybindings/labels.ts +0 -72
  952. package/src/settings/sections/keybindings/rows.ts +0 -103
  953. package/src/settings/sections/logs/LogsSection.tsx +0 -153
  954. package/src/settings/sections/logs/labels.ts +0 -20
  955. package/src/settings/sections/mcp/McpAddForm.tsx +0 -245
  956. package/src/settings/sections/mcp/McpSection.tsx +0 -358
  957. package/src/settings/sections/mcp/McpServerRow.tsx +0 -404
  958. package/src/settings/sections/mcp/labels.ts +0 -193
  959. package/src/settings/sections/models/AgentDefaults.tsx +0 -365
  960. package/src/settings/sections/models/ModelListPicker.tsx +0 -265
  961. package/src/settings/sections/models/ModelPickField.tsx +0 -220
  962. package/src/settings/sections/models/ModelRows.tsx +0 -381
  963. package/src/settings/sections/models/SpacesDefaultsSection.tsx +0 -102
  964. package/src/settings/sections/models/labels.ts +0 -119
  965. package/src/settings/sections/models/model-test.tsx +0 -125
  966. package/src/settings/sections/performance/PerfSparkline.tsx +0 -64
  967. package/src/settings/sections/performance/PerformanceHud.tsx +0 -110
  968. package/src/settings/sections/performance/PerformanceSection.tsx +0 -770
  969. package/src/settings/sections/performance/labels.ts +0 -114
  970. package/src/settings/sections/performance/use-perf-monitor.ts +0 -26
  971. package/src/settings/sections/plugins/PluginsSection.tsx +0 -151
  972. package/src/settings/sections/plugins/labels.ts +0 -23
  973. package/src/settings/sections/providers/CredentialSources.tsx +0 -237
  974. package/src/settings/sections/providers/ProvidersSection.tsx +0 -389
  975. package/src/settings/sections/providers/ServerProvidersSection.tsx +0 -244
  976. package/src/settings/sections/providers/ServerSignIn.tsx +0 -137
  977. package/src/settings/sections/providers/labels.ts +0 -160
  978. package/src/settings/sections/shared/catalog.tsx +0 -265
  979. package/src/settings/sections/shared/labels.ts +0 -31
  980. package/src/settings/sections/skills/SkillList.tsx +0 -494
  981. package/src/settings/sections/skills/SkillsSection.tsx +0 -249
  982. package/src/settings/sections/skills/labels.ts +0 -54
  983. package/src/settings/sections/use-section-labels.ts +0 -10
  984. package/src/settings/testing/accounts-demo.ts +0 -110
  985. package/src/settings/testing/accounts.contract.ts +0 -319
  986. package/src/settings/testing/claude-import.contract.ts +0 -93
  987. package/src/settings/testing/contract.ts +0 -192
  988. package/src/settings/testing/extension-options.contract.ts +0 -163
  989. package/src/settings/testing/index.ts +0 -11
  990. package/src/settings/testing/models.contract.ts +0 -135
  991. package/src/settings/testing/performance.contract.ts +0 -219
  992. package/src/settings/testing/sections.contract.ts +0 -306
  993. package/src/terminal/HostTerminalSurface.tsx +0 -917
  994. package/src/terminal/TerminalDrawer.tsx +0 -228
  995. package/src/terminal/TerminalPanel.tsx +0 -740
  996. package/src/terminal/TerminalProvider.tsx +0 -201
  997. package/src/terminal/TerminalSurface.tsx +0 -262
  998. package/src/terminal/box-glyphs.ts +0 -333
  999. package/src/terminal/ghostty.ts +0 -116
  1000. package/src/terminal/grid-size.ts +0 -46
  1001. package/src/terminal/headless/fixture-host.ts +0 -250
  1002. package/src/terminal/headless/host.ts +0 -99
  1003. package/src/terminal/headless/index.ts +0 -11
  1004. package/src/terminal/headless/labels.ts +0 -69
  1005. package/src/terminal/headless/layout.ts +0 -57
  1006. package/src/terminal/headless/links.ts +0 -227
  1007. package/src/terminal/headless/order.ts +0 -28
  1008. package/src/terminal/headless/output-cursor.ts +0 -66
  1009. package/src/terminal/headless/recent.ts +0 -20
  1010. package/src/terminal/headless/replay.ts +0 -45
  1011. package/src/terminal/headless/scope.ts +0 -60
  1012. package/src/terminal/headless/store.ts +0 -637
  1013. package/src/terminal/index.ts +0 -40
  1014. package/src/terminal/keys.ts +0 -34
  1015. package/src/terminal/testing/contract.ts +0 -274
  1016. package/src/terminal/testing/demo.ts +0 -40
  1017. package/src/terminal/testing/index.ts +0 -7
  1018. package/src/terminal/theme.ts +0 -110
  1019. package/src/terminal/useTerminalLabels.ts +0 -14
  1020. package/src/theme/accents.ts +0 -46
  1021. package/src/theme/color.ts +0 -450
  1022. package/src/theme/css-vars.ts +0 -187
  1023. package/src/theme/derive.ts +0 -700
  1024. package/src/theme/from-theme.ts +0 -52
  1025. package/src/theme/stylesheet.ts +0 -55
  1026. package/src/theme/themes.ts +0 -767
  1027. package/src/theme/without-transitions.ts +0 -18
  1028. package/src/uno.ts +0 -167
  1029. package/src/workspace/LayoutBudget.tsx +0 -143
  1030. package/src/workspace/PanelContentView.tsx +0 -523
  1031. package/src/workspace/PanelCorner.tsx +0 -111
  1032. package/src/workspace/PanelGroups.tsx +0 -264
  1033. package/src/workspace/PanelHome.tsx +0 -71
  1034. package/src/workspace/PanelItems.tsx +0 -368
  1035. package/src/workspace/PanelStrip.tsx +0 -316
  1036. package/src/workspace/SidePanel.tsx +0 -240
  1037. package/src/workspace/TabParking.tsx +0 -120
  1038. package/src/workspace/WorkspaceProvider.tsx +0 -558
  1039. package/src/workspace/dnd/engine.ts +0 -371
  1040. package/src/workspace/dnd/hooks.ts +0 -72
  1041. package/src/workspace/dnd/index.ts +0 -57
  1042. package/src/workspace/dnd/parking.tsx +0 -181
  1043. package/src/workspace/extension-tabs.tsx +0 -174
  1044. package/src/workspace/frame-motion.ts +0 -160
  1045. package/src/workspace/headless/contents.ts +0 -125
  1046. package/src/workspace/headless/host.ts +0 -129
  1047. package/src/workspace/headless/index.ts +0 -33
  1048. package/src/workspace/headless/labels.ts +0 -44
  1049. package/src/workspace/headless/layout-memory.ts +0 -649
  1050. package/src/workspace/headless/layouts.ts +0 -224
  1051. package/src/workspace/headless/open-target.ts +0 -125
  1052. package/src/workspace/headless/ops.ts +0 -163
  1053. package/src/workspace/headless/panel-focus.ts +0 -58
  1054. package/src/workspace/headless/panel-tree.ts +0 -259
  1055. package/src/workspace/headless/resolve.ts +0 -146
  1056. package/src/workspace/headless/reveal-at.ts +0 -27
  1057. package/src/workspace/headless/strip-drop.ts +0 -81
  1058. package/src/workspace/headless/tree.ts +0 -480
  1059. package/src/workspace/headless/view.ts +0 -164
  1060. package/src/workspace/index.ts +0 -23
  1061. package/src/workspace/panel-group-keys.ts +0 -36
  1062. package/src/workspace/panel-visibility.ts +0 -28
  1063. package/src/workspace/tab-scopes.ts +0 -245
  1064. package/src/workspace/testing/contract.ts +0 -282
  1065. package/src/workspace/testing/index.ts +0 -140
  1066. package/src/workspace/use-split-drag.ts +0 -73
  1067. package/src/workspace/useScopeLayout.ts +0 -26
  1068. package/src/workspace/useViewport.ts +0 -22
  1069. package/src/workspace/useWorkspaceLabels.ts +0 -14
  1070. package/src/workspace/workspace-key-commands.ts +0 -108
  1071. /package/dist/dist/{types-bDQagoiL.d.ts → types-2HrgolQz.d.ts} +0 -0
@@ -1,1107 +0,0 @@
1
- /**
2
- * The per-session stream store: every session's live transcript window and
3
- * run state, reduced from zidane's host signals, with per-session listeners
4
- * so a tick on one session never wakes the readers of another.
5
- *
6
- * State shape and merge semantics match `zidane/chat`'s `useStreamBuffer`:
7
- * same-owner same-kind markdown / thinking deltas coalesce onto the trailing
8
- * block; tool / tool-result / error / spawn-* events append verbatim;
9
- * `turn:end` and `run:end` finalize the trailing streaming markdown so the
10
- * renderer stops absorbing tokens. React-free: the desktop app binds it with
11
- * `useSyncExternalStore`, a {@link ChatHost} reads it through
12
- * `SessionStreams.transcript`.
13
- */
14
- import type { Owner, StreamEvent, SystemMdFile } from 'zidane/chat';
15
- import {
16
- discardThinking,
17
- finalizeStreamingMarkdownForOwner,
18
- type MarkdownDeltaOptions,
19
- type PromptSegmentRef,
20
- reconcileEvents,
21
- retagUserPromptEventsFromRefs,
22
- } from 'zidane/chat/pure';
23
-
24
- import type { ChatAttachment, ChatEvent } from '../host';
25
- import { inheritRowIdentity } from '../transcript/collapse';
26
- import { applyLiveEvent, closeThinkingSegment, finishLive } from './live-events';
27
- import { mergeLiveTail } from './merge';
28
- import type { DrainPlan } from './pacer';
29
- import { mergePromptPreviews, missingPreviewData } from './prompt-previews';
30
- import { defaultFrameScheduler, type FrameScheduler } from './scheduler';
31
- import type {
32
- OtherStreamSignal,
33
- SessionFallbackModel,
34
- SessionPageState,
35
- SessionRetryState,
36
- SessionStreamPage,
37
- SessionStreamSignal,
38
- } from './types';
39
-
40
- const PARENT_OWNER: Owner = 'parent';
41
-
42
- /**
43
- * Module-level stable empty array — returned by `getEventsSnapshot` when
44
- * the session has no entry yet. Keeping this reference identical across
45
- * calls avoids breaking downstream `useMemo([events])` deps when a
46
- * consumer mounts before its session hydrates.
47
- */
48
- const EMPTY_EVENTS: readonly ChatEvent[] = Object.freeze([]) as readonly ChatEvent[];
49
-
50
- /** Page-state snapshot for a session with no hydrated page — stable identity. */
51
- const NO_PAGE: SessionPageState = Object.freeze({ firstSeq: 0, hasMore: false, loadingEarlier: false });
52
-
53
- /**
54
- * Markdown merge options by default. No 64 KB segmenting: a reloaded
55
- * transcript shows each message whole (the renderer chunks long text
56
- * itself, see `markdown-chunks.ts`), so a split live message would carry
57
- * per-segment message actions that vanish on reload.
58
- */
59
- const WHOLE_MESSAGES: MarkdownDeltaOptions = { segmentChars: Number.POSITIVE_INFINITY };
60
-
61
- /** Notifications held for the next frame are delivered after this long when frames do not run (a hidden window). */
62
- const NOTIFY_FALLBACK_MS = 50;
63
-
64
- /** Options for {@link SessionStreamStore}. */
65
- export interface SessionStreamStoreOptions {
66
- /** Frames and timers for batched notifications. Default: {@link defaultFrameScheduler}. */
67
- scheduler?: FrameScheduler;
68
- /** How streamed markdown merges. Default: one event per message (`segmentChars: Infinity`). */
69
- markdown?: MarkdownDeltaOptions;
70
- /** Deliver transcript-event notifications once per frame (`true`, the default) or at once (`false`). The state is current at once either way. */
71
- batch?: boolean;
72
- }
73
-
74
- /** One write to a session's window, see {@link SessionStreamStore.write}. */
75
- export interface SessionStreamWrite {
76
- /** Replaces the events. */
77
- events?: readonly ChatEvent[];
78
- /** Sets the run flag. */
79
- running?: boolean;
80
- /** Sets the page state (and so marks the window hydrated); `null` drops it. */
81
- page?: SessionPageState | null;
82
- }
83
-
84
- /**
85
- * External store backing all per-session reads. Mutates the underlying
86
- * Maps in place and notifies only the per-`sessionId` listeners that
87
- * actually subscribed to the changed session — that's what isolates
88
- * sibling sessions from each other's stream churn. Every write path
89
- * replaces the session's events array, so identity says whether anything
90
- * landed in between (the run-end compaction and scrollback guards rely on
91
- * it).
92
- *
93
- * The reducer alone: {@link createSessionStreams} adds smooth-stream pacing,
94
- * lazy scrollback and run-end compaction around it.
95
- *
96
- * @typeParam K - The session key type (the desktop app's branded `SessionKey`). Default: `string`.
97
- */
98
- export class SessionStreamStore<K extends string = string> {
99
- private _events = new Map<K, ChatEvent[]>();
100
- private _running = new Map<K, boolean>();
101
- private readonly _scheduler: FrameScheduler;
102
- private readonly _markdown: MarkdownDeltaOptions;
103
- private readonly _batch: boolean;
104
- /** Bumped by every run-state change (`run:start`, `run:end`, `dropAll`): a snapshot fetched before a bump is stale. */
105
- runStateVersion = 0;
106
-
107
- /**
108
- * @param options - The scheduler for batched notifications, the markdown merge rule and whether to batch.
109
- */
110
- constructor(options: SessionStreamStoreOptions = {}) {
111
- this._scheduler = options.scheduler ?? defaultFrameScheduler;
112
- this._markdown = options.markdown ?? WHOLE_MESSAGES;
113
- this._batch = options.batch ?? true;
114
- }
115
- /**
116
- * Per-session run-sticky fallback target — set by the `model:fallback`
117
- * signal when the agent's stream failed terminally on the picked model
118
- * and the run advanced down its fallback chain. Cleared on `run:start`
119
- * (every run starts from the primary again). Read by the model pill so
120
- * the user always sees the model ACTUALLY serving the run.
121
- */
122
- private _fallback = new Map<K, SessionFallbackModel>();
123
- /**
124
- * Per-session `SYSTEM.md` override the HOST composed the prompt with, or
125
- * `null` when none applied. Pushed by the `system-md` signal at agent-build
126
- * time.
127
- *
128
- * Not derivable in the renderer: the override is resolved where the prompt
129
- * is composed, against a cwd and a `userInstructionsScope` this window does
130
- * not own (under a daemon it is another process entirely). Surfaced because
131
- * an override REPLACES the built-in doctrine — including the safety and git
132
- * guidance — and does so without erroring.
133
- */
134
- private _systemMd = new Map<K, SystemMdFile | null>();
135
- /**
136
- * Per-session provider-retry state. Cleared on `run:end` rather than
137
- * `run:start`: a terminal stream failure never streams again, so run end is
138
- * the only guaranteed clear — the same backstop the TUI uses.
139
- */
140
- private _retry = new Map<K, SessionRetryState>();
141
- /**
142
- * Monotonically increasing per-session run-start counter — bumped on
143
- * every `run:start` this window observes (including runs started by
144
- * OTHER windows, which fan out through the same signal path). Read
145
- * non-reactively by the re-convergence guard so a disk snapshot
146
- * kicked off before a run started is dropped instead of clobbering
147
- * the just-seeded stream.
148
- */
149
- private _runSeq = new Map<K, number>();
150
- private _pages = new Map<K, SessionPageState>();
151
- /**
152
- * Texts of user prompts THIS window appended optimistically that still
153
- * await their host echo. The host stamps `echo: true` on the broadcast
154
- * of the sender's own prompt (send / steer paths) for EVERY peer — it
155
- * cannot know which window originated the send — so the dedupe lives
156
- * here: one pending entry consumes one echo (keeping the local copy,
157
- * which carries refs + attachments the canonical event doesn't).
158
- * Echo-tagged prompts with NO pending match are genuine remote sends
159
- * (another window, a daemon-drained queued prompt) and must render.
160
- * Leftovers (failed sends) are cleared at `run:end`.
161
- */
162
- private _pendingEcho = new Map<K, string[]>();
163
- /**
164
- * Image previews of prompts THIS window queued, FIFO per session, until
165
- * the prompt shows up in the transcript (see `prompt-previews.ts`).
166
- */
167
- private _promptPreviews = new Map<K, Array<{ text: string; attachments: ChatAttachment[] }>>();
168
- private _listenersBySession = new Map<K, Set<() => void>>();
169
- private _listenersForHas = new Set<() => void>();
170
-
171
- /**
172
- * A session's events: the stored array itself (stable identity until a write), or a shared empty array.
173
- *
174
- * @param sessionId - The session, or `null` for none.
175
- */
176
- getEventsSnapshot(sessionId: K | null): readonly ChatEvent[] {
177
- if (!sessionId) {
178
- return EMPTY_EVENTS;
179
- }
180
-
181
- return this._events.get(sessionId) ?? EMPTY_EVENTS;
182
- }
183
-
184
- /**
185
- * Whether a run is in flight for the session.
186
- *
187
- * @param sessionId - The session, or `null` for none.
188
- */
189
- getRunningSnapshot(sessionId: K | null): boolean {
190
- if (!sessionId) {
191
- return false;
192
- }
193
-
194
- return this._running.get(sessionId) ?? false;
195
- }
196
-
197
- /**
198
- * Seed "running" from the store row for a run this window never saw
199
- * start — a session driven by the daemon or another client, opened
200
- * mid-run. Only ever sets TRUE: clearing belongs to `run:end` (or a
201
- * runtime drop), since a list fetched just before a local run:start
202
- * would otherwise flip a genuinely live session back to idle.
203
- *
204
- * @param sessionId - The session.
205
- */
206
- markRunning(sessionId: K): void {
207
- if (this._running.get(sessionId)) {
208
- return;
209
- }
210
-
211
- if (!this._events.has(sessionId)) {
212
- this._events.set(sessionId, []);
213
- this._notifyHas();
214
- }
215
-
216
- this._running.set(sessionId, true);
217
- this._notifySession(sessionId);
218
- }
219
-
220
- /**
221
- * How many runs this client saw start for the session (0 for none). Read non-reactively: a snapshot fetched before a run started is stale.
222
- *
223
- * @param sessionId - The session, or `null` for none.
224
- */
225
- getRunSeqSnapshot(sessionId: K | null): number {
226
- if (!sessionId) {
227
- return 0;
228
- }
229
-
230
- return this._runSeq.get(sessionId) ?? 0;
231
- }
232
-
233
- /**
234
- * Stable-reference snapshot (the stored object itself) — safe for
235
- * `useSyncExternalStore`, which compares snapshots by identity.
236
- *
237
- * @param sessionId - The session, or `null` for none.
238
- */
239
- getFallbackSnapshot(sessionId: K | null): SessionFallbackModel | null {
240
- if (!sessionId) {
241
- return null;
242
- }
243
-
244
- return this._fallback.get(sessionId) ?? null;
245
- }
246
-
247
- /**
248
- * Seed the override from the main-process PULL (`sessions.systemMd`).
249
- *
250
- * The `system-md` signal only fires when an agent is BUILT, and agents are
251
- * cached — so opening the app onto a warm session, or switching back to one,
252
- * delivers no signal at all. Without this seed the badge is silent in the
253
- * most common flow rather than an edge case, which is the wrong direction
254
- * for a warning that the built-in doctrine has been replaced.
255
- *
256
- * Skipped while a live signal already holds a value for the session: the
257
- * push is authoritative and may have landed while this fetch was in flight.
258
- *
259
- * @param sessionId - The session.
260
- * @param file - The override, or `null` for none.
261
- */
262
- seedSystemMd(sessionId: K, file: SystemMdFile | null): void {
263
- if (this._systemMd.has(sessionId)) {
264
- return;
265
- }
266
-
267
- this._systemMd.set(sessionId, file);
268
- this._notifySession(sessionId);
269
- }
270
-
271
- /**
272
- * Stable-reference snapshot of the active `SYSTEM.md` override, for
273
- * `useSyncExternalStore` (compared by identity, and the stored object is the
274
- * one the signal delivered).
275
- *
276
- * @param sessionId - The session, or `null` for none.
277
- */
278
- getSystemMdSnapshot(sessionId: K | null): SystemMdFile | null {
279
- if (!sessionId) {
280
- return null;
281
- }
282
-
283
- return this._systemMd.get(sessionId) ?? null;
284
- }
285
-
286
- /**
287
- * Stable-reference snapshot of in-flight provider-retry state.
288
- *
289
- * @param sessionId - The session, or `null` for none.
290
- */
291
- getRetrySnapshot(sessionId: K | null): SessionRetryState | null {
292
- if (!sessionId) {
293
- return null;
294
- }
295
-
296
- return this._retry.get(sessionId) ?? null;
297
- }
298
-
299
- /**
300
- * Whether the store holds any record for the session (live-only windows included; see `isHydrated`).
301
- *
302
- * @param sessionId - The session, or `null` for none.
303
- */
304
- hasEvents(sessionId: K | null): boolean {
305
- if (!sessionId) {
306
- return false;
307
- }
308
-
309
- return this._events.has(sessionId);
310
- }
311
-
312
- /**
313
- * Whether the session's window was hydrated from DISK (`setEventsPage`),
314
- * as opposed to merely having a record. `markRunning` and every live
315
- * signal seed `_events` for a session this window never loaded — a run
316
- * driven by the TUI or another window — and `hasEvents` alone read those
317
- * live-only windows as hydrated, so activation skipped `loadEvents` and
318
- * the transcript showed nothing but the deltas that had arrived so far,
319
- * with no page state to scroll back from.
320
- *
321
- * @param sessionId - The session, or `null` for none.
322
- */
323
- isHydrated(sessionId: K | null): boolean {
324
- if (!sessionId) {
325
- return false;
326
- }
327
-
328
- return this._pages.has(sessionId);
329
- }
330
-
331
- /**
332
- * The session's scrollback bookkeeping (a shared empty state when it was never hydrated). Stable identity until a page write.
333
- *
334
- * @param sessionId - The session, or `null` for none.
335
- */
336
- getPageSnapshot(sessionId: K | null): SessionPageState {
337
- if (!sessionId) {
338
- return NO_PAGE;
339
- }
340
-
341
- return this._pages.get(sessionId) ?? NO_PAGE;
342
- }
343
-
344
- /**
345
- * Hydrate one replay page as the session's full window — the
346
- * `loadEvents` (tail page) path. One notify covers both the events
347
- * swap and the page-state swap.
348
- *
349
- * @param sessionId - The session.
350
- * @param page - The persisted page.
351
- */
352
- setEventsPage(sessionId: K, page: SessionStreamPage): void {
353
- const had = this._events.has(sessionId);
354
- const wasHydrated = this._pages.has(sessionId);
355
- const prior = this._events.get(sessionId) ?? [];
356
- /*
357
- * Reuse the OBJECTS of events that are unchanged. Row identity in the
358
- * timeline is keyed by event object (`rowIdFor`), so a page that merely
359
- * re-states the same tool calls with fresh objects would remount every
360
- * row: expanded tool results snap shut, `zg-row-enter` replays, the
361
- * viewport jumps. Re-convergence (`sessions:changed` while another
362
- * surface drives the session, run-end compaction, reconnect backfill)
363
- * hits this path on every persisted turn.
364
- *
365
- * A window that was never hydrated holds ONLY live deltas (see
366
- * `isHydrated`); the disk page goes in front of them and the not-yet-
367
- * persisted suffix survives, instead of the page clobbering the stream.
368
- */
369
- const next = wasHydrated ? reconcileEvents(prior, page.events) : mergeLiveTail(prior, page.events);
370
- // A prompt on show whose persisted copy replaces it (a new chat's first read) stays the same bubble.
371
- inheritRowIdentity(prior, next);
372
- this._events.set(sessionId, next);
373
- this._pages.set(sessionId, { firstSeq: page.firstSeq, hasMore: page.hasMore, loadingEarlier: false });
374
- this._notifySession(sessionId);
375
-
376
- if (!had || !wasHydrated) {
377
- this._notifyHas();
378
- }
379
- }
380
-
381
- /**
382
- * Splice an OLDER page in front of the hydrated window (lazy scrollback).
383
- *
384
- * @param sessionId - The session.
385
- * @param page - The persisted page.
386
- */
387
- prependEventsPage(sessionId: K, page: SessionStreamPage): void {
388
- const existing = this._events.get(sessionId) ?? [];
389
- const wasHydrated = this._pages.has(sessionId);
390
- this._events.set(sessionId, [...page.events, ...existing]);
391
- this._pages.set(sessionId, { firstSeq: page.firstSeq, hasMore: page.hasMore, loadingEarlier: false });
392
- this._notifySession(sessionId);
393
-
394
- if (!wasHydrated) {
395
- this._notifyHas();
396
- }
397
- }
398
-
399
- /**
400
- * Marks a fetch of the previous page in flight, or done.
401
- *
402
- * @param sessionId - The session.
403
- * @param loading - Whether a fetch is in flight.
404
- */
405
- setLoadingEarlier(sessionId: K, loading: boolean): void {
406
- const prior = this._pages.get(sessionId) ?? NO_PAGE;
407
-
408
- if (prior.loadingEarlier === loading) {
409
- return;
410
- }
411
-
412
- this._pages.set(sessionId, { ...prior, loadingEarlier: loading });
413
- this._notifySession(sessionId);
414
- }
415
-
416
- /**
417
- * Registers a listener for one session's changes. Returns the function that removes it.
418
- *
419
- * @param sessionId - The session, or `null` for none.
420
- * @param listener - Called after the state changes.
421
- */
422
- subscribeSession(sessionId: K | null, listener: () => void): () => void {
423
- /*
424
- * `null` sessions need a still-callable subscription (returns a noop
425
- * unsubscriber). `useSyncExternalStore` calls `subscribe` once on
426
- * mount + on every snapshot identity change — we honor the signature
427
- * even for "no session" callers so the empty-state Center doesn't
428
- * crash.
429
- */
430
- if (!sessionId) {
431
- return () => undefined;
432
- }
433
-
434
- let set = this._listenersBySession.get(sessionId);
435
-
436
- if (!set) {
437
- set = new Set();
438
- this._listenersBySession.set(sessionId, set);
439
- }
440
-
441
- set.add(listener);
442
-
443
- return () => {
444
- const live = this._listenersBySession.get(sessionId);
445
-
446
- if (!live) {
447
- return;
448
- }
449
-
450
- live.delete(listener);
451
-
452
- if (live.size === 0) {
453
- this._listenersBySession.delete(sessionId);
454
- }
455
- };
456
- }
457
-
458
- /**
459
- * Subscribe to "the set of known sessions changed" — used by
460
- * `useHasEvents` so we only re-render the consumer when its target
461
- * session flips between hydrated / not.
462
- *
463
- * @param listener - Called after the state changes.
464
- */
465
- subscribeHas(listener: () => void): () => void {
466
- this._listenersForHas.add(listener);
467
-
468
- return () => {
469
- this._listenersForHas.delete(listener);
470
- };
471
- }
472
-
473
- /**
474
- * Drop EVERY session's transient state — used when the execution runtime
475
- * changes underneath the window (`useDaemon` toggled: the authority for
476
- * every transcript, run flag and per-run chip just moved to another
477
- * process, or back). Unlike `evictExcept`, running sessions are NOT spared:
478
- * a `running` flag from the previous runtime is exactly the kind of stale
479
- * truth this exists to discard. Sessions re-hydrate through the ordinary
480
- * cold path on next view, and the new runtime's `run:start`/`run:end`
481
- * re-establish the flags.
482
- */
483
- dropAll(): void {
484
- this.runStateVersion++;
485
- const had = this._events.size > 0;
486
- const sessionIds = new Set([...this._events.keys(), ...this._running.keys(), ...this._systemMd.keys()]);
487
- this._events.clear();
488
- this._running.clear();
489
- this._runSeq.clear();
490
- this._fallback.clear();
491
- this._retry.clear();
492
- this._systemMd.clear();
493
- this._pages.clear();
494
- // Echoes of sends made to the previous runtime never arrive, and no
495
- // `run:end` from it will sweep them: left in place they would swallow an
496
- // identical prompt sent through the new runtime.
497
- this._pendingEcho.clear();
498
-
499
- for (const sessionId of sessionIds) {
500
- this._notifySession(sessionId);
501
- }
502
-
503
- if (had) {
504
- this._notifyHas();
505
- }
506
- }
507
-
508
- /**
509
- * Empties a session's window and run state, and drops its hydration so the next activation reloads from disk.
510
- *
511
- * @param sessionId - The session.
512
- */
513
- reset(sessionId: K): void {
514
- const had = this._events.has(sessionId);
515
- const wasHydrated = this._pages.has(sessionId);
516
- this._events.set(sessionId, []);
517
- this._running.set(sessionId, false);
518
- this._fallback.delete(sessionId);
519
- this._retry.delete(sessionId);
520
- this._systemMd.delete(sessionId);
521
- this._pages.delete(sessionId);
522
- this._notifySession(sessionId);
523
-
524
- if (!had || wasHydrated) {
525
- this._notifyHas();
526
- }
527
- }
528
-
529
- /**
530
- * Evict every hydrated window whose session id is not in `keep` — the
531
- * memory bound for a long-lived window. Prewarm slides a window of
532
- * likely-next sessions into the cache, and this slides old entries
533
- * OUT, so a long browsing session does not accumulate one tail page per
534
- * session ever visited. Revisiting an evicted session re-hydrates through the
535
- * exact same `hydrated()` → `loadEvents` path a cold session uses.
536
- *
537
- * Never evicts:
538
- * - running sessions (live deltas exist only in this store — dropping
539
- * them would blank an in-flight background run's transcript);
540
- * - sessions with a scrollback fetch in flight (`loadingEarlier` —
541
- * the prepend landing after eviction would resurrect a window
542
- * containing ONLY the old page).
543
- *
544
- * @param keep - The sessions to keep.
545
- */
546
- evictExcept(keep: ReadonlySet<K>): void {
547
- let dropped = false;
548
-
549
- for (const sessionId of [...this._events.keys()]) {
550
- if (keep.has(sessionId) || this._running.get(sessionId) || this._pages.get(sessionId)?.loadingEarlier) {
551
- continue;
552
- }
553
-
554
- this._events.delete(sessionId);
555
- this._running.delete(sessionId);
556
- this._fallback.delete(sessionId);
557
- this._retry.delete(sessionId);
558
- /*
559
- * `_systemMd` is deliberately NOT evicted here. This pass exists to
560
- * bound the memory held by transcript EVENT windows; the override is one
561
- * small object per session, and dropping it silently hides the badge
562
- * warning that the built-in safety and git doctrine has been replaced —
563
- * with no way to recover it until the agent is rebuilt.
564
- */
565
- this._pages.delete(sessionId);
566
- this._notifySession(sessionId);
567
- dropped = true;
568
- }
569
-
570
- if (dropped) {
571
- this._notifyHas();
572
- }
573
- }
574
-
575
- /**
576
- * Drop a session entirely — called by `SessionsContext.deleteSession`
577
- * so a removed row's stored events don't leak past the IPC delete.
578
- *
579
- * @param sessionId - The session.
580
- */
581
- drop(sessionId: K): void {
582
- const had = this._events.has(sessionId) || this._running.has(sessionId);
583
- this._events.delete(sessionId);
584
- this._running.delete(sessionId);
585
- this._runSeq.delete(sessionId);
586
- this._fallback.delete(sessionId);
587
- this._retry.delete(sessionId);
588
- this._systemMd.delete(sessionId);
589
- this._pages.delete(sessionId);
590
- this._pendingEcho.delete(sessionId);
591
- this._promptPreviews.delete(sessionId);
592
-
593
- if (had) {
594
- this._notifySession(sessionId);
595
- this._notifyHas();
596
- }
597
- }
598
-
599
- /**
600
- * Remember the image previews of a prompt this window queued, so the copy
601
- * that reaches the transcript later (host drain / push) keeps thumbnails.
602
- * Bounded: a queue that never drains can't grow this without limit.
603
- *
604
- * @param sessionId - The session.
605
- * @param text - The queued prompt's text.
606
- * @param attachments - The prompt's attachments.
607
- */
608
- rememberPromptPreviews(sessionId: K, text: string, attachments: readonly ChatAttachment[]): void {
609
- const withData = attachments.filter((a) => a.dataUrl !== undefined);
610
- if (withData.length === 0) return;
611
- const list = this._promptPreviews.get(sessionId) ?? [];
612
- list.push({ text, attachments: withData });
613
- this._promptPreviews.set(sessionId, list.slice(-16));
614
- }
615
-
616
- /**
617
- * Unwind the latest `rememberPromptPreviews` entry for `text` after a failed enqueue.
618
- *
619
- * @param sessionId - The session.
620
- * @param text - The queued prompt's text.
621
- */
622
- dropPromptPreviews(sessionId: K, text: string): void {
623
- const list = this._promptPreviews.get(sessionId);
624
- if (!list) return;
625
- for (let i = list.length - 1; i >= 0; i--) {
626
- if (list[i]!.text === text) {
627
- list.splice(i, 1);
628
- if (list.length === 0) this._promptPreviews.delete(sessionId);
629
- return;
630
- }
631
- }
632
- }
633
-
634
- /**
635
- * Follow a queued entry's text edit so its previews still match when it's sent.
636
- *
637
- * @param sessionId - The session.
638
- * @param from - The queued prompt's text before the edit.
639
- * @param to - Its text after the edit.
640
- */
641
- renamePromptPreviews(sessionId: K, from: string, to: string): void {
642
- const list = this._promptPreviews.get(sessionId) ?? [];
643
- for (let i = list.length - 1; i >= 0; i--) {
644
- if (list[i]!.text === from) {
645
- list[i]!.text = to;
646
- return;
647
- }
648
- }
649
- }
650
-
651
- private takePromptPreviews(sessionId: K, text: string): ChatAttachment[] {
652
- const list = this._promptPreviews.get(sessionId);
653
- const index = list?.findIndex((entry) => entry.text === text) ?? -1;
654
- if (!list || index === -1) return [];
655
- const [taken] = list.splice(index, 1);
656
- if (list.length === 0) this._promptPreviews.delete(sessionId);
657
- return taken!.attachments;
658
- }
659
-
660
- /**
661
- * Shows the user's prompt at once (optimistic append) and waits for its host echo, which is then dropped.
662
- *
663
- * @param sessionId - The session.
664
- * @param text - The prompt text.
665
- * @param refs - The completions the prompt used (skills, files), for its chips.
666
- * @param rawAttachments - The prompt's attachments. Omitted for a pushed queued prompt, which takes the previews this client remembered for it.
667
- */
668
- appendUserPrompt(
669
- sessionId: K,
670
- text: string,
671
- refs?: readonly PromptSegmentRef[],
672
- rawAttachments?: readonly ChatAttachment[],
673
- ): void {
674
- const had = this._events.has(sessionId);
675
- const events = this._events.get(sessionId)?.slice() ?? [];
676
- /*
677
- * A pushed queued entry is appended with no attachment list at all:
678
- * restore its previews. A local send passes its own list (possibly
679
- * empty), so it never inherits another prompt's previews.
680
- */
681
- const attachments =
682
- rawAttachments === undefined || missingPreviewData(rawAttachments)
683
- ? mergePromptPreviews(rawAttachments, this.takePromptPreviews(sessionId, text))
684
- : rawAttachments;
685
-
686
- /*
687
- * `refs` only attaches when the user actually used a completion —
688
- * bare prompts skip the field entirely so downstream `refs?.length`
689
- * checks fast-path without a clone.
690
- *
691
- * `attachments` rides along on `ChatEvent` — canonical
692
- * `StreamEvent` has no slot for it (TUI doesn't render inline
693
- * images), but the GUI wire type extends it with the optional
694
- * field.
695
- */
696
- const event: ChatEvent = {
697
- kind: 'user-prompt',
698
- text,
699
- ...(refs && refs.length > 0 ? { refs: [...refs] } : {}),
700
- ...(attachments && attachments.length > 0 ? { attachments: [...attachments] } : {}),
701
- };
702
- events.push(event);
703
-
704
- const pending = this._pendingEcho.get(sessionId) ?? [];
705
- pending.push(text);
706
- this._pendingEcho.set(sessionId, pending);
707
-
708
- this._events.set(sessionId, events);
709
- this._notifySession(sessionId);
710
-
711
- if (!had) {
712
- this._notifyHas();
713
- }
714
- }
715
-
716
- /**
717
- * Unwind ONE pending echo after a FAILED send — a refused/errored send
718
- * produces no run, so the `run:end` sweep never fires and the stale
719
- * entry would silently swallow an identical remote prompt later.
720
- *
721
- * @param sessionId - The session.
722
- * @param text - The prompt text.
723
- */
724
- dropPendingEcho(sessionId: K, text: string): void {
725
- const pending = this._pendingEcho.get(sessionId);
726
- const index = pending?.indexOf(text) ?? -1;
727
-
728
- if (pending && index !== -1) {
729
- pending.splice(index, 1);
730
- }
731
- }
732
-
733
- /**
734
- * The prompt texts this client appended that still await their host echo
735
- * (see `appendUserPrompt`). The live list: an adapter that keeps its own
736
- * echo rule (`createLiveState`) edits it in place.
737
- *
738
- * @param sessionId - The session.
739
- */
740
- pendingEchoes(sessionId: K): string[] {
741
- let pending = this._pendingEcho.get(sessionId);
742
-
743
- if (!pending) {
744
- pending = [];
745
- this._pendingEcho.set(sessionId, pending);
746
- }
747
-
748
- return pending;
749
- }
750
-
751
- /**
752
- * Low-level write: sets any of a session's events, run flag and page state
753
- * in one notification, with none of the signal rules (no finalize, no
754
- * reconcile). For adapters that own their merge rules (`createLiveState`).
755
- * The store keeps `events` as given and never mutates it.
756
- *
757
- * @param sessionId - The session.
758
- * @param patch - The fields to set.
759
- */
760
- write(sessionId: K, patch: SessionStreamWrite): void {
761
- const had = this._events.has(sessionId);
762
- const wasHydrated = this._pages.has(sessionId);
763
-
764
- if (patch.events !== undefined) {
765
- this._events.set(sessionId, patch.events as ChatEvent[]);
766
- } else if (!had) {
767
- this._events.set(sessionId, []);
768
- }
769
-
770
- if (patch.running !== undefined) {
771
- this._running.set(sessionId, patch.running);
772
- }
773
-
774
- if (patch.page === null) {
775
- this._pages.delete(sessionId);
776
- } else if (patch.page !== undefined) {
777
- this._pages.set(sessionId, patch.page);
778
- }
779
-
780
- this._notifySession(sessionId);
781
-
782
- if (!had || wasHydrated !== this._pages.has(sessionId)) {
783
- this._notifyHas();
784
- }
785
- }
786
-
787
- /**
788
- * Appends a display-only error row (a send that failed before any run).
789
- *
790
- * @param sessionId - The session.
791
- * @param text - The error message.
792
- */
793
- appendErrorEvent(sessionId: K, text: string): void {
794
- const had = this._events.has(sessionId);
795
- const events = this._events.get(sessionId)?.slice() ?? [];
796
- events.push({ kind: 'error', text });
797
- this._events.set(sessionId, events);
798
- this._notifySession(sessionId);
799
-
800
- if (!had) {
801
- this._notifyHas();
802
- }
803
- }
804
-
805
- /**
806
- * Reduces one live signal into its session (see {@link SessionStreamSignal}). Signals of other kinds are ignored.
807
- *
808
- * @param input - The signal.
809
- */
810
- applySignal(input: SessionStreamSignal<K> | OtherStreamSignal): void {
811
- const signal = input as SessionStreamSignal<K>;
812
- switch (signal.kind) {
813
- case 'run:start': {
814
- this.runStateVersion++;
815
- const had = this._events.has(signal.sessionId);
816
-
817
- if (!had) {
818
- this._events.set(signal.sessionId, []);
819
- this._notifyHas();
820
- }
821
-
822
- this._running.set(signal.sessionId, true);
823
- this._runSeq.set(signal.sessionId, (this._runSeq.get(signal.sessionId) ?? 0) + 1);
824
- // Fallback is run-sticky — a new run starts from the primary, so
825
- // the pill snaps back until (unless) this run falls back too.
826
- this._fallback.delete(signal.sessionId);
827
- this._notifySession(signal.sessionId);
828
-
829
- return;
830
- }
831
- case 'run:end': {
832
- this.runStateVersion++;
833
- const prior = this._events.get(signal.sessionId) ?? [];
834
-
835
- /*
836
- * Finalize any in-flight streaming markdown first so its caret
837
- * disappears and the final text persists.
838
- */
839
- // Run over: close every reasoning lane still open, whatever its owner
840
- // (a worker aborted mid-thought gets no `turn:end`), so each row
841
- // collapses with its duration.
842
- let next = finishLive(prior);
843
-
844
- /*
845
- * When the run rejected, append an error row carrying the message.
846
- * Without this the failure is silent — the user sees their prompt
847
- * submitted, then nothing, with no clue why. The most common
848
- * causes are provider auth issues, protocol-history rejections
849
- * (unresolved tool_use from a prior session), and aborts.
850
- */
851
- if (!signal.ok && signal.error) {
852
- next = [...next, { kind: 'error', text: signal.error, ...(signal.detail ? { detail: signal.detail } : {}) }];
853
- }
854
-
855
- const had = this._events.has(signal.sessionId);
856
- this._events.set(signal.sessionId, next);
857
- this._running.set(signal.sessionId, false);
858
- // Retry can't outlive its run: a terminal failure never streams again,
859
- // so nothing else would ever clear the indicator.
860
- this._retry.delete(signal.sessionId);
861
- // No echo can follow its run — drop leftovers (e.g. failed sends)
862
- // so they can't swallow an identical future remote prompt.
863
- this._pendingEcho.delete(signal.sessionId);
864
- this._notifySession(signal.sessionId);
865
-
866
- if (!had) {
867
- this._notifyHas();
868
- }
869
-
870
- return;
871
- }
872
- case 'turn:end': {
873
- const prior = this._events.get(signal.sessionId) ?? [];
874
- const owner: Owner = signal.childId ?? PARENT_OWNER;
875
- const had = this._events.has(signal.sessionId);
876
- this._events.set(
877
- signal.sessionId,
878
- finalizeStreamingMarkdownForOwner(closeThinkingSegment(prior, owner), owner),
879
- );
880
- this._notifySession(signal.sessionId);
881
-
882
- if (!had) {
883
- this._notifyHas();
884
- }
885
-
886
- return;
887
- }
888
- case 'event': {
889
- // The sender's own echo: consume exactly one pending optimistic
890
- // append (see `_pendingEcho`) instead of rendering a duplicate.
891
- if (signal.event.kind === 'user-prompt' && signal.echo) {
892
- const pending = this._pendingEcho.get(signal.sessionId);
893
- const index = pending?.indexOf(signal.event.text) ?? -1;
894
-
895
- if (pending && index !== -1) {
896
- pending.splice(index, 1);
897
- return;
898
- }
899
- }
900
-
901
- // A host-sent queued prompt carries attachment metadata only; paint
902
- // the thumbnails this window kept when it queued the message.
903
- let event = signal.event as ChatEvent;
904
-
905
- if (event.kind === 'user-prompt' && missingPreviewData(event.attachments)) {
906
- const previews = this.takePromptPreviews(signal.sessionId, event.text);
907
- if (previews.length > 0) event = { ...event, attachments: mergePromptPreviews(event.attachments, previews) };
908
- }
909
-
910
- const had = this._events.has(signal.sessionId);
911
- const prior = this._events.get(signal.sessionId) ?? [];
912
- this._events.set(signal.sessionId, this._append(prior, event));
913
- // Transcript events arrive at token rate (thinking deltas, tool bursts): the state is
914
- // current at once, subscribers hear about it once per frame.
915
- if (this._batch) this._notifySoon(signal.sessionId);
916
- else this._notifySession(signal.sessionId);
917
-
918
- if (!had) {
919
- this._notifyHas();
920
- }
921
-
922
- return;
923
- }
924
- case 'model:fallback': {
925
- this._fallback.set(signal.sessionId, signal.to);
926
- if (signal.discardTurnId) this._discardThinking(signal.sessionId, 'parent', signal.discardTurnId);
927
- this._notifySession(signal.sessionId);
928
-
929
- return;
930
- }
931
- // `cache:break` falls to `default`: the transcript row arrives as a persisted notice `event`, filed after the turn it describes.
932
- case 'stream:retry': {
933
- this._retry.set(signal.sessionId, {
934
- attempt: signal.attempt,
935
- max: signal.max,
936
- source: signal.source,
937
- });
938
- if (signal.discardTurnId) this._discardThinking(signal.sessionId, signal.source, signal.discardTurnId);
939
- this._notifySession(signal.sessionId);
940
-
941
- return;
942
- }
943
- case 'prompt-turns': {
944
- /*
945
- * Bind just-persisted prompt turns to their live `user-prompt` echoes so
946
- * a prompt sent from THIS window becomes selectable (hover actions,
947
- * edit, delete, fork) during the run — not only after the run-end
948
- * hydration replaces the transcript. Same fix the TUI applies via
949
- * `onPromptTurns`, on the same shared matcher. `ChatEvent` only
950
- * narrows `attachments`, which the matcher reads structurally, so the
951
- * cast back is safe.
952
- */
953
- const events = this._events.get(signal.sessionId);
954
-
955
- if (!events || events.length === 0) {
956
- return;
957
- }
958
-
959
- const next = retagUserPromptEventsFromRefs(events as unknown as StreamEvent[], signal.refs);
960
-
961
- if (next !== events) {
962
- // The bound prompt is the same bubble: its row keeps its key, so it updates in place
963
- // instead of remounting (the send "blinked": the bubble rose a second time).
964
- inheritRowIdentity(events, next);
965
- this._events.set(signal.sessionId, next as unknown as ChatEvent[]);
966
- this._notifySession(signal.sessionId);
967
- }
968
-
969
- return;
970
- }
971
- case 'stream:retry:cleared': {
972
- /*
973
- * Source-matched: a subagent stream dying must not clear a retry the
974
- * PARENT stream is still in the middle of (and vice versa).
975
- */
976
- const current = this._retry.get(signal.sessionId);
977
-
978
- if (current?.source === signal.source) {
979
- this._retry.delete(signal.sessionId);
980
- this._notifySession(signal.sessionId);
981
- }
982
-
983
- return;
984
- }
985
- case 'system-md': {
986
- /*
987
- * Which `SYSTEM.md` composed this session's prompt, or null for none.
988
- *
989
- * This must be surfaced, not merely stored: a `SYSTEM.md` REPLACES the
990
- * built-in doctrine rather than appending to it, so an override in
991
- * force means the safety and git guidance the user expects is gone —
992
- * silently, since nothing errors. The host applies it wherever the
993
- * prompt is composed, which can be another process.
994
- */
995
- this._systemMd.set(signal.sessionId, signal.file);
996
- this._notifySession(signal.sessionId);
997
-
998
- return;
999
- }
1000
- default: {
1001
- return;
1002
- }
1003
- }
1004
- }
1005
-
1006
- /**
1007
- * Apply a batch of synthesized smooth-stream deltas in one shot.
1008
- * Coalesces per-session work so a tick that touches sessions A and B
1009
- * fires exactly one notify per session — not one per delta.
1010
- *
1011
- * @param plan - The text released from the smooth-stream buckets.
1012
- */
1013
- applyDrainPlan(plan: readonly DrainPlan<K>[]): void {
1014
- if (plan.length === 0) {
1015
- return;
1016
- }
1017
-
1018
- const touched = new Set<K>();
1019
-
1020
- for (const entry of plan) {
1021
- const prior = this._events.get(entry.sessionId) ?? [];
1022
-
1023
- const synthetic: StreamEvent = {
1024
- kind: 'markdown',
1025
- text: entry.text,
1026
- streaming: true,
1027
- ...(entry.childId ? { childId: entry.childId } : {}),
1028
- ...(entry.depth != null ? { depth: entry.depth } : {}),
1029
- ...(entry.turnId ? { turnId: entry.turnId } : {}),
1030
- };
1031
-
1032
- this._events.set(entry.sessionId, this._append(prior, synthetic));
1033
- touched.add(entry.sessionId);
1034
- }
1035
-
1036
- for (const sessionId of touched) {
1037
- this._notifySession(sessionId);
1038
- }
1039
- }
1040
-
1041
- /** Sessions whose subscribers are owed a notification at the next frame (`_notifySoon`). */
1042
- private _pendingNotify = new Set<K>();
1043
- private _flushHandles: { raf: unknown; timer: unknown } = { raf: null, timer: null };
1044
-
1045
- /**
1046
- * Coalesce notifications to one per frame. A frame callback when frames run, a
1047
- * timer when they don't (a hidden window throttles rAF; updates must still land).
1048
- */
1049
- private _notifySoon(sessionId: K): void {
1050
- this._pendingNotify.add(sessionId);
1051
- if (this._flushHandles.raf !== null || this._flushHandles.timer !== null) return;
1052
- const flush = () => this.flushNotifications();
1053
- this._flushHandles.raf = this._scheduler.frame(flush) ?? null;
1054
- this._flushHandles.timer = this._scheduler.timeout(flush, NOTIFY_FALLBACK_MS);
1055
- }
1056
-
1057
- /** Deliver notifications `_notifySoon` held back (also called before anything that must be immediate). */
1058
- flushNotifications(): void {
1059
- const { raf, timer } = this._flushHandles;
1060
- if (raf !== null) this._scheduler.cancelFrame(raf);
1061
- if (timer !== null) this._scheduler.cancelTimeout(timer);
1062
- this._flushHandles = { raf: null, timer: null };
1063
- if (this._pendingNotify.size === 0) return;
1064
- const ids = [...this._pendingNotify];
1065
- this._pendingNotify.clear();
1066
- for (const id of ids) this._notifySession(id);
1067
- }
1068
-
1069
- /** Drop a stalled attempt's reasoning lane: the retry (or next model) streams its own, and the saved turn never holds it. */
1070
- private _discardThinking(sessionId: K, source: string, turnId: string): void {
1071
- const events = this._events.get(sessionId);
1072
- if (!events) return;
1073
- const next = discardThinking(events, source, turnId);
1074
- if (next !== events) this._events.set(sessionId, next);
1075
- }
1076
-
1077
- /**
1078
- * Append a fresh event with the kit's live rule (`applyLiveEvent`, the
1079
- * web chat's too): markdown / thinking deltas grow the owner's open block
1080
- * even when concurrent subagents rotate the tail between them, a new
1081
- * thinking lane is stamped with its start, any other event of an owner
1082
- * closes that owner's lane ("Thought for Ns"), and tool rows get their
1083
- * live arrival time (`receivedAt`, the fallback for a host that sends no
1084
- * timing of its own).
1085
- */
1086
- private _append(events: ChatEvent[], event: ChatEvent | StreamEvent): ChatEvent[] {
1087
- return applyLiveEvent<ChatEvent>(events, event as ChatEvent, Date.now(), this._markdown);
1088
- }
1089
-
1090
- private _notifySession(sessionId: K): void {
1091
- // Anything owed to this session goes out with this notification.
1092
- this._pendingNotify.delete(sessionId);
1093
- const set = this._listenersBySession.get(sessionId);
1094
-
1095
- if (set) {
1096
- for (const listener of set) {
1097
- listener();
1098
- }
1099
- }
1100
- }
1101
-
1102
- private _notifyHas(): void {
1103
- for (const listener of this._listenersForHas) {
1104
- listener();
1105
- }
1106
- }
1107
- }