@kabmo-labs/kabmo 0.24.0 → 0.26.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 (325) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +585 -512
  3. package/dist/client/static/js/{index-jcr5twtp.js → index-95b3n20k.js} +1105 -1207
  4. package/dist/client/static/js/index-p2yw9ywf.css +1 -0
  5. package/package.json +2 -4
  6. package/src/cli/lib/args.js +24 -1
  7. package/src/cli/lib/args.test.js +16 -0
  8. package/src/cli/lib/commands/session.js +233 -0
  9. package/src/cli/lib/commands/session.test.js +103 -0
  10. package/src/cli/main.js +1 -1
  11. package/src/client/components/common/ComposerPicker.tsx +3 -0
  12. package/src/client/components/common/code-surface/shiki.test.ts +82 -0
  13. package/src/client/components/common/code-surface/shiki.ts +28 -7
  14. package/src/client/components/common/session-actions-menu/index.tsx +59 -2
  15. package/src/client/components/common/session-branch/BranchGuides.tsx +93 -0
  16. package/src/client/components/common/session-branch/SubagentRow.tsx +77 -0
  17. package/src/client/components/common/session-branch/index.tsx +169 -0
  18. package/src/client/components/common/session-branch/session-branch.test.tsx +240 -0
  19. package/src/client/components/common/session-branch/style.ts +29 -0
  20. package/src/client/components/common/session-row/StatusSlot.tsx +17 -5
  21. package/src/client/components/common/session-row/index.tsx +28 -3
  22. package/src/client/components/common/session-row/session-row.test.tsx +11 -0
  23. package/src/client/components/common/session-state-provider/index.tsx +1 -1
  24. package/src/client/components/layout/desktop-layout/resizer/separator-drag.ts +3 -3
  25. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +70 -61
  26. package/src/client/components/layout/session-sidebar/SessionItem.batch.test.ts +3 -3
  27. package/src/client/components/layout/session-sidebar/SessionItem.test.ts +25 -2
  28. package/src/client/components/layout/session-sidebar/SessionItem.tsx +35 -7
  29. package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +261 -0
  30. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +39 -198
  31. package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +114 -0
  32. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.test.tsx +130 -0
  33. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +128 -0
  34. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +56 -0
  35. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +44 -36
  36. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +62 -47
  37. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +63 -50
  38. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +5 -0
  39. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +37 -12
  40. package/src/client/components/settings/Sidebar.tsx +1 -1
  41. package/src/client/components/settings/categories/NotificationSettings.test.tsx +92 -0
  42. package/src/client/components/settings/categories/NotificationSettings.tsx +112 -2
  43. package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +1 -1
  44. package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +94 -0
  45. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +31 -5
  46. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +64 -70
  47. package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +35 -0
  48. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +128 -122
  49. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +22 -1
  50. package/src/client/components/workspace/chat-timeline/MessageList.tsx +11 -5
  51. package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +10 -0
  52. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +12 -3
  53. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +3 -0
  54. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +2 -0
  55. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +15 -1
  56. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +85 -0
  57. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +84 -0
  58. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +2 -0
  59. package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +5 -0
  60. package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +155 -0
  61. package/src/client/components/workspace/chat-timeline/index.tsx +11 -20
  62. package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +115 -0
  63. package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +173 -0
  64. package/src/client/components/workspace/chat-timeline/target-picker/parent-session-options.test.ts +49 -0
  65. package/src/client/components/workspace/terminal-panel/KeyBar.tsx +10 -8
  66. package/src/client/components/workspace/terminal-panel/{RealtimeXtermView.tsx → RealtimeTerminalView.tsx} +51 -58
  67. package/src/client/components/workspace/terminal-panel/fit.test.ts +37 -0
  68. package/src/client/components/workspace/terminal-panel/fit.ts +64 -0
  69. package/src/client/components/workspace/terminal-panel/fonts.test.ts +161 -0
  70. package/src/client/components/workspace/terminal-panel/fonts.ts +164 -0
  71. package/src/client/components/workspace/terminal-panel/grid.test.ts +52 -0
  72. package/src/client/components/workspace/terminal-panel/grid.ts +118 -0
  73. package/src/client/components/workspace/terminal-panel/index.tsx +25 -21
  74. package/src/client/components/workspace/terminal-panel/mount.ts +247 -223
  75. package/src/client/components/workspace/terminal-panel/navigation.test.ts +54 -0
  76. package/src/client/components/workspace/terminal-panel/navigation.ts +47 -0
  77. package/src/client/data/settings/omp-schema.json +1 -1
  78. package/src/client/data/theme/terminal.test.ts +25 -0
  79. package/src/client/data/theme/terminal.ts +96 -79
  80. package/src/client/hooks/chat/composer/items.test.ts +31 -26
  81. package/src/client/hooks/chat/composer/pick-mapping.test.ts +42 -0
  82. package/src/client/hooks/chat/omp/folder-auto-expand.ts +1 -1
  83. package/src/client/hooks/chat/omp/pending-adoption.ts +51 -0
  84. package/src/client/hooks/chat/omp/pending-child.test.ts +73 -0
  85. package/src/client/hooks/chat/omp/pending-entry.ts +59 -0
  86. package/src/client/hooks/chat/omp/pending-rows.ts +6 -2
  87. package/src/client/hooks/chat/omp/pending-sessions.test.ts +1 -2
  88. package/src/client/hooks/chat/omp/pending-sessions.ts +45 -69
  89. package/src/client/hooks/chat/omp/pending-waiting.ts +1 -1
  90. package/src/client/hooks/chat/omp/prompt-send.test.ts +7 -7
  91. package/src/client/hooks/chat/omp/prompt-send.ts +26 -14
  92. package/src/client/hooks/chat/omp/run-switch.ts +1 -1
  93. package/src/client/hooks/chat/omp/session-list.tsx +4 -0
  94. package/src/client/hooks/chat/subagents/roster.ts +122 -0
  95. package/src/client/hooks/chat/timeline/child-spawn.test.ts +55 -0
  96. package/src/client/hooks/chat/timeline/child-spawn.ts +45 -0
  97. package/src/client/hooks/chat/timeline/fork-request.test.ts +54 -0
  98. package/src/client/hooks/chat/timeline/fork-request.ts +43 -0
  99. package/src/client/hooks/chat/timeline/mode-availability.test.ts +1 -1
  100. package/src/client/hooks/chat/timeline/mode-availability.ts +33 -0
  101. package/src/client/hooks/chat/timeline/mode-markers.ts +7 -1
  102. package/src/client/hooks/chat/timeline/mode-post.ts +15 -3
  103. package/src/client/hooks/chat/timeline/modes-contract.ts +9 -4
  104. package/src/client/hooks/chat/timeline/modes.test.ts +56 -18
  105. package/src/client/hooks/chat/timeline/modes.ts +42 -29
  106. package/src/client/hooks/chat/timeline/pending-branch.ts +205 -0
  107. package/src/client/hooks/chat/timeline/pending-dispatch.ts +253 -0
  108. package/src/client/hooks/chat/timeline/prompt-text.test.ts +34 -1
  109. package/src/client/hooks/chat/timeline/prompt-text.ts +47 -20
  110. package/src/client/hooks/chat/timeline/send-execute.test.ts +39 -0
  111. package/src/client/hooks/chat/timeline/send-helpers.ts +30 -1
  112. package/src/client/hooks/chat/timeline/send-steer.test.ts +3 -1
  113. package/src/client/hooks/chat/timeline/send.test-util.ts +7 -1
  114. package/src/client/hooks/chat/timeline/send.test.ts +3 -1
  115. package/src/client/hooks/chat/timeline/send.ts +48 -133
  116. package/src/client/hooks/chat/timeline/session-harness.ts +6 -0
  117. package/src/client/hooks/chat/timeline/stop-with-queue.ts +42 -0
  118. package/src/client/hooks/chat/timeline/use-fork-session.ts +58 -0
  119. package/src/client/hooks/models/use-harness-update.test.ts +286 -0
  120. package/src/client/hooks/models/use-harness-update.ts +250 -0
  121. package/src/client/hooks/ui/input-required-alert.ts +12 -5
  122. package/src/client/hooks/ui/notifications.ts +45 -0
  123. package/src/client/hooks/ui/run-outcome-alert.ts +48 -0
  124. package/src/client/hooks/workspace/expanded-sessions.ts +36 -7
  125. package/src/client/hooks/workspace/terminal/index.ts +17 -3
  126. package/src/client/hooks/workspace/terminal/socket.ts +9 -4
  127. package/src/client/lib/native/open-session.ts +33 -0
  128. package/src/client/lib/notifications/os.test.ts +125 -0
  129. package/src/client/lib/notifications/os.ts +130 -0
  130. package/src/client/lib/plugins/sidebar-bridge.ts +2 -20
  131. package/src/client/lib/router/open-session.test.ts +75 -0
  132. package/src/client/lib/router/open-session.ts +34 -0
  133. package/src/client/lib/session-tree.test.ts +50 -0
  134. package/src/client/lib/session-tree.ts +59 -0
  135. package/src/client/lib/signals.ts +5 -1
  136. package/src/client/main.tsx +6 -0
  137. package/src/client/tailwind.css +17 -11
  138. package/src/server/index.ts +2 -0
  139. package/src/server/lib/auth/guard.ts +10 -0
  140. package/src/server/lib/btw/session-copy.server.ts +6 -44
  141. package/src/server/lib/btw/session-copy.test.ts +2 -1
  142. package/src/server/lib/db/schema.ts +5 -0
  143. package/src/server/lib/db/seed-terminal.test.ts +1 -1
  144. package/src/server/lib/db/seed.test.ts +1 -1
  145. package/src/server/lib/harness/acp/background-work.test.ts +262 -0
  146. package/src/server/lib/harness/acp/background-work.ts +320 -0
  147. package/src/server/lib/harness/acp/calls.ts +15 -1
  148. package/src/server/lib/harness/acp/client-capabilities.test.ts +55 -0
  149. package/src/server/lib/harness/acp/client-capabilities.ts +61 -0
  150. package/src/server/lib/harness/acp/client-fs.test.ts +135 -0
  151. package/src/server/lib/harness/acp/client-fs.ts +131 -0
  152. package/src/server/lib/harness/acp/client-initialize.test.ts +70 -0
  153. package/src/server/lib/harness/acp/client-initialize.ts +84 -0
  154. package/src/server/lib/harness/acp/client.ts +33 -23
  155. package/src/server/lib/harness/acp/commands.test.ts +5 -5
  156. package/src/server/lib/harness/acp/commands.ts +14 -2
  157. package/src/server/lib/harness/acp/frames-timing.test.ts +68 -0
  158. package/src/server/lib/harness/acp/frames-v2.test.ts +85 -0
  159. package/src/server/lib/harness/acp/frames.ts +71 -158
  160. package/src/server/lib/harness/acp/gateway-env.test.ts +64 -0
  161. package/src/server/lib/harness/acp/gateway-env.ts +70 -0
  162. package/src/server/lib/harness/acp/mapper.test.ts +40 -0
  163. package/src/server/lib/harness/acp/mapper.ts +12 -0
  164. package/src/server/lib/harness/acp/permissions.ts +6 -0
  165. package/src/server/lib/harness/acp/prompt.test.ts +20 -0
  166. package/src/server/lib/harness/acp/prompt.ts +19 -3
  167. package/src/server/lib/harness/acp/protocol.ts +41 -2
  168. package/src/server/lib/harness/acp/session-background.test.ts +129 -0
  169. package/src/server/lib/harness/acp/session-exit.ts +31 -0
  170. package/src/server/lib/harness/acp/session-facts.ts +1 -1
  171. package/src/server/lib/harness/acp/session-handshake.test.ts +197 -0
  172. package/src/server/lib/harness/acp/session-handshake.ts +110 -7
  173. package/src/server/lib/harness/acp/session-idle.ts +7 -6
  174. package/src/server/lib/harness/acp/session-listeners.ts +31 -0
  175. package/src/server/lib/harness/acp/session-notifications.ts +41 -2
  176. package/src/server/lib/harness/acp/session-observers.test.ts +63 -0
  177. package/src/server/lib/harness/acp/session-permissions.test.ts +29 -0
  178. package/src/server/lib/harness/acp/session-permissions.ts +36 -0
  179. package/src/server/lib/harness/acp/session-requests.test.ts +92 -0
  180. package/src/server/lib/harness/acp/session-requests.ts +89 -0
  181. package/src/server/lib/harness/acp/session-turns.ts +28 -8
  182. package/src/server/lib/harness/acp/session-usage.ts +4 -0
  183. package/src/server/lib/harness/acp/session-web-state.ts +30 -2
  184. package/src/server/lib/harness/acp/session.test-util.ts +42 -2
  185. package/src/server/lib/harness/acp/session.ts +115 -115
  186. package/src/server/lib/harness/acp/tool-calls.ts +223 -0
  187. package/src/server/lib/harness/acp/turn.test.ts +183 -0
  188. package/src/server/lib/harness/acp/turn.ts +102 -10
  189. package/src/server/lib/harness/acp/v2.test.ts +144 -0
  190. package/src/server/lib/harness/acp/v2.ts +220 -0
  191. package/src/server/lib/harness/acp/verbs.ts +58 -8
  192. package/src/server/lib/harness/launch.test.ts +25 -0
  193. package/src/server/lib/harness/launch.ts +24 -10
  194. package/src/server/lib/harness/session.ts +3 -0
  195. package/src/server/lib/harness/spawn.server.ts +15 -2
  196. package/src/server/lib/harness/update-job-store.test.ts +151 -0
  197. package/src/server/lib/harness/update-job-store.ts +115 -0
  198. package/src/server/lib/harness/update-job.server.ts +94 -0
  199. package/src/server/lib/harness/update-queue.server.ts +292 -0
  200. package/src/server/lib/harness/update-queue.test.ts +265 -0
  201. package/src/server/lib/harness/update-spawn.server.ts +96 -0
  202. package/src/server/lib/harness/update-worker.test.ts +153 -0
  203. package/src/server/lib/harness/update-worker.ts +202 -0
  204. package/src/server/lib/lifecycle/after-listen.ts +9 -0
  205. package/src/server/lib/lifecycle/paths.ts +28 -0
  206. package/src/server/lib/omp/rpc/manager.ts +5 -5
  207. package/src/server/lib/omp/rpc/prewarm-pool.ts +12 -3
  208. package/src/server/lib/omp/rpc/run-settle.server.ts +10 -1
  209. package/src/server/lib/omp/rpc/session-registry.ts +14 -2
  210. package/src/server/lib/omp/rpc/subagent-liveness.ts +5 -5
  211. package/src/server/lib/omp/rpc/terminal-settle.ts +58 -6
  212. package/src/server/lib/omp/session/delete-flow.server.ts +48 -0
  213. package/src/server/lib/omp/session/delete.server.ts +5 -0
  214. package/src/server/lib/omp/session/rewind-file.ts +39 -21
  215. package/src/server/lib/omp/session/sidebar-data.server.ts +16 -18
  216. package/src/server/lib/omp/session/transcript-copy.ts +123 -0
  217. package/src/server/lib/sessions/agent-token.server.test.ts +64 -0
  218. package/src/server/lib/sessions/agent-token.server.ts +134 -0
  219. package/src/server/lib/sessions/answers.server.test.ts +33 -0
  220. package/src/server/lib/sessions/answers.server.ts +37 -0
  221. package/src/server/lib/sessions/dispatch.server.test.ts +143 -0
  222. package/src/server/lib/sessions/dispatch.server.ts +128 -0
  223. package/src/server/lib/sessions/fork.server.test.ts +277 -0
  224. package/src/server/lib/sessions/fork.server.ts +329 -0
  225. package/src/server/lib/sessions/lifecycle.server.test.ts +75 -0
  226. package/src/server/lib/sessions/lifecycle.server.ts +71 -0
  227. package/src/server/lib/sessions/notify.server.test.ts +112 -0
  228. package/src/server/lib/sessions/notify.server.ts +212 -0
  229. package/src/server/lib/sessions/relation-types.ts +76 -0
  230. package/src/server/lib/sessions/relations.server.test.ts +207 -0
  231. package/src/server/lib/sessions/relations.server.ts +337 -0
  232. package/src/server/lib/sessions/resolve.server.ts +106 -0
  233. package/src/server/lib/sessions/schema.server.ts +82 -0
  234. package/src/server/lib/sessions/sidebar-relations.server.test.ts +61 -0
  235. package/src/server/lib/sessions/sidebar-relations.server.ts +47 -0
  236. package/src/server/lib/sessions/spawn.server.test.ts +237 -0
  237. package/src/server/lib/sessions/spawn.server.ts +335 -0
  238. package/src/server/lib/terminal/attach-replay.test.ts +2 -2
  239. package/src/server/lib/terminal/output.test.ts +2 -2
  240. package/src/server/lib/terminal/output.ts +1 -1
  241. package/src/server/lib/terminal/resize.test.ts +99 -0
  242. package/src/server/lib/terminal/runtime.server.ts +26 -6
  243. package/src/server/lib/terminal/send-result.test.ts +18 -1
  244. package/src/server/lib/terminal/send-result.ts +26 -2
  245. package/src/server/lib/terminal/session.server.ts +6 -6
  246. package/src/server/lib/usage/new-api.test.ts +92 -0
  247. package/src/server/lib/usage/new-api.ts +131 -0
  248. package/src/server/lib/usage/provider-endpoint.test.ts +106 -0
  249. package/src/server/lib/usage/provider-key.ts +33 -0
  250. package/src/server/lib/usage/providers.server.ts +10 -3
  251. package/src/server/lib/usage/vendor-balance.server.ts +4 -53
  252. package/src/server/lib/usage/vendor-http.ts +41 -0
  253. package/src/server/lib/usage/window.ts +55 -0
  254. package/src/server/routes/agent/command.ts +14 -1
  255. package/src/server/routes/agent/harness-command.ts +12 -5
  256. package/src/server/routes/agent/new.ts +15 -0
  257. package/src/server/routes/chat/stream.ts +7 -2
  258. package/src/server/routes/harness/add-provider.test.ts +9 -1
  259. package/src/server/routes/harness/import-action.ts +4 -0
  260. package/src/server/routes/harness/import.test.ts +1 -1
  261. package/src/server/routes/harness/index.ts +5 -1
  262. package/src/server/routes/harness/update-status.ts +32 -0
  263. package/src/server/routes/harness/update.test.ts +156 -0
  264. package/src/server/routes/harness/update.ts +64 -147
  265. package/src/server/routes/sessions/answer.ts +24 -0
  266. package/src/server/routes/sessions/batch-delete.ts +11 -5
  267. package/src/server/routes/sessions/body-readers.ts +43 -0
  268. package/src/server/routes/sessions/delete.ts +4 -2
  269. package/src/server/routes/sessions/fork.ts +89 -0
  270. package/src/server/routes/sessions/index.ts +14 -0
  271. package/src/server/routes/sessions/relations.ts +85 -0
  272. package/src/server/routes/sessions/routes.test.ts +1 -2
  273. package/src/server/routes/sessions/session.ts +23 -0
  274. package/src/server/routes/sessions/spawn.ts +137 -0
  275. package/src/server/routes/terminal/ws.ts +3 -3
  276. package/src/shared/lib/chat/composer/client.ts +31 -2
  277. package/src/shared/lib/chat/composer/delegation.test.ts +93 -0
  278. package/src/shared/lib/chat/composer/delegation.ts +206 -0
  279. package/src/shared/lib/chat/notice-text.ts +1 -1
  280. package/src/shared/lib/chat/omp/agent-events.ts +11 -0
  281. package/src/shared/lib/chat/omp/session-modes-signal.test.ts +41 -0
  282. package/src/shared/lib/chat/tool/summary-wait.test.ts +11 -0
  283. package/src/shared/lib/code/ansi.ts +1 -1
  284. package/src/shared/lib/fonts/nerd-symbols.css +4 -3
  285. package/src/shared/lib/fonts/nerd-symbols.test.ts +9 -9
  286. package/src/shared/lib/harness/mode-signal.ts +20 -0
  287. package/src/shared/lib/harness/provider-facts.test.ts +27 -0
  288. package/src/shared/lib/harness/providers.ts +35 -1
  289. package/src/shared/lib/harness/session-modes.ts +24 -0
  290. package/src/shared/lib/harness/update-job.ts +80 -0
  291. package/src/shared/lib/harness/update-plan.test.ts +21 -6
  292. package/src/shared/lib/harness/update-plan.ts +12 -4
  293. package/src/shared/lib/icons/tint-hues.generated.ts +34 -34
  294. package/src/shared/lib/notifications/outcomes.test.ts +96 -0
  295. package/src/shared/lib/notifications/outcomes.ts +64 -0
  296. package/src/shared/lib/notifications/settings.test.ts +49 -0
  297. package/src/shared/lib/notifications/settings.ts +34 -0
  298. package/src/shared/lib/omp/session/default-title.ts +5 -4
  299. package/src/shared/lib/omp/session/prewarm-misc.test.ts +3 -2
  300. package/src/shared/lib/omp/session/schema-migrations.ts +4 -0
  301. package/src/shared/lib/omp/session/stream-state.server.test.ts +19 -0
  302. package/src/shared/lib/omp/session/stream-state.server.ts +24 -4
  303. package/src/shared/lib/omp/session/wait-idle.test.ts +11 -0
  304. package/src/shared/lib/omp/session/wait-idle.ts +12 -2
  305. package/src/shared/lib/settings/defaults.ts +3 -0
  306. package/src/shared/lib/theme/catalog.test.ts +13 -9
  307. package/src/shared/lib/theme/color.test.ts +2 -2
  308. package/src/shared/lib/theme/color.ts +4 -4
  309. package/src/shared/lib/theme/theme.test.ts +1 -1
  310. package/src/shared/lib/workspace/terminal/input.test.ts +27 -0
  311. package/src/shared/lib/workspace/terminal/input.ts +33 -0
  312. package/src/shared/lib/workspace/terminal/keys.test.ts +1 -1
  313. package/src/shared/lib/workspace/terminal/keys.ts +7 -7
  314. package/src/shared/types/chat.ts +1 -1
  315. package/src/shared/types/harness-update.ts +89 -0
  316. package/src/shared/types/omp/agent.ts +19 -2
  317. package/src/shared/types/realtime.ts +2 -0
  318. package/src/shared/types/settings/state.ts +10 -0
  319. package/src/shared/types/workspace.ts +8 -0
  320. package/src/test-support/fake-omp-fork.ts +16 -2
  321. package/src/test-support/harness-table.test-util.ts +31 -1
  322. package/dist/client/static/js/index-z3w7n85q.css +0 -1
  323. package/src/client/components/common/subagent-list/index.tsx +0 -165
  324. package/src/client/components/workspace/terminal-panel/webgl.test.ts +0 -75
  325. package/src/client/components/workspace/terminal-panel/webgl.ts +0 -108
@@ -28,13 +28,15 @@ export interface MessageListProps {
28
28
  onRetry?: (id: string) => void;
29
29
  /** Seeds a new chat from a row. A user row also hands over its attachments. */
30
30
  onNewChat?: (content: string, attachments?: Attachment[]) => void;
31
+ /** Branch the session at a user row. */
32
+ onFork?: (msgId: string) => void;
31
33
  isMobile?: boolean;
32
34
  /**
33
- * Whether chat-owning actions render: a USER row's Undo / New-chat, and the
34
- * run footer's Retry / New-chat. All of them act on the CHAT (rewind a chat
35
- * turn, re-run it, branch a session from it), so a renderer that draws rows
36
- * the chat does not own — the BTW panel's side question and its answer — turns
37
- * them off instead of showing buttons that do nothing.
35
+ * Whether chat-owning actions render: a USER row's Undo / Fork / New-chat,
36
+ * and the run footer's Retry / Fork / New-chat. All of them act on the CHAT
37
+ * (rewind a chat turn, re-run it, branch a session from it), so a renderer
38
+ * that draws rows the chat does not own — the BTW panel's side question and
39
+ * its answer — turns them off instead of showing buttons that do nothing.
38
40
  */
39
41
  userActions?: boolean;
40
42
  /**
@@ -71,6 +73,7 @@ export const MessageList = memo(function MessageList({
71
73
  onUndo,
72
74
  onRetry,
73
75
  onNewChat,
76
+ onFork,
74
77
  isMobile = false,
75
78
  userActions = true,
76
79
  rowWindow,
@@ -139,6 +142,7 @@ export const MessageList = memo(function MessageList({
139
142
  isStreaming={isLoading}
140
143
  onUndo={onUndo}
141
144
  onNewChat={onNewChat}
145
+ onFork={onFork}
142
146
  isPrevAssistant={isPrevAssistant}
143
147
  userActions={userActions}
144
148
  isMobile={isMobile}
@@ -158,6 +162,7 @@ export const MessageList = memo(function MessageList({
158
162
  retryTargetId={inlineFooter.runUserId}
159
163
  onRetry={onRetry}
160
164
  onNewChat={onNewChat}
165
+ onFork={onFork}
161
166
  isMobile={isMobile}
162
167
  showActions={userActions}
163
168
  />
@@ -180,6 +185,7 @@ export const MessageList = memo(function MessageList({
180
185
  retryTargetId={trailingFooter.runUserId}
181
186
  onRetry={onRetry}
182
187
  onNewChat={onNewChat}
188
+ onFork={onFork}
183
189
  isMobile={isMobile}
184
190
  showActions={userActions}
185
191
  />
@@ -63,6 +63,12 @@ export interface PendingChatViewProps {
63
63
  /** Where the chat will run: the folder, or one of its worktrees. */
64
64
  spawnTarget?: SpawnTarget | null;
65
65
  onSpawnTargetChange?: (next: SpawnTarget | null) => void;
66
+ /** The session this chat runs under, or null for a top-level chat. */
67
+ parentSessionId?: string | null;
68
+ onParentSessionChange?: (sessionId: string | null) => void;
69
+ /** "Parent session" for a child, "Fork from" for a fork. */
70
+ branchLabel?: string;
71
+ branchAllowNone?: boolean;
66
72
  onWorktreeReport?: (message: string) => void;
67
73
  /**
68
74
  * The harness this chat will spawn on, and the pick that writes it.
@@ -119,6 +125,10 @@ export function PendingChatView(props: PendingChatViewProps) {
119
125
  onCancelWait={props.onCancelWait}
120
126
  spawnTarget={props.spawnTarget}
121
127
  onSpawnTargetChange={props.onSpawnTargetChange}
128
+ parentSessionId={props.parentSessionId}
129
+ onParentSessionChange={props.onParentSessionChange}
130
+ branchLabel={props.branchLabel}
131
+ branchAllowNone={props.branchAllowNone}
122
132
  onWorktreeReport={props.onWorktreeReport}
123
133
  {...(props.harness ? { harness: props.harness } : {})}
124
134
  harnessEditable={props.harnessEditable}
@@ -31,12 +31,18 @@ interface RunFooterProps {
31
31
  retryTargetId?: string;
32
32
  onRetry?: (msgId: string) => void;
33
33
  onNewChat?: (content: string, attachments?: Attachment[]) => void;
34
+ /**
35
+ * Branch the session from this answer. The anchor is the run's owner row
36
+ * (`msg.id`), never `retryTargetId`: the opening user row would fork BEFORE
37
+ * the answer, while the footer sits under it.
38
+ */
39
+ onFork?: (msgId: string) => void;
34
40
  /** Mobile uses a compact provider/model footer with a bottom-sheet menu. */
35
41
  isMobile?: boolean;
36
42
  /**
37
- * Whether the footer offers Retry / New-chat. Both act on the CHAT, so a
38
- * footer describing a row the chat does not own (the BTW panel's side answer)
39
- * turns them off rather than rendering dead buttons.
43
+ * Whether the footer offers Retry / Fork / New-chat. All of them act on the
44
+ * CHAT, so a footer describing a row the chat does not own (the BTW panel's
45
+ * side answer) turns them off rather than rendering dead buttons.
40
46
  */
41
47
  showActions?: boolean;
42
48
  }
@@ -60,6 +66,7 @@ export function RunFooter({
60
66
  retryTargetId,
61
67
  onRetry,
62
68
  onNewChat,
69
+ onFork,
63
70
  isMobile = false,
64
71
  showActions = true,
65
72
  }: RunFooterProps) {
@@ -78,6 +85,8 @@ export function RunFooter({
78
85
  msgId={retryTargetId || msg.id}
79
86
  onRetry={onRetry}
80
87
  onNewChat={onNewChat}
88
+ forkTargetId={msg.id}
89
+ onFork={onFork}
81
90
  isMobile={isMobile}
82
91
  showActions={showActions}
83
92
  />
@@ -35,6 +35,7 @@ interface TimelineBodyProps {
35
35
  onUndo: (id: string, content?: string) => void;
36
36
  onRetry: (id: string) => void;
37
37
  onNewChat: (content: string, attachments?: Attachment[]) => void;
38
+ onFork?: (msgId: string) => void;
38
39
  showScrollBottom: boolean;
39
40
  jumpToBottom: (behavior?: ScrollBehavior) => void;
40
41
  /** Which rows of `messages` are mounted (see `useTimelineRowWindow`). */
@@ -70,6 +71,7 @@ export function TimelineBody({
70
71
  onUndo,
71
72
  onRetry,
72
73
  onNewChat,
74
+ onFork,
73
75
  showScrollBottom,
74
76
  jumpToBottom,
75
77
  rowWindow,
@@ -123,6 +125,7 @@ export function TimelineBody({
123
125
  onUndo={onUndo}
124
126
  onRetry={onRetry}
125
127
  onNewChat={onNewChat}
128
+ onFork={onFork}
126
129
  isMobile={isMobile}
127
130
  rowWindow={rowWindow}
128
131
  />
@@ -111,6 +111,8 @@ export function AttachmentToolbar({ attachments, onFilesSelected, onRemove, mode
111
111
  onOpenGoal={onOpenGoal}
112
112
  planAvailable={modes.planAvailable}
113
113
  goalAvailable={modes.goalAvailable}
114
+ mode={modes.sessionMode ?? null}
115
+ onSelectMode={modes.onSelectSessionMode}
114
116
  />
115
117
  </div>
116
118
  )}
@@ -30,6 +30,8 @@
30
30
  import { ClipboardList, Target } from 'lucide-preact';
31
31
  import type { GoalRecord } from '@/shared/lib/omp/mode/types';
32
32
  import type { ArmedGoal } from '@/shared/lib/omp/mode/actions';
33
+ import type { SessionModeState } from '@/shared/lib/harness/session-modes';
34
+ import { SessionModeDropdown } from '@/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown';
33
35
 
34
36
  export interface ModeTogglesProps {
35
37
  plan: boolean;
@@ -49,6 +51,10 @@ export interface ModeTogglesProps {
49
51
  /** Whether Goal is offered at all: a non-omp ACP agent has no `/kabmo-mode`
50
52
  * extension, so the button could only produce a refusal. */
51
53
  goalAvailable: boolean;
54
+ /** The agent's own mode selector. When it has more than one value the
55
+ * dropdown replaces the Plan button, so plan is still reachable. */
56
+ mode?: SessionModeState | null;
57
+ onSelectMode?: (value: string) => void;
52
58
  }
53
59
 
54
60
  /** omp's own footer shows goal token usage beside the mode indicator; that
@@ -73,10 +79,18 @@ export function ModeToggles({
73
79
  onOpenGoal,
74
80
  planAvailable,
75
81
  goalAvailable,
82
+ mode,
83
+ onSelectMode,
76
84
  }: ModeTogglesProps) {
85
+ // More than one mode: the dropdown can express every value, including plan,
86
+ // so the single-purpose Plan button would be a second control for one item.
87
+ const hasModeMenu = Boolean(mode && mode.values.length > 1 && onSelectMode);
77
88
  return (
78
89
  <div className="flex items-center gap-0.5">
79
- {planAvailable && (
90
+ {hasModeMenu && mode && onSelectMode && (
91
+ <SessionModeDropdown mode={mode} pending={pending} onSelect={onSelectMode} />
92
+ )}
93
+ {!hasModeMenu && planAvailable && (
80
94
  <button
81
95
  type="button"
82
96
  onClick={() => onTogglePlan(!plan)}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The ACP mode chip: hidden when there is nothing to choose, and it reports the
8
+ * chosen value. Rendered with `h()` against happy-dom.
9
+ */
10
+
11
+ import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
12
+ import { Window } from 'happy-dom';
13
+ import { h, render } from 'preact';
14
+ import { act } from 'preact/test-utils';
15
+ import { SessionModeDropdown } from '@/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown';
16
+ import type { SessionModeState } from '@/shared/lib/harness/session-modes';
17
+
18
+ const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event', 'CustomEvent'] as const;
19
+ const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
20
+
21
+ let container: HTMLElement | undefined;
22
+
23
+ const TWO_MODES: SessionModeState = {
24
+ currentValue: 'ask',
25
+ values: [{ value: 'ask', name: 'Ask' }, { value: 'code', name: 'Code' }],
26
+ };
27
+
28
+ beforeAll(() => {
29
+ const win = new Window({ url: 'http://localhost' });
30
+ const target = globalThis as unknown as Record<string, unknown>;
31
+ for (const key of DOM_GLOBALS) {
32
+ if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
33
+ target[key] = (win as unknown as Record<string, unknown>)[key];
34
+ }
35
+ });
36
+
37
+ afterAll(() => {
38
+ const target = globalThis as unknown as Record<string, unknown>;
39
+ for (const key of DOM_GLOBALS) {
40
+ if (nativeGlobals[key] === undefined) delete target[key];
41
+ else target[key] = nativeGlobals[key];
42
+ }
43
+ });
44
+
45
+ afterEach(() => {
46
+ if (container) render(null, container);
47
+ container?.remove();
48
+ container = undefined;
49
+ });
50
+
51
+ async function mount(mode: SessionModeState | null, onSelect: (value: string) => void = () => {}) {
52
+ container ??= document.body.appendChild(document.createElement('div'));
53
+ await act(async () => {
54
+ render(h(SessionModeDropdown, { mode, pending: false, onSelect }), container as HTMLElement);
55
+ });
56
+ return container;
57
+ }
58
+
59
+ describe('SessionModeDropdown', () => {
60
+ test('renders nothing for a harness with no selector or one value', async () => {
61
+ expect((await mount(null)).textContent).toBe('');
62
+ await mount({ currentValue: 'ask', values: [{ value: 'ask', name: 'Ask' }] });
63
+ expect(container?.textContent).toBe('');
64
+ });
65
+
66
+ test('names the current mode and reports a pick', async () => {
67
+ const picks: string[] = [];
68
+ const el = await mount(TWO_MODES, (value) => picks.push(value));
69
+ const trigger = el.querySelector('button[aria-haspopup="listbox"]');
70
+ expect(trigger?.getAttribute('aria-label')).toBe('Session mode: Ask');
71
+
72
+ await act(async () => {
73
+ (trigger as HTMLButtonElement).click();
74
+ });
75
+ const options = el.querySelectorAll('[role="option"]');
76
+ expect(options).toHaveLength(2);
77
+ expect(options[0]?.getAttribute('aria-selected')).toBe('true');
78
+
79
+ await act(async () => {
80
+ (options[1] as HTMLButtonElement).click();
81
+ });
82
+ expect(picks).toEqual(['code']);
83
+ expect(el.querySelector('[role="listbox"]')).toBeNull();
84
+ });
85
+ });
@@ -0,0 +1,84 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The ACP agent's own session-mode selector.
8
+ *
9
+ * ACP exposes modes as a `mode`-category config option (the older `modes` list
10
+ * is normalized into the same shape server-side). Kabmo's Plan toggle only
11
+ * names one value; an agent that offers `ask`/`code`/`architect` needs the whole
12
+ * list. The control is hidden when there is nothing to choose — null for omp,
13
+ * or a one-value ladder — and `ModeToggles` then keeps the Plan button.
14
+ *
15
+ * The popover mirrors `AccessDropdown`: a chip, a list, a check on the current
16
+ * value, and dismissal on outside press.
17
+ */
18
+
19
+ import { useRef, useState } from 'preact/hooks';
20
+ import { Check, Layers } from 'lucide-preact';
21
+ import { useOnClickOutside } from '@/client/hooks/ui/on-click-outside';
22
+ import type { SessionModeState } from '@/shared/lib/harness/session-modes';
23
+
24
+ export interface SessionModeDropdownProps {
25
+ mode: SessionModeState | null;
26
+ /** A mode command is in flight; the chip reads as pending, not dead. */
27
+ pending: boolean;
28
+ onSelect: (value: string) => void;
29
+ }
30
+
31
+ export function SessionModeDropdown({ mode, pending, onSelect }: SessionModeDropdownProps) {
32
+ const [open, setOpen] = useState(false);
33
+ const ref = useRef<HTMLDivElement>(null);
34
+ useOnClickOutside(ref, () => setOpen(false));
35
+
36
+ if (!mode || mode.values.length < 2) return null;
37
+ const current = mode.values.find((choice) => choice.value === mode.currentValue);
38
+ const label = current?.name ?? mode.currentValue;
39
+
40
+ return (
41
+ <div className="relative" ref={ref}>
42
+ <button
43
+ type="button"
44
+ onClick={() => setOpen((value) => !value)}
45
+ disabled={pending}
46
+ aria-haspopup="listbox"
47
+ aria-expanded={open}
48
+ aria-label={`Session mode: ${label}`}
49
+ title={`Session mode: ${label}`}
50
+ className="tap-chip flex items-center space-x-1 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-muted disabled:opacity-60 disabled:cursor-wait"
51
+ >
52
+ <Layers size={12} className="text-ink/60" />
53
+ <span className="hidden @[420px]:inline max-w-[9rem] truncate">{label}</span>
54
+ </button>
55
+ {open && (
56
+ <div
57
+ role="listbox"
58
+ aria-label="Session mode"
59
+ className="glass-popover absolute bottom-full left-0 mb-1 w-44 bg-paper border border-ink/20 rounded-md shadow-lg z-50 py-1 text-xs"
60
+ >
61
+ <div className="px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold mb-1">
62
+ Session Mode
63
+ </div>
64
+ {mode.values.map((choice) => (
65
+ <button
66
+ key={choice.value}
67
+ type="button"
68
+ role="option"
69
+ aria-selected={choice.value === mode.currentValue}
70
+ onClick={() => {
71
+ setOpen(false);
72
+ onSelect(choice.value);
73
+ }}
74
+ className="w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center justify-between gap-2 transition-colors"
75
+ >
76
+ <span className="truncate">{choice.name}</span>
77
+ {choice.value === mode.currentValue && <Check size={12} className="text-ink shrink-0" />}
78
+ </button>
79
+ ))}
80
+ </div>
81
+ )}
82
+ </div>
83
+ );
84
+ }
@@ -194,6 +194,8 @@ export function ComposerToolbar({
194
194
  onOpenGoal={onOpenGoal}
195
195
  planAvailable={modes.planAvailable}
196
196
  goalAvailable={modes.goalAvailable}
197
+ mode={modes.sessionMode ?? null}
198
+ onSelectMode={modes.onSelectSessionMode}
197
199
  />
198
200
  </>
199
201
  )}
@@ -15,6 +15,7 @@
15
15
  import type { GoalContinuation, GoalRecord } from '@/shared/lib/omp/mode/types';
16
16
  import type { ArmedGoal, GoalAction } from '@/shared/lib/omp/mode/actions';
17
17
  import type { GoalActionResult } from '@/client/hooks/chat/timeline/goal-command';
18
+ import type { SessionModeState } from '@/shared/lib/harness/session-modes';
18
19
 
19
20
  export interface ComposerModes {
20
21
  plan: boolean;
@@ -48,6 +49,10 @@ export interface ComposerModes {
48
49
  * button could only refuse.
49
50
  */
50
51
  goalAvailable: boolean;
52
+ /** The agent's own mode selector (ACP), or null when it publishes none. */
53
+ sessionMode?: SessionModeState | null;
54
+ /** Move the agent's mode selector. */
55
+ onSelectSessionMode?: (value: string) => void;
51
56
  /**
52
57
  * The last mode-command refusal, from either side of the wire (the route's
53
58
  * error, or a `KABMO_MODE_ERROR` from the extension). The composer renders
@@ -0,0 +1,155 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The pending chat's dock is the REAL timeline's dock.
8
+ *
9
+ * The generating indicator is drawn from one component, but its height in the
10
+ * pane came from two different wrappers: the real timeline docked it in
11
+ * `ComposerDock` (`p-4 pt-1`), while the pending `new-…` chat kept the landing
12
+ * page's centred `p-8` column with a `space-y-3` stack. Measured with the
13
+ * built CSS at 1200x1400: the indicator sat **141px** above the pane's bottom
14
+ * while the spawn was in flight (`Loading…`) and **113px** once the run
15
+ * streamed (`Thinking…`) — the row jumped 28px at adoption, which is why the
16
+ * two states read as two different indicators.
17
+ *
18
+ * Both are `ComposerDockFrame` now. What this suite pins is that the frame is
19
+ * the ONE wrapper for the pending dock, that the indicator is inside it in both
20
+ * identity states, and that the landing page — which has no run to report — is
21
+ * the only state that keeps the centred column.
22
+ */
23
+
24
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
25
+ import { Window } from 'happy-dom';
26
+ import { h, render } from 'preact';
27
+ import { act } from 'preact/test-utils';
28
+
29
+ import { EmptyWorkspacePrompt } from '@/client/components/workspace/chat-timeline/EmptyWorkspacePrompt';
30
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
31
+ import { silenceRealtime, restoreRealtime } from '@/test-support/silent-socket';
32
+ import { resetHarnessesStore } from '@/client/hooks/models/harness-catalog';
33
+ import { invalidateModelsCache } from '@/shared/lib/models/client';
34
+
35
+ let container: HTMLElement;
36
+
37
+ beforeAll(() => {
38
+ installDomGlobals(new Window({ url: 'http://localhost' }));
39
+ // The composer measures its textarea through the BARE global (`auto-grow.ts`),
40
+ // which happy-dom only provides on the window it installed.
41
+ (globalThis as unknown as Record<string, unknown>).getComputedStyle = window.getComputedStyle.bind(window);
42
+ });
43
+ afterAll(() => restoreDomGlobals());
44
+
45
+ beforeEach(() => {
46
+ silenceRealtime();
47
+ resetHarnessesStore();
48
+ invalidateModelsCache();
49
+ globalThis.fetch = (async (input: RequestInfo | URL) => {
50
+ const url = String(input);
51
+ if (url.startsWith('/api/harness')) {
52
+ return Response.json({ harnesses: [], configs: {}, providerSupport: {} });
53
+ }
54
+ if (url.startsWith('/api/models')) {
55
+ return Response.json({ models: {}, modelList: [], selectedModel: null, defaultModel: null, thinkingLevels: {} });
56
+ }
57
+ return Response.json({});
58
+ }) as typeof fetch;
59
+ container = document.createElement('div');
60
+ document.body.appendChild(container);
61
+ });
62
+
63
+ afterEach(() => {
64
+ render(null, container);
65
+ container.remove();
66
+ restoreRealtime();
67
+ });
68
+
69
+ function mount(props: Record<string, unknown>) {
70
+ act(() => {
71
+ render(h(EmptyWorkspacePrompt, {
72
+ selectedFolderId: 1,
73
+ setSelectedFolderId: () => {},
74
+ inputValue: '',
75
+ setInputValue: () => {},
76
+ onSend: () => {},
77
+ isGenerating: false,
78
+ accessMode: 'always-ask',
79
+ onAccessModeChange: () => {},
80
+ composerModelRef: { current: null },
81
+ deferredComposerPickRef: { current: null },
82
+ ...props,
83
+ } as never), container);
84
+ });
85
+ return container;
86
+ }
87
+
88
+ /** The model catalog is read through a promise chain; one macrotask drains it. */
89
+ async function settle(): Promise<void> {
90
+ await act(async () => {
91
+ const { promise, resolve } = Promise.withResolvers<void>();
92
+ setTimeout(resolve, 30);
93
+ await promise;
94
+ });
95
+ }
96
+
97
+ const USER_ROW = { id: 'msg-1-user', role: 'user', content: 'halo', date: 'Today, 12:22 PM' };
98
+
99
+ describe('pending chat dock frame', () => {
100
+ test('the indicator rides the dock frame in both identity states', async () => {
101
+ // `Loading…` — the spawn has not answered, so neither half is known.
102
+ const loading = mount({ messages: [USER_ROW], isGenerating: true, generatingVerb: 'Thinking' });
103
+ await settle();
104
+ const loadingDock = loading.querySelector('[data-composer-dock]');
105
+ const loadingIndicator = loading.querySelector('#generating-docked-indicator');
106
+ expect(loadingDock).not.toBeNull();
107
+ expect(loadingIndicator).not.toBeNull();
108
+ expect(loadingDock!.contains(loadingIndicator!)).toBe(true);
109
+ expect(loading.textContent).toContain('Loading');
110
+
111
+ render(null, container);
112
+ // `Thinking…` — same run, identity resolved.
113
+ const thinking = mount({
114
+ messages: [USER_ROW],
115
+ isGenerating: true,
116
+ generatingVerb: 'Thinking',
117
+ provider: 'kenari',
118
+ modelName: 'DeepSeek V4',
119
+ });
120
+ await settle();
121
+ const thinkingDock = thinking.querySelector('[data-composer-dock]');
122
+ const thinkingIndicator = thinking.querySelector('#generating-docked-indicator');
123
+ expect(thinkingDock).not.toBeNull();
124
+ expect(thinkingDock!.contains(thinkingIndicator!)).toBe(true);
125
+ expect(thinking.textContent).toContain('Thinking');
126
+
127
+ // The one fact: no second wrapper may change between the two states.
128
+ expect(thinkingDock!.className).toBe(loadingDock!.className);
129
+ });
130
+
131
+ test('the frame carries the real dock padding on both layouts', async () => {
132
+ const desktop = mount({ messages: [USER_ROW], isGenerating: true });
133
+ await settle();
134
+ const desktopDock = desktop.querySelector('[data-composer-dock]') as HTMLElement;
135
+ // The dock's box, not the landing page's `p-8`.
136
+ expect(desktopDock.className).toContain('p-4');
137
+ expect(desktopDock.className).not.toContain('p-8');
138
+
139
+ render(null, container);
140
+ const mobile = mount({ messages: [USER_ROW], isGenerating: true, variant: 'mobile' });
141
+ await settle();
142
+ const mobileDock = mobile.querySelector('[data-composer-dock]') as HTMLElement;
143
+ expect(mobileDock.className).toContain('px-3');
144
+ expect(mobileDock.className).not.toContain('p-8');
145
+ });
146
+
147
+ test('the landing page keeps the centred column and draws no dock', async () => {
148
+ const el = mount({ messages: [], isGenerating: false });
149
+ await settle();
150
+ expect(el.querySelector('[data-composer-dock]')).toBeNull();
151
+ const column = el.firstElementChild?.firstElementChild as HTMLElement;
152
+ expect(column.className).toContain('my-auto');
153
+ expect(column.className).toContain('justify-center');
154
+ });
155
+ });
@@ -13,6 +13,9 @@ import { useChatTimeline } from '@/client/hooks/chat/timeline';
13
13
  import { useSessionTitle } from '@/client/hooks/chat/timeline/session-title';
14
14
  import { useSubagentView } from '@/client/hooks/chat/timeline/subagent-view';
15
15
  import { useUndoConfirmation } from '@/client/hooks/chat/timeline/undo-confirmation';
16
+ import { usePendingBranch } from '@/client/hooks/chat/timeline/pending-branch';
17
+ import { useForkSession } from '@/client/hooks/chat/timeline/use-fork-session';
18
+ import { useStopWithQueuedPrompts } from '@/client/hooks/chat/timeline/stop-with-queue';
16
19
  import { useModelNames } from '@/client/hooks/models/use-model-names';
17
20
  import { useRunIdentity } from '@/client/hooks/chat/timeline/run-identity';
18
21
  import { useProviderNames } from '@/client/hooks/models/use-provider-names';
@@ -118,23 +121,8 @@ export function ChatTimeline({ className = '', appSettings = {}, onSessionTitle,
118
121
  const [searchParams, setSearchParams] = useSearchParams();
119
122
 
120
123
  // Stop-all semantics: the run stops AND the queued follow-ups stay in the
121
- // panel (the auto-process holds off). Surface what just happened and how to
122
- // proceed — the toast action delivers the head item immediately.
123
- const handleStop = useCallback(() => {
124
- const heldCount = stopGenerating();
125
- if (heldCount === 0) return;
126
- pushToast(
127
- `Stopped. ${heldCount} message${heldCount > 1 ? 's' : ''} still queued — nothing was sent.`,
128
- 'success',
129
- {
130
- action: { label: 'Send now', onClick: () => {
131
- const first = messageQueue[0];
132
- if (first) void handleSendNowQueueItem(first);
133
- } },
134
- duration: 8000,
135
- },
136
- );
137
- }, [stopGenerating, pushToast, messageQueue, handleSendNowQueueItem]);
124
+ // panel (the auto-process holds off); the toast offers the head item.
125
+ const handleStop = useStopWithQueuedPrompts(stopGenerating, messageQueue, handleSendNowQueueItem, pushToast);
138
126
  const { activeSubagent, back: handleSubagentBack } = useSubagentView(
139
127
  sessionId,
140
128
  searchParams.get('subagent'),
@@ -148,7 +136,6 @@ export function ChatTimeline({ className = '', appSettings = {}, onSessionTitle,
148
136
  }, [jumpToUserTurn]);
149
137
 
150
138
  const handleNewChat = newChat.open;
151
-
152
139
  const modelNames = useModelNames();
153
140
  const { sessionProvider, sessionModelName } = useRunIdentity({ folders, sessionId, sessionData, modelNames });
154
141
  const providerNames = useProviderNames();
@@ -163,6 +150,8 @@ export function ChatTimeline({ className = '', appSettings = {}, onSessionTitle,
163
150
  // uses, so the pending composer's pill does not promise Kabmo's global pick.
164
151
  const pendingProjectModel = usePendingProjectModel(folders, selectedFolderId);
165
152
  const sessionDataModel = typeof sessionData?.model === 'object' ? sessionData.model : null;
153
+ const branch = usePendingBranch({ sessionId, folders, selectedFolderId, setSelectedFolderId, urlParentId: searchParams.get('parentSessionId'), urlForkFrom: searchParams.get('forkFrom'), urlForkAt: searchParams.get('forkAt'), setSearchParams, harnessPicker: activeHarness.picker, pendingHarnessRef });
154
+ const fork = useForkSession(sessionId, folders, selectedFolderId);
166
155
 
167
156
  // The chat-level "a run is in flight" flag is computed in `useChatTimeline`
168
157
  // (it owns the queue-vs-send decision that depends on it) and consumed here
@@ -202,7 +191,7 @@ export function ChatTimeline({ className = '', appSettings = {}, onSessionTitle,
202
191
  modes={modes}
203
192
  composerModelRef={composerModelRef}
204
193
  deferredComposerPickRef={deferredComposerPickRef}
205
- sessionModel={sessionDataModel ?? pendingProjectModel}
194
+ sessionModel={branch.parentModel ?? sessionDataModel ?? pendingProjectModel}
206
195
  sessionThinkingLevel={sessionData?.thinkingLevel}
207
196
  generatingVerb={generatingVerb}
208
197
  variant={variant}
@@ -217,8 +206,9 @@ export function ChatTimeline({ className = '', appSettings = {}, onSessionTitle,
217
206
  onCancelWait={cancelHeldWait}
218
207
  spawnTarget={spawnTarget}
219
208
  onSpawnTargetChange={setSpawnTarget}
209
+ {...branch.viewProps}
220
210
  onWorktreeReport={(message) => pushToast(message, 'success', { duration: 6000 })}
221
- {...activeHarness.picker}
211
+ {...branch.composerProps}
222
212
  />
223
213
  );
224
214
  }
@@ -266,6 +256,7 @@ export function ChatTimeline({ className = '', appSettings = {}, onSessionTitle,
266
256
  onUndo={handleRequestUndo}
267
257
  onRetry={handleRetry}
268
258
  onNewChat={handleNewChat}
259
+ onFork={fork}
269
260
  showScrollBottom={showScrollBottom}
270
261
  jumpToBottom={jumpToBottom}
271
262
  rowWindow={rowWindow}