@kabmo-labs/kabmo 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (354) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +502 -474
  3. package/dist/client/static/js/index-81f7berm.css +1 -0
  4. package/dist/client/static/js/{index-95b3n20k.js → index-xzvyrxya.js} +799 -799
  5. package/marketplace/plugins/command-runner/package.json +3 -17
  6. package/marketplace/plugins/command-runner/settings-schema.json +14 -0
  7. package/marketplace/plugins/git-forge/README.md +17 -7
  8. package/marketplace/plugins/git-forge/package.json +4 -30
  9. package/marketplace/plugins/git-forge/panel.css +16 -0
  10. package/marketplace/plugins/git-forge/settings-schema.json +27 -0
  11. package/marketplace/plugins/git-forge/src/panel/Badge.tsx +35 -22
  12. package/marketplace/plugins/git-forge/src/panel/Change.tsx +20 -24
  13. package/marketplace/plugins/git-forge/src/panel/CiBadge.tsx +16 -7
  14. package/marketplace/plugins/git-forge/src/panel/Credential.tsx +31 -26
  15. package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +18 -2
  16. package/marketplace/plugins/git-forge/src/panel/Header.tsx +160 -96
  17. package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +60 -44
  18. package/marketplace/plugins/git-forge/src/panel/List.tsx +150 -22
  19. package/marketplace/plugins/git-forge/src/panel/Row.tsx +11 -5
  20. package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +17 -15
  21. package/marketplace/plugins/git-forge/src/panel/Write.tsx +84 -61
  22. package/marketplace/plugins/git-forge/src/panel/format.test.ts +99 -0
  23. package/marketplace/plugins/git-forge/src/panel/format.ts +59 -16
  24. package/marketplace/plugins/git-forge/src/panel/index.test.tsx +109 -5
  25. package/marketplace/plugins/git-forge/src/panel/index.tsx +37 -4
  26. package/marketplace/plugins/git-forge/src/panel/use-forge.ts +17 -0
  27. package/marketplace/plugins/git-forge/src/panel/write.test.tsx +31 -0
  28. package/marketplace/plugins/session-info/package.json +2 -10
  29. package/marketplace/plugins/session-info/settings-schema.json +8 -0
  30. package/marketplace/plugins/stats/README.md +17 -5
  31. package/marketplace/plugins/stats/package.json +3 -23
  32. package/marketplace/plugins/stats/settings-schema.json +20 -0
  33. package/marketplace/plugins/stats/src/app.tsx +1 -1
  34. package/marketplace/plugins/stats/src/groups.test.ts +46 -1
  35. package/marketplace/plugins/stats/src/groups.ts +22 -11
  36. package/marketplace/plugins/stats/src/harness-leases.test.ts +84 -0
  37. package/marketplace/plugins/stats/src/harness-leases.ts +132 -0
  38. package/marketplace/plugins/stats/src/labels.test.ts +54 -1
  39. package/marketplace/plugins/stats/src/labels.ts +33 -7
  40. package/marketplace/plugins/stats/src/sampler.test.ts +61 -0
  41. package/marketplace/plugins/stats/src/sampler.ts +39 -5
  42. package/marketplace/plugins/stats/src/snapshot.ts +6 -0
  43. package/package.json +2 -2
  44. package/src/client/components/common/Toast.test.tsx +28 -2
  45. package/src/client/components/common/Toast.tsx +21 -9
  46. package/src/client/components/common/harness-glyph/index.tsx +18 -1
  47. package/src/client/components/common/session-actions-menu/index.test.tsx +106 -0
  48. package/src/client/components/common/session-actions-menu/index.tsx +43 -1
  49. package/src/client/components/common/session-row/TrailingSlot.tsx +9 -4
  50. package/src/client/components/common/session-row/index.tsx +4 -0
  51. package/src/client/components/common/session-row/session-row.test.tsx +6 -0
  52. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +2 -1
  53. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +4 -2
  54. package/src/client/components/layout/session-sidebar/SessionItem.tsx +9 -1
  55. package/src/client/components/layout/session-sidebar/SessionList.tsx +2 -1
  56. package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +3 -2
  57. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +2 -1
  58. package/src/client/components/layout/session-sidebar/modern/RevealRow.tsx +56 -0
  59. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +12 -29
  60. package/src/client/components/layout/session-sidebar/modern/reveal-row.test.tsx +104 -0
  61. package/src/client/components/layout/session-sidebar/scheduler-modal/ModelFields.tsx +202 -0
  62. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +80 -19
  63. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +23 -3
  64. package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +5 -1
  65. package/src/client/components/layout/session-sidebar/variant-props.ts +2 -1
  66. package/src/client/components/mobile/SessionSidebar.tsx +2 -1
  67. package/src/client/components/mobile/mobile-right-sidebar/EditorSurface.tsx +156 -0
  68. package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +41 -86
  69. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +2 -1
  70. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +4 -2
  71. package/src/client/components/mobile/mobile-session-sidebar/List.tsx +2 -1
  72. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +6 -0
  73. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +9 -1
  74. package/src/client/components/settings/Modal.tsx +7 -3
  75. package/src/client/components/settings/Sidebar.tsx +30 -3
  76. package/src/client/components/settings/categories/HarnessSettings.tsx +11 -7
  77. package/src/client/components/settings/categories/NotificationSettings.test.tsx +40 -15
  78. package/src/client/components/settings/categories/NotificationSettings.tsx +142 -64
  79. package/src/client/components/settings/categories/PanelPluginSettings.tsx +1 -1
  80. package/src/client/components/settings/categories/harness-settings/CustomHarnessForm.tsx +186 -0
  81. package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +11 -0
  82. package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +1 -0
  83. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +15 -1
  84. package/src/client/components/settings/categories/panel-plugins/SettingsModal.test.tsx +165 -0
  85. package/src/client/components/settings/categories/panel-plugins/SettingsModal.tsx +260 -0
  86. package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
  87. package/src/client/components/settings/categories/usage-settings/LimitsSection.tsx +39 -19
  88. package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +1 -0
  89. package/src/client/components/settings/categories/usage-settings/limit-groups.test.ts +94 -0
  90. package/src/client/components/settings/categories/usage-settings/limit-groups.ts +118 -0
  91. package/src/client/components/settings/categories/usage-settings/limits-section.test.tsx +118 -0
  92. package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +24 -0
  93. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +8 -4
  94. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +34 -0
  95. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +61 -56
  96. package/src/client/components/workspace/chat-timeline/MessageItem.fork.test.ts +80 -0
  97. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +9 -3
  98. package/src/client/components/workspace/chat-timeline/MessageList.tsx +3 -1
  99. package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +11 -1
  100. package/src/client/components/workspace/chat-timeline/PendingTranscript.tsx +130 -0
  101. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +2 -1
  102. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +2 -1
  103. package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +8 -0
  104. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +9 -0
  105. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +4 -1
  106. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +24 -0
  107. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +13 -20
  108. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +2 -0
  109. package/src/client/components/workspace/chat-timeline/chat-input/props.ts +5 -5
  110. package/src/client/components/workspace/chat-timeline/fork-preview.test.tsx +141 -0
  111. package/src/client/components/workspace/chat-timeline/index.tsx +17 -6
  112. package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +3 -10
  113. package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.test.tsx +101 -0
  114. package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +2 -2
  115. package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +5 -4
  116. package/src/client/components/workspace/editor/FilePane.tsx +9 -4
  117. package/src/client/components/workspace/editor/Notices.tsx +2 -2
  118. package/src/client/components/workspace/editor/Pane.tsx +2 -2
  119. package/src/client/components/workspace/editor/Toolbar.tsx +16 -10
  120. package/src/client/components/workspace/editor/index.tsx +6 -10
  121. package/src/client/components/workspace/editor/toolbar-clusters.test.ts +4 -3
  122. package/src/client/components/workspace/editor/toolbar-clusters.tsx +23 -14
  123. package/src/client/components/workspace/git-panel/index.tsx +2 -2
  124. package/src/client/components/workspace/terminal-panel/RealtimeTerminalView.tsx +17 -6
  125. package/src/client/components/workspace/terminal-panel/focus.test.ts +70 -0
  126. package/src/client/components/workspace/terminal-panel/focus.ts +46 -0
  127. package/src/client/components/workspace/terminal-panel/index.tsx +17 -1
  128. package/src/client/components/workspace/terminal-panel/mount.ts +17 -9
  129. package/src/client/components/workspace/terminal-panel/scroll-hold.test.ts +158 -0
  130. package/src/client/components/workspace/terminal-panel/scroll-hold.ts +136 -0
  131. package/src/client/hooks/chat/composer/use-draft.ts +45 -1
  132. package/src/client/hooks/chat/omp/pending-sessions.waiting.test.ts +11 -10
  133. package/src/client/hooks/chat/omp/pending-waiting.ts +15 -7
  134. package/src/client/hooks/chat/omp/prompt-send.test.ts +11 -0
  135. package/src/client/hooks/chat/omp/prompt-send.ts +3 -0
  136. package/src/client/hooks/chat/omp/session-list.tsx +5 -0
  137. package/src/client/hooks/chat/omp/sidebar-reload.test.ts +85 -0
  138. package/src/client/hooks/chat/omp/sidebar-reload.ts +30 -0
  139. package/src/client/hooks/chat/timeline/actions.ts +4 -4
  140. package/src/client/hooks/chat/timeline/composer-modes.ts +13 -2
  141. package/src/client/hooks/chat/timeline/fork-open.ts +52 -0
  142. package/src/client/hooks/chat/timeline/fork-preview.test.ts +148 -0
  143. package/src/client/hooks/chat/timeline/fork-preview.ts +104 -0
  144. package/src/client/hooks/chat/timeline/fork-send.test.ts +139 -0
  145. package/src/client/hooks/chat/timeline/index.ts +5 -2
  146. package/src/client/hooks/chat/timeline/mode-availability.ts +7 -0
  147. package/src/client/hooks/chat/timeline/modes-contract.ts +6 -0
  148. package/src/client/hooks/chat/timeline/modes-hydrate.ts +93 -0
  149. package/src/client/hooks/chat/timeline/modes.ts +32 -52
  150. package/src/client/hooks/chat/timeline/new-chat-open.ts +7 -6
  151. package/src/client/hooks/chat/timeline/new-chat.ts +10 -1
  152. package/src/client/hooks/chat/timeline/pending-branch.ts +9 -0
  153. package/src/client/hooks/chat/timeline/pending-dispatch.ts +53 -0
  154. package/src/client/hooks/chat/timeline/pending-session-mode.test.ts +136 -0
  155. package/src/client/hooks/chat/timeline/pending-session-mode.ts +69 -0
  156. package/src/client/hooks/chat/timeline/pending-warmup.test.ts +147 -0
  157. package/src/client/hooks/chat/timeline/pending-warmup.ts +62 -0
  158. package/src/client/hooks/chat/timeline/run-identity.test.ts +12 -0
  159. package/src/client/hooks/chat/timeline/run-identity.ts +4 -1
  160. package/src/client/hooks/chat/timeline/send-props.ts +2 -0
  161. package/src/client/hooks/chat/timeline/send-steer.test.ts +1 -0
  162. package/src/client/hooks/chat/timeline/send.test-util.ts +1 -0
  163. package/src/client/hooks/chat/timeline/send.test.ts +1 -0
  164. package/src/client/hooks/chat/timeline/session-harness.ts +4 -0
  165. package/src/client/hooks/chat/timeline/stop-with-queue.ts +1 -1
  166. package/src/client/hooks/chat/timeline/use-fork-session.ts +9 -22
  167. package/src/client/hooks/chat/waiting/cancel.ts +15 -7
  168. package/src/client/hooks/chat/waiting/choice.ts +13 -16
  169. package/src/client/hooks/chat/waiting/composer-wait.ts +70 -0
  170. package/src/client/hooks/chat/waiting/dispatch.ts +50 -29
  171. package/src/client/hooks/chat/waiting/held.ts +38 -13
  172. package/src/client/hooks/chat/waiting/hold.test.ts +22 -0
  173. package/src/client/hooks/chat/waiting/hold.ts +20 -11
  174. package/src/client/hooks/chat/waiting/restore.test.ts +69 -0
  175. package/src/client/hooks/chat/waiting/restore.ts +34 -0
  176. package/src/client/hooks/chat/waiting/store.ts +9 -3
  177. package/src/client/hooks/editor/file-editor-types.ts +21 -12
  178. package/src/client/hooks/editor/save-file.test.ts +1 -1
  179. package/src/client/hooks/editor/save-file.ts +35 -8
  180. package/src/client/hooks/editor/target-key.ts +17 -0
  181. package/src/client/hooks/editor/use-disk-digest.test.ts +82 -0
  182. package/src/client/hooks/editor/use-disk-digest.ts +164 -0
  183. package/src/client/hooks/editor/use-disk-sync.ts +212 -0
  184. package/src/client/hooks/editor/use-file-cache.ts +113 -0
  185. package/src/client/hooks/editor/use-file-editor.test.ts +90 -0
  186. package/src/client/hooks/editor/use-file-editor.ts +90 -52
  187. package/src/client/hooks/editor/use-file-read.ts +24 -10
  188. package/src/client/hooks/editor/use-file-writes.ts +4 -4
  189. package/src/client/hooks/models/harness-catalog.ts +15 -0
  190. package/src/client/hooks/settings/providers/actions.ts +3 -2
  191. package/src/client/hooks/settings/providers/messages.ts +9 -7
  192. package/src/client/hooks/settings/providers/model-actions.ts +2 -1
  193. package/src/client/hooks/ui/editor-error-toast.ts +2 -1
  194. package/src/client/hooks/ui/notifications.ts +17 -8
  195. package/src/client/hooks/workspace/batch-archive.test.ts +2 -2
  196. package/src/client/hooks/workspace/batch-archive.ts +4 -2
  197. package/src/client/hooks/workspace/git-action-outcome.ts +4 -3
  198. package/src/client/hooks/workspace/navbar-session-actions.ts +2 -1
  199. package/src/client/hooks/workspace/panel-registry.ts +1 -1
  200. package/src/client/hooks/workspace/scheduled-tasks.ts +26 -11
  201. package/src/client/hooks/workspace/session-actions.test.ts +2 -1
  202. package/src/client/hooks/workspace/session-actions.ts +2 -1
  203. package/src/client/hooks/workspace/terminal/connection.test.ts +63 -0
  204. package/src/client/hooks/workspace/terminal/connection.ts +47 -0
  205. package/src/client/hooks/workspace/terminal/index.ts +35 -4
  206. package/src/client/hooks/workspace/workspace-folder-actions.ts +2 -1
  207. package/src/client/lib/notifications/os.test.ts +1 -30
  208. package/src/client/lib/notifications/os.ts +0 -15
  209. package/src/client/lib/notifications/platform.test.ts +68 -0
  210. package/src/client/lib/notifications/platform.ts +36 -0
  211. package/src/server/index.ts +7 -0
  212. package/src/server/lib/harness/acp/client.ts +81 -87
  213. package/src/server/lib/harness/acp/prewarm.server.ts +237 -0
  214. package/src/server/lib/harness/acp/prewarm.test.ts +171 -0
  215. package/src/server/lib/harness/acp/prompt.test.ts +70 -1
  216. package/src/server/lib/harness/acp/prompt.ts +32 -1
  217. package/src/server/lib/harness/acp/protocol.ts +23 -0
  218. package/src/server/lib/harness/acp/session-handshake.test.ts +26 -0
  219. package/src/server/lib/harness/acp/session-handshake.ts +22 -20
  220. package/src/server/lib/harness/acp/session-options.ts +16 -0
  221. package/src/server/lib/harness/acp/session-process.ts +43 -0
  222. package/src/server/lib/harness/acp/session.ts +11 -12
  223. package/src/server/lib/harness/acp/stdio.ts +129 -0
  224. package/src/server/lib/harness/acp/verbs.test.ts +97 -0
  225. package/src/server/lib/harness/acp/verbs.ts +16 -6
  226. package/src/server/lib/harness/auto-probe.server.ts +4 -3
  227. package/src/server/lib/harness/capabilities.ts +8 -0
  228. package/src/server/lib/harness/config.server.ts +3 -2
  229. package/src/server/lib/harness/custom.server.ts +209 -0
  230. package/src/server/lib/harness/launch.ts +6 -1
  231. package/src/server/lib/harness/register.server.ts +8 -1
  232. package/src/server/lib/harness/schema.server.ts +21 -0
  233. package/src/server/lib/harness/session-lease.server.test.ts +99 -0
  234. package/src/server/lib/harness/session-lease.server.ts +193 -0
  235. package/src/server/lib/harness/session-store.server.test.ts +8 -8
  236. package/src/server/lib/harness/session-store.server.ts +25 -4
  237. package/src/server/lib/harness/session-title.server.ts +12 -2
  238. package/src/server/lib/harness/spawn.server.ts +123 -20
  239. package/src/server/lib/harness/update-queue.server.ts +3 -3
  240. package/src/server/lib/lifecycle/after-listen.ts +12 -1
  241. package/src/server/lib/lifecycle/paths.ts +19 -1
  242. package/src/server/lib/mcp/registry.server.ts +155 -0
  243. package/src/server/lib/mcp/registry.test.ts +169 -0
  244. package/src/server/lib/mcp/store.server.ts +38 -0
  245. package/src/server/lib/omp/rpc/frame-fold-contract.ts +59 -0
  246. package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +64 -1
  247. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +2 -1
  248. package/src/server/lib/omp/rpc/frame-fold.test.ts +2 -1
  249. package/src/server/lib/omp/rpc/frame-fold.ts +6 -45
  250. package/src/server/lib/omp/rpc/prewarm-pool.ts +19 -5
  251. package/src/server/lib/omp/rpc/run-model.test.ts +116 -0
  252. package/src/server/lib/omp/rpc/run-model.ts +4 -2
  253. package/src/server/lib/omp/session/sidebar-data.harness.test.ts +6 -3
  254. package/src/server/lib/omp/session/standby.server.ts +13 -2
  255. package/src/server/lib/panels/manifest.test.ts +47 -1
  256. package/src/server/lib/panels/manifest.ts +19 -0
  257. package/src/server/lib/panels/registry.server.ts +19 -2
  258. package/src/server/lib/panels/scan.server.ts +26 -2
  259. package/src/server/lib/panels/settings-schema.server.ts +72 -0
  260. package/src/server/lib/plugins/background.server.ts +21 -3
  261. package/src/server/lib/plugins/background.test.ts +13 -0
  262. package/src/server/lib/plugins/loader.server.ts +35 -51
  263. package/src/server/lib/plugins/mcp.server.ts +100 -0
  264. package/src/server/lib/plugins/mcp.test.ts +75 -0
  265. package/src/server/lib/plugins/schedule-runner.server.ts +153 -0
  266. package/src/server/lib/plugins/schedule-runner.test.ts +186 -0
  267. package/src/server/lib/plugins/schedule-store.server.ts +107 -0
  268. package/src/server/lib/plugins/schema.server.ts +8 -0
  269. package/src/server/lib/plugins/settings.server.ts +56 -19
  270. package/src/server/lib/plugins/shutdown.server.ts +58 -0
  271. package/src/server/lib/plugins/shutdown.test.ts +28 -3
  272. package/src/server/lib/realtime/topics/global.server.ts +5 -1
  273. package/src/server/lib/schedule/rows.server.ts +9 -0
  274. package/src/server/lib/schedule/runtime.server.test.ts +91 -0
  275. package/src/server/lib/schedule/runtime.server.ts +101 -23
  276. package/src/server/lib/schedule/schema.server.ts +15 -0
  277. package/src/server/lib/schedule/store.server.test.ts +34 -0
  278. package/src/server/lib/schedule/store.server.ts +33 -9
  279. package/src/server/lib/sessions/fork.server.test.ts +47 -0
  280. package/src/server/lib/sessions/fork.server.ts +17 -1
  281. package/src/server/lib/sessions/spawn.server.ts +2 -2
  282. package/src/server/lib/usage/report.server.ts +57 -0
  283. package/src/server/lib/waiting/runtime.server.test.ts +48 -0
  284. package/src/server/lib/waiting/runtime.server.ts +22 -0
  285. package/src/server/lib/waiting/schema.server.ts +8 -0
  286. package/src/server/lib/waiting/store.server.test.ts +14 -0
  287. package/src/server/lib/waiting/store.server.ts +6 -2
  288. package/src/server/routes/agent/command-resume.test.ts +9 -4
  289. package/src/server/routes/agent/new-mode.test.ts +40 -0
  290. package/src/server/routes/agent/new.ts +31 -10
  291. package/src/server/routes/agent/prewarm.ts +48 -7
  292. package/src/server/routes/fs/action.ts +9 -1
  293. package/src/server/routes/fs/digest.test.ts +100 -0
  294. package/src/server/routes/fs/digest.ts +106 -0
  295. package/src/server/routes/fs/index.ts +2 -0
  296. package/src/server/routes/fs/read.ts +6 -1
  297. package/src/server/routes/harness/custom.test.ts +131 -0
  298. package/src/server/routes/harness/import-action.ts +2 -2
  299. package/src/server/routes/harness/root.ts +41 -8
  300. package/src/server/routes/harness/update.ts +2 -2
  301. package/src/server/routes/panels/bindings.ts +2 -0
  302. package/src/server/routes/panels/settings.test.ts +165 -0
  303. package/src/server/routes/panels/settings.ts +106 -0
  304. package/src/server/routes/schedule/body.ts +14 -0
  305. package/src/server/routes/schedule/index.ts +28 -4
  306. package/src/server/routes/settings/mcp.ts +9 -26
  307. package/src/server/routes/waiting/index.ts +21 -2
  308. package/src/server/routes/waiting/routes.test.ts +21 -0
  309. package/src/shared/lib/chat/composer/delegation.ts +3 -3
  310. package/src/shared/lib/chat/timeline/fork-anchor.test.ts +97 -0
  311. package/src/shared/lib/chat/timeline/fork-anchor.ts +47 -0
  312. package/src/shared/lib/chat/timeline/fork-preview.test.ts +62 -0
  313. package/src/shared/lib/chat/timeline/fork-preview.ts +36 -0
  314. package/src/shared/lib/fs/content-hash.ts +29 -0
  315. package/src/shared/lib/harness/catalog.ts +48 -6
  316. package/src/shared/lib/harness/fork.ts +60 -0
  317. package/src/shared/lib/harness/mcp-facts.test.ts +30 -0
  318. package/src/shared/lib/harness/mcp-facts.ts +65 -0
  319. package/src/shared/lib/harness/menu.test.ts +16 -1
  320. package/src/shared/lib/harness/menu.ts +2 -2
  321. package/src/shared/lib/harness/rewind.ts +6 -6
  322. package/src/shared/lib/harness/session-modes.ts +31 -0
  323. package/src/shared/lib/harness/transcript.test.ts +29 -0
  324. package/src/shared/lib/harness/transcript.ts +19 -0
  325. package/src/shared/lib/notifications/settings.test.ts +21 -0
  326. package/src/shared/lib/notifications/settings.ts +24 -0
  327. package/src/shared/lib/omp/session/prewarm.test.ts +28 -4
  328. package/src/shared/lib/omp/session/prewarm.ts +25 -6
  329. package/src/shared/lib/omp/session/stream-state.server.test.ts +25 -0
  330. package/src/shared/lib/omp/session/stream-state.server.ts +8 -4
  331. package/src/shared/lib/panels/capabilities.test.ts +1 -1
  332. package/src/shared/lib/panels/capabilities.ts +3 -0
  333. package/src/shared/lib/plugins/settings.ts +22 -0
  334. package/src/shared/lib/schedule/parse.test.ts +48 -0
  335. package/src/shared/lib/schedule/parse.ts +69 -45
  336. package/src/shared/lib/schedule/timezone.ts +128 -0
  337. package/src/shared/lib/settings/defaults.ts +2 -0
  338. package/src/shared/lib/ui/toast-duration.test.ts +25 -1
  339. package/src/shared/lib/ui/toast-duration.ts +22 -4
  340. package/src/shared/lib/workspace/refresh-cadence.test.ts +25 -1
  341. package/src/shared/lib/workspace/relative-time.ts +16 -0
  342. package/src/shared/lib/workspace/session-state/store.ts +4 -0
  343. package/src/shared/types/harness.ts +7 -0
  344. package/src/shared/types/omp/agent.ts +6 -0
  345. package/src/shared/types/panels-registry.ts +3 -3
  346. package/src/shared/types/panels.ts +4 -2
  347. package/src/shared/types/schedule.ts +13 -0
  348. package/src/shared/types/settings/state.ts +12 -1
  349. package/src/shared/types/waiting.ts +9 -0
  350. package/src/test-support/file-editor.test-util.ts +70 -5
  351. package/dist/client/static/js/index-p2yw9ywf.css +0 -1
  352. package/src/client/hooks/editor/use-external-change-notice.ts +0 -71
  353. package/src/client/hooks/editor/use-external-change.test.ts +0 -88
  354. package/src/client/hooks/editor/use-external-change.ts +0 -146
@@ -1,22 +1,20 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';
2
2
  import { getLanguageFromPath } from '@/shared/lib/code/language';
3
3
  import { resolveViewer } from '@/client/hooks/editor/resolve-viewer';
4
- import { detectLineEnding, toDiskText, toLf, type LineEnding } from '@/shared/lib/code/line-endings';
5
- import { retainKeys } from '@/client/hooks/editor/save-file';
4
+ import { toDiskText, toLf, type LineEnding } from '@/shared/lib/code/line-endings';
6
5
  import { deviceFileFor } from '@/client/lib/launch/device-files';
7
6
  import { fileHandleFor } from '@/client/lib/launch/file-handlers';
8
7
  import { useFileRead } from '@/client/hooks/editor/use-file-read';
9
8
  import { useFileTransfer } from '@/client/hooks/editor/use-file-transfer';
10
9
  import { useFileWrites } from '@/client/hooks/editor/use-file-writes';
11
10
  import { useWriteConflict } from '@/client/hooks/editor/use-write-conflict';
11
+ import { useDiskSync } from '@/client/hooks/editor/use-disk-sync';
12
+ import { useFileCache } from '@/client/hooks/editor/use-file-cache';
13
+ import { editorTargetKey as targetKey } from '@/client/hooks/editor/target-key';
12
14
  import type { FileEditorSaveStatus, FileEditorTarget, UseFileEditorOptions, UseFileEditorResult } from '@/client/hooks/editor/file-editor-types';
13
15
 
14
16
  export type { FileEditorSaveStatus, FileEditorTarget, UseFileEditorOptions, UseFileEditorResult } from '@/client/hooks/editor/file-editor-types';
15
17
 
16
- function targetKey(target: FileEditorTarget): string {
17
- return String(target.id ?? target.path ?? target.name);
18
- }
19
-
20
18
  /**
21
19
  * Owns the file-editing contract shared by the desktop editor and the phone's
22
20
  * full-screen editor: read, debounced FormData save, copy, download, dirty
@@ -52,6 +50,16 @@ export function useFileEditor(
52
50
  * inline attachment, a handle-backed file, or a read that failed.
53
51
  */
54
52
  const [mtimes, setMtimes] = useState<Record<string, number | null>>({});
53
+ /**
54
+ * The content hash of the bytes each cached file was read at (or last wrote).
55
+ *
56
+ * The auto-refresh watcher compares the disk against it, so a file rewritten
57
+ * with identical bytes — a checkout of the revision already open, a formatter
58
+ * that changes nothing, a `touch` — never replaces a buffer. `null` means "no
59
+ * fingerprint": an inline attachment, a failed read, a file too large for the
60
+ * digest, or a handle-backed write (nothing to hash against).
61
+ */
62
+ const [hashes, setHashes] = useState<Record<string, string | null>>({});
55
63
  const [saveStatus, setSaveStatus] = useState<FileEditorSaveStatus>('idle');
56
64
  /** Bumped by `reset()` to re-run the read effect for the active file. */
57
65
  const [revision, setRevision] = useState(0);
@@ -84,6 +92,8 @@ export function useFileEditor(
84
92
  // duplicate fetch while the first one is still in flight.
85
93
  const loadedRef = useRef<Set<string>>(new Set());
86
94
  const pendingRef = useRef<{ timer: number; file: FileEditorTarget; content: string } | null>(null);
95
+ /** Reads on their way — see `useFileRead`. */
96
+ const readingRef = useRef(0);
87
97
 
88
98
  // Live mirrors of the content maps: a read response resolves long after it
89
99
  // was requested, and it has to know whether the buffer it read is still the
@@ -98,17 +108,24 @@ export function useFileEditor(
98
108
  lineEndingsRef.current = lineEndings;
99
109
  const mtimesRef = useRef(mtimes);
100
110
  mtimesRef.current = mtimes;
111
+ const hashesRef = useRef(hashes);
112
+ hashesRef.current = hashes;
101
113
 
102
- const remember = useCallback((fileKey: string, text: string, mtimeMs: number | null) => {
103
- // The buffer holds LF only; the style the bytes arrived with is kept beside
104
- // it so the write can put the file back the way it was found.
105
- const ending = detectLineEnding(text);
106
- const lf = toLf(text);
107
- setContents((prev) => ({ ...prev, [fileKey]: lf }));
108
- setBaselines((prev) => ({ ...prev, [fileKey]: lf }));
109
- setLineEndings((prev) => ({ ...prev, [fileKey]: ending }));
110
- setMtimes((prev) => ({ ...prev, [fileKey]: mtimeMs }));
111
- }, []);
114
+ /**
115
+ * The cache's lifecycle (refresh everything, drop closed tabs, switch the saved
116
+ * ending) lives in its own hook — see `use-file-cache.ts` for why the five caches
117
+ * must move together.
118
+ */
119
+ const { remember, reset, retain, setEol } = useFileCache({
120
+ target,
121
+ loadedRef,
122
+ bumpRevision: () => setRevision((prev) => prev + 1),
123
+ setContents,
124
+ setBaselines,
125
+ setLineEndings,
126
+ setMtimes,
127
+ setHashes,
128
+ });
112
129
 
113
130
  /**
114
131
  * The read path lives in its own hook — see `use-file-read.ts` for the two
@@ -123,6 +140,7 @@ export function useFileEditor(
123
140
  contentsRef,
124
141
  baselinesRef,
125
142
  pendingRef,
143
+ readingRef,
126
144
  remember,
127
145
  });
128
146
 
@@ -145,9 +163,15 @@ export function useFileEditor(
145
163
  pendingRef,
146
164
  flushOnUnmount,
147
165
  onSaveStart: () => setSaveStatus('saving'),
148
- onSaved: (fileKey, text) => {
166
+ onSaved: (fileKey, text, written) => {
149
167
  setSaveStatus('saved');
150
168
  setBaselines((prev) => ({ ...prev, [fileKey]: text }));
169
+ // Adopt what the server reported about the bytes it just wrote: the mtime
170
+ // is the next save's conflict base, and the hash is the auto-refresh
171
+ // baseline. Without them the watcher would read the user's own save as an
172
+ // external change, and the next save would be refused against its base.
173
+ if (written.mtimeMs !== null) setMtimes((prev) => ({ ...prev, [fileKey]: written.mtimeMs }));
174
+ if (written.hash !== null) setHashes((prev) => ({ ...prev, [fileKey]: written.hash }));
151
175
  onFileSaved?.();
152
176
  },
153
177
  onSaveFailed: () => setSaveStatus(reportSaveError ? 'error' : 'idle'),
@@ -186,6 +210,48 @@ export function useFileEditor(
186
210
  bumpRevision: () => setRevision((prev) => prev + 1),
187
211
  });
188
212
 
213
+ /**
214
+ * Drop the debounced write for `fileKey`, if one is armed.
215
+ *
216
+ * A Reload throws the buffer away, so the write that buffer had queued must go
217
+ * with it — and the read path yields to a queued write, so leaving it armed
218
+ * would also make the reload land nowhere.
219
+ */
220
+ const discardPendingWrite = useCallback((fileKey: string) => {
221
+ const queued = pendingRef.current;
222
+ if (!queued || targetKey(queued.file) !== fileKey) return;
223
+ window.clearTimeout(queued.timer);
224
+ pendingRef.current = null;
225
+ }, []);
226
+
227
+ /**
228
+ * The disk watcher and the answers it produces — one cluster, in its own hook
229
+ * (see `use-disk-sync.ts`): a clean buffer follows the disk, a dirty one is
230
+ * never replaced, and a file that still hashes the same is not a change.
231
+ *
232
+ * The conflict machine is passed in rather than imported there so "adopt the
233
+ * mtime" and "discard and re-read" stay the SAME implementations the strips
234
+ * call; a second copy is how one of them refuses a save the other accepted.
235
+ */
236
+ const { diskChange, reloadFromDisk, keepMineAgainstDisk } = useDiskSync({
237
+ key,
238
+ target,
239
+ baseHash: hashes[key] ?? null,
240
+ revision,
241
+ hashesRef,
242
+ mtimesRef,
243
+ contentsRef,
244
+ baselinesRef,
245
+ pendingRef,
246
+ readingRef,
247
+ loadedRef,
248
+ bumpRevision: () => setRevision((prev) => prev + 1),
249
+ adoptDiskMtime: conflictState.adopt,
250
+ clearConflict: conflictState.clear,
251
+ reloadDiscardingEdits: conflictState.reload,
252
+ discardPendingWrite,
253
+ });
254
+
189
255
  useEffect(() => {
190
256
  if (saveStatus !== 'saved') return;
191
257
  const timer = window.setTimeout(() => setSaveStatus('idle'), 1500);
@@ -225,35 +291,6 @@ export function useFileEditor(
225
291
  byteViewer: isBinaryViewer,
226
292
  });
227
293
 
228
- const reset = useCallback(() => {
229
- // Invalidate every key, then let the read effect refetch the active one.
230
- // Content is deliberately NOT cleared: it stays on screen until the fresh
231
- // bytes land, so a refresh can never blank the editor (or drop the file
232
- // that is open) while the request is in flight.
233
- loadedRef.current.clear();
234
- setRevision((prev) => prev + 1);
235
- }, []);
236
-
237
- /**
238
- * Switch the ending this buffer saves in.
239
- *
240
- * Only the ending moves: the BUFFER is LF-only either way, and the bytes are built
241
- * at write time, so nothing on screen changes and no re-read is needed.
242
- */
243
- const setEol = useCallback((next: LineEnding) => {
244
- if (!target) return;
245
- setLineEndings((prev) => ({ ...prev, [targetKey(target)]: next }));
246
- }, [target]);
247
-
248
- const retain = useCallback((ids: Array<number | string>) => {
249
- const keep = new Set(ids.map(String));
250
- for (const loaded of Array.from(loadedRef.current)) {
251
- if (!keep.has(loaded)) loadedRef.current.delete(loaded);
252
- }
253
- setContents((prev) => retainKeys(prev, keep));
254
- setLineEndings((prev) => retainKeys(prev, keep));
255
- setMtimes((prev) => retainKeys(prev, keep));
256
- }, []);
257
294
 
258
295
  return {
259
296
  content,
@@ -293,12 +330,13 @@ export function useFileEditor(
293
330
  confirmSaveMissing: writes.confirmSaveMissing,
294
331
  cancelSaveMissing: writes.cancelSaveMissing,
295
332
  conflict: conflictState.conflict,
296
- resolveConflictByReload: conflictState.reload,
333
+ resolveConflictByReload: () => {
334
+ if (key) discardPendingWrite(key);
335
+ conflictState.reload();
336
+ },
297
337
  resolveConflictByKeepingMine: conflictState.keepMine,
298
- // Revert and Reload are the same operation: throw the buffer away and take the
299
- // disk copy. Two names because the reason differs — a Revert is the user's own
300
- // choice, a Reload is an answer to a conflict — and neither needs its own path.
301
- revertToDisk: conflictState.reload,
302
- adoptDiskMtime: conflictState.adopt,
338
+ reloadFromDisk,
339
+ diskChange,
340
+ keepMineAgainstDisk,
303
341
  };
304
342
  }
@@ -71,13 +71,20 @@ export interface UseFileReadOptions {
71
71
  /** The queued write, which owns the key if it is still pending. */
72
72
  pendingRef: LiveRef<PendingWrite | null>;
73
73
  /**
74
- * Store bytes, the line ending they arrived with, and the mtime they were read
75
- * at.
74
+ * How many reads are in flight, so the auto-refresh watcher does not ask for a
75
+ * second one while the first is still on its way.
76
+ */
77
+ readingRef: LiveRef<number>;
78
+ /**
79
+ * Store bytes, the line ending they arrived with, the mtime they were read at,
80
+ * and the hash of those bytes.
76
81
  *
77
82
  * The mtime is the save path's conflict base: a write whose base no longer
78
83
  * matches the disk is refused rather than clobbering another writer's change.
84
+ * The hash is the auto-refresh watcher's baseline: a file that still hashes
85
+ * the same has not changed, however far its mtime moved.
79
86
  */
80
- remember: (fileKey: string, text: string, mtimeMs: number | null) => void;
87
+ remember: (fileKey: string, text: string, mtimeMs: number | null, hash: string | null) => void;
81
88
  }
82
89
 
83
90
  export interface FileReadState {
@@ -101,6 +108,7 @@ export function useFileRead({
101
108
  contentsRef,
102
109
  baselinesRef,
103
110
  pendingRef,
111
+ readingRef,
104
112
  remember,
105
113
  }: UseFileReadOptions): FileReadState {
106
114
  const [isLoading, setIsLoading] = useState(false);
@@ -129,7 +137,7 @@ export function useFileRead({
129
137
  if (target.content !== undefined) {
130
138
  // Inline content (an attachment chip) has no file behind it, so there is no
131
139
  // mtime to check a later write against.
132
- remember(fileKey, target.content, null);
140
+ remember(fileKey, target.content, null, null);
133
141
  setLoadError(null);
134
142
  setUnsupported(null);
135
143
  return;
@@ -153,10 +161,11 @@ export function useFileRead({
153
161
  const params = new URLSearchParams({ path: target.path });
154
162
  if (target.root) params.set('root', target.root);
155
163
  if (target.repo && target.repo !== '.') params.set('repo', target.repo);
164
+ readingRef.current += 1;
156
165
  fetch(`/api/fs/read?${params.toString()}`)
157
166
  .then(async (res) => {
158
167
  const data = (await res.json().catch(() => null)) as
159
- | { content?: unknown; error?: string; kind?: 'binary' | 'too-large'; mtimeMs?: unknown }
168
+ | { content?: unknown; error?: string; kind?: 'binary' | 'too-large'; mtimeMs?: unknown; hash?: unknown }
160
169
  | null;
161
170
  if (!res.ok || !data || typeof data.content !== 'string') {
162
171
  const error: FileReadError = new Error(data?.error || `HTTP ${res.status}`);
@@ -166,9 +175,13 @@ export function useFileRead({
166
175
  else if (res.status === 415) error.kind = 'binary';
167
176
  throw error;
168
177
  }
169
- return { text: data.content, mtimeMs: typeof data.mtimeMs === 'number' ? data.mtimeMs : null };
178
+ return {
179
+ text: data.content,
180
+ mtimeMs: typeof data.mtimeMs === 'number' ? data.mtimeMs : null,
181
+ hash: typeof data.hash === 'string' ? data.hash : null,
182
+ };
170
183
  })
171
- .then(({ text, mtimeMs }) => {
184
+ .then(({ text, mtimeMs, hash }) => {
172
185
  if (cancelled) return;
173
186
  // These bytes were read before the response arrived, so anything typed
174
187
  // since is newer. Applying them would replace those keystrokes (and,
@@ -178,7 +191,7 @@ export function useFileRead({
178
191
  if (typed !== undefined && typed !== baselinesRef.current[fileKey]) return;
179
192
  const queued = pendingRef.current;
180
193
  if (queued && targetKey(queued.file) === fileKey) return;
181
- remember(fileKey, text, mtimeMs);
194
+ remember(fileKey, text, mtimeMs, hash);
182
195
  })
183
196
  .catch((err: unknown) => {
184
197
  if (cancelled) return;
@@ -186,20 +199,21 @@ export function useFileRead({
186
199
  if (!firstLoad) return;
187
200
  // An empty buffer, never a substitute: the next save would write the
188
201
  // substitute over the real file.
189
- remember(fileKey, '', null);
202
+ remember(fileKey, '', null, null);
190
203
  const message = err instanceof Error ? err.message : 'Failed to read file';
191
204
  const kind = (err as FileReadError)?.kind;
192
205
  setUnsupported(kind ? message : null);
193
206
  setLoadError(message);
194
207
  })
195
208
  .finally(() => {
209
+ readingRef.current -= 1;
196
210
  if (!cancelled) setIsLoading(false);
197
211
  });
198
212
 
199
213
  return () => {
200
214
  cancelled = true;
201
215
  };
202
- }, [key, target, remember, revision, isBinaryViewer, loadedRef, contentsRef, baselinesRef, pendingRef]);
216
+ }, [key, target, remember, revision, isBinaryViewer, loadedRef, contentsRef, baselinesRef, pendingRef, readingRef]);
203
217
 
204
218
  return { isLoading, loadError, unsupported };
205
219
  }
@@ -28,7 +28,7 @@
28
28
  import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
29
29
  import { fileHandleFor } from '@/client/lib/launch/file-handlers';
30
30
  import type { LineEnding } from '@/shared/lib/code/line-endings';
31
- import { saveEditorFile } from '@/client/hooks/editor/save-file';
31
+ import { saveEditorFile, type WrittenFile } from '@/client/hooks/editor/save-file';
32
32
  import type { FileEditorTarget } from '@/client/hooks/editor/use-file-editor';
33
33
 
34
34
  /**
@@ -72,8 +72,8 @@ export interface FileWriteDeps {
72
72
  flushOnUnmount: boolean;
73
73
  /** A write started; the toolbar shows `saving`. */
74
74
  onSaveStart: () => void;
75
- /** A write landed; the baseline moves and the workspace re-reads. */
76
- onSaved: (fileKey: string, text: string) => void;
75
+ /** A write landed; the baseline, the conflict base and the digest all move. */
76
+ onSaved: (fileKey: string, text: string, written: WrittenFile) => void;
77
77
  /** A write was refused or dropped. */
78
78
  onSaveFailed: () => void;
79
79
  /**
@@ -161,7 +161,7 @@ export function useFileWrites({
161
161
  interactive: options.interactive === true,
162
162
  baseMtimeMs,
163
163
  });
164
- if (outcome.status === 'written') onSaved(fileKey, text);
164
+ if (outcome.status === 'written') onSaved(fileKey, text, outcome.written);
165
165
  else if (outcome.status === 'needs-permission') onNeedsPermission();
166
166
  else if (outcome.status === 'conflict') onConflict(fileKey, outcome.diskMtimeMs);
167
167
  else onSaveFailed();
@@ -16,6 +16,7 @@
16
16
  import type {
17
17
  HarnessConfig, HarnessProviderSupport, HarnessesPayload, HarnessSummary, LiveHarnessModels,
18
18
  } from '@/shared/types/harness';
19
+ import { registerHarnessDescriptors } from '@/shared/lib/harness/catalog';
19
20
 
20
21
  export interface HarnessStore {
21
22
  harnesses: HarnessSummary[];
@@ -73,6 +74,20 @@ export async function loadCatalog(): Promise<void> {
73
74
  })
74
75
  .then((payload) => {
75
76
  loaded = true;
77
+ // A user-added harness has no entry in the build's static catalog, and the
78
+ // glyph/badge helpers are synchronous. Publish the descriptors the server
79
+ // answered before any surface renders a row for one.
80
+ registerHarnessDescriptors(
81
+ (payload.harnesses ?? [])
82
+ .filter((entry) => entry.custom)
83
+ .map((entry) => ({
84
+ id: entry.id,
85
+ label: entry.label,
86
+ initial: entry.initial ?? entry.label.charAt(0).toUpperCase(),
87
+ transport: entry.transport,
88
+ glyph: 'custom' as const,
89
+ })),
90
+ );
76
91
  emit({
77
92
  harnesses: Array.isArray(payload.harnesses) ? payload.harnesses : [],
78
93
  // Absent from an answer written before per-harness config existed: an
@@ -31,12 +31,13 @@ import type { ProviderItem } from '@/shared/types';
31
31
  import { saveProviderOverlay, setProviderEnabled, deleteProvider } from '@/shared/lib/models/provider/connection';
32
32
  import { addProviderMessage } from '@/client/hooks/settings/providers/messages';
33
33
  import { loadProvidersFromApi } from '@/client/hooks/settings/providers/api';
34
+ import type { ToastTone } from '@/shared/lib/ui/toast-duration';
34
35
 
35
36
  export interface ProviderActionsDeps {
36
37
  providers: ProviderItem[];
37
38
  selectedProvider: ProviderItem | undefined;
38
39
  isDeletingProvider: boolean;
39
- pushToast: (message: string, tone: 'success' | 'error') => void;
40
+ pushToast: (message: string, tone: ToastTone) => void;
40
41
  setProviders: (providers: ProviderItem[]) => void;
41
42
  setSelectedProviderId: (id: string) => void;
42
43
  setIsAddModalOpen: (open: boolean) => void;
@@ -209,7 +210,7 @@ export function createProviderActions(deps: ProviderActionsDeps) {
209
210
  // The overlay row is gone even when the file cleanup failed, so the
210
211
  // warning is reported rather than presented as a clean delete.
211
212
  if (result.warning) {
212
- pushToast(`${provider.name} removed from Kabmo, but models.yml cleanup failed: ${result.warning}`, 'error');
213
+ pushToast(`${provider.name} removed from Kabmo, but models.yml cleanup failed: ${result.warning}`, 'warning');
213
214
  } else if (result.removedFromOmp) {
214
215
  const count = result.modelsRemoved ?? 0;
215
216
  pushToast(
@@ -14,12 +14,13 @@
14
14
  */
15
15
 
16
16
  import type { ProviderItem } from '@/shared/types';
17
+ import type { ToastTone } from '@/shared/lib/ui/toast-duration';
17
18
 
18
19
  /** The success/failure line for an Add Provider submission. */
19
20
  export function addProviderMessage(
20
21
  provider: ProviderItem,
21
22
  options: { fetchedCount: number; ompNote?: string },
22
- ): { text: string; tone: 'success' | 'error' } {
23
+ ): { text: string; tone: ToastTone } {
23
24
  if (provider.modelSource === 'discovery') {
24
25
  return { text: `${provider.name} registered — omp discovers its models on each run.`, tone: 'success' };
25
26
  }
@@ -37,12 +38,13 @@ export function addProviderMessage(
37
38
  }
38
39
  if (options.fetchedCount === -1) {
39
40
  // The listing failed. When omp reported a reason it is the actionable half,
40
- // so it is quoted rather than replaced by a generic line.
41
+ // so it is quoted rather than replaced by a generic line. The provider IS
42
+ // registered, so this is a partial outcome, not a failed add.
41
43
  return {
42
44
  text: options.ompNote
43
45
  ? `Provider registered, but models could not be listed: ${options.ompNote}`
44
46
  : 'Auto-fetch models failed — provider added with default models.',
45
- tone: 'error',
47
+ tone: 'warning',
46
48
  };
47
49
  }
48
50
  return { text: `${provider.name} registered — no new models to add.`, tone: 'success' };
@@ -56,7 +58,7 @@ export function addProviderMessage(
56
58
  */
57
59
  export function fetchModelsMessage(counts: { addedCount: number; removedCount: number }): {
58
60
  text: string;
59
- tone: 'success' | 'error';
61
+ tone: ToastTone;
60
62
  } {
61
63
  const plural = (count: number) => (count === 1 ? '' : 's');
62
64
  if (counts.addedCount > 0 && counts.removedCount > 0) {
@@ -87,7 +89,7 @@ export function fetchModelsMessage(counts: { addedCount: number; removedCount: n
87
89
  */
88
90
  export function fetchModelsNote(result: {
89
91
  omp?: { written: boolean; addedCount: number; backfilledCount: number; removedCount?: number; reason?: string };
90
- }): { text: string; tone: 'success' | 'error' } | null {
92
+ }): { text: string; tone: ToastTone } | null {
91
93
  if (!result.omp) return null;
92
94
  if (result.omp.written) {
93
95
  const parts: string[] = [];
@@ -106,7 +108,7 @@ export function fetchModelsNote(result: {
106
108
  };
107
109
  }
108
110
  if (result.omp.reason) {
109
- return { text: `omp models.yml not updated: ${result.omp.reason}`, tone: 'error' };
111
+ return { text: `omp models.yml not updated: ${result.omp.reason}`, tone: 'warning' };
110
112
  }
111
113
  return null;
112
114
  }
@@ -122,7 +124,7 @@ export function fetchModelsNote(result: {
122
124
  export function refreshModelsMessage(
123
125
  providerName: string,
124
126
  result: { added: number; removed: number },
125
- ): { text: string; tone: 'success' | 'error' } {
127
+ ): { text: string; tone: ToastTone } {
126
128
  const plural = (count: number) => (count === 1 ? '' : 's');
127
129
  if (result.added > 0 || result.removed > 0) {
128
130
  const parts: string[] = [];
@@ -24,12 +24,13 @@ import {
24
24
  import { removeLegacyKenariModels } from '@/shared/lib/models/provider/cleanup';
25
25
  import { fetchModelsMessage, fetchModelsNote, refreshModelsMessage } from '@/client/hooks/settings/providers/messages';
26
26
  import { saveModelOverrideRemote } from '@/client/hooks/settings/providers/api';
27
+ import type { ToastTone } from '@/shared/lib/ui/toast-duration';
27
28
 
28
29
  export interface ModelActionsDeps {
29
30
  providers: ProviderItem[];
30
31
  selectedProvider: ProviderItem | undefined;
31
32
  isFetchingModels: boolean;
32
- pushToast: (message: string, tone: 'success' | 'error') => void;
33
+ pushToast: (message: string, tone: ToastTone) => void;
33
34
  setProviders: (providers: ProviderItem[]) => void;
34
35
  setIsFetchingModels: (fetching: boolean) => void;
35
36
  persistProviders: (updated: ProviderItem[]) => Promise<void>;
@@ -24,11 +24,12 @@
24
24
 
25
25
  import { useKabmoEvent } from '@/client/hooks/ui/window-event';
26
26
  import { EDITOR_ERROR_EVENT } from '@/client/lib/editor-errors';
27
+ import type { ToastTone } from '@/shared/lib/ui/toast-duration';
27
28
 
28
29
  /** What `pushToast` accepts, named so this hook does not import the toast host. */
29
30
  type PushToast = (
30
31
  message: string,
31
- type?: 'success' | 'error',
32
+ type?: ToastTone,
32
33
  options?: { duration?: number | null },
33
34
  ) => void;
34
35
 
@@ -6,19 +6,28 @@
6
6
  /**
7
7
  * The one gate every system notification passes through.
8
8
  *
9
- * Two rules, and both are the feature rather than plumbing:
9
+ * Three rules, and all of them are the feature rather than plumbing:
10
10
  *
11
11
  * - the event's own setting must be the literal `true` (they ship false);
12
- * - the page must not be the window the user is looking at. The sidebar badge,
13
- * the ask card and the inline error row already report these events on
14
- * screen, so a banner over the app would only repeat what is visible.
12
+ * - the master switch for THIS device class (`Desktop` / `Mobile`) must not be
13
+ * `false` — the two switches exist so a phone can stay quiet while a desktop
14
+ * banners, and vice versa;
15
+ * - the banner is sent in every window state. Focus is not a gate: the user
16
+ * asked to be told, and the OS decides how to present a banner for the app it
17
+ * belongs to (the shells install a foreground presentation delegate for
18
+ * exactly this reason). The sidebar badge stays the in-app record.
15
19
  *
16
20
  * Text is clipped here because a failure reason can be a whole provider
17
21
  * response; an OS notification is a headline, not a log.
18
22
  */
19
23
 
20
- import { isNotificationEnabled, type NotificationEvent } from '@/shared/lib/notifications/settings';
21
- import { showOsNotification, shouldShowSystemNotification } from '@/client/lib/notifications/os';
24
+ import {
25
+ isNotificationEnabled,
26
+ isNotificationPlatformEnabled,
27
+ type NotificationEvent,
28
+ } from '@/shared/lib/notifications/settings';
29
+ import { showOsNotification } from '@/client/lib/notifications/os';
30
+ import { notificationPlatformForClient } from '@/client/lib/notifications/platform';
22
31
 
23
32
  const TITLE_LIMIT = 120;
24
33
  const BODY_LIMIT = 240;
@@ -29,13 +38,13 @@ function clip(text: string, limit: number): string {
29
38
  return `${trimmed.slice(0, limit - 1).trimEnd()}…`;
30
39
  }
31
40
 
32
- /** Send a system notification for `event`, unless the setting or focus says no. */
41
+ /** Send a system notification for `event`, unless its setting or platform switch says no. */
33
42
  export function sendNotification(
34
43
  event: NotificationEvent,
35
44
  notification: { title: string; body: string; tag?: string; sessionId?: string },
36
45
  ): void {
37
46
  if (!isNotificationEnabled(event)) return;
38
- if (!shouldShowSystemNotification()) return;
47
+ if (!isNotificationPlatformEnabled(notificationPlatformForClient())) return;
39
48
  void showOsNotification({
40
49
  title: clip(notification.title, TITLE_LIMIT) || 'Kabmo',
41
50
  body: clip(notification.body, BODY_LIMIT),
@@ -34,14 +34,14 @@ describe('archiveOutcomeMessage', () => {
34
34
  .toEqual({ message: 'Archived 1 session.', tone: 'success' });
35
35
  });
36
36
 
37
- test('a partial refusal names both counts and is not dressed as success', () => {
37
+ test('a partial refusal names both counts and is dressed as a warning', () => {
38
38
  const report = archiveOutcomeMessage(outcome({
39
39
  archived: ['a', 'b'],
40
40
  refused: [{ id: 'new-1', error: 'This chat has not been created yet.' }],
41
41
  }));
42
42
  expect(report?.message).toContain('Archived 2 sessions');
43
43
  expect(report?.message).toContain('1 refused');
44
- expect(report?.tone).toBe('error');
44
+ expect(report?.tone).toBe('warning');
45
45
  });
46
46
 
47
47
  test('an all-refused run is an error and names the refusal count', () => {
@@ -14,6 +14,8 @@
14
14
  * against the list.
15
15
  */
16
16
 
17
+ import type { ToastTone } from '@/shared/lib/ui/toast-duration';
18
+
17
19
  export interface BatchArchiveRefusal {
18
20
  id: string;
19
21
  error: string;
@@ -60,7 +62,7 @@ export function archiveSessionsBatch(ids: readonly string[]): Promise<BatchArchi
60
62
  */
61
63
  export function archiveOutcomeMessage(
62
64
  outcome: BatchArchiveOutcome,
63
- ): { message: string; tone: 'success' | 'error' } | null {
65
+ ): { message: string; tone: ToastTone } | null {
64
66
  if (outcome.error) return { message: outcome.error, tone: 'error' };
65
67
  const archived = outcome.archived.length;
66
68
  const refused = outcome.refused.length;
@@ -73,6 +75,6 @@ export function archiveOutcomeMessage(
73
75
  }
74
76
  return {
75
77
  message: `Archived ${archived} ${archived === 1 ? 'session' : 'sessions'}; ${refused} refused.`,
76
- tone: 'error',
78
+ tone: 'warning',
77
79
  };
78
80
  }
@@ -28,6 +28,7 @@ import { useEffect, useRef } from 'preact/hooks';
28
28
  import type { CommitHistoryPage } from '@/shared/types';
29
29
  import type { GitActionFetcher } from '@/client/hooks/workspace/git-actions';
30
30
  import { gitActionSuccessMessage } from '@/client/lib/git/action-message';
31
+ import type { ToastTone } from '@/shared/lib/ui/toast-duration';
31
32
 
32
33
  export interface GitActionOutcomeOptions {
33
34
  /** The mutation channel, with the action its payload answers. */
@@ -36,8 +37,8 @@ export interface GitActionOutcomeOptions {
36
37
  onPage: (page: CommitHistoryPage) => void;
37
38
  /** An accepted mutation landed: re-read the working tree. */
38
39
  onReload: () => void;
39
- /** An accepted mutation, in the sentence the user reads. */
40
- onSuccess: (message: string) => void;
40
+ /** An accepted mutation, in the sentence the user reads and the tone it earns. */
41
+ onSuccess: (message: string, tone: ToastTone) => void;
41
42
  /** The server's refusal, or a transport failure. */
42
43
  onError: (message: string) => void;
43
44
  }
@@ -81,6 +82,6 @@ export function useGitActionOutcome(options: GitActionOutcomeOptions): void {
81
82
  const message = dispatched
82
83
  ? gitActionSuccessMessage({ ...dispatched, stopped: payload.stopped })
83
84
  : null;
84
- if (message) handlers.onSuccess(message);
85
+ if (message) handlers.onSuccess(message, payload.stopped ? 'warning' : 'success');
85
86
  }, [fetcher.state, fetcher.data, fetcher.lastAction]);
86
87
  }
@@ -23,6 +23,7 @@ import { useSidebarData } from '@/client/hooks/chat/omp/session-list';
23
23
  import { useSessionActions } from '@/client/hooks/workspace/session-actions';
24
24
  import { useSessionDelete, type SessionDeleteActions } from '@/client/hooks/workspace/session-delete';
25
25
  import type { WorkspaceFolderData } from '@/shared/types';
26
+ import type { ToastTone } from '@/shared/lib/ui/toast-duration';
26
27
 
27
28
  /** What `TopNavbar` needs to draw its title menu. */
28
29
  export interface NavbarSessionMenu {
@@ -42,7 +43,7 @@ export interface NavbarSessionActions {
42
43
  export function useNavbarSessionActions(
43
44
  folders: WorkspaceFolderData[],
44
45
  sessionId: string | null,
45
- report: (message: string, tone?: 'success' | 'error') => void,
46
+ report: (message: string, tone?: ToastTone) => void,
46
47
  ): NavbarSessionActions {
47
48
  const sidebar = useSidebarData();
48
49
  const actions = useSessionActions(sidebar.refresh, report);
@@ -55,7 +55,7 @@ interface PanelRegistryState {
55
55
  /**
56
56
  * Every panel id switched off — a bare built-in view id, or `plugin:<id>`.
57
57
  * Read by the built-in registrations and the activity bar; the single source
58
- * of "is this panel on", shared with the Panel Plugins switches.
58
+ * of "is this panel on", shared with the Plugins Kabmo switches.
59
59
  */
60
60
  disabledPanels: string[];
61
61
  /** The last known freshness of each git-installed plugin, by plugin id. */