@kabmo-labs/kabmo 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (354) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +502 -474
  3. package/dist/client/static/js/index-81f7berm.css +1 -0
  4. package/dist/client/static/js/{index-95b3n20k.js → index-xzvyrxya.js} +799 -799
  5. package/marketplace/plugins/command-runner/package.json +3 -17
  6. package/marketplace/plugins/command-runner/settings-schema.json +14 -0
  7. package/marketplace/plugins/git-forge/README.md +17 -7
  8. package/marketplace/plugins/git-forge/package.json +4 -30
  9. package/marketplace/plugins/git-forge/panel.css +16 -0
  10. package/marketplace/plugins/git-forge/settings-schema.json +27 -0
  11. package/marketplace/plugins/git-forge/src/panel/Badge.tsx +35 -22
  12. package/marketplace/plugins/git-forge/src/panel/Change.tsx +20 -24
  13. package/marketplace/plugins/git-forge/src/panel/CiBadge.tsx +16 -7
  14. package/marketplace/plugins/git-forge/src/panel/Credential.tsx +31 -26
  15. package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +18 -2
  16. package/marketplace/plugins/git-forge/src/panel/Header.tsx +160 -96
  17. package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +60 -44
  18. package/marketplace/plugins/git-forge/src/panel/List.tsx +150 -22
  19. package/marketplace/plugins/git-forge/src/panel/Row.tsx +11 -5
  20. package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +17 -15
  21. package/marketplace/plugins/git-forge/src/panel/Write.tsx +84 -61
  22. package/marketplace/plugins/git-forge/src/panel/format.test.ts +99 -0
  23. package/marketplace/plugins/git-forge/src/panel/format.ts +59 -16
  24. package/marketplace/plugins/git-forge/src/panel/index.test.tsx +109 -5
  25. package/marketplace/plugins/git-forge/src/panel/index.tsx +37 -4
  26. package/marketplace/plugins/git-forge/src/panel/use-forge.ts +17 -0
  27. package/marketplace/plugins/git-forge/src/panel/write.test.tsx +31 -0
  28. package/marketplace/plugins/session-info/package.json +2 -10
  29. package/marketplace/plugins/session-info/settings-schema.json +8 -0
  30. package/marketplace/plugins/stats/README.md +17 -5
  31. package/marketplace/plugins/stats/package.json +3 -23
  32. package/marketplace/plugins/stats/settings-schema.json +20 -0
  33. package/marketplace/plugins/stats/src/app.tsx +1 -1
  34. package/marketplace/plugins/stats/src/groups.test.ts +46 -1
  35. package/marketplace/plugins/stats/src/groups.ts +22 -11
  36. package/marketplace/plugins/stats/src/harness-leases.test.ts +84 -0
  37. package/marketplace/plugins/stats/src/harness-leases.ts +132 -0
  38. package/marketplace/plugins/stats/src/labels.test.ts +54 -1
  39. package/marketplace/plugins/stats/src/labels.ts +33 -7
  40. package/marketplace/plugins/stats/src/sampler.test.ts +61 -0
  41. package/marketplace/plugins/stats/src/sampler.ts +39 -5
  42. package/marketplace/plugins/stats/src/snapshot.ts +6 -0
  43. package/package.json +2 -2
  44. package/src/client/components/common/Toast.test.tsx +28 -2
  45. package/src/client/components/common/Toast.tsx +21 -9
  46. package/src/client/components/common/harness-glyph/index.tsx +18 -1
  47. package/src/client/components/common/session-actions-menu/index.test.tsx +106 -0
  48. package/src/client/components/common/session-actions-menu/index.tsx +43 -1
  49. package/src/client/components/common/session-row/TrailingSlot.tsx +9 -4
  50. package/src/client/components/common/session-row/index.tsx +4 -0
  51. package/src/client/components/common/session-row/session-row.test.tsx +6 -0
  52. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +2 -1
  53. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +4 -2
  54. package/src/client/components/layout/session-sidebar/SessionItem.tsx +9 -1
  55. package/src/client/components/layout/session-sidebar/SessionList.tsx +2 -1
  56. package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +3 -2
  57. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +2 -1
  58. package/src/client/components/layout/session-sidebar/modern/RevealRow.tsx +56 -0
  59. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +12 -29
  60. package/src/client/components/layout/session-sidebar/modern/reveal-row.test.tsx +104 -0
  61. package/src/client/components/layout/session-sidebar/scheduler-modal/ModelFields.tsx +202 -0
  62. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +80 -19
  63. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +23 -3
  64. package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +5 -1
  65. package/src/client/components/layout/session-sidebar/variant-props.ts +2 -1
  66. package/src/client/components/mobile/SessionSidebar.tsx +2 -1
  67. package/src/client/components/mobile/mobile-right-sidebar/EditorSurface.tsx +156 -0
  68. package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +41 -86
  69. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +2 -1
  70. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +4 -2
  71. package/src/client/components/mobile/mobile-session-sidebar/List.tsx +2 -1
  72. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +6 -0
  73. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +9 -1
  74. package/src/client/components/settings/Modal.tsx +7 -3
  75. package/src/client/components/settings/Sidebar.tsx +30 -3
  76. package/src/client/components/settings/categories/HarnessSettings.tsx +11 -7
  77. package/src/client/components/settings/categories/NotificationSettings.test.tsx +40 -15
  78. package/src/client/components/settings/categories/NotificationSettings.tsx +142 -64
  79. package/src/client/components/settings/categories/PanelPluginSettings.tsx +1 -1
  80. package/src/client/components/settings/categories/harness-settings/CustomHarnessForm.tsx +186 -0
  81. package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +11 -0
  82. package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +1 -0
  83. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +15 -1
  84. package/src/client/components/settings/categories/panel-plugins/SettingsModal.test.tsx +165 -0
  85. package/src/client/components/settings/categories/panel-plugins/SettingsModal.tsx +260 -0
  86. package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
  87. package/src/client/components/settings/categories/usage-settings/LimitsSection.tsx +39 -19
  88. package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +1 -0
  89. package/src/client/components/settings/categories/usage-settings/limit-groups.test.ts +94 -0
  90. package/src/client/components/settings/categories/usage-settings/limit-groups.ts +118 -0
  91. package/src/client/components/settings/categories/usage-settings/limits-section.test.tsx +118 -0
  92. package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +24 -0
  93. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +8 -4
  94. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +34 -0
  95. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +61 -56
  96. package/src/client/components/workspace/chat-timeline/MessageItem.fork.test.ts +80 -0
  97. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +9 -3
  98. package/src/client/components/workspace/chat-timeline/MessageList.tsx +3 -1
  99. package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +11 -1
  100. package/src/client/components/workspace/chat-timeline/PendingTranscript.tsx +130 -0
  101. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +2 -1
  102. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +2 -1
  103. package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +8 -0
  104. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +9 -0
  105. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +4 -1
  106. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +24 -0
  107. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +13 -20
  108. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +2 -0
  109. package/src/client/components/workspace/chat-timeline/chat-input/props.ts +5 -5
  110. package/src/client/components/workspace/chat-timeline/fork-preview.test.tsx +141 -0
  111. package/src/client/components/workspace/chat-timeline/index.tsx +17 -6
  112. package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +3 -10
  113. package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.test.tsx +101 -0
  114. package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +2 -2
  115. package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +5 -4
  116. package/src/client/components/workspace/editor/FilePane.tsx +9 -4
  117. package/src/client/components/workspace/editor/Notices.tsx +2 -2
  118. package/src/client/components/workspace/editor/Pane.tsx +2 -2
  119. package/src/client/components/workspace/editor/Toolbar.tsx +16 -10
  120. package/src/client/components/workspace/editor/index.tsx +6 -10
  121. package/src/client/components/workspace/editor/toolbar-clusters.test.ts +4 -3
  122. package/src/client/components/workspace/editor/toolbar-clusters.tsx +23 -14
  123. package/src/client/components/workspace/git-panel/index.tsx +2 -2
  124. package/src/client/components/workspace/terminal-panel/RealtimeTerminalView.tsx +17 -6
  125. package/src/client/components/workspace/terminal-panel/focus.test.ts +70 -0
  126. package/src/client/components/workspace/terminal-panel/focus.ts +46 -0
  127. package/src/client/components/workspace/terminal-panel/index.tsx +17 -1
  128. package/src/client/components/workspace/terminal-panel/mount.ts +17 -9
  129. package/src/client/components/workspace/terminal-panel/scroll-hold.test.ts +158 -0
  130. package/src/client/components/workspace/terminal-panel/scroll-hold.ts +136 -0
  131. package/src/client/hooks/chat/composer/use-draft.ts +45 -1
  132. package/src/client/hooks/chat/omp/pending-sessions.waiting.test.ts +11 -10
  133. package/src/client/hooks/chat/omp/pending-waiting.ts +15 -7
  134. package/src/client/hooks/chat/omp/prompt-send.test.ts +11 -0
  135. package/src/client/hooks/chat/omp/prompt-send.ts +3 -0
  136. package/src/client/hooks/chat/omp/session-list.tsx +5 -0
  137. package/src/client/hooks/chat/omp/sidebar-reload.test.ts +85 -0
  138. package/src/client/hooks/chat/omp/sidebar-reload.ts +30 -0
  139. package/src/client/hooks/chat/timeline/actions.ts +4 -4
  140. package/src/client/hooks/chat/timeline/composer-modes.ts +13 -2
  141. package/src/client/hooks/chat/timeline/fork-open.ts +52 -0
  142. package/src/client/hooks/chat/timeline/fork-preview.test.ts +148 -0
  143. package/src/client/hooks/chat/timeline/fork-preview.ts +104 -0
  144. package/src/client/hooks/chat/timeline/fork-send.test.ts +139 -0
  145. package/src/client/hooks/chat/timeline/index.ts +5 -2
  146. package/src/client/hooks/chat/timeline/mode-availability.ts +7 -0
  147. package/src/client/hooks/chat/timeline/modes-contract.ts +6 -0
  148. package/src/client/hooks/chat/timeline/modes-hydrate.ts +93 -0
  149. package/src/client/hooks/chat/timeline/modes.ts +32 -52
  150. package/src/client/hooks/chat/timeline/new-chat-open.ts +7 -6
  151. package/src/client/hooks/chat/timeline/new-chat.ts +10 -1
  152. package/src/client/hooks/chat/timeline/pending-branch.ts +9 -0
  153. package/src/client/hooks/chat/timeline/pending-dispatch.ts +53 -0
  154. package/src/client/hooks/chat/timeline/pending-session-mode.test.ts +136 -0
  155. package/src/client/hooks/chat/timeline/pending-session-mode.ts +69 -0
  156. package/src/client/hooks/chat/timeline/pending-warmup.test.ts +147 -0
  157. package/src/client/hooks/chat/timeline/pending-warmup.ts +62 -0
  158. package/src/client/hooks/chat/timeline/run-identity.test.ts +12 -0
  159. package/src/client/hooks/chat/timeline/run-identity.ts +4 -1
  160. package/src/client/hooks/chat/timeline/send-props.ts +2 -0
  161. package/src/client/hooks/chat/timeline/send-steer.test.ts +1 -0
  162. package/src/client/hooks/chat/timeline/send.test-util.ts +1 -0
  163. package/src/client/hooks/chat/timeline/send.test.ts +1 -0
  164. package/src/client/hooks/chat/timeline/session-harness.ts +4 -0
  165. package/src/client/hooks/chat/timeline/stop-with-queue.ts +1 -1
  166. package/src/client/hooks/chat/timeline/use-fork-session.ts +9 -22
  167. package/src/client/hooks/chat/waiting/cancel.ts +15 -7
  168. package/src/client/hooks/chat/waiting/choice.ts +13 -16
  169. package/src/client/hooks/chat/waiting/composer-wait.ts +70 -0
  170. package/src/client/hooks/chat/waiting/dispatch.ts +50 -29
  171. package/src/client/hooks/chat/waiting/held.ts +38 -13
  172. package/src/client/hooks/chat/waiting/hold.test.ts +22 -0
  173. package/src/client/hooks/chat/waiting/hold.ts +20 -11
  174. package/src/client/hooks/chat/waiting/restore.test.ts +69 -0
  175. package/src/client/hooks/chat/waiting/restore.ts +34 -0
  176. package/src/client/hooks/chat/waiting/store.ts +9 -3
  177. package/src/client/hooks/editor/file-editor-types.ts +21 -12
  178. package/src/client/hooks/editor/save-file.test.ts +1 -1
  179. package/src/client/hooks/editor/save-file.ts +35 -8
  180. package/src/client/hooks/editor/target-key.ts +17 -0
  181. package/src/client/hooks/editor/use-disk-digest.test.ts +82 -0
  182. package/src/client/hooks/editor/use-disk-digest.ts +164 -0
  183. package/src/client/hooks/editor/use-disk-sync.ts +212 -0
  184. package/src/client/hooks/editor/use-file-cache.ts +113 -0
  185. package/src/client/hooks/editor/use-file-editor.test.ts +90 -0
  186. package/src/client/hooks/editor/use-file-editor.ts +90 -52
  187. package/src/client/hooks/editor/use-file-read.ts +24 -10
  188. package/src/client/hooks/editor/use-file-writes.ts +4 -4
  189. package/src/client/hooks/models/harness-catalog.ts +15 -0
  190. package/src/client/hooks/settings/providers/actions.ts +3 -2
  191. package/src/client/hooks/settings/providers/messages.ts +9 -7
  192. package/src/client/hooks/settings/providers/model-actions.ts +2 -1
  193. package/src/client/hooks/ui/editor-error-toast.ts +2 -1
  194. package/src/client/hooks/ui/notifications.ts +17 -8
  195. package/src/client/hooks/workspace/batch-archive.test.ts +2 -2
  196. package/src/client/hooks/workspace/batch-archive.ts +4 -2
  197. package/src/client/hooks/workspace/git-action-outcome.ts +4 -3
  198. package/src/client/hooks/workspace/navbar-session-actions.ts +2 -1
  199. package/src/client/hooks/workspace/panel-registry.ts +1 -1
  200. package/src/client/hooks/workspace/scheduled-tasks.ts +26 -11
  201. package/src/client/hooks/workspace/session-actions.test.ts +2 -1
  202. package/src/client/hooks/workspace/session-actions.ts +2 -1
  203. package/src/client/hooks/workspace/terminal/connection.test.ts +63 -0
  204. package/src/client/hooks/workspace/terminal/connection.ts +47 -0
  205. package/src/client/hooks/workspace/terminal/index.ts +35 -4
  206. package/src/client/hooks/workspace/workspace-folder-actions.ts +2 -1
  207. package/src/client/lib/notifications/os.test.ts +1 -30
  208. package/src/client/lib/notifications/os.ts +0 -15
  209. package/src/client/lib/notifications/platform.test.ts +68 -0
  210. package/src/client/lib/notifications/platform.ts +36 -0
  211. package/src/server/index.ts +7 -0
  212. package/src/server/lib/harness/acp/client.ts +81 -87
  213. package/src/server/lib/harness/acp/prewarm.server.ts +237 -0
  214. package/src/server/lib/harness/acp/prewarm.test.ts +171 -0
  215. package/src/server/lib/harness/acp/prompt.test.ts +70 -1
  216. package/src/server/lib/harness/acp/prompt.ts +32 -1
  217. package/src/server/lib/harness/acp/protocol.ts +23 -0
  218. package/src/server/lib/harness/acp/session-handshake.test.ts +26 -0
  219. package/src/server/lib/harness/acp/session-handshake.ts +22 -20
  220. package/src/server/lib/harness/acp/session-options.ts +16 -0
  221. package/src/server/lib/harness/acp/session-process.ts +43 -0
  222. package/src/server/lib/harness/acp/session.ts +11 -12
  223. package/src/server/lib/harness/acp/stdio.ts +129 -0
  224. package/src/server/lib/harness/acp/verbs.test.ts +97 -0
  225. package/src/server/lib/harness/acp/verbs.ts +16 -6
  226. package/src/server/lib/harness/auto-probe.server.ts +4 -3
  227. package/src/server/lib/harness/capabilities.ts +8 -0
  228. package/src/server/lib/harness/config.server.ts +3 -2
  229. package/src/server/lib/harness/custom.server.ts +209 -0
  230. package/src/server/lib/harness/launch.ts +6 -1
  231. package/src/server/lib/harness/register.server.ts +8 -1
  232. package/src/server/lib/harness/schema.server.ts +21 -0
  233. package/src/server/lib/harness/session-lease.server.test.ts +99 -0
  234. package/src/server/lib/harness/session-lease.server.ts +193 -0
  235. package/src/server/lib/harness/session-store.server.test.ts +8 -8
  236. package/src/server/lib/harness/session-store.server.ts +25 -4
  237. package/src/server/lib/harness/session-title.server.ts +12 -2
  238. package/src/server/lib/harness/spawn.server.ts +123 -20
  239. package/src/server/lib/harness/update-queue.server.ts +3 -3
  240. package/src/server/lib/lifecycle/after-listen.ts +12 -1
  241. package/src/server/lib/lifecycle/paths.ts +19 -1
  242. package/src/server/lib/mcp/registry.server.ts +155 -0
  243. package/src/server/lib/mcp/registry.test.ts +169 -0
  244. package/src/server/lib/mcp/store.server.ts +38 -0
  245. package/src/server/lib/omp/rpc/frame-fold-contract.ts +59 -0
  246. package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +64 -1
  247. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +2 -1
  248. package/src/server/lib/omp/rpc/frame-fold.test.ts +2 -1
  249. package/src/server/lib/omp/rpc/frame-fold.ts +6 -45
  250. package/src/server/lib/omp/rpc/prewarm-pool.ts +19 -5
  251. package/src/server/lib/omp/rpc/run-model.test.ts +116 -0
  252. package/src/server/lib/omp/rpc/run-model.ts +4 -2
  253. package/src/server/lib/omp/session/sidebar-data.harness.test.ts +6 -3
  254. package/src/server/lib/omp/session/standby.server.ts +13 -2
  255. package/src/server/lib/panels/manifest.test.ts +47 -1
  256. package/src/server/lib/panels/manifest.ts +19 -0
  257. package/src/server/lib/panels/registry.server.ts +19 -2
  258. package/src/server/lib/panels/scan.server.ts +26 -2
  259. package/src/server/lib/panels/settings-schema.server.ts +72 -0
  260. package/src/server/lib/plugins/background.server.ts +21 -3
  261. package/src/server/lib/plugins/background.test.ts +13 -0
  262. package/src/server/lib/plugins/loader.server.ts +35 -51
  263. package/src/server/lib/plugins/mcp.server.ts +100 -0
  264. package/src/server/lib/plugins/mcp.test.ts +75 -0
  265. package/src/server/lib/plugins/schedule-runner.server.ts +153 -0
  266. package/src/server/lib/plugins/schedule-runner.test.ts +186 -0
  267. package/src/server/lib/plugins/schedule-store.server.ts +107 -0
  268. package/src/server/lib/plugins/schema.server.ts +8 -0
  269. package/src/server/lib/plugins/settings.server.ts +56 -19
  270. package/src/server/lib/plugins/shutdown.server.ts +58 -0
  271. package/src/server/lib/plugins/shutdown.test.ts +28 -3
  272. package/src/server/lib/realtime/topics/global.server.ts +5 -1
  273. package/src/server/lib/schedule/rows.server.ts +9 -0
  274. package/src/server/lib/schedule/runtime.server.test.ts +91 -0
  275. package/src/server/lib/schedule/runtime.server.ts +101 -23
  276. package/src/server/lib/schedule/schema.server.ts +15 -0
  277. package/src/server/lib/schedule/store.server.test.ts +34 -0
  278. package/src/server/lib/schedule/store.server.ts +33 -9
  279. package/src/server/lib/sessions/fork.server.test.ts +47 -0
  280. package/src/server/lib/sessions/fork.server.ts +17 -1
  281. package/src/server/lib/sessions/spawn.server.ts +2 -2
  282. package/src/server/lib/usage/report.server.ts +57 -0
  283. package/src/server/lib/waiting/runtime.server.test.ts +48 -0
  284. package/src/server/lib/waiting/runtime.server.ts +22 -0
  285. package/src/server/lib/waiting/schema.server.ts +8 -0
  286. package/src/server/lib/waiting/store.server.test.ts +14 -0
  287. package/src/server/lib/waiting/store.server.ts +6 -2
  288. package/src/server/routes/agent/command-resume.test.ts +9 -4
  289. package/src/server/routes/agent/new-mode.test.ts +40 -0
  290. package/src/server/routes/agent/new.ts +31 -10
  291. package/src/server/routes/agent/prewarm.ts +48 -7
  292. package/src/server/routes/fs/action.ts +9 -1
  293. package/src/server/routes/fs/digest.test.ts +100 -0
  294. package/src/server/routes/fs/digest.ts +106 -0
  295. package/src/server/routes/fs/index.ts +2 -0
  296. package/src/server/routes/fs/read.ts +6 -1
  297. package/src/server/routes/harness/custom.test.ts +131 -0
  298. package/src/server/routes/harness/import-action.ts +2 -2
  299. package/src/server/routes/harness/root.ts +41 -8
  300. package/src/server/routes/harness/update.ts +2 -2
  301. package/src/server/routes/panels/bindings.ts +2 -0
  302. package/src/server/routes/panels/settings.test.ts +165 -0
  303. package/src/server/routes/panels/settings.ts +106 -0
  304. package/src/server/routes/schedule/body.ts +14 -0
  305. package/src/server/routes/schedule/index.ts +28 -4
  306. package/src/server/routes/settings/mcp.ts +9 -26
  307. package/src/server/routes/waiting/index.ts +21 -2
  308. package/src/server/routes/waiting/routes.test.ts +21 -0
  309. package/src/shared/lib/chat/composer/delegation.ts +3 -3
  310. package/src/shared/lib/chat/timeline/fork-anchor.test.ts +97 -0
  311. package/src/shared/lib/chat/timeline/fork-anchor.ts +47 -0
  312. package/src/shared/lib/chat/timeline/fork-preview.test.ts +62 -0
  313. package/src/shared/lib/chat/timeline/fork-preview.ts +36 -0
  314. package/src/shared/lib/fs/content-hash.ts +29 -0
  315. package/src/shared/lib/harness/catalog.ts +48 -6
  316. package/src/shared/lib/harness/fork.ts +60 -0
  317. package/src/shared/lib/harness/mcp-facts.test.ts +30 -0
  318. package/src/shared/lib/harness/mcp-facts.ts +65 -0
  319. package/src/shared/lib/harness/menu.test.ts +16 -1
  320. package/src/shared/lib/harness/menu.ts +2 -2
  321. package/src/shared/lib/harness/rewind.ts +6 -6
  322. package/src/shared/lib/harness/session-modes.ts +31 -0
  323. package/src/shared/lib/harness/transcript.test.ts +29 -0
  324. package/src/shared/lib/harness/transcript.ts +19 -0
  325. package/src/shared/lib/notifications/settings.test.ts +21 -0
  326. package/src/shared/lib/notifications/settings.ts +24 -0
  327. package/src/shared/lib/omp/session/prewarm.test.ts +28 -4
  328. package/src/shared/lib/omp/session/prewarm.ts +25 -6
  329. package/src/shared/lib/omp/session/stream-state.server.test.ts +25 -0
  330. package/src/shared/lib/omp/session/stream-state.server.ts +8 -4
  331. package/src/shared/lib/panels/capabilities.test.ts +1 -1
  332. package/src/shared/lib/panels/capabilities.ts +3 -0
  333. package/src/shared/lib/plugins/settings.ts +22 -0
  334. package/src/shared/lib/schedule/parse.test.ts +48 -0
  335. package/src/shared/lib/schedule/parse.ts +69 -45
  336. package/src/shared/lib/schedule/timezone.ts +128 -0
  337. package/src/shared/lib/settings/defaults.ts +2 -0
  338. package/src/shared/lib/ui/toast-duration.test.ts +25 -1
  339. package/src/shared/lib/ui/toast-duration.ts +22 -4
  340. package/src/shared/lib/workspace/refresh-cadence.test.ts +25 -1
  341. package/src/shared/lib/workspace/relative-time.ts +16 -0
  342. package/src/shared/lib/workspace/session-state/store.ts +4 -0
  343. package/src/shared/types/harness.ts +7 -0
  344. package/src/shared/types/omp/agent.ts +6 -0
  345. package/src/shared/types/panels-registry.ts +3 -3
  346. package/src/shared/types/panels.ts +4 -2
  347. package/src/shared/types/schedule.ts +13 -0
  348. package/src/shared/types/settings/state.ts +12 -1
  349. package/src/shared/types/waiting.ts +9 -0
  350. package/src/test-support/file-editor.test-util.ts +70 -5
  351. package/dist/client/static/js/index-p2yw9ywf.css +0 -1
  352. package/src/client/hooks/editor/use-external-change-notice.ts +0 -71
  353. package/src/client/hooks/editor/use-external-change.test.ts +0 -88
  354. package/src/client/hooks/editor/use-external-change.ts +0 -146
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Provider-aware grouping for the generic quota section.
8
+ *
9
+ * omp reports every provider's windows as one flat list, but three of them are
10
+ * not one list:
11
+ *
12
+ * - Anthropic mixes plan windows (5h, 7d, per-tier 7d) with a USD spend limit
13
+ * (`anthropic:extra`). Drawing the spend limit as a fourth quota window made
14
+ * it look like another reset window instead of "what happens after the
15
+ * windows run out".
16
+ * - Antigravity emits one entry per model family AND per window, so a Google
17
+ * bucket and the shared Claude/GPT bucket sat in one grid with no boundary;
18
+ * the rows even repeat the family in their label because there was nowhere
19
+ * else to put it.
20
+ * - Every other provider is one list, and stays one list.
21
+ *
22
+ * The grouping is a pure function of (provider slug, limit id) so it can be
23
+ * unit-tested without mounting the panel. Group order is first-seen order and
24
+ * rows keep omp's own order inside a group (omp sorts by remaining fraction).
25
+ */
26
+
27
+ import type { UsageLimitWindow } from '@/shared/types';
28
+
29
+ export interface LimitGroup {
30
+ /** Stable key inside one provider's section: `windows`, `balance`, `google`, … */
31
+ id: string;
32
+ /** The group's own heading; the panel draws one heading per group. */
33
+ title: string;
34
+ limits: UsageLimitWindow[];
35
+ }
36
+
37
+ const CLAUDE_EXTRA_ID = 'anthropic:extra';
38
+ const QUOTA_TITLE = 'Quota windows';
39
+
40
+ /** Push a row into the group named `id`, creating it on first use. */
41
+ function push(
42
+ groups: LimitGroup[],
43
+ id: string,
44
+ title: string,
45
+ limit: UsageLimitWindow,
46
+ ): void {
47
+ const existing = groups.find((group) => group.id === id);
48
+ if (existing) {
49
+ existing.limits.push(limit);
50
+ return;
51
+ }
52
+ groups.push({ id, title, limits: [limit] });
53
+ }
54
+
55
+ /**
56
+ * The model family Antigravity put in the second segment of the limit id:
57
+ * `${provider}:${counterKey}:${tier}:${windowId}`. `anthropic` and `openai`
58
+ * share one upstream bucket, which omp labels "Claude & GPT (shared)".
59
+ */
60
+ function antigravityBucket(id: string): { id: string; title: string } {
61
+ const counter = (id.split(':')[1] ?? '').toLowerCase();
62
+ if (counter === 'google') return { id: 'google', title: 'Google' };
63
+ if (counter === 'anthropic' || counter === 'openai') {
64
+ return { id: 'third-party', title: 'Claude & GPT (shared)' };
65
+ }
66
+ if (counter === 'default' || counter === '') return { id: 'default', title: 'Usage' };
67
+ // An unknown counter still has to be visible; naming it beats dropping it.
68
+ return { id: counter, title: counter };
69
+ }
70
+
71
+ /** Split Claude's plan windows from its USD spend limit. */
72
+ function groupClaude(limits: UsageLimitWindow[]): LimitGroup[] {
73
+ const groups: LimitGroup[] = [];
74
+ for (const limit of limits) {
75
+ if (limit.id === CLAUDE_EXTRA_ID) push(groups, 'balance', 'Balance', limit);
76
+ else push(groups, 'windows', QUOTA_TITLE, limit);
77
+ }
78
+ return groups;
79
+ }
80
+
81
+ /** Group Antigravity's rows by model family, merging the shared third-party bucket. */
82
+ function groupAntigravity(limits: UsageLimitWindow[]): LimitGroup[] {
83
+ const groups: LimitGroup[] = [];
84
+ for (const limit of limits) {
85
+ const bucket = antigravityBucket(limit.id);
86
+ // The quota-summary response emits the SAME shared bucket once for
87
+ // `anthropic:` and once for `openai:` — identical label, amount and reset,
88
+ // only the id differs. Rendering both would show the same number twice under
89
+ // one heading; the first row is the whole fact.
90
+ if (bucket.id === 'third-party') {
91
+ const shared = groups.find((group) => group.id === 'third-party');
92
+ if (shared?.limits.some((row) => isSameReading(row, limit))) continue;
93
+ }
94
+ push(groups, bucket.id, bucket.title, limit);
95
+ }
96
+ return groups;
97
+ }
98
+
99
+ /** Whether two rows describe the same reading of the same bucket. */
100
+ function isSameReading(a: UsageLimitWindow, b: UsageLimitWindow): boolean {
101
+ return a.unit === b.unit
102
+ && a.label === b.label
103
+ && a.usedFraction === b.usedFraction
104
+ && a.remaining === b.remaining
105
+ && a.resetsAt === b.resetsAt;
106
+ }
107
+
108
+ /**
109
+ * The panel's sections for one provider: one group for an ordinary provider,
110
+ * two for Claude (windows + balance), and one per model family for Antigravity.
111
+ */
112
+ export function groupProviderLimits(providerId: string, limits: UsageLimitWindow[]): LimitGroup[] {
113
+ if (limits.length === 0) return [];
114
+ const slug = providerId.trim().toLowerCase();
115
+ if (slug === 'anthropic') return groupClaude(limits);
116
+ if (slug === 'google-antigravity') return groupAntigravity(limits);
117
+ return [{ id: 'all', title: QUOTA_TITLE, limits: [...limits] }];
118
+ }
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The quota section's two new shapes are asserted on the DOM, not on the
8
+ * grouping helper alone: a correct group list wired to the wrong prop renders
9
+ * one flat "Quota windows" grid, which is exactly the regression this covers.
10
+ */
11
+
12
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
13
+ import { Window } from 'happy-dom';
14
+ import { render } from 'preact';
15
+ import { act } from 'preact/test-utils';
16
+ import { LimitsSection } from '@/client/components/settings/categories/usage-settings/LimitsSection';
17
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
18
+ import type { UsageLimitWindow } from '@/shared/types';
19
+
20
+ let container: HTMLElement;
21
+
22
+ const limit = (id: string, overrides: Partial<UsageLimitWindow> = {}): UsageLimitWindow => ({
23
+ id,
24
+ label: id,
25
+ unit: 'percent',
26
+ status: 'ok',
27
+ ...overrides,
28
+ });
29
+
30
+ function mount(node: preact.ComponentChild): HTMLElement {
31
+ act(() => render(node, container));
32
+ return container;
33
+ }
34
+
35
+ function headings(dom: HTMLElement): string[] {
36
+ return [...dom.querySelectorAll('h4')].map((heading) => heading.textContent ?? '');
37
+ }
38
+
39
+ beforeEach(() => {
40
+ installDomGlobals(new Window());
41
+ container = document.createElement('div');
42
+ document.body.appendChild(container);
43
+ });
44
+
45
+ afterEach(() => {
46
+ act(() => render(null, container));
47
+ container.remove();
48
+ restoreDomGlobals();
49
+ });
50
+
51
+ describe('LimitsSection sections', () => {
52
+ test('Claude draws plan windows and its spend balance as separate sections', () => {
53
+ const dom = mount(
54
+ <LimitsSection
55
+ providerId="anthropic"
56
+ tracked
57
+ limits={[
58
+ limit('anthropic:5h', { label: 'Claude 5 Hour', usedFraction: 0.42 }),
59
+ limit('anthropic:extra', {
60
+ label: 'Claude Extra Usage',
61
+ unit: 'usd',
62
+ used: 4.2,
63
+ limit: 25,
64
+ remaining: 20.8,
65
+ usedFraction: 0.168,
66
+ }),
67
+ ]}
68
+ />,
69
+ );
70
+ expect(headings(dom)).toEqual(['Quota windows', 'Balance']);
71
+ expect(dom.textContent).toContain('Claude Extra Usage');
72
+ expect(dom.textContent).toContain('$4,20');
73
+ expect(dom.textContent).toContain('$20,80');
74
+ });
75
+
76
+ test('Antigravity draws one heading per model family and merges the shared bucket', () => {
77
+ const dom = mount(
78
+ <LimitsSection
79
+ providerId="google-antigravity"
80
+ tracked
81
+ limits={[
82
+ limit('google-antigravity:google:default:weekly', {
83
+ label: 'Gemini',
84
+ windowLabel: 'weekly',
85
+ usedFraction: 0.42,
86
+ }),
87
+ limit('google-antigravity:anthropic:default:5h', {
88
+ label: 'Claude & GPT (shared)',
89
+ usedFraction: 0.71,
90
+ }),
91
+ limit('google-antigravity:openai:default:5h', {
92
+ label: 'Claude & GPT (shared)',
93
+ usedFraction: 0.13,
94
+ }),
95
+ ]}
96
+ />,
97
+ );
98
+ expect(headings(dom)).toEqual(['Google', 'Claude & GPT (shared)']);
99
+ expect(dom.textContent).toContain('Gemini');
100
+ expect(dom.textContent).toContain('weekly');
101
+ // Two rows, one 5h row per third-party family, under ONE heading.
102
+ expect(dom.querySelectorAll('h4')).toHaveLength(2);
103
+ expect(dom.textContent?.match(/Claude & GPT \(shared\)/g)).toHaveLength(3);
104
+ });
105
+
106
+ test('an ordinary provider keeps the single Quota windows section', () => {
107
+ const dom = mount(
108
+ <LimitsSection providerId="openrouter" tracked limits={[limit('openrouter:credits', { unit: 'usd' })]} />,
109
+ );
110
+ expect(headings(dom)).toEqual(['Quota windows']);
111
+ });
112
+
113
+ test('an untracked provider with no rows keeps its explanation', () => {
114
+ const dom = mount(<LimitsSection providerId="kenari" tracked={false} limits={[]} />);
115
+ expect(headings(dom)).toEqual(['Quota windows']);
116
+ expect(dom.textContent).toContain('No quota source for this provider');
117
+ });
118
+ });
@@ -91,4 +91,28 @@ describe('assistant footer fork', () => {
91
91
  const el = mount(h(RunFooter, { msg: answerRow, retryTargetId: 'user-3' }));
92
92
  expect(el.querySelector('button[aria-label="Fork session from this answer"]')).toBeNull();
93
93
  });
94
+
95
+ test('an AIR adapter offers Fork on the answer', () => {
96
+ for (const harness of ['claude', 'codex']) {
97
+ const el = mount(h(RunFooter, {
98
+ msg: answerRow,
99
+ retryTargetId: 'user-3',
100
+ harness,
101
+ onFork: () => {},
102
+ }));
103
+ expect(el.querySelector('button[aria-label="Fork session from this answer"]')).not.toBeNull();
104
+ }
105
+ });
106
+
107
+ test('a harness that can only fork the whole chat draws no Fork action', () => {
108
+ for (const harness of ['zcode', 'opencode', 'dsh']) {
109
+ const el = mount(h(RunFooter, {
110
+ msg: answerRow,
111
+ retryTargetId: 'user-3',
112
+ harness,
113
+ onFork: () => {},
114
+ }));
115
+ expect(el.querySelector('button[aria-label="Fork session from this answer"]')).toBeNull();
116
+ }
117
+ });
94
118
  });
@@ -7,6 +7,7 @@ import { PluginMessageActions } from '@/client/components/workspace/chat-timelin
7
7
  import { formatDuration } from '@/shared/lib/chat/duration';
8
8
  import { providerLabel } from '@/shared/lib/models/provider/label';
9
9
  import { formatCompactTokens } from '@/shared/lib/format/number';
10
+ import { canForkAt, type ForkAnchorRole } from '@/shared/lib/chat/timeline/fork-anchor';
10
11
 
11
12
  interface AiMessageFooterProps {
12
13
  provider?: string;
@@ -40,7 +41,7 @@ interface AiMessageFooterProps {
40
41
  * keeps the answer.
41
42
  */
42
43
  forkTargetId?: string;
43
- onFork?: (msgId: string) => void;
44
+ onFork?: (msgId: string, role: ForkAnchorRole) => void;
44
45
  isMobile?: boolean;
45
46
  /**
46
47
  * Whether the row offers Retry / Fork / New-chat. All of them act on the
@@ -70,6 +71,9 @@ export function AiMessageFooter({
70
71
  showActions = true,
71
72
  }: AiMessageFooterProps) {
72
73
  const [isMenuOpen, setIsMenuOpen] = useState(false);
74
+ // A harness that cannot fork at an assistant row draws no Fork action: the
75
+ // button would only ever answer "whole chat", which is the dropdown's job.
76
+ const canFork = Boolean(onFork && forkTargetId) && canForkAt(harness, 'assistant');
73
77
 
74
78
  const handleRetry = () => {
75
79
  setIsMenuOpen(false);
@@ -83,7 +87,7 @@ export function AiMessageFooter({
83
87
 
84
88
  const handleFork = () => {
85
89
  setIsMenuOpen(false);
86
- if (forkTargetId) onFork?.(forkTargetId);
90
+ if (forkTargetId) onFork?.(forkTargetId, 'assistant');
87
91
  };
88
92
 
89
93
  useEffect(() => {
@@ -236,7 +240,7 @@ export function AiMessageFooter({
236
240
  <RotateCcw size={20} className="shrink-0 text-ink/55" />
237
241
  <span>Retry response</span>
238
242
  </button>
239
- {onFork && forkTargetId && (
243
+ {canFork && (
240
244
  <button type="button" aria-label="Fork session from this answer" onClick={handleFork} className="flex min-h-12 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-ink transition-colors hover:bg-ink/5 cursor-pointer">
241
245
  <GitFork size={20} className="shrink-0 text-ink/55" />
242
246
  <span>Fork from this answer</span>
@@ -288,7 +292,7 @@ export function AiMessageFooter({
288
292
  ariaLabel="Copy response"
289
293
  emptyTitle="Nothing to copy — this run produced no text"
290
294
  />
291
- {showActions && onFork && forkTargetId && (
295
+ {showActions && canFork && (
292
296
  <button type="button" className="flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer" title="Fork from here" aria-label="Fork session from this answer" onClick={handleFork}>
293
297
  <GitFork size={12} />
294
298
  </button>
@@ -8,7 +8,9 @@ import { QueueList } from '@/client/components/workspace/chat-timeline/QueueList
8
8
  import type { Attachment, QueuedMessage } from '@/shared/types';
9
9
  import type { ApprovalMode } from '@/shared/lib/omp/config/access-mode';
10
10
  import type { ComposerModes } from '@/client/components/workspace/chat-timeline/chat-input/modes-props';
11
+ import type { WaitingCandidate } from '@/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker';
11
12
  import { PluginComposerBanners } from '@/client/components/workspace/chat-timeline/chat-input/PluginComposerSlots';
13
+ import { Hourglass } from 'lucide-preact';
12
14
 
13
15
  interface ComposerDockProps {
14
16
  isMobile: boolean;
@@ -71,6 +73,15 @@ interface ComposerDockProps {
71
73
  * switching needs a new chat rather than changing the transport silently. */
72
74
  harnessEditable?: boolean;
73
75
  onSelectHarness?: (harness: string) => void;
76
+ /** "Wait for session" for the next prompt, mounted in the toolbar. */
77
+ waiting?: {
78
+ value: WaitingCandidate | null;
79
+ candidates: WaitingCandidate[];
80
+ onChange: (candidate: WaitingCandidate | null) => void;
81
+ };
82
+ /** A held prompt for THIS chat: the composer waits until it is released. */
83
+ heldWait?: { title: string | null } | null;
84
+ onCancelWait?: () => void;
74
85
  }
75
86
 
76
87
  /**
@@ -115,6 +126,9 @@ export function ComposerDock({
115
126
  harness,
116
127
  harnessEditable = true,
117
128
  onSelectHarness,
129
+ waiting,
130
+ heldWait = null,
131
+ onCancelWait,
118
132
  }: ComposerDockProps) {
119
133
  // Side questions take over the composer entirely: the chat's own input is
120
134
  // hidden while the form is open, so a stray Enter cannot send to the wrong
@@ -136,6 +150,24 @@ export function ComposerDock({
136
150
  {...(harness ? { harness } : {})}
137
151
  />
138
152
  )}
153
+ {heldWait && (
154
+ <div className="mb-2 flex items-center gap-2 rounded-lg border border-ink/15 bg-ink/[0.03] px-3 py-2 text-xs text-ink/70">
155
+ <Hourglass size={12} className="shrink-0 animate-pulse text-ink/60" />
156
+ <span className="min-w-0 flex-1 truncate">
157
+ Waiting for {heldWait.title ?? 'another session'} to finish before this prompt is sent.
158
+ </span>
159
+ {onCancelWait && (
160
+ <button
161
+ type="button"
162
+ data-testid="cancel-held-prompt"
163
+ onClick={onCancelWait}
164
+ className="shrink-0 rounded border border-ink/20 px-2 py-0.5 text-[11px] text-ink/70 hover:bg-ink/5 hover:text-ink cursor-pointer"
165
+ >
166
+ Cancel
167
+ </button>
168
+ )}
169
+ </div>
170
+ )}
139
171
  <QueueList
140
172
  queue={messageQueue}
141
173
  onRemove={onRemoveQueueItem}
@@ -164,6 +196,7 @@ export function ComposerDock({
164
196
  onAttachmentsChange={setAttachments}
165
197
  onSend={onSend}
166
198
  isGenerating={isGenerating}
199
+ disabled={Boolean(heldWait)}
167
200
  chatRunning={showGeneratingIndicator}
168
201
  onStop={onStop}
169
202
  appSettings={appSettings}
@@ -174,6 +207,7 @@ export function ComposerDock({
174
207
  modes={modes}
175
208
  composerModelRef={composerModelRef}
176
209
  deferredComposerPickRef={deferredComposerPickRef}
210
+ {...(waiting ? { waiting } : {})}
177
211
  sessionModel={sessionModel}
178
212
  sessionThinkingLevel={sessionThinkingLevel}
179
213
  harness={harness}
@@ -1,13 +1,10 @@
1
1
  import type { SetStateAction } from 'preact/compat';
2
- import { Fragment } from 'preact';
3
2
  import { useEffect, useMemo, useRef } from 'preact/hooks';
4
3
  import type { Attachment, ChatMessageData, WorkspaceFolderData } from '@/shared/types';
5
4
  import { ChatInput } from '@/client/components/workspace/chat-timeline/chat-input/index';
6
- import { ChatMessageItem } from '@/client/components/workspace/chat-timeline/MessageItem';
7
- import { RunFooter } from '@/client/components/workspace/chat-timeline/RunFooter';
5
+ import { PendingTranscript } from '@/client/components/workspace/chat-timeline/PendingTranscript';
8
6
  import { ComposerDockFrame } from '@/client/components/workspace/chat-timeline/ComposerDockFrame';
9
7
  import { GeneratingIndicator } from '@/client/components/workspace/chat-timeline/GeneratingIndicator';
10
- import { resolveRunFooters, streamingRowIndex } from '@/shared/lib/chat/timeline/run-footer';
11
8
  import type { ApprovalMode } from '@/shared/lib/omp/config/access-mode';
12
9
  import {
13
10
  waitingCandidates,
@@ -15,7 +12,10 @@ import {
15
12
  } from '@/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker';
16
13
  import { Hourglass } from 'lucide-preact';
17
14
  import { DraftTargetRow } from '@/client/components/workspace/chat-timeline/target-picker/DraftTargetRow';
15
+ import { ParentSessionPicker } from '@/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker';
18
16
  import type { SpawnTarget } from '@/client/hooks/chat/timeline/spawn-target';
17
+ import type { ForkPreview } from '@/client/hooks/chat/timeline/fork-preview';
18
+ import type { ToastTone } from '@/shared/lib/ui/toast-duration';
19
19
 
20
20
  interface EmptyWorkspacePromptProps {
21
21
  className?: string;
@@ -78,8 +78,17 @@ interface EmptyWorkspacePromptProps {
78
78
  /** "Parent session" for a child, "Fork from" for a fork. */
79
79
  branchLabel?: string;
80
80
  branchAllowNone?: boolean;
81
+ /**
82
+ * The source transcript this FORK will carry.
83
+ *
84
+ * Present only for a fork that has not been created yet (the branch is built
85
+ * on the first send), so it both draws the history above the composer and
86
+ * marks the view as docked — which is what keeps the branch picker reachable
87
+ * while switching "Fork from".
88
+ */
89
+ branchPreview?: ForkPreview | null;
81
90
  /** Reports a worktree the composer created or failed to create. */
82
- onWorktreeReport?: (message: string) => void;
91
+ onWorktreeReport?: (message: string, tone?: ToastTone) => void;
83
92
  /** The "wait for session" pick, persisted per chat. */
84
93
  waitingFor?: WaitingCandidate | null;
85
94
  onWaitingForChange?: (candidate: WaitingCandidate | null) => void;
@@ -134,6 +143,7 @@ export function EmptyWorkspacePrompt({
134
143
  onParentSessionChange,
135
144
  branchLabel,
136
145
  branchAllowNone,
146
+ branchPreview = null,
137
147
  onWorktreeReport,
138
148
  waitingFor = null,
139
149
  onWaitingForChange,
@@ -152,21 +162,16 @@ export function EmptyWorkspacePrompt({
152
162
  [folders, streamStatusMap, titleForSession],
153
163
  );
154
164
 
155
- // Run footers are boundary rows: emitted after the run's last row, so a
156
- // trailing notice never separates the footer from the next user message.
157
- const { streamingIdx, footers } = useMemo(
158
- () => ({
159
- streamingIdx: streamingRowIndex(messages),
160
- footers: resolveRunFooters(messages, isGenerating),
161
- }),
162
- [messages, isGenerating],
163
- );
165
+ // The rows the fork will carry, above the composer. A fork is composed on an
166
+ // empty `new-…` chat, so without this the operator chose the branch's first
167
+ // turn with none of the history it continues in sight.
168
+ const previewLength = branchPreview?.messages.length ?? 0;
164
169
 
165
170
  useEffect(() => {
166
171
  if (timelineRef.current) {
167
172
  timelineRef.current.scrollTop = timelineRef.current.scrollHeight;
168
173
  }
169
- }, [messages.length]);
174
+ }, [messages.length, previewLength]);
170
175
 
171
176
  const isMobile = variant === 'mobile';
172
177
  // A chat with rows to show (or a prompt in flight) draws the SAME dock the
@@ -176,7 +181,11 @@ export function EmptyWorkspacePrompt({
176
181
  // pane's bottom) than once the run streamed in the real timeline
177
182
  // (`Thinking…`, 113px). The row jumped at the moment the chat was adopted,
178
183
  // which read as two different indicators.
179
- const docked = messages.length > 0 || isGenerating;
184
+ //
185
+ // A fork's preview docks from the FIRST frame, with or without rows: the
186
+ // "Fork from" picker must stay reachable while the source is being changed,
187
+ // and it lives in the docked branch.
188
+ const docked = messages.length > 0 || isGenerating || Boolean(branchPreview);
180
189
 
181
190
  const heldPrompt = heldWait ? (
182
191
  <div className="flex items-center gap-2 rounded-lg border border-ink/15 bg-ink/[0.03] px-3 py-2 text-xs text-ink/70">
@@ -218,14 +227,18 @@ export function EmptyWorkspacePrompt({
218
227
  modes={modes}
219
228
  composerModelRef={composerModelRef}
220
229
  deferredComposerPickRef={deferredComposerPickRef}
230
+ {...(onWaitingForChange && docked
231
+ ? { waiting: { value: waitingFor ?? null, candidates, onChange: onWaitingForChange } }
232
+ : {})}
221
233
  {...(harness ? { harness } : {})}
222
234
  harnessEditable={harnessEditable}
223
235
  {...(onSelectHarness ? { onSelectHarness } : {})}
224
236
  variant={variant}
225
237
  expandable
226
238
  // A brand-new chat has no turns: the `stage` composer style draws its
227
- // wider, taller card here and nowhere else.
228
- hero={messages.length === 0}
239
+ // wider, taller card here and nowhere else. A fork's preview is history,
240
+ // so its composer docks like any chat that already has rows.
241
+ hero={messages.length === 0 && previewLength === 0}
229
242
  />
230
243
  );
231
244
 
@@ -236,6 +249,21 @@ export function EmptyWorkspacePrompt({
236
249
  >
237
250
  {docked ? (
238
251
  <>
252
+ {/* A fork is composed, not created: the source it branches from is
253
+ still switchable, so its picker stays above the transcript the
254
+ preview draws. Every other pending chat loses the row once docked
255
+ because its first send already dispatched the spawn. */}
256
+ {branchPreview && onParentSessionChange && (
257
+ <div className={`shrink-0 flex items-center gap-1 flex-wrap ${isMobile ? 'pl-4 pr-3 pt-3' : 'px-4 pt-3'}`}>
258
+ <ParentSessionPicker
259
+ folders={folders as WorkspaceFolderData[]}
260
+ value={parentSessionId}
261
+ onChange={onParentSessionChange}
262
+ label={branchLabel ?? 'Fork from'}
263
+ allowNone={branchAllowNone ?? false}
264
+ />
265
+ </div>
266
+ )}
239
267
  {/* The pending transcript reserves the box the real timeline's own
240
268
  scroller does (`TimelineBody`), so adoption moves no text either. */}
241
269
  <div
@@ -244,42 +272,21 @@ export function EmptyWorkspacePrompt({
244
272
  isMobile ? 'pl-4 pr-3 py-3 pb-8' : 'p-4 pb-10'
245
273
  }`}
246
274
  >
247
- <div className="chat-column">
248
- {messages.map((msg, idx) => {
249
- const prev = messages[idx - 1];
250
- const isLoading = isGenerating && idx === streamingIdx && msg.role === 'ai';
251
- const isAiFragment = msg.role !== 'user' && prev && prev.role !== 'user';
252
- const footer = footers[idx];
253
- return (
254
- <Fragment key={msg.id}>
255
- <ChatMessageItem
256
- msg={msg}
257
- isStreaming={isLoading}
258
- onUndo={onUndo}
259
- onNewChat={onNewChat}
260
- isMobile={isMobile}
261
- className={isAiFragment ? 'mt-1' : 'mt-8'}
262
- />
263
- {footer && (
264
- <RunFooter
265
- msg={footer.msg}
266
- provider={provider}
267
- providerNames={providerNames}
268
- modelName={modelName}
269
- modelNames={modelNames}
270
- thinkingLevel={sessionThinkingLevel ?? undefined}
271
- {...(harness ? { harness } : {})}
272
- durationMs={footer.durationMs}
273
- answerText={footer.answerText}
274
- retryTargetId={footer.runUserId}
275
- onRetry={onRetry}
276
- onNewChat={onNewChat}
277
- />
278
- )}
279
- </Fragment>
280
- );
281
- })}
282
- </div>
275
+ <PendingTranscript
276
+ messages={messages}
277
+ preview={branchPreview}
278
+ isGenerating={isGenerating}
279
+ isMobile={isMobile}
280
+ {...(provider ? { provider } : {})}
281
+ {...(providerNames ? { providerNames } : {})}
282
+ {...(modelName ? { modelName } : {})}
283
+ {...(modelNames ? { modelNames } : {})}
284
+ sessionThinkingLevel={sessionThinkingLevel}
285
+ {...(harness ? { harness } : {})}
286
+ {...(onUndo ? { onUndo } : {})}
287
+ {...(onRetry ? { onRetry } : {})}
288
+ {...(onNewChat ? { onNewChat } : {})}
289
+ />
283
290
  </div>
284
291
 
285
292
  {/* One frame with the real dock (`ComposerDock`), so the indicator and
@@ -316,8 +323,6 @@ export function EmptyWorkspacePrompt({
316
323
  branchAllowNone={branchAllowNone}
317
324
  waitingFor={waitingFor}
318
325
  onWaitingForChange={onWaitingForChange}
319
- streamStatusMap={streamStatusMap}
320
- titleForSession={titleForSession}
321
326
  candidates={candidates}
322
327
  />
323
328
  {/* A held prompt owns this chat until it is released: there is no
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The user row's Fork action is drawn only where the harness can fork at a
8
+ * user turn. omp cuts its own JSONL at any turn; the AIR adapters (claude,
9
+ * codex) only take an assistant message; every other agent forks the whole
10
+ * chat, which is the "Fork from" picker's job, not a per-row button.
11
+ */
12
+
13
+ import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
14
+ import { Window } from 'happy-dom';
15
+ import { h, render } from 'preact';
16
+ import { act } from 'preact/test-utils';
17
+ import { ChatMessageItem } from '@/client/components/workspace/chat-timeline/MessageItem';
18
+ import { SessionStateProvider } from '@/client/components/common/session-state-provider';
19
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
20
+ import type { ChatMessageData } from '@/shared/types';
21
+
22
+ let container: HTMLElement;
23
+
24
+ beforeEach(() => {
25
+ installDomGlobals(new Window({ url: 'http://localhost' }));
26
+ container = document.body.appendChild(document.createElement('div'));
27
+ });
28
+
29
+ afterEach(() => {
30
+ render(null, container);
31
+ container.remove();
32
+ });
33
+
34
+ afterAll(() => restoreDomGlobals());
35
+
36
+ const userRow: ChatMessageData = { id: 'u1', role: 'user', content: 'hello' };
37
+
38
+ function mount(harness?: string): { el: HTMLElement; calls: Array<[string, string]> } {
39
+ const calls: Array<[string, string]> = [];
40
+ act(() => {
41
+ render(
42
+ h(SessionStateProvider, {
43
+ sessionId: 'fork-test',
44
+ children: h(ChatMessageItem, {
45
+ msg: userRow,
46
+ onFork: (id, role) => calls.push([id, role]),
47
+ ...(harness ? { harness } : {}),
48
+ }),
49
+ }),
50
+ container,
51
+ );
52
+ });
53
+ return { el: container, calls };
54
+ }
55
+
56
+ const FORK = 'button[aria-label="Fork this session from this message"]';
57
+
58
+ describe('user row fork visibility', () => {
59
+ test('omp offers Fork on a user turn and anchors at that row', () => {
60
+ const { el, calls } = mount('omp-rpc');
61
+ const fork = el.querySelector(FORK) as HTMLButtonElement | null;
62
+ expect(fork).not.toBeNull();
63
+ act(() => fork!.click());
64
+ expect(calls).toEqual([['u1', 'user']]);
65
+ });
66
+
67
+ test('an AIR adapter has no fork point on a user turn', () => {
68
+ expect(mount('claude').el.querySelector(FORK)).toBeNull();
69
+ expect(mount('codex').el.querySelector(FORK)).toBeNull();
70
+ });
71
+
72
+ test('a harness that can only fork the whole chat draws no per-row Fork', () => {
73
+ expect(mount('zcode').el.querySelector(FORK)).toBeNull();
74
+ expect(mount('opencode').el.querySelector(FORK)).toBeNull();
75
+ });
76
+
77
+ test('an unresolved harness keeps the historical button', () => {
78
+ expect(mount().el.querySelector(FORK)).not.toBeNull();
79
+ });
80
+ });