@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,8 +1,10 @@
1
1
  import { ChevronDown, ChevronRight, GitBranch, MessageSquare, Plus } from 'lucide-preact';
2
2
  import { FolderItemMenu } from '@/client/components/mobile/mobile-session-sidebar/ItemMenu';
3
3
  import { useSearchParams } from '@/client/lib/router/search-params';
4
- import { MobileSessionRow } from '@/client/components/mobile/mobile-session-sidebar/SessionRow';
5
- import { SubagentList } from '@/client/components/common/subagent-list';
4
+ import { MobileSessionRow, MOBILE_BRANCH_STYLE } from '@/client/components/mobile/mobile-session-sidebar/SessionRow';
5
+ import { SessionBranch, branchControlFor } from '@/client/components/common/session-branch';
6
+ import type { BranchControl } from '@/client/components/common/session-branch';
7
+ import { buildSessionTree } from '@/client/lib/session-tree';
6
8
  import { useWorktreeDialog } from '@/client/components/mobile/mobile-session-sidebar/WorktreeDialog';
7
9
  import { useShowMore } from '@/client/hooks/ui/show-more';
8
10
  import { useExpandedSessions } from '@/client/hooks/workspace/expanded-sessions';
@@ -11,8 +13,9 @@ import { useSessionDelete } from '@/client/hooks/workspace/session-delete';
11
13
  import { SessionDeleteModal } from '@/client/components/common/session-delete-modal';
12
14
  import { getProjectIcon } from '@/shared/lib/workspace/project-icon';
13
15
  import { relativeTimeAgo } from '@/shared/lib/workspace/relative-time';
16
+ import { isPendingSessionId } from '@/shared/lib/omp/session/default-title';
14
17
  import { useSidebarData } from '@/client/hooks/chat/omp/session-list';
15
- import type { WorkspaceFolderData } from '@/shared/types';
18
+ import type { SessionItemData, WorkspaceFolderData } from '@/shared/types';
16
19
  import type { BatchBinding } from '@/client/components/common/batch-selection/types';
17
20
  import { folderBatchState } from '@/client/components/common/batch-selection/folder-state';
18
21
  import { SelectionCheckbox } from '@/client/components/common/batch-selection/SelectionCheckbox';
@@ -112,8 +115,51 @@ export function MobileSessionCategory({
112
115
  activeSessionId,
113
116
  sessionStatus,
114
117
  });
118
+ const tree = buildSessionTree(visibleSessions);
115
119
  const listOpen = isExpanded || sessionCheckboxes;
116
120
 
121
+ // Roots and descendants share this renderer, so the phone cannot draw a
122
+ // child session differently from the row it hangs under.
123
+ const renderSessionRow = (session: SessionItemData, control: BranchControl) => {
124
+ const sessionKey = String(session.id);
125
+ const isSessionActive = String(activeSessionId) === sessionKey;
126
+ // While one of its subagents is being viewed, the row dims so the
127
+ // highlighted leaf reads as the active one (desktop parity).
128
+ const isViewingSubagent = isSessionActive && urlSessionId === sessionKey && Boolean(urlSubagentId);
129
+ const pending = isPendingSessionId(sessionKey);
130
+ return (
131
+ <MobileSessionRow
132
+ session={session}
133
+ harness={session.harness}
134
+ folderId={session.folder_id}
135
+ isActive={isSessionActive && !isViewingSubagent}
136
+ status={sessionStatus[sessionKey]}
137
+ awaitingInput={Boolean(session.awaitingInput)}
138
+ timeAgo={relativeTimeAgo(session.updated_at ?? session.created_at)}
139
+ expandable={control.expandable} isChild={control.isChild}
140
+ isExpanded={control.isExpanded}
141
+ onToggleExpand={control.onToggleExpand}
142
+ onSelect={() => onSelectSession(session.id)}
143
+ onArchive={() => handleArchive(session)}
144
+ // A pending `new-…` chat has no transcript anywhere yet, so there is
145
+ // nothing to delete and nothing to rename from.
146
+ onDelete={pending ? undefined : () => sessionDelete.requestDelete(session)}
147
+ onRename={pending ? undefined : (name) => void handleRename(session, name)}
148
+ onRenameWithAi={pending ? undefined : () => void handleRenameWithAi(session)}
149
+ waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
150
+ onCancelWait={
151
+ session.waitingFor ? () => onCancelWait?.(session.waitingFor!.waitId) : undefined
152
+ }
153
+ selectable={sessionCheckboxes}
154
+ selected={Boolean(batch?.selected.includes(sessionKey))}
155
+ onToggleSelect={batch ? () => batch.toggle(sessionKey) : undefined}
156
+ />
157
+ );
158
+ };
159
+
160
+ const controlFor = (session: SessionItemData): BranchControl =>
161
+ branchControlFor(session, tree.childrenOf, expandedSessionIds, toggleSession);
162
+
117
163
  return (
118
164
  <div className={folderGroupGap(listOpen)} data-testid="session-folder">
119
165
  <div
@@ -224,56 +270,23 @@ export function MobileSessionCategory({
224
270
 
225
271
  {listOpen && (
226
272
  <div className="mt-0.5 space-y-0.5">
227
- {visibleSessions.map((session) => {
273
+ {tree.roots.map((session) => {
228
274
  const sessionKey = String(session.id);
229
- const isSessionActive = String(activeSessionId) === sessionKey;
230
- // While one of its subagents is being viewed, the parent session
231
- // row dims so the highlighted roster entry reads as the active one
232
- // (desktop parity).
233
- const isViewingSubagent = isSessionActive && urlSessionId === sessionKey && Boolean(urlSubagentId);
234
- // Same gate as desktop: the omp-side loader flag is authoritative,
235
- // so a session whose roster exists on disk can be opened without a
236
- // live process.
237
- const hasSubagents = Boolean(session.hasSubagents);
238
- const isRosterOpen = hasSubagents && expandedSessionIds.has(sessionKey);
239
-
275
+ const control = controlFor(session);
240
276
  return (
241
277
  <div key={session.id} className="space-y-0.5">
242
- <MobileSessionRow
243
- session={session}
244
- harness={session.harness}
245
- isActive={isSessionActive && !isViewingSubagent}
246
- status={sessionStatus[sessionKey]}
247
- awaitingInput={Boolean(session.awaitingInput)}
248
- timeAgo={relativeTimeAgo(session.updated_at ?? session.created_at)}
249
- hasSubagents={hasSubagents}
250
- isExpanded={isRosterOpen}
251
- onToggleExpand={() => toggleSession(sessionKey)}
252
- onSelect={() => onSelectSession(session.id)}
253
- onArchive={() => handleArchive(session)}
254
- onDelete={
255
- // A pending `new-…` chat has no transcript anywhere yet —
256
- // there is nothing to delete, and the server refuses it.
257
- sessionKey.startsWith('new-')
258
- ? undefined
259
- : () => sessionDelete.requestDelete(session)
260
- }
261
- onRename={sessionKey.startsWith('new-') ? undefined : (name) => void handleRename(session, name)}
262
- onRenameWithAi={
263
- sessionKey.startsWith('new-') ? undefined : () => void handleRenameWithAi(session)
264
- }
265
- waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
266
- onCancelWait={
267
- session.waitingFor
268
- ? () => onCancelWait?.(session.waitingFor!.waitId)
269
- : undefined
270
- }
271
- selectable={sessionCheckboxes}
272
- selected={Boolean(batch?.selected.includes(sessionKey))}
273
- onToggleSelect={batch ? () => batch.toggle(sessionKey) : undefined}
274
- />
275
- {isRosterOpen && (
276
- <SubagentList sessionId={session.id} isActiveSession={isSessionActive} />
278
+ {renderSessionRow(session, control)}
279
+ {control.isExpanded && (
280
+ <SessionBranch
281
+ parentId={sessionKey}
282
+ hasSubagents={Boolean(session.hasSubagents)}
283
+ childrenOf={tree.childrenOf}
284
+ expandedIds={expandedSessionIds}
285
+ onToggle={toggleSession}
286
+ activeSessionId={activeSessionId === null ? null : String(activeSessionId)}
287
+ renderSession={renderSessionRow}
288
+ style={MOBILE_BRANCH_STYLE}
289
+ />
277
290
  )}
278
291
  </div>
279
292
  );
@@ -89,6 +89,11 @@ describe('mobile session row status slot', () => {
89
89
  const slot = el.querySelector('span.w-4');
90
90
  expect(slot?.querySelector('svg')).toBeNull();
91
91
  });
92
+
93
+ test('a leaf child fills the empty slot with the child mark', async () => {
94
+ const el = await mount({ isChild: true });
95
+ expect(el.querySelector('[data-testid="child-indicator"] svg')).not.toBeNull();
96
+ });
92
97
  });
93
98
 
94
99
  /**
@@ -1,12 +1,23 @@
1
- import { Check, ChevronDown, ChevronRight, CircleQuestionMark, Hourglass, Loader2, MoreHorizontal } from 'lucide-preact';
1
+ import { Check, ChevronDown, ChevronRight, CircleQuestionMark, GitBranch, Hourglass, Loader2, MoreHorizontal } from 'lucide-preact';
2
2
  import type { SessionItemData } from '@/shared/types';
3
3
  import { useInlineRename } from '@/client/hooks/ui/inline-rename';
4
4
  import { useSessionRenaming } from '@/client/hooks/workspace/renaming-sessions';
5
5
  import { SessionActionsMenu, useRowMenu } from '@/client/components/common/session-actions-menu';
6
6
  import { SelectionCheckbox } from '@/client/components/common/batch-selection/SelectionCheckbox';
7
7
  import { HarnessGlyph, HARNESS_GLYPH_SIZE } from '@/client/components/common/harness-glyph';
8
+ import type { BranchRowStyle } from '@/client/components/common/session-branch/style';
8
9
  import { WorktreeBadge } from '@/client/components/layout/session-sidebar/WorktreeBadge';
9
10
 
11
+ /** What a subagent row under this chrome's rows borrows from it. */
12
+ export const MOBILE_BRANCH_STYLE: BranchRowStyle = {
13
+ inset: '',
14
+ insetPx: 0,
15
+ slotWidth: 16,
16
+ markGap: 8,
17
+ padding: 'py-2',
18
+ glyph: HARNESS_GLYPH_SIZE.touch,
19
+ };
20
+
10
21
  export interface MobileSessionRowProps {
11
22
  session: SessionItemData;
12
23
  /** Harness that ran this session (`omp-rpc`, `claude`, …). Absent draws no
@@ -18,10 +29,15 @@ export interface MobileSessionRowProps {
18
29
  awaitingInput?: boolean;
19
30
  /** Relative age of the session, or null when no usable timestamp exists. */
20
31
  timeAgo: string | null;
21
- /** The session has a subagent roster (on disk or live), so it can be expanded. */
22
- hasSubagents?: boolean;
32
+ /** The session has a branch (child sessions and/or a subagent roster). */
33
+ expandable?: boolean;
23
34
  isExpanded?: boolean;
24
35
  onToggleExpand?: () => void;
36
+ /** Drawn inside a parent's branch; a leaf child gets a child mark in its slot. */
37
+ isChild?: boolean;
38
+ /** The folder the row belongs to, so a child spawned from its menu lands in
39
+ * the right list before the server answers. */
40
+ folderId?: number | string;
25
41
  onSelect: () => void;
26
42
  onArchive: () => void;
27
43
  /** Omitted for a session that cannot be deleted yet (a pending `new-…` chat,
@@ -50,9 +66,11 @@ export function MobileSessionRow({
50
66
  status,
51
67
  awaitingInput = false,
52
68
  timeAgo,
53
- hasSubagents = false,
69
+ expandable = false,
54
70
  isExpanded = false,
55
71
  onToggleExpand,
72
+ isChild = false,
73
+ folderId,
56
74
  onSelect,
57
75
  onArchive,
58
76
  onDelete,
@@ -81,16 +99,16 @@ export function MobileSessionRow({
81
99
  const hasActions = Boolean(onRename || onArchive || onDelete || onCancelWait);
82
100
  const waiting = Boolean(waitingFor);
83
101
 
84
- // The roster toggle is the row's LAST element, so its glyph lands in the same
85
- // column as the folder header's expand chevron — one vertical line of
86
- // disclosure controls down the drawer. The toggle is a SIBLING of the select
102
+ // The branch chevron is the row's LAST element, so its glyph lands in the
103
+ // same column as the folder header's expand chevron — one vertical line of
104
+ // disclosure controls down the drawer. The chevron is a SIBLING of the select
87
105
  // button, never a child: a button inside a button is invalid and the browser
88
106
  // reparents it.
89
107
  //
90
108
  // Touch has no hover to reveal a hidden toggle the way desktop does, so it is
91
- // pinned whenever the row has a roster; a hidden one would leave the roster
92
- // unreachable on a phone.
93
- const showChevron = hasSubagents && Boolean(onToggleExpand);
109
+ // pinned whenever the row has a branch; a hidden one would leave child
110
+ // sessions and subagents unreachable on a phone.
111
+ const showChevron = expandable && Boolean(onToggleExpand);
94
112
  const title = session.title.charAt(0).toUpperCase() + session.title.slice(1);
95
113
 
96
114
  if (isEditing) {
@@ -171,6 +189,10 @@ export function MobileSessionRow({
171
189
  </span>
172
190
  ) : status ? (
173
191
  <Check size={13} className="text-ink/50" />
192
+ ) : isChild ? (
193
+ <span data-testid="child-indicator" className="text-ink/35" aria-hidden="true">
194
+ <GitBranch size={13} />
195
+ </span>
174
196
  ) : null}
175
197
  </span>
176
198
  )}
@@ -229,9 +251,9 @@ export function MobileSessionRow({
229
251
  <button
230
252
  type="button"
231
253
  onClick={onToggleExpand}
232
- title={isExpanded ? 'Collapse subagents' : 'Expand subagents'}
254
+ title={isExpanded ? 'Collapse sessions and subagents' : 'Expand sessions and subagents'}
233
255
  aria-expanded={isExpanded}
234
- aria-label={isExpanded ? 'Collapse subagents' : 'Expand subagents'}
256
+ aria-label={isExpanded ? 'Collapse sessions and subagents' : 'Expand sessions and subagents'}
235
257
  className="flex-shrink-0 py-1.5 pl-1.5 pr-1 flex items-center justify-center text-ink/50 hover:text-ink rounded-lg cursor-pointer"
236
258
  >
237
259
  {isExpanded ? <ChevronDown size={14} /> : <ChevronRight size={14} />}
@@ -242,6 +264,9 @@ export function MobileSessionRow({
242
264
  {menu.anchor && (
243
265
  <SessionActionsMenu
244
266
  anchor={menu.anchor}
267
+ sessionId={session.id}
268
+ {...(harness ? { harness } : {})}
269
+ {...(folderId !== undefined ? { folderId } : {})}
245
270
  isArchived={session.is_archived === 1}
246
271
  onRename={onRename ? startRename : undefined}
247
272
  onRenameWithAi={onRenameWithAi}
@@ -23,7 +23,7 @@ export const SETTINGS_CATEGORIES: CategoryDef[] = [
23
23
  // KABMO
24
24
  { id: 'appearance', label: 'Appearance', icon: Palette, section: 'KABMO', description: 'Custom themes, typography scale, and layout density.' },
25
25
  { id: 'chats', label: 'Chats', icon: MessageSquare, section: 'KABMO', description: 'Chat width, composer style, tool call rendering, session titles, goal mode, and keybindings.' },
26
- { id: 'notifications', label: 'Notifications', icon: Bell, section: 'KABMO', description: 'Build failure alerts, sounds, and system popups.' },
26
+ { id: 'notifications', label: 'Notifications', icon: Bell, section: 'KABMO', description: 'Completion sound, plus system notifications for finished, waiting-for-you and failed runs.' },
27
27
  { id: 'usage', label: 'Usage', icon: BarChart3, section: 'KABMO', description: 'Build minutes quota, storage, and general usage.' },
28
28
  { id: 'token-usage', label: 'Token Usage', icon: Coins, section: 'KABMO', description: 'Token telemetry, cache, and cost breakdown.' },
29
29
  { id: 'panel-plugins', label: 'Panel Plugins', icon: Puzzle, section: 'KABMO', description: 'Panels a plugin adds to Kabmo: right-panel views, navbar readouts and editor tabs.' },
@@ -0,0 +1,92 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The three system-notification preferences.
8
+ *
9
+ * They ship FALSE, and the UI is where that promise becomes a user-visible
10
+ * fact: a default of `true` would show three switches already on, and the first
11
+ * agent run would ask the OS for permission nobody chose. The toggle must also
12
+ * write ONE key — the settings modal persists the diff, so a handler that
13
+ * touched the others would republish values the user never changed.
14
+ */
15
+
16
+ import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
17
+ import { Window } from 'happy-dom';
18
+ import { h, render } from 'preact';
19
+ import { act } from 'preact/test-utils';
20
+
21
+ import { NotificationSettings } from '@/client/components/settings/categories/NotificationSettings';
22
+ import { DEFAULT_SETTINGS } from '@/shared/lib/settings/defaults';
23
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
24
+ import type { SettingsState } from '@/shared/types';
25
+
26
+ let container: HTMLElement | undefined;
27
+
28
+ beforeAll(() => {
29
+ installDomGlobals(new Window({ url: 'http://localhost' }));
30
+ });
31
+
32
+ afterEach(() => {
33
+ if (container) {
34
+ render(null, container);
35
+ container.remove();
36
+ container = undefined;
37
+ }
38
+ });
39
+
40
+ afterAll(() => {
41
+ restoreDomGlobals();
42
+ });
43
+
44
+ type Updater = Partial<SettingsState> | ((prev: SettingsState) => SettingsState);
45
+
46
+ function mount(onUpdate: (updater: Updater) => void): HTMLElement {
47
+ const host = document.createElement('div');
48
+ container = host;
49
+ document.body.append(host);
50
+ act(() => {
51
+ render(h(NotificationSettings, { settings: { ...DEFAULT_SETTINGS }, onUpdate }), host);
52
+ });
53
+ return host;
54
+ }
55
+
56
+ function switches(): HTMLElement[] {
57
+ return [...document.querySelectorAll('[role="switch"]')] as HTMLElement[];
58
+ }
59
+
60
+ describe('NotificationSettings', () => {
61
+ test('the three system toggles are off on a fresh install', () => {
62
+ mount(() => {});
63
+ // The sound switch is first and keeps its shipped-on default; the three
64
+ // system preferences follow it.
65
+ const system = switches().slice(1);
66
+ expect(system).toHaveLength(3);
67
+ for (const toggle of system) expect(toggle.getAttribute('aria-checked')).toBe('false');
68
+ });
69
+
70
+ test('turning Run finished on writes only that key', () => {
71
+ const updates: Updater[] = [];
72
+ mount((update) => updates.push(update));
73
+ const finish = switches().find((toggle) => toggle.getAttribute('aria-label')?.includes('Run finished'));
74
+ expect(finish).toBeDefined();
75
+
76
+ act(() => {
77
+ finish?.click();
78
+ });
79
+ expect(updates).toEqual([{ notifyOnFinish: true }]);
80
+ });
81
+
82
+ test('turning Waiting for you on writes its own key', () => {
83
+ const updates: Updater[] = [];
84
+ mount((update) => updates.push(update));
85
+ const ask = switches().find((toggle) => toggle.getAttribute('aria-label')?.includes('Waiting for you'));
86
+
87
+ act(() => {
88
+ ask?.click();
89
+ });
90
+ expect(updates).toEqual([{ notifyOnAsk: true }]);
91
+ });
92
+ });
@@ -1,13 +1,64 @@
1
- import { useState } from 'preact/hooks';
2
- import { Sparkles, Volume2, VolumeX } from 'lucide-preact';
1
+ import { useEffect, useState } from 'preact/hooks';
2
+ import {
3
+ BellRing,
4
+ CircleCheck,
5
+ CircleQuestionMark,
6
+ Sparkles,
7
+ TriangleAlert,
8
+ Volume2,
9
+ VolumeX,
10
+ } from 'lucide-preact';
3
11
  import type { SettingsState } from '@/shared/types';
4
12
  import { playNotificationSound } from '@/client/hooks/ui/notification-sound';
13
+ import { requestNotificationPermission } from '@/client/lib/notifications/os';
5
14
 
6
15
  interface NotificationSettingsProps {
7
16
  settings: SettingsState;
8
17
  onUpdate: (updater: Partial<SettingsState> | ((prev: SettingsState) => SettingsState)) => void;
9
18
  }
10
19
 
20
+ interface SystemToggleProps {
21
+ icon: typeof BellRing;
22
+ title: string;
23
+ description: string;
24
+ enabled: boolean;
25
+ onToggle: () => void;
26
+ }
27
+
28
+ function SystemToggle({ icon: Icon, title, description, enabled, onToggle }: SystemToggleProps) {
29
+ return (
30
+ <div className="flex items-start justify-between gap-4 py-3">
31
+ <div className="flex items-start gap-3">
32
+ <div className="w-8 h-8 rounded-md bg-ink/5 border border-ink/10 flex items-center justify-center flex-shrink-0 mt-0.5">
33
+ <Icon size={16} className={enabled ? 'text-ink' : 'text-ink/40'} />
34
+ </div>
35
+ <div>
36
+ <div className="text-sm font-semibold text-ink">{title}</div>
37
+ <p className="text-ink/65 text-[11px] mt-1 leading-relaxed">{description}</p>
38
+ </div>
39
+ </div>
40
+
41
+ <button
42
+ type="button"
43
+ role="switch"
44
+ aria-checked={enabled}
45
+ aria-label={`${enabled ? 'Disable' : 'Enable'} ${title}`}
46
+ onClick={onToggle}
47
+ className={`relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${
48
+ enabled ? 'bg-ink' : 'bg-ink/20'
49
+ }`}
50
+ >
51
+ <span
52
+ aria-hidden="true"
53
+ className={`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-paper shadow ring-0 transition duration-200 ease-in-out ${
54
+ enabled ? 'translate-x-5' : 'translate-x-0'
55
+ }`}
56
+ />
57
+ </button>
58
+ </div>
59
+ );
60
+ }
61
+
11
62
  export function NotificationSettings({ settings, onUpdate }: NotificationSettingsProps) {
12
63
  const [isPlayingTest, setIsPlayingTest] = useState(false);
13
64
 
@@ -18,6 +69,24 @@ export function NotificationSettings({ settings, onUpdate }: NotificationSetting
18
69
  };
19
70
 
20
71
  const isSoundEnabled = settings.chatCompletionSound ?? settings.soundAlerts ?? true;
72
+ const anySystemNotification = settings.notifyOnFinish === true
73
+ || settings.notifyOnAsk === true
74
+ || settings.notifyOnError === true;
75
+
76
+ // A preference can be turned on in another tab, a browser, or before this
77
+ // shell was installed — and the OS permission belongs to THIS shell. Opening
78
+ // the page that owns the preference is the honest moment to ask, and the
79
+ // shell answers immediately when permission is already granted.
80
+ useEffect(() => {
81
+ if (anySystemNotification) void requestNotificationPermission();
82
+ }, [anySystemNotification]);
83
+
84
+ // Turning one of these on asks for permission immediately, so the toggle can
85
+ // never read "on" without the shell having had its chance to prompt.
86
+ const setSystemNotification = (key: 'notifyOnFinish' | 'notifyOnAsk' | 'notifyOnError', next: boolean) => {
87
+ onUpdate({ [key]: next });
88
+ if (next) void requestNotificationPermission();
89
+ };
21
90
 
22
91
  return (
23
92
  <div className="w-full space-y-6 text-xs text-ink">
@@ -92,6 +161,47 @@ export function NotificationSettings({ settings, onUpdate }: NotificationSetting
92
161
  </button>
93
162
  </div>
94
163
  </div>
164
+
165
+ {/* System Notifications */}
166
+ <div className="bg-paper border border-ink/15 rounded-lg p-4 shadow-xs">
167
+ <div className="flex items-start gap-3 pb-3 border-b border-ink/10">
168
+ <div className="w-8 h-8 rounded-md bg-ink/5 border border-ink/10 flex items-center justify-center flex-shrink-0 mt-0.5">
169
+ <BellRing size={16} className="text-ink" />
170
+ </div>
171
+ <div>
172
+ <div className="text-sm font-semibold text-ink">System Notifications</div>
173
+ <p className="text-ink/65 text-[11px] mt-1 leading-relaxed">
174
+ Shown by Android, iOS and the desktop shell — and by the browser outside a shell — only
175
+ while Kabmo is not the window you are looking at. Clicking one opens that session.
176
+ The sidebar badge stays the in-app record either way.
177
+ </p>
178
+ </div>
179
+ </div>
180
+
181
+ <div className="divide-y divide-ink/10">
182
+ <SystemToggle
183
+ icon={CircleCheck}
184
+ title="Run finished"
185
+ description="A session's agent finished its turn."
186
+ enabled={settings.notifyOnFinish === true}
187
+ onToggle={() => setSystemNotification('notifyOnFinish', settings.notifyOnFinish !== true)}
188
+ />
189
+ <SystemToggle
190
+ icon={CircleQuestionMark}
191
+ title="Waiting for you"
192
+ description="An agent is blocked on a question or an approval."
193
+ enabled={settings.notifyOnAsk === true}
194
+ onToggle={() => setSystemNotification('notifyOnAsk', settings.notifyOnAsk !== true)}
195
+ />
196
+ <SystemToggle
197
+ icon={TriangleAlert}
198
+ title="Run failed"
199
+ description="A run ended in failure, with the reason when the agent reported one."
200
+ enabled={settings.notifyOnError === true}
201
+ onToggle={() => setSystemNotification('notifyOnError', settings.notifyOnError !== true)}
202
+ />
203
+ </div>
204
+ </div>
95
205
  </div>
96
206
  );
97
207
  }
@@ -193,7 +193,7 @@ export function HarnessCard({
193
193
  <div className="grid gap-x-6 sm:grid-cols-2">
194
194
  <div>
195
195
  <div className="mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink/40">Session</div>
196
- <Capability label="Load / resume history" value={caps ? caps.loadSession : null} />
196
+ <Capability label="Load / resume history" value={caps ? caps.loadSession || caps.resumeSession : null} />
197
197
  <Capability label="List sessions" value={caps ? caps.listSessions : null} />
198
198
  <Capability label="Fork" value={caps ? caps.forkSession : null} />
199
199
  <Capability label="Delete" value={caps ? caps.deleteSession : null} />
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The assistant run footer's Fork action.
8
+ *
9
+ * The footer already carries a `msgId`, but it is the run's OPENING user row
10
+ * (Retry rewinds there). Forking at that anchor branches BEFORE the answer the
11
+ * button sits under, so the footer's fork has to use the run's owner row. These
12
+ * pin the anchor on both the desktop strip and the phone sheet — the same
13
+ * handler feeds both, and a future call site that passes only `msgId` must not
14
+ * silently fork at the wrong place.
15
+ */
16
+
17
+ import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
18
+ import { Window } from 'happy-dom';
19
+ import { h, render } from 'preact';
20
+ import { act } from 'preact/test-utils';
21
+
22
+ import { RunFooter } from '@/client/components/workspace/chat-timeline/RunFooter';
23
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
24
+ import type { ChatMessageData } from '@/shared/types';
25
+
26
+ let container: HTMLElement;
27
+
28
+ beforeEach(() => {
29
+ installDomGlobals(new Window({ url: 'http://localhost' }));
30
+ container = document.body.appendChild(document.createElement('div'));
31
+ });
32
+
33
+ afterEach(() => {
34
+ render(null, container);
35
+ container.remove();
36
+ });
37
+
38
+ afterAll(() => restoreDomGlobals());
39
+
40
+ function mount(node: preact.ComponentChild): HTMLElement {
41
+ act(() => {
42
+ render(node, container);
43
+ });
44
+ return container;
45
+ }
46
+
47
+ const answerRow: ChatMessageData = {
48
+ id: 'ai-7',
49
+ role: 'ai',
50
+ content: 'the answer',
51
+ model: 'gpt-5',
52
+ provider: 'openai',
53
+ };
54
+
55
+ describe('assistant footer fork', () => {
56
+ test('desktop forks at the run owner row, not the Retry anchor', () => {
57
+ const calls: string[] = [];
58
+ const el = mount(h(RunFooter, {
59
+ msg: answerRow,
60
+ retryTargetId: 'user-3',
61
+ onFork: (id) => calls.push(id),
62
+ }));
63
+
64
+ const fork = el.querySelector('button[aria-label="Fork session from this answer"]') as HTMLButtonElement | null;
65
+ expect(fork).not.toBeNull();
66
+ act(() => fork!.click());
67
+
68
+ expect(calls).toEqual(['ai-7']);
69
+ });
70
+
71
+ test('the phone sheet offers the same fork action', () => {
72
+ const calls: string[] = [];
73
+ const el = mount(h(RunFooter, {
74
+ msg: answerRow,
75
+ retryTargetId: 'user-3',
76
+ isMobile: true,
77
+ onFork: (id) => calls.push(id),
78
+ }));
79
+
80
+ act(() => {
81
+ (el.querySelector('button[aria-label="More actions"]') as HTMLButtonElement).click();
82
+ });
83
+ const fork = el.querySelector('button[aria-label="Fork session from this answer"]') as HTMLButtonElement | null;
84
+ expect(fork).not.toBeNull();
85
+ act(() => fork!.click());
86
+
87
+ expect(calls).toEqual(['ai-7']);
88
+ });
89
+
90
+ test('no onFork keeps the strip unchanged', () => {
91
+ const el = mount(h(RunFooter, { msg: answerRow, retryTargetId: 'user-3' }));
92
+ expect(el.querySelector('button[aria-label="Fork session from this answer"]')).toBeNull();
93
+ });
94
+ });