@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
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState } from 'preact/hooks';
2
2
  import type { ReactNode } from 'preact/compat';
3
- import { Brain, Clock3, Coins, Hourglass, MessageSquarePlus, MoreHorizontal, RotateCcw, X } from 'lucide-preact';
3
+ import { Brain, Clock3, Coins, GitFork, Hourglass, MessageSquarePlus, MoreHorizontal, RotateCcw, X } from 'lucide-preact';
4
4
  import { CopyButton } from '@/client/components/common/CopyButton';
5
5
  import { RunMark } from '@/client/components/workspace/chat-timeline/RunMark';
6
6
  import { PluginMessageActions } from '@/client/components/workspace/chat-timeline/PluginMessageActions';
@@ -33,12 +33,20 @@ interface AiMessageFooterProps {
33
33
  msgId: string;
34
34
  onRetry?: (msgId: string) => void;
35
35
  onNewChat?: (content: string) => void;
36
+ /**
37
+ * Anchor row for Fork. Separate from `msgId`, which Retry resolves to the
38
+ * run's OPENING user row: forking there branches before the answer this
39
+ * footer sits under. The anchor is the run's owner row instead, so the fork
40
+ * keeps the answer.
41
+ */
42
+ forkTargetId?: string;
43
+ onFork?: (msgId: string) => void;
36
44
  isMobile?: boolean;
37
45
  /**
38
- * Whether the row offers Retry / New-chat. Both act on the CHAT (re-run a chat
39
- * turn, branch a chat session from an answer), so a footer that describes a
40
- * row the chat does not own — the BTW panel's side answer — turns them off
41
- * instead of rendering buttons that do nothing.
46
+ * Whether the row offers Retry / Fork / New-chat. All of them act on the
47
+ * CHAT (re-run a chat turn, branch a session from it), so a footer that
48
+ * describes a row the chat does not own — the BTW panel's side answer —
49
+ * turns them off instead of rendering buttons that do nothing.
42
50
  */
43
51
  showActions?: boolean;
44
52
  }
@@ -56,6 +64,8 @@ export function AiMessageFooter({
56
64
  harness,
57
65
  onRetry,
58
66
  onNewChat,
67
+ forkTargetId,
68
+ onFork,
59
69
  isMobile = false,
60
70
  showActions = true,
61
71
  }: AiMessageFooterProps) {
@@ -71,6 +81,11 @@ export function AiMessageFooter({
71
81
  onNewChat?.(content);
72
82
  };
73
83
 
84
+ const handleFork = () => {
85
+ setIsMenuOpen(false);
86
+ if (forkTargetId) onFork?.(forkTargetId);
87
+ };
88
+
74
89
  useEffect(() => {
75
90
  if (!isMenuOpen) return;
76
91
  const handleKeyDown = (event: globalThis.KeyboardEvent) => {
@@ -221,6 +236,12 @@ export function AiMessageFooter({
221
236
  <RotateCcw size={20} className="shrink-0 text-ink/55" />
222
237
  <span>Retry response</span>
223
238
  </button>
239
+ {onFork && forkTargetId && (
240
+ <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
+ <GitFork size={20} className="shrink-0 text-ink/55" />
242
+ <span>Fork from this answer</span>
243
+ </button>
244
+ )}
224
245
  <button type="button" aria-label="Start new chat from this answer" onClick={handleNewChat} 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">
225
246
  <MessageSquarePlus size={20} className="shrink-0 text-ink/55" />
226
247
  <span>Start new chat from this answer</span>
@@ -267,6 +288,11 @@ export function AiMessageFooter({
267
288
  ariaLabel="Copy response"
268
289
  emptyTitle="Nothing to copy — this run produced no text"
269
290
  />
291
+ {showActions && onFork && forkTargetId && (
292
+ <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
+ <GitFork size={12} />
294
+ </button>
295
+ )}
270
296
  {showActions && (
271
297
  <button type="button" className="flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer" title="New Chat from here" aria-label="Start new chat from this answer" onClick={handleNewChat}>
272
298
  <MessageSquarePlus size={12} />
@@ -2,6 +2,7 @@ import type { Dispatch, SetStateAction } from 'preact/compat';
2
2
  import { ChatInput } from '@/client/components/workspace/chat-timeline/chat-input/index';
3
3
  import { BtwForm } from '@/client/components/workspace/btw-panel/index';
4
4
  import { useBtwMode } from '@/client/hooks/chat/btw/mode';
5
+ import { ComposerDockFrame } from '@/client/components/workspace/chat-timeline/ComposerDockFrame';
5
6
  import { GeneratingIndicator } from '@/client/components/workspace/chat-timeline/GeneratingIndicator';
6
7
  import { QueueList } from '@/client/components/workspace/chat-timeline/QueueList';
7
8
  import type { Attachment, QueuedMessage } from '@/shared/types';
@@ -121,76 +122,69 @@ export function ComposerDock({
121
122
  const btw = useBtwMode(sessionId);
122
123
 
123
124
  return (
124
- <div
125
- className={`bg-transparent border-t-0 flex-shrink-0 space-y-2 ${isMobile ? 'px-3 pt-1' : 'p-4 pt-1'}`}
126
- style={isMobile ? { paddingBottom: 'max(0.75rem, env(safe-area-inset-bottom, 0px))' } : undefined}
127
- >
128
- {/* `relative` keeps the queue/indicator stack anchored above the input
129
- while the side-question form takes the composer's place. */}
130
- <div className="chat-column relative">
131
- {/* Plugin banner strip: above the input, in the chat's own composer.
132
- An empty slot renders nothing, so a Kabmo with no plugins keeps
133
- this dock byte-identical. */}
134
- <PluginComposerBanners />
135
- {showGeneratingIndicator && (
136
- <GeneratingIndicator
137
- modelName={modelName}
138
- generatingVerb={generatingVerb}
139
- provider={provider}
140
- providerNames={providerNames}
141
- {...(harness ? { harness } : {})}
142
- />
143
- )}
144
- <QueueList
145
- queue={messageQueue}
146
- onRemove={onRemoveQueueItem}
147
- onReorder={onReorderQueue}
148
- onEdit={onEditQueueItem}
149
- onSendNow={onSendNowQueueItem}
125
+ <ComposerDockFrame isMobile={isMobile}>
126
+ {/* Plugin banner strip: above the input, in the chat's own composer.
127
+ An empty slot renders nothing, so a Kabmo with no plugins keeps
128
+ this dock byte-identical. */}
129
+ <PluginComposerBanners />
130
+ {showGeneratingIndicator && (
131
+ <GeneratingIndicator
132
+ modelName={modelName}
133
+ generatingVerb={generatingVerb}
134
+ provider={provider}
135
+ providerNames={providerNames}
136
+ {...(harness ? { harness } : {})}
150
137
  />
151
- {btw.open ? (
152
- <BtwForm
153
- mode={btw}
154
- appSettings={appSettings}
155
- composerModelRef={composerModelRef}
156
- rootPath={rootPath}
157
- variant={variant}
158
- modelName={modelName}
159
- provider={provider}
160
- providerNames={providerNames}
161
- />
162
- ) : (
163
- <ChatInput
164
- value={inputValue}
165
- onChange={setInputValue}
166
- sessionId={sessionId}
167
- rootPath={rootPath}
168
- attachments={attachments}
169
- onAttachmentsChange={setAttachments}
170
- onSend={onSend}
171
- isGenerating={isGenerating}
172
- chatRunning={showGeneratingIndicator}
173
- onStop={onStop}
174
- appSettings={appSettings}
175
- onThinkingLevelChange={onThinkingLevelChange}
176
- onModelChange={onModelChange}
177
- accessMode={accessMode}
178
- onAccessModeChange={onAccessModeChange}
179
- modes={modes}
180
- composerModelRef={composerModelRef}
181
- deferredComposerPickRef={deferredComposerPickRef}
182
- sessionModel={sessionModel}
183
- sessionThinkingLevel={sessionThinkingLevel}
184
- harness={harness}
185
- harnessEditable={harnessEditable}
186
- onSelectHarness={onSelectHarness}
187
- variant={variant}
188
- expandable
189
- hero={hero}
190
- shrinkWhileReading={shrinkWhileReading}
191
- />
192
- )}
193
- </div>
194
- </div>
138
+ )}
139
+ <QueueList
140
+ queue={messageQueue}
141
+ onRemove={onRemoveQueueItem}
142
+ onReorder={onReorderQueue}
143
+ onEdit={onEditQueueItem}
144
+ onSendNow={onSendNowQueueItem}
145
+ />
146
+ {btw.open ? (
147
+ <BtwForm
148
+ mode={btw}
149
+ appSettings={appSettings}
150
+ composerModelRef={composerModelRef}
151
+ rootPath={rootPath}
152
+ variant={variant}
153
+ modelName={modelName}
154
+ provider={provider}
155
+ providerNames={providerNames}
156
+ />
157
+ ) : (
158
+ <ChatInput
159
+ value={inputValue}
160
+ onChange={setInputValue}
161
+ sessionId={sessionId}
162
+ rootPath={rootPath}
163
+ attachments={attachments}
164
+ onAttachmentsChange={setAttachments}
165
+ onSend={onSend}
166
+ isGenerating={isGenerating}
167
+ chatRunning={showGeneratingIndicator}
168
+ onStop={onStop}
169
+ appSettings={appSettings}
170
+ onThinkingLevelChange={onThinkingLevelChange}
171
+ onModelChange={onModelChange}
172
+ accessMode={accessMode}
173
+ onAccessModeChange={onAccessModeChange}
174
+ modes={modes}
175
+ composerModelRef={composerModelRef}
176
+ deferredComposerPickRef={deferredComposerPickRef}
177
+ sessionModel={sessionModel}
178
+ sessionThinkingLevel={sessionThinkingLevel}
179
+ harness={harness}
180
+ harnessEditable={harnessEditable}
181
+ onSelectHarness={onSelectHarness}
182
+ variant={variant}
183
+ expandable
184
+ hero={hero}
185
+ shrinkWhileReading={shrinkWhileReading}
186
+ />
187
+ )}
188
+ </ComposerDockFrame>
195
189
  );
196
190
  }
@@ -0,0 +1,35 @@
1
+ import type { ComponentChildren } from 'preact';
2
+
3
+ interface ComposerDockFrameProps {
4
+ isMobile: boolean;
5
+ children: ComponentChildren;
6
+ }
7
+
8
+ /**
9
+ * The dock's frame: the padding, the chat-column width and the phone's
10
+ * safe-area inset every "rows above the composer" stack shares.
11
+ *
12
+ * It exists because that dock is drawn in two places — the real timeline
13
+ * (`ComposerDock`) and the pending `new-…` chat, whose composer lives in
14
+ * `EmptyWorkspacePrompt` until the spawn adopts it. Spelled out separately, the
15
+ * two drifted: the pending view kept the landing page's `p-8` and its
16
+ * `space-y-3` stack, while the dock used `p-4 pt-1` with the rows flush. The
17
+ * generating indicator therefore sat **28px higher** while the spawn was in
18
+ * flight (`Loading…`, 141px above the pane's bottom) than once the run streamed
19
+ * (`Thinking…`, 113px) — the row jumped at the moment the chat was adopted, and
20
+ * the jump read as two different indicators.
21
+ *
22
+ * The `relative` belongs here: it keeps the queue/indicator stack anchored
23
+ * above the input while the side-question form takes the composer's place.
24
+ */
25
+ export function ComposerDockFrame({ isMobile, children }: ComposerDockFrameProps) {
26
+ return (
27
+ <div
28
+ data-composer-dock=""
29
+ className={`border-t-0 bg-transparent flex-shrink-0 ${isMobile ? 'px-3 pt-1' : 'p-4 pt-1'}`}
30
+ style={isMobile ? { paddingBottom: 'max(0.75rem, env(safe-area-inset-bottom, 0px))' } : undefined}
31
+ >
32
+ <div className="chat-column relative">{children}</div>
33
+ </div>
34
+ );
35
+ }
@@ -5,17 +5,16 @@ import type { Attachment, ChatMessageData, WorkspaceFolderData } from '@/shared/
5
5
  import { ChatInput } from '@/client/components/workspace/chat-timeline/chat-input/index';
6
6
  import { ChatMessageItem } from '@/client/components/workspace/chat-timeline/MessageItem';
7
7
  import { RunFooter } from '@/client/components/workspace/chat-timeline/RunFooter';
8
+ import { ComposerDockFrame } from '@/client/components/workspace/chat-timeline/ComposerDockFrame';
8
9
  import { GeneratingIndicator } from '@/client/components/workspace/chat-timeline/GeneratingIndicator';
9
10
  import { resolveRunFooters, streamingRowIndex } from '@/shared/lib/chat/timeline/run-footer';
10
11
  import type { ApprovalMode } from '@/shared/lib/omp/config/access-mode';
11
12
  import {
12
- WaitingDependencyPicker,
13
13
  waitingCandidates,
14
14
  type WaitingCandidate,
15
15
  } from '@/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker';
16
16
  import { Hourglass } from 'lucide-preact';
17
- import { WorkspacePicker } from '@/client/components/workspace/chat-timeline/target-picker/WorkspacePicker';
18
- import { WorktreePicker } from '@/client/components/workspace/chat-timeline/target-picker/WorktreePicker';
17
+ import { DraftTargetRow } from '@/client/components/workspace/chat-timeline/target-picker/DraftTargetRow';
19
18
  import type { SpawnTarget } from '@/client/hooks/chat/timeline/spawn-target';
20
19
 
21
20
  interface EmptyWorkspacePromptProps {
@@ -73,6 +72,12 @@ interface EmptyWorkspacePromptProps {
73
72
  */
74
73
  spawnTarget?: SpawnTarget | null;
75
74
  onSpawnTargetChange?: (next: SpawnTarget | null) => void;
75
+ /** The session this chat runs UNDER, or null for a top-level chat. */
76
+ parentSessionId?: string | null;
77
+ onParentSessionChange?: (sessionId: string | null) => void;
78
+ /** "Parent session" for a child, "Fork from" for a fork. */
79
+ branchLabel?: string;
80
+ branchAllowNone?: boolean;
76
81
  /** Reports a worktree the composer created or failed to create. */
77
82
  onWorktreeReport?: (message: string) => void;
78
83
  /** The "wait for session" pick, persisted per chat. */
@@ -125,6 +130,10 @@ export function EmptyWorkspacePrompt({
125
130
  titleForSession,
126
131
  spawnTarget = null,
127
132
  onSpawnTargetChange,
133
+ parentSessionId = null,
134
+ onParentSessionChange,
135
+ branchLabel,
136
+ branchAllowNone,
128
137
  onWorktreeReport,
129
138
  waitingFor = null,
130
139
  onWaitingForChange,
@@ -159,65 +168,81 @@ export function EmptyWorkspacePrompt({
159
168
  }
160
169
  }, [messages.length]);
161
170
 
171
+ const isMobile = variant === 'mobile';
172
+ // A chat with rows to show (or a prompt in flight) draws the SAME dock the
173
+ // real timeline does. It used to keep this page's centred `p-8` column and a
174
+ // `space-y-3` stack, so the generating indicator — and the composer under it
175
+ // — sat 28px higher while the spawn was in flight (`Loading…`, 141px from the
176
+ // pane's bottom) than once the run streamed in the real timeline
177
+ // (`Thinking…`, 113px). The row jumped at the moment the chat was adopted,
178
+ // which read as two different indicators.
179
+ const docked = messages.length > 0 || isGenerating;
180
+
181
+ const heldPrompt = heldWait ? (
182
+ <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">
183
+ <Hourglass size={12} className="shrink-0 animate-pulse text-ink/60" />
184
+ <span className="min-w-0 flex-1 truncate">
185
+ Waiting for {heldWait.title ?? 'another session'} to finish before this prompt is sent.
186
+ </span>
187
+ {onCancelWait && (
188
+ <button
189
+ type="button"
190
+ data-testid="cancel-held-prompt"
191
+ onClick={onCancelWait}
192
+ 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"
193
+ >
194
+ Cancel
195
+ </button>
196
+ )}
197
+ </div>
198
+ ) : null;
199
+
200
+ const composer = (
201
+ <ChatInput
202
+ value={inputValue}
203
+ onChange={setInputValue}
204
+ rootPath={rootPath}
205
+ attachments={inputAttachments}
206
+ onAttachmentsChange={setInputAttachments}
207
+ onSend={onSend}
208
+ isGenerating={isGenerating}
209
+ disabled={!selectedFolderId || Boolean(heldWait)}
210
+ className="w-full shrink-0"
211
+ appSettings={appSettings}
212
+ onThinkingLevelChange={onThinkingLevelChange}
213
+ onModelChange={onModelChange}
214
+ sessionModel={sessionModel}
215
+ sessionThinkingLevel={sessionThinkingLevel}
216
+ accessMode={accessMode}
217
+ onAccessModeChange={onAccessModeChange}
218
+ modes={modes}
219
+ composerModelRef={composerModelRef}
220
+ deferredComposerPickRef={deferredComposerPickRef}
221
+ {...(harness ? { harness } : {})}
222
+ harnessEditable={harnessEditable}
223
+ {...(onSelectHarness ? { onSelectHarness } : {})}
224
+ variant={variant}
225
+ expandable
226
+ // 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}
229
+ />
230
+ );
231
+
162
232
  return (
163
- <div className={`flex flex-col h-full bg-canvas ${variant === 'mobile' ? 'px-3 py-4' : 'p-8'} ${className}`}
164
- style={variant === 'mobile' ? { paddingBottom: 'max(1rem, env(safe-area-inset-bottom, 0px))' } : undefined}
233
+ <div
234
+ className={`flex flex-col h-full bg-canvas ${docked ? '' : isMobile ? 'px-3 py-4' : 'p-8'} ${className}`}
235
+ style={!docked && isMobile ? { paddingBottom: 'max(1rem, env(safe-area-inset-bottom, 0px))' } : undefined}
165
236
  >
166
- <div
167
- className={`chat-column flex flex-col min-h-0 space-y-3 ${
168
- messages.length > 0 ? 'flex-1' : 'my-auto justify-center'
169
- }`}
170
- >
171
- {/* Workspace Selection Seamless Dropdown (No border, transparent
172
- background). Hidden once a chat has been sent — the session now has
173
- a target workspace, so the composer is the only focus. */}
174
- {messages.length === 0 && (
175
- <div className="flex items-center gap-1 flex-wrap">
176
- {/* Two controls, because they answer two questions: the workspace
177
- (which project) and the worktree (which checkout of it). The
178
- worktree control draws itself only for a git repository, and it
179
- reads its list on mount because its own trigger names the branch
180
- the project root holds. */}
181
- <WorkspacePicker
182
- folders={folders as WorkspaceFolderData[]}
183
- selectedFolderId={selectedFolderId}
184
- setSelectedFolderId={setSelectedFolderId}
185
- onClearWorktree={() => onSpawnTargetChange?.(null)}
186
- />
187
- {onSpawnTargetChange && (
188
- <WorktreePicker
189
- folders={folders as WorkspaceFolderData[]}
190
- selectedFolderId={selectedFolderId}
191
- target={spawnTarget}
192
- setTarget={onSpawnTargetChange}
193
- onReport={onWorktreeReport}
194
- />
195
- )}
196
- {/* The wait picker sits BESIDE the workspace picker, because both
197
- answer the same question about the chat that has not started:
198
- where it runs, and what it waits for. It only appears while there
199
- is something to wait for (or a pick already made). */}
200
- {onWaitingForChange && (waitingFor || candidates.length > 0) && (
201
- <WaitingDependencyPicker
202
- folders={folders}
203
- streamStatusMap={streamStatusMap}
204
- sessionId={null}
205
- titleFor={titleForSession}
206
- value={waitingFor}
207
- onChange={onWaitingForChange}
208
- />
209
- )}
210
- </div>
211
- )}
212
-
213
- {/* Pending session timeline: optimistic bubbles render here immediately
214
- on send, then the real session (UUID) takes over the ChatTimeline.
215
- Only shown when there are messages so the empty composer stays
216
- centered next to the workspace picker. */}
217
- {messages.length > 0 && (
237
+ {docked ? (
238
+ <>
239
+ {/* The pending transcript reserves the box the real timeline's own
240
+ scroller does (`TimelineBody`), so adoption moves no text either. */}
218
241
  <div
219
242
  ref={timelineRef}
220
- className="flex-1 min-h-0 overflow-y-auto scroll-smooth overscroll-contain"
243
+ className={`flex-1 min-h-0 overflow-y-auto scroll-smooth overscroll-contain ${
244
+ isMobile ? 'pl-4 pr-3 py-3 pb-8' : 'p-4 pb-10'
245
+ }`}
221
246
  >
222
247
  <div className="chat-column">
223
248
  {messages.map((msg, idx) => {
@@ -232,7 +257,7 @@ export function EmptyWorkspacePrompt({
232
257
  isStreaming={isLoading}
233
258
  onUndo={onUndo}
234
259
  onNewChat={onNewChat}
235
- isMobile={variant === 'mobile'}
260
+ isMobile={isMobile}
236
261
  className={isAiFragment ? 'mt-1' : 'mt-8'}
237
262
  />
238
263
  {footer && (
@@ -256,71 +281,52 @@ export function EmptyWorkspacePrompt({
256
281
  })}
257
282
  </div>
258
283
  </div>
259
- )}
260
284
 
261
- {/* Docked above the input, mirroring chat-timeline/index.tsx so the
262
- indicator does not jump when a pending new chat adopts its omp
263
- session and the main timeline branch takes over rendering. */}
264
- {isGenerating && (
265
- <GeneratingIndicator
266
- modelName={modelName}
267
- generatingVerb={generatingVerb}
268
- provider={provider}
269
- providerNames={providerNames}
270
- {...(harness ? { harness } : {})}
271
- />
272
- )}
273
- {/* A held prompt owns this chat until it is released: there is no
274
- session to send a second prompt to, and a composer that looked live
275
- would accept one that could not be delivered. */}
276
- {heldWait && (
277
- <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">
278
- <Hourglass size={12} className="shrink-0 animate-pulse text-ink/60" />
279
- <span className="min-w-0 flex-1 truncate">
280
- Waiting for {heldWait.title ?? 'another session'} to finish before this prompt is sent.
281
- </span>
282
- {onCancelWait && (
283
- <button
284
- type="button"
285
- data-testid="cancel-held-prompt"
286
- onClick={onCancelWait}
287
- 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"
288
- >
289
- Cancel
290
- </button>
285
+ {/* One frame with the real dock (`ComposerDock`), so the indicator and
286
+ the composer cannot sit at two different heights. */}
287
+ <ComposerDockFrame isMobile={isMobile}>
288
+ {isGenerating && (
289
+ <GeneratingIndicator
290
+ modelName={modelName}
291
+ generatingVerb={generatingVerb}
292
+ provider={provider}
293
+ providerNames={providerNames}
294
+ {...(harness ? { harness } : {})}
295
+ />
291
296
  )}
292
- </div>
293
- )}
294
- <ChatInput
295
- value={inputValue}
296
- onChange={setInputValue}
297
- rootPath={rootPath}
298
- attachments={inputAttachments}
299
- onAttachmentsChange={setInputAttachments}
300
- onSend={onSend}
301
- isGenerating={isGenerating}
302
- disabled={!selectedFolderId || Boolean(heldWait)}
303
- className="w-full shrink-0"
304
- appSettings={appSettings}
305
- onThinkingLevelChange={onThinkingLevelChange}
306
- onModelChange={onModelChange}
307
- sessionModel={sessionModel}
308
- sessionThinkingLevel={sessionThinkingLevel}
309
- accessMode={accessMode}
310
- onAccessModeChange={onAccessModeChange}
311
- modes={modes}
312
- composerModelRef={composerModelRef}
313
- deferredComposerPickRef={deferredComposerPickRef}
314
- {...(harness ? { harness } : {})}
315
- harnessEditable={harnessEditable}
316
- {...(onSelectHarness ? { onSelectHarness } : {})}
317
- variant={variant}
318
- expandable
319
- // A brand-new chat has no turns: the `stage` composer style draws its
320
- // wider, taller card here and nowhere else.
321
- hero={messages.length === 0}
322
- />
323
- </div>
297
+ {heldPrompt}
298
+ {composer}
299
+ </ComposerDockFrame>
300
+ </>
301
+ ) : (
302
+ <div className="chat-column flex flex-col min-h-0 my-auto justify-center space-y-3">
303
+ {/* Workspace Selection Seamless Dropdown (No border, transparent
304
+ background). A chat with rows keeps its target and drops the
305
+ picker; this branch is only the chat that has not started. */}
306
+ <DraftTargetRow
307
+ folders={folders as WorkspaceFolderData[]}
308
+ selectedFolderId={selectedFolderId}
309
+ setSelectedFolderId={setSelectedFolderId}
310
+ spawnTarget={spawnTarget}
311
+ onSpawnTargetChange={onSpawnTargetChange}
312
+ onWorktreeReport={onWorktreeReport}
313
+ parentSessionId={parentSessionId}
314
+ onParentSessionChange={onParentSessionChange}
315
+ branchLabel={branchLabel}
316
+ branchAllowNone={branchAllowNone}
317
+ waitingFor={waitingFor}
318
+ onWaitingForChange={onWaitingForChange}
319
+ streamStatusMap={streamStatusMap}
320
+ titleForSession={titleForSession}
321
+ candidates={candidates}
322
+ />
323
+ {/* A held prompt owns this chat until it is released: there is no
324
+ session to send a second prompt to, and a composer that looked live
325
+ would accept one that could not be delivered. */}
326
+ {heldPrompt}
327
+ {composer}
328
+ </div>
329
+ )}
324
330
  </div>
325
331
  );
326
332
  }
@@ -1,7 +1,7 @@
1
1
  import type { TargetedMouseEvent } from 'preact';
2
2
  import { useMemo } from 'preact/hooks';
3
3
  import { memo } from 'preact/compat';
4
- import { AlertCircle, Bot, Info, MessageSquarePlus, Undo2, User } from 'lucide-preact';
4
+ import { AlertCircle, Bot, GitFork, Info, MessageSquarePlus, Undo2, User } from 'lucide-preact';
5
5
  import type { Attachment, ChatMessageData } from '@/shared/types';
6
6
  import { toAttachmentList } from '@/shared/lib/chat/attachments';
7
7
  import { ThinkingSection } from '@/client/components/workspace/chat-timeline/ThinkingSection';
@@ -29,6 +29,8 @@ interface ChatMessageItemProps {
29
29
  * it from the new chat.
30
30
  */
31
31
  onNewChat?: (content: string, attachments?: Attachment[]) => void;
32
+ /** Branch the chat before/at this row. Absent draws no button. */
33
+ onFork?: (msgId: string) => void;
32
34
 
33
35
  /** Extra classes on the root wrapper (e.g. spacing between messages). */
34
36
  className?: string;
@@ -52,6 +54,7 @@ export const ChatMessageItem = memo(function ChatMessageItem({
52
54
  isStreaming = false,
53
55
  onUndo,
54
56
  onNewChat,
57
+ onFork,
55
58
  className = '',
56
59
  isPrevAssistant = false,
57
60
  userActions = true,
@@ -155,6 +158,24 @@ export const ChatMessageItem = memo(function ChatMessageItem({
155
158
  emptyTitle="Nothing to copy — attachment-only prompt"
156
159
  />
157
160
 
161
+ {/* Fork Button — branches the session at this row, leaving the
162
+ source untouched. Separate from New Chat: a fork carries the
163
+ history, a new chat does not. */}
164
+ {userActions && onFork && (
165
+ <button
166
+ type="button"
167
+ className="flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer"
168
+ title="Fork from here"
169
+ aria-label="Fork this session from this message"
170
+ onClick={(e) => {
171
+ e.preventDefault();
172
+ onFork(msg.id);
173
+ }}
174
+ >
175
+ <GitFork size={12} />
176
+ </button>
177
+ )}
178
+
158
179
  {/* New Chat Button */}
159
180
  {userActions && (
160
181
  <button