@kabmo-labs/kabmo 0.22.0 → 0.24.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 (446) hide show
  1. package/README.md +1 -1
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +873 -524
  4. package/dist/client/static/js/{index-297dck9a.js → index-jcr5twtp.js} +799 -795
  5. package/dist/client/static/js/index-z3w7n85q.css +1 -0
  6. package/marketplace/plugins/stats/package.json +2 -2
  7. package/marketplace/plugins/stats/src/groups.test.ts +14 -0
  8. package/marketplace/plugins/stats/src/groups.ts +20 -0
  9. package/marketplace/plugins/stats/src/labels.test.ts +9 -0
  10. package/marketplace/plugins/stats/src/labels.ts +7 -0
  11. package/marketplace/plugins/stats/src/server.ts +1 -1
  12. package/package.json +1 -1
  13. package/src/client/App.tsx +20 -19
  14. package/src/client/components/common/ComposerTextarea.tsx +10 -1
  15. package/src/client/components/common/Modal.tsx +2 -6
  16. package/src/client/components/common/PWAInstallButton.tsx +3 -2
  17. package/src/client/components/common/Toast.test.tsx +298 -0
  18. package/src/client/components/common/Toast.tsx +103 -37
  19. package/src/client/components/common/ToastStack.tsx +33 -12
  20. package/src/client/components/common/ViewportSelector.tsx +122 -114
  21. package/src/client/components/common/context-usage-button/Ring.tsx +38 -1
  22. package/src/client/components/common/context-usage-button/index.test.tsx +19 -3
  23. package/src/client/components/common/context-usage-button/index.tsx +5 -2
  24. package/src/client/components/common/harness-glyph/brands.ts +65 -0
  25. package/src/client/components/common/harness-glyph/harness-glyph.test.ts +185 -0
  26. package/src/client/components/common/harness-glyph/index.tsx +131 -0
  27. package/src/client/components/common/header-controls/MoreMenu.tsx +2 -1
  28. package/src/client/components/common/header-controls/index.tsx +16 -8
  29. package/src/client/components/common/header-panel-buttons/index.tsx +4 -3
  30. package/src/client/components/common/panel-mark/index.test.tsx +2 -2
  31. package/src/client/components/common/panel-mark/index.tsx +11 -2
  32. package/src/client/components/common/search-select/index.tsx +305 -0
  33. package/src/client/components/common/search-select/search-select.test.tsx +217 -0
  34. package/src/client/components/common/server-control/index.tsx +3 -2
  35. package/src/client/components/common/session-row/index.tsx +18 -1
  36. package/src/client/components/common/toolbar-row/index.tsx +57 -20
  37. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -3
  38. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +3 -2
  39. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +7 -1
  40. package/src/client/components/layout/desktop-layout/index.tsx +1 -3
  41. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +1 -0
  42. package/src/client/components/layout/session-sidebar/SessionItem.tsx +18 -1
  43. package/src/client/components/layout/session-sidebar/SessionsView.tsx +1 -3
  44. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.test.tsx +332 -0
  45. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +310 -0
  46. package/src/client/components/layout/session-sidebar/about-modal/SocialLinks.tsx +63 -51
  47. package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +4 -2
  48. package/src/client/components/layout/session-sidebar/about-modal/index.test.tsx +122 -0
  49. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +136 -35
  50. package/src/client/components/layout/session-sidebar/harness-mark.test.tsx +126 -0
  51. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +4 -3
  52. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +1 -0
  53. package/src/client/components/mobile/LayoutWrapper.tsx +1 -7
  54. package/src/client/components/mobile/SessionSidebar.tsx +1 -3
  55. package/src/client/components/mobile/mobile-main-view/Header.tsx +3 -2
  56. package/src/client/components/mobile/mobile-session-sidebar/Dialogs.tsx +0 -8
  57. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +1 -0
  58. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +17 -1
  59. package/src/client/components/settings/Modal.tsx +26 -22
  60. package/src/client/components/settings/Sidebar.tsx +45 -5
  61. package/src/client/components/settings/categories/HarnessSettings.tsx +207 -0
  62. package/src/client/components/settings/categories/ProjectSettings.tsx +1 -3
  63. package/src/client/components/settings/categories/ProviderSettings.tsx +0 -4
  64. package/src/client/components/settings/categories/SkillCatalogSettings.tsx +13 -23
  65. package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +23 -30
  66. package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +20 -11
  67. package/src/client/components/settings/categories/chat-settings/GoalSection.tsx +16 -16
  68. package/src/client/components/settings/categories/harness-settings/AddProviderForm.tsx +219 -0
  69. package/src/client/components/settings/categories/harness-settings/ConfigForm.tsx +268 -0
  70. package/src/client/components/settings/categories/harness-settings/EnvProviderForm.tsx +146 -0
  71. package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +278 -0
  72. package/src/client/components/settings/categories/harness-settings/ImportSection.tsx +195 -0
  73. package/src/client/components/settings/categories/harness-settings/ProviderPanel.tsx +152 -0
  74. package/src/client/components/settings/categories/harness-settings/ToggleList.tsx +147 -0
  75. package/src/client/components/settings/categories/harness-settings/parts.test.tsx +97 -0
  76. package/src/client/components/settings/categories/harness-settings/parts.tsx +84 -0
  77. package/src/client/components/settings/categories/harness-settings/provider-panel.test.tsx +313 -0
  78. package/src/client/components/settings/categories/omp-settings/RoleEditor.test.ts +60 -39
  79. package/src/client/components/settings/categories/omp-settings/RoleRow.tsx +32 -41
  80. package/src/client/components/settings/categories/omp-settings/role-picker.test-util.ts +45 -0
  81. package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +1 -1
  82. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +11 -4
  83. package/src/client/components/settings/groups.test.tsx +160 -0
  84. package/src/client/components/settings/harness-icons.test.tsx +134 -0
  85. package/src/client/components/workspace/browser-panel/AddressBar.tsx +3 -13
  86. package/src/client/components/workspace/browser-toolbar/clusters.tsx +237 -0
  87. package/src/client/components/workspace/browser-toolbar/index.test.tsx +167 -0
  88. package/src/client/components/workspace/browser-toolbar/index.tsx +99 -100
  89. package/src/client/components/workspace/btw-panel/Messages.tsx +4 -1
  90. package/src/client/components/workspace/btw-panel/index.tsx +2 -0
  91. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +11 -7
  92. package/src/client/components/workspace/chat-timeline/ChatOverlays.tsx +5 -2
  93. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +13 -0
  94. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +13 -0
  95. package/src/client/components/workspace/chat-timeline/GeneratingIndicator.test.ts +41 -0
  96. package/src/client/components/workspace/chat-timeline/GeneratingIndicator.tsx +19 -14
  97. package/src/client/components/workspace/chat-timeline/MessageList.test.ts +14 -0
  98. package/src/client/components/workspace/chat-timeline/MessageList.tsx +6 -0
  99. package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +14 -0
  100. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +4 -0
  101. package/src/client/components/workspace/chat-timeline/RunMark.tsx +58 -0
  102. package/src/client/components/workspace/chat-timeline/SubagentView.tsx +4 -1
  103. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +4 -0
  104. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -0
  105. package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +11 -0
  106. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +13 -0
  107. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +8 -1
  108. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +27 -1
  109. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +48 -23
  110. package/src/client/components/workspace/chat-timeline/chat-input/composer-portal.test.tsx +1 -0
  111. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +21 -1
  112. package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +7 -0
  113. package/src/client/components/workspace/chat-timeline/chat-input/props.ts +13 -0
  114. package/src/client/components/workspace/chat-timeline/chat-input/selection.ts +11 -2
  115. package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +1 -0
  116. package/src/client/components/workspace/chat-timeline/index.tsx +17 -15
  117. package/src/client/components/workspace/chat-timeline/pending-harness.test.tsx +157 -0
  118. package/src/client/components/workspace/chat-timeline/run-mark.test.ts +104 -0
  119. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +11 -20
  120. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx +1 -1
  121. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +1 -1
  122. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +1 -1
  123. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -1
  124. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +31 -3
  125. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +5 -1
  126. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +56 -45
  127. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +38 -94
  128. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-parts.tsx +76 -0
  129. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +2 -1
  130. package/src/client/components/workspace/file-explorer/index.test.ts +25 -0
  131. package/src/client/components/workspace/file-explorer/index.tsx +10 -6
  132. package/src/client/components/workspace/git-panel/index.test.ts +13 -3
  133. package/src/client/components/workspace/git-panel/index.tsx +1 -3
  134. package/src/client/components/workspace/model-dropdown/Fullscreen.tsx +92 -0
  135. package/src/client/components/workspace/model-dropdown/HarnessTabs.tsx +290 -0
  136. package/src/client/components/workspace/model-dropdown/Item.tsx +11 -0
  137. package/src/client/components/workspace/model-dropdown/Panel.tsx +119 -8
  138. package/src/client/components/workspace/model-dropdown/Section.tsx +4 -0
  139. package/src/client/components/workspace/model-dropdown/fullscreen-picker.ts +51 -0
  140. package/src/client/components/workspace/model-dropdown/harness-models.test.ts +177 -0
  141. package/src/client/components/workspace/model-dropdown/harness-models.ts +148 -0
  142. package/src/client/components/workspace/model-dropdown/harness-tabs.test.tsx +336 -0
  143. package/src/client/components/workspace/model-dropdown/index.tsx +114 -85
  144. package/src/client/components/workspace/model-dropdown/placement.test.tsx +127 -0
  145. package/src/client/components/workspace/model-dropdown/popover-metrics.test.ts +107 -0
  146. package/src/client/components/workspace/model-dropdown/popover-metrics.ts +118 -0
  147. package/src/client/components/workspace/model-dropdown/row-mutations.ts +106 -0
  148. package/src/client/components/workspace/model-dropdown/trigger.test.ts +22 -2
  149. package/src/client/components/workspace/model-dropdown/use-popover-size.ts +89 -0
  150. package/src/client/data/settings/omp-schema.json +224 -17
  151. package/src/client/hooks/chat/composer/index.ts +11 -2
  152. package/src/client/hooks/chat/composer/items.test.ts +11 -0
  153. package/src/client/hooks/chat/composer/items.ts +4 -2
  154. package/src/client/hooks/chat/composer/model-selection.test.ts +110 -0
  155. package/src/client/hooks/chat/composer/model-selection.ts +45 -4
  156. package/src/client/hooks/chat/omp/prompt-send.ts +4 -2
  157. package/src/client/hooks/chat/timeline/actions.ts +10 -5
  158. package/src/client/hooks/chat/timeline/ask-frames.ts +5 -4
  159. package/src/client/hooks/chat/timeline/composer-local-actions.test.ts +19 -81
  160. package/src/client/hooks/chat/timeline/composer-modes.ts +11 -2
  161. package/src/client/hooks/chat/timeline/composer-refs.ts +16 -1
  162. package/src/client/hooks/chat/timeline/index.ts +27 -35
  163. package/src/client/hooks/chat/timeline/mode-availability.test.ts +51 -0
  164. package/src/client/hooks/chat/timeline/modes-contract.ts +6 -0
  165. package/src/client/hooks/chat/timeline/modes.ts +41 -2
  166. package/src/client/hooks/chat/timeline/new-chat-open.test.ts +86 -0
  167. package/src/client/hooks/chat/timeline/new-chat-open.ts +23 -5
  168. package/src/client/hooks/chat/timeline/new-chat.test.ts +32 -4
  169. package/src/client/hooks/chat/timeline/new-chat.ts +18 -6
  170. package/src/client/hooks/chat/timeline/prompt-text.test.ts +7 -0
  171. package/src/client/hooks/chat/timeline/prompt-text.ts +15 -6
  172. package/src/client/hooks/chat/timeline/rewind-actions.test.ts +51 -1
  173. package/src/client/hooks/chat/timeline/rewind-actions.ts +23 -1
  174. package/src/client/hooks/chat/timeline/run-identity.test.ts +52 -0
  175. package/src/client/hooks/chat/timeline/run-identity.ts +23 -11
  176. package/src/client/hooks/chat/timeline/send-execute.test.ts +55 -0
  177. package/src/client/hooks/chat/timeline/send-props.ts +11 -3
  178. package/src/client/hooks/chat/timeline/send-steer.test.ts +2 -3
  179. package/src/client/hooks/chat/timeline/send.test-util.ts +3 -2
  180. package/src/client/hooks/chat/timeline/send.test.ts +2 -3
  181. package/src/client/hooks/chat/timeline/send.ts +34 -8
  182. package/src/client/hooks/chat/timeline/session-harness.test.ts +163 -0
  183. package/src/client/hooks/chat/timeline/session-harness.ts +164 -0
  184. package/src/client/hooks/chat/timeline/session-load.test-util.ts +6 -2
  185. package/src/client/hooks/chat/timeline/session-load.test.ts +31 -0
  186. package/src/client/hooks/chat/timeline/session-load.ts +6 -14
  187. package/src/client/hooks/chat/timeline/session-shapes.ts +32 -0
  188. package/src/client/hooks/chat/timeline/spawn-harness.ts +41 -0
  189. package/src/client/hooks/chat/timeline/timeline-running.ts +55 -0
  190. package/src/client/hooks/chat/timeline/tui-only-guard.ts +9 -0
  191. package/src/client/hooks/chat/timeline/undo-confirmation.test.ts +131 -0
  192. package/src/client/hooks/models/harness-catalog.ts +114 -0
  193. package/src/client/hooks/models/provider-writes.test.ts +81 -0
  194. package/src/client/hooks/models/provider-writes.ts +144 -0
  195. package/src/client/hooks/models/use-harness-versions.test.ts +152 -0
  196. package/src/client/hooks/models/use-harness-versions.ts +136 -0
  197. package/src/client/hooks/models/use-harnesses-controller.ts +57 -0
  198. package/src/client/hooks/models/use-harnesses-signal.test.ts +128 -0
  199. package/src/client/hooks/models/use-harnesses.test.ts +187 -0
  200. package/src/client/hooks/models/use-harnesses.ts +215 -0
  201. package/src/client/hooks/settings/providers/index.ts +1 -3
  202. package/src/client/hooks/ui/editor-error-toast.ts +10 -3
  203. package/src/client/hooks/ui/icon-style.ts +28 -0
  204. package/src/client/hooks/ui/on-click-outside.test.ts +104 -0
  205. package/src/client/hooks/ui/on-click-outside.ts +14 -2
  206. package/src/client/hooks/ui/theme.ts +6 -0
  207. package/src/client/hooks/ui/toast-queue.test.ts +126 -0
  208. package/src/client/hooks/ui/toasts.ts +132 -27
  209. package/src/client/hooks/ui/ui-feedback.test.ts +4 -91
  210. package/src/client/lib/ui/control-plate.test.ts +76 -0
  211. package/src/client/lib/ui/control-plate.ts +65 -0
  212. package/src/client/tailwind.css +47 -1
  213. package/src/server/lib/assets/shell-attributes.server.ts +9 -2
  214. package/src/server/lib/assets/shell-attributes.test.ts +22 -6
  215. package/src/server/lib/db/schema.ts +4 -0
  216. package/src/server/lib/harness/acp/acp-audit.server.ts +107 -0
  217. package/src/server/lib/harness/acp/acp-goal-driver.server.ts +153 -0
  218. package/src/server/lib/harness/acp/acp-goal-state.server.ts +136 -0
  219. package/src/server/lib/harness/acp/acp-goal.server.ts +273 -0
  220. package/src/server/lib/harness/acp/acp-goal.test.ts +229 -0
  221. package/src/server/lib/harness/acp/acp-telemetry.server.ts +133 -0
  222. package/src/server/lib/harness/acp/acp-telemetry.test.ts +85 -0
  223. package/src/server/lib/harness/acp/acp-todos.server.ts +45 -0
  224. package/src/server/lib/harness/acp/acp-todos.test.ts +43 -0
  225. package/src/server/lib/harness/acp/activation.test.ts +81 -0
  226. package/src/server/lib/harness/acp/activation.ts +72 -0
  227. package/src/server/lib/harness/acp/calls.ts +97 -0
  228. package/src/server/lib/harness/acp/client.test.ts +73 -0
  229. package/src/server/lib/harness/acp/client.ts +339 -0
  230. package/src/server/lib/harness/acp/commands.test.ts +92 -0
  231. package/src/server/lib/harness/acp/commands.ts +165 -0
  232. package/src/server/lib/harness/acp/frames.test.ts +315 -0
  233. package/src/server/lib/harness/acp/frames.ts +349 -0
  234. package/src/server/lib/harness/acp/mapper.ts +204 -0
  235. package/src/server/lib/harness/acp/permissions.test.ts +66 -0
  236. package/src/server/lib/harness/acp/permissions.ts +155 -0
  237. package/src/server/lib/harness/acp/prompt.test.ts +130 -0
  238. package/src/server/lib/harness/acp/prompt.ts +134 -0
  239. package/src/server/lib/harness/acp/protocol.ts +162 -0
  240. package/src/server/lib/harness/acp/session-config.test.ts +73 -0
  241. package/src/server/lib/harness/acp/session-config.ts +148 -0
  242. package/src/server/lib/harness/acp/session-facts.ts +71 -0
  243. package/src/server/lib/harness/acp/session-handshake.ts +89 -0
  244. package/src/server/lib/harness/acp/session-idle.ts +51 -0
  245. package/src/server/lib/harness/acp/session-notifications.ts +95 -0
  246. package/src/server/lib/harness/acp/session-observers.test.ts +193 -0
  247. package/src/server/lib/harness/acp/session-options.ts +33 -0
  248. package/src/server/lib/harness/acp/session-permissions.test.ts +105 -0
  249. package/src/server/lib/harness/acp/session-permissions.ts +74 -0
  250. package/src/server/lib/harness/acp/session-reaper.test.ts +96 -0
  251. package/src/server/lib/harness/acp/session-turns.ts +95 -0
  252. package/src/server/lib/harness/acp/session-usage.ts +60 -0
  253. package/src/server/lib/harness/acp/session-web-state.ts +61 -0
  254. package/src/server/lib/harness/acp/session.test-util.ts +160 -0
  255. package/src/server/lib/harness/acp/session.test.ts +233 -0
  256. package/src/server/lib/harness/acp/session.ts +350 -0
  257. package/src/server/lib/harness/acp/turn.ts +199 -0
  258. package/src/server/lib/harness/acp/verbs.ts +87 -0
  259. package/src/server/lib/harness/auto-probe.server.test.ts +121 -0
  260. package/src/server/lib/harness/auto-probe.server.ts +178 -0
  261. package/src/server/lib/harness/capabilities.ts +67 -0
  262. package/src/server/lib/harness/config-invalidation.test.ts +91 -0
  263. package/src/server/lib/harness/config.server.test.ts +105 -0
  264. package/src/server/lib/harness/config.server.ts +98 -0
  265. package/src/server/lib/harness/enabled.server.test.ts +87 -0
  266. package/src/server/lib/harness/enabled.server.ts +61 -0
  267. package/src/server/lib/harness/launch-table.ts +195 -0
  268. package/src/server/lib/harness/launch.test.ts +220 -0
  269. package/src/server/lib/harness/launch.ts +216 -0
  270. package/src/server/lib/harness/probe-cache.server.test.ts +154 -0
  271. package/src/server/lib/harness/probe-cache.server.ts +177 -0
  272. package/src/server/lib/harness/provider-entry.ts +212 -0
  273. package/src/server/lib/harness/provider-file.server.ts +67 -0
  274. package/src/server/lib/harness/provider-import.test.ts +191 -0
  275. package/src/server/lib/harness/provider-probe.server.ts +123 -0
  276. package/src/server/lib/harness/provider-sources.server.test.ts +45 -0
  277. package/src/server/lib/harness/provider-sources.server.ts +308 -0
  278. package/src/server/lib/harness/provider-write-error.ts +19 -0
  279. package/src/server/lib/harness/provider-write.server.test.ts +308 -0
  280. package/src/server/lib/harness/provider-write.server.ts +339 -0
  281. package/src/server/lib/harness/provider-zcode.server.test.ts +270 -0
  282. package/src/server/lib/harness/provider-zcode.server.ts +324 -0
  283. package/src/server/lib/harness/register.server.ts +36 -0
  284. package/src/server/lib/harness/registry.ts +58 -0
  285. package/src/server/lib/harness/schema.server.ts +129 -0
  286. package/src/server/lib/harness/session-store.server.test.ts +175 -0
  287. package/src/server/lib/harness/session-store.server.ts +206 -0
  288. package/src/server/lib/harness/session-title.server.test.ts +109 -0
  289. package/src/server/lib/harness/session-title.server.ts +70 -0
  290. package/src/server/lib/harness/session.ts +74 -0
  291. package/src/server/lib/harness/spawn.server.ts +133 -0
  292. package/src/server/lib/harness/update-state.server.ts +185 -0
  293. package/src/server/lib/lifecycle/after-listen.ts +7 -0
  294. package/src/server/lib/models/provider-items.server.ts +1 -1
  295. package/src/server/lib/models/registry-refresh.server.test.ts +87 -0
  296. package/src/server/lib/models/registry-refresh.server.ts +98 -0
  297. package/src/server/lib/omp/config/models-config.ts +4 -0
  298. package/src/server/lib/omp/core/cli.ts +13 -0
  299. package/src/server/lib/omp/core/host-resolution.test.ts +6 -3
  300. package/src/server/lib/omp/rpc/child-config.ts +5 -4
  301. package/src/server/lib/omp/rpc/constants.test.ts +2 -1
  302. package/src/server/lib/omp/rpc/event-fanout.ts +9 -0
  303. package/src/server/lib/omp/rpc/forked-resume.test.ts +14 -3
  304. package/src/server/lib/omp/rpc/rpc-primitives.test.ts +11 -0
  305. package/src/server/lib/omp/rpc/session-registration.ts +7 -2
  306. package/src/server/lib/omp/rpc/session-registry.test.ts +2 -1
  307. package/src/server/lib/omp/rpc/session-registry.ts +74 -5
  308. package/src/server/lib/omp/session/acp-rows.server.ts +79 -0
  309. package/src/server/lib/omp/session/delete-flow.server.ts +15 -8
  310. package/src/server/lib/omp/session/delete.server.ts +12 -0
  311. package/src/server/lib/omp/session/sidebar-data.harness.test.ts +247 -0
  312. package/src/server/lib/omp/session/sidebar-data.server.ts +56 -3
  313. package/src/server/lib/queue/delivery.server.test.ts +4 -2
  314. package/src/server/lib/queue/payload.test.ts +67 -0
  315. package/src/server/lib/queue/payload.ts +9 -3
  316. package/src/server/lib/realtime/signals.server.test.ts +99 -0
  317. package/src/server/lib/realtime/signals.server.ts +25 -5
  318. package/src/server/lib/realtime/topics/session-data.server.ts +29 -0
  319. package/src/server/lib/realtime/topics/session.server.ts +3 -3
  320. package/src/server/routes/agent/command-resume.test.ts +77 -0
  321. package/src/server/routes/agent/command.test.ts +243 -2
  322. package/src/server/routes/agent/command.ts +78 -15
  323. package/src/server/routes/agent/harness-command.ts +133 -0
  324. package/src/server/routes/agent/new.ts +63 -1
  325. package/src/server/routes/chat/rewind.test.ts +147 -0
  326. package/src/server/routes/chat/rewind.ts +29 -7
  327. package/src/server/routes/chat/session.test.ts +240 -0
  328. package/src/server/routes/chat/session.ts +96 -4
  329. package/src/server/routes/harness/add-provider.test.ts +233 -0
  330. package/src/server/routes/harness/import-action.ts +272 -0
  331. package/src/server/routes/harness/import.test.ts +196 -0
  332. package/src/server/routes/harness/index.ts +13 -0
  333. package/src/server/routes/harness/root.ts +280 -0
  334. package/src/server/routes/harness/toggle.test.ts +127 -0
  335. package/src/server/routes/harness/update.ts +259 -0
  336. package/src/server/routes/harness/versions.test.ts +148 -0
  337. package/src/server/routes/harness/versions.ts +105 -0
  338. package/src/server/routes/index.ts +2 -0
  339. package/src/server/routes/sessions/delete-acp.test.ts +227 -0
  340. package/src/server/routes/sessions/queue.ts +7 -2
  341. package/src/server/routes/sessions/routes-queue.test.ts +52 -0
  342. package/src/server/routes/sessions/routes.test.ts +47 -13
  343. package/src/server/routes/sessions/session.ts +35 -0
  344. package/src/server/routes/settings/commands-harness.test.ts +92 -0
  345. package/src/server/routes/settings/commands.ts +26 -0
  346. package/src/server/routes/settings/model-override.ts +5 -2
  347. package/src/server/routes/settings/provider-entry.ts +2 -2
  348. package/src/server/routes/settings/provider-model.ts +2 -2
  349. package/src/server/routes/settings/provider-models.ts +2 -2
  350. package/src/server/routes/settings/provider-refresh.ts +6 -4
  351. package/src/server/routes/settings/providers.ts +3 -1
  352. package/src/server/routes/settings/settings-config-routes.test.ts +10 -2
  353. package/src/server/routes/settings/skills.ts +12 -0
  354. package/src/shared/lib/chat/ask-form/fields.ts +76 -0
  355. package/src/shared/lib/chat/ask-form/index.ts +323 -0
  356. package/src/shared/lib/chat/ask-form/tokens.ts +199 -0
  357. package/src/shared/lib/chat/ask-form/types.ts +43 -0
  358. package/src/shared/lib/chat/ask-form.test.ts +137 -0
  359. package/src/shared/lib/chat/ask-questions.test.ts +65 -1
  360. package/src/shared/lib/chat/ask-questions.ts +51 -145
  361. package/src/shared/lib/chat/ask-results.ts +198 -0
  362. package/src/shared/lib/chat/composer/client.ts +20 -8
  363. package/src/shared/lib/chat/context/usage.test.ts +8 -4
  364. package/src/shared/lib/chat/context/usage.ts +17 -3
  365. package/src/shared/lib/chat/omp/abort.test.ts +61 -0
  366. package/src/shared/lib/chat/omp/abort.ts +8 -2
  367. package/src/shared/lib/chat/omp/tool-frames.test.ts +23 -0
  368. package/src/shared/lib/chat/omp/tool-frames.ts +12 -2
  369. package/src/shared/lib/chat/timeline/omp-callbacks.ts +13 -1
  370. package/src/shared/lib/chat/timeline/prompt-error.test.ts +146 -0
  371. package/src/shared/lib/chat/timeline/prompt-error.ts +88 -0
  372. package/src/shared/lib/chat/tool/summary-wait.test.ts +18 -8
  373. package/src/shared/lib/chat/tool/wait-facts.ts +14 -8
  374. package/src/shared/lib/harness/brand-color.test.ts +66 -0
  375. package/src/shared/lib/harness/brand-color.ts +96 -0
  376. package/src/shared/lib/harness/catalog.test.ts +88 -0
  377. package/src/shared/lib/harness/catalog.ts +169 -0
  378. package/src/shared/lib/harness/config-fields.test.ts +139 -0
  379. package/src/shared/lib/harness/config-fields.ts +168 -0
  380. package/src/shared/lib/harness/config.test.ts +153 -0
  381. package/src/shared/lib/harness/config.ts +206 -0
  382. package/src/shared/lib/harness/dialects.test.ts +140 -0
  383. package/src/shared/lib/harness/dialects.ts +249 -0
  384. package/src/shared/lib/harness/enabled.test.ts +79 -0
  385. package/src/shared/lib/harness/enabled.ts +72 -0
  386. package/src/shared/lib/harness/menu.test.ts +94 -0
  387. package/src/shared/lib/harness/menu.ts +88 -0
  388. package/src/shared/lib/harness/provider-facts.test.ts +199 -0
  389. package/src/shared/lib/harness/provider-facts.ts +349 -0
  390. package/src/shared/lib/harness/provider-slug.ts +46 -0
  391. package/src/shared/lib/harness/providers.ts +175 -0
  392. package/src/shared/lib/harness/rewind.ts +24 -0
  393. package/src/shared/lib/harness/status.test.ts +158 -0
  394. package/src/shared/lib/harness/status.ts +112 -0
  395. package/src/shared/lib/harness/update-plan.test.ts +163 -0
  396. package/src/shared/lib/harness/update-plan.ts +140 -0
  397. package/src/shared/lib/harness/updates.test.ts +106 -0
  398. package/src/shared/lib/harness/updates.ts +177 -0
  399. package/src/shared/lib/icons/icon-paint-authority.test.ts +16 -4
  400. package/src/shared/lib/icons/icon-paint-authority.ts +57 -12
  401. package/src/shared/lib/icons/icon-paint-bucket.test.ts +84 -0
  402. package/src/shared/lib/icons/icon-paint-css.test.ts +23 -25
  403. package/src/shared/lib/icons/icon-paint-css.ts +69 -55
  404. package/src/shared/lib/icons/icon-paint-harness.test.ts +73 -0
  405. package/src/shared/lib/icons/icon-paint-harness.ts +75 -0
  406. package/src/shared/lib/icons/icon-paint-ink.ts +108 -0
  407. package/src/shared/lib/icons/icon-paint-panel.ts +19 -4
  408. package/src/shared/lib/icons/icon-paint-weight.ts +21 -2
  409. package/src/shared/lib/icons/icon-tone.ts +118 -21
  410. package/src/shared/lib/icons/tint-hues.generated.ts +100 -284
  411. package/src/shared/lib/icons/tint-tones.test.ts +79 -25
  412. package/src/shared/lib/icons/tint.ts +66 -6
  413. package/src/shared/lib/models/client.ts +10 -1
  414. package/src/shared/lib/models/provider/vendors.ts +72 -0
  415. package/src/shared/lib/omp/config/schema.test.ts +36 -0
  416. package/src/shared/lib/omp/dialog-methods.ts +4 -3
  417. package/src/shared/lib/omp/session/messages-map-trace.test.ts +42 -0
  418. package/src/shared/lib/omp/session/messages-map.ts +6 -1
  419. package/src/shared/lib/omp/session/parse-message-blocks-toolcall.test.ts +8 -0
  420. package/src/shared/lib/omp/session/parse-message-blocks.ts +6 -1
  421. package/src/shared/lib/omp/session/shell-trace.test.ts +69 -0
  422. package/src/shared/lib/omp/session/shell-trace.ts +63 -0
  423. package/src/shared/lib/omp/session/sidebar.ts +37 -10
  424. package/src/shared/lib/omp/session/wait-idle.test.ts +47 -0
  425. package/src/shared/lib/omp/session/wait-idle.ts +93 -0
  426. package/src/shared/lib/omp/session/wait.test.ts +34 -33
  427. package/src/shared/lib/omp/session/wait.ts +25 -39
  428. package/src/shared/lib/settings/sections.ts +24 -0
  429. package/src/shared/lib/theme/css.ts +2 -0
  430. package/src/shared/lib/theme/ink-scale.ts +21 -1
  431. package/src/shared/lib/theme/theme.test.ts +25 -9
  432. package/src/shared/lib/ui/safe-area.test.ts +28 -0
  433. package/src/shared/lib/ui/safe-area.ts +42 -0
  434. package/src/shared/lib/ui/toast-duration.test.ts +74 -0
  435. package/src/shared/lib/ui/toast-duration.ts +70 -0
  436. package/src/shared/types/harness-version.ts +59 -0
  437. package/src/shared/types/harness.ts +201 -0
  438. package/src/shared/types/index.ts +2 -0
  439. package/src/shared/types/omp/agent.ts +13 -0
  440. package/src/shared/types/settings/state.ts +10 -1
  441. package/src/shared/types/workspace.ts +10 -0
  442. package/src/test-support/env.ts +38 -0
  443. package/src/test-support/file-explorer-render.test-util.ts +37 -0
  444. package/src/test-support/file-explorer.test-util.ts +20 -18
  445. package/src/test-support/harness-table.test-util.ts +108 -0
  446. package/dist/client/static/js/index-7ppta1pb.css +0 -1
@@ -27,7 +27,10 @@ import { healStaleStreamStatuses } from '@/shared/lib/omp/session/stream-heal.se
27
27
  import { getAwaitingInputSessionIds, getLiveRunSessionIds, listRpcSessions } from '@/server/lib/omp/rpc/session-registry';
28
28
  import type { SessionItemData, SessionSortOption, WorkspaceFolderData } from '@/shared/types';
29
29
  import { sessionWorktreeMap } from '@/server/lib/fs/worktree/topology';
30
+ import { DEFAULT_HARNESS_ID, HARNESS_IDS } from '@/shared/lib/harness/catalog';
31
+ import { knownHarness, loadAcpSessions, loadHarnessBySession } from '@/server/lib/harness/session-store.server';
30
32
  import { canonicalPath } from '@/server/lib/fs/canonical';
33
+ import { acpRowsFor } from '@/server/lib/omp/session/acp-rows.server';
31
34
  import type { SessionWorktreeInfo } from '@/shared/lib/workspace/worktree/types';
32
35
  import type { OmpSession } from '@/shared/types/omp/session';
33
36
 
@@ -236,6 +239,22 @@ async function serverSidebarSort(): Promise<SessionSortOption> {
236
239
  async function buildRealFolders(folderRows: FolderRow[], archivedIds: Set<string>): Promise<WorkspaceFolderData[]> {
237
240
  const data = await loadOmpSidebarData();
238
241
  const sessionsByRoot = groupSessionsByRoot(data.sessions);
242
+ // WHICH HARNESS OWNS EACH SESSION, read once for the whole list. The live
243
+ // registry cannot answer this: it is a `WeakMap` on the session objects of
244
+ // THIS process, so a restart, a closed tab or a second instance loses it — and
245
+ // that is why every row used to be reported as `omp`. This table is written at
246
+ // spawn and outlives all three.
247
+ let harnessBySession: Map<string, string>;
248
+ let acpSessions: Awaited<ReturnType<typeof loadAcpSessions>>;
249
+ try {
250
+ [harnessBySession, acpSessions] = await Promise.all([loadHarnessBySession(), loadAcpSessions()]);
251
+ } catch {
252
+ // A database without the table yet (an older file opened before this
253
+ // migration ran). Every row then falls back to the omp default below, which
254
+ // is what a reader saw before — never an error page over the whole sidebar.
255
+ harnessBySession = new Map();
256
+ acpSessions = [];
257
+ }
239
258
 
240
259
  return Promise.all(folderRows.map(async (folder) => {
241
260
  const root = folder.project_path ?? '';
@@ -267,6 +286,13 @@ async function buildRealFolders(folderRows: FolderRow[], archivedIds: Set<string
267
286
  id: session.id,
268
287
  folder_id: folder.id,
269
288
  title: sessionTitleFor(session),
289
+ // WHICH AGENT PRODUCED THIS CHAT, from the persisted record. A session
290
+ // discovered in omp's JSONL store with no row is an omp one by
291
+ // construction (that is where omp writes), and `DEFAULT_HARNESS_ID` is
292
+ // then the truth rather than a guess. A session spawned over ACP has its
293
+ // own row, so the mark beside its name names the agent that ran it —
294
+ // reporting `omp` for every row made the mark decorative.
295
+ harness: knownHarness(harnessBySession.get(String(session.id)), HARNESS_IDS) ?? DEFAULT_HARNESS_ID,
270
296
  created_at: session.created,
271
297
  updated_at: session.modified,
272
298
  is_active: 0,
@@ -279,6 +305,33 @@ async function buildRealFolders(folderRows: FolderRow[], archivedIds: Set<string
279
305
  ...(worktree ? { worktree } : {}),
280
306
  };
281
307
  }));
308
+ // ACP chats live ONLY here: their agent writes no session file, so omp's
309
+ // discovery cannot see them and a chat vanished from the sidebar the moment
310
+ // its tab closed. They are filed under the folder whose PROJECT contains
311
+ // their cwd, resolved the same way the discovery scan resolves it — a chat
312
+ // started in a subdirectory belongs to the folder that owns it, not to none.
313
+ const folderAcp = rootKey
314
+ ? await acpRowsFor(acpSessions, rootKey, folder.id, archivedIds)
315
+ : [];
316
+ // ONE CHAT, ONE ROW. The two producers overlap whenever the agent writes a
317
+ // session file AND has a `harness_sessions` record, and that is not a
318
+ // corner case: `omp-acp` launches `omp acp`, so its chats are ordinary
319
+ // `.jsonl` files discovery finds — measured, an `omp (ACP)` chat appeared
320
+ // TWICE in the sidebar under the same id, one row from the scan and one
321
+ // from the record. The scan's row is authoritative (it carries the real
322
+ // title, timestamps and subagent state), so a recorded row whose id the
323
+ // scan already listed is dropped rather than replaced.
324
+ const discoveredIds = new Set(folderSessions.map((session) => String(session.id)));
325
+ const uniqueAcp = folderAcp.filter((row) => !discoveredIds.has(String(row.id)));
326
+ // MERGED, then ordered as ONE list. Appending the ACP rows after omp's
327
+ // already-sorted bucket put them at the bottom of a 240-row folder, which is
328
+ // why a chat just spawned on `opencode2` never appeared above "Show more".
329
+ // The scan's own rule is `b.modified.localeCompare(a.modified)`
330
+ // (`groupSessionsByRoot`), so this uses the same key rather than a second
331
+ // definition of "newest".
332
+ const allSessions = [...folderSessions, ...uniqueAcp].sort((a, b) =>
333
+ (b.updated_at ?? b.created_at ?? '').localeCompare(a.updated_at ?? a.created_at ?? ''),
334
+ );
282
335
  return {
283
336
  id: folder.id,
284
337
  name: folder.name,
@@ -289,9 +342,9 @@ async function buildRealFolders(folderRows: FolderRow[], archivedIds: Set<string
289
342
  accentColor: folder.accent_color || '',
290
343
  icon: folder.icon || 'default',
291
344
  customIconUrl: folder.custom_icon_url || undefined,
292
- sessions: folderSessions,
293
- hasMore: folderSessions.length > 7,
294
- totalSessions: folderSessions.length,
345
+ sessions: allSessions,
346
+ hasMore: allSessions.length > 7,
347
+ totalSessions: allSessions.length,
295
348
  };
296
349
  }));
297
350
  }
@@ -215,8 +215,10 @@ describe('queue delivery scheduling', () => {
215
215
  queue.set(sessionId, [queueItem('a'), queueItem('b'), queueItem('c')]);
216
216
  const { host } = makeHost(sessionId);
217
217
  let attempts = 0;
218
- host.send = async () => {
219
- attempts++;
218
+ host.send = async (command) => {
219
+ // The model snapshot is best-effort and writes two selectors first; the
220
+ // invariant here is one CLAIMED HEAD, so count prompts only.
221
+ if (command.type === 'prompt') attempts++;
220
222
  throw new Error('agent_busy');
221
223
  };
222
224
 
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The stored-model snapshot is a RE-TARGET, not part of the message.
8
+ *
9
+ * A harness that publishes no model or thinking selector answers the verb with
10
+ * an error (ACP: "This harness exposes no model selector"). Letting that abort
11
+ * the delivery re-queued the user's message forever — measured in the delivery
12
+ * loop, which retries a failed dispatch every two seconds.
13
+ */
14
+
15
+ import { describe, expect, test } from 'bun:test';
16
+ import { applyModelSnapshot, promptCommand } from '@/server/lib/queue/payload';
17
+
18
+ const model = { provider: 'claude', modelId: 'default', thinkingLevel: 'high', accessMode: 'always-ask' as const };
19
+
20
+ describe('applyModelSnapshot', () => {
21
+ test('writes the model, then the thinking level', async () => {
22
+ const sent: Record<string, unknown>[] = [];
23
+ await applyModelSnapshot(async (command) => { sent.push(command); }, model);
24
+ expect(sent).toEqual([
25
+ { type: 'set_model', provider: 'claude', modelId: 'default' },
26
+ { type: 'set_thinking_level', level: 'high' },
27
+ ]);
28
+ });
29
+
30
+ test('a refused selector does not stop the prompt from being delivered', async () => {
31
+ const sent: Record<string, unknown>[] = [];
32
+ await applyModelSnapshot(async (command) => {
33
+ sent.push(command);
34
+ throw new Error('This harness exposes no model selector');
35
+ }, model);
36
+ // Both writes were attempted, and the caller gets no rejection, so the
37
+ // queued prompt that follows is still dispatched.
38
+ expect(sent).toHaveLength(2);
39
+ });
40
+
41
+ test("'auto' leaves the thinking level untouched", async () => {
42
+ const sent: Record<string, unknown>[] = [];
43
+ await applyModelSnapshot(async (command) => { sent.push(command); }, { ...model, thinkingLevel: 'auto' });
44
+ expect(sent.map((command) => command.type)).toEqual(['set_model']);
45
+ });
46
+
47
+ test('no snapshot writes nothing', async () => {
48
+ const sent: Record<string, unknown>[] = [];
49
+ await applyModelSnapshot(async (command) => { sent.push(command); }, null);
50
+ expect(sent).toEqual([]);
51
+ });
52
+ });
53
+
54
+ describe('promptCommand', () => {
55
+ test('carries the access tier and flattens a stored text attachment', () => {
56
+ const command = promptCommand({
57
+ text: 'see the file',
58
+ attachments: [
59
+ { id: 'a1', name: 'notes.txt', type: 'text/plain', size: 4, content: 'body', preview: '' },
60
+ ],
61
+ model: { ...model, accessMode: 'yolo' },
62
+ });
63
+ expect(command.type).toBe('prompt');
64
+ expect(command.accessMode).toBe('yolo');
65
+ expect(String(command.message)).toContain('body');
66
+ });
67
+ });
@@ -58,16 +58,22 @@ export function promptCommand(prompt: StoredPrompt): Record<string, unknown> {
58
58
  };
59
59
  }
60
60
 
61
- /** Apply a stored model snapshot to a live child before its prompt. */
61
+ /** Apply a stored model snapshot to a live child before its prompt.
62
+ *
63
+ * Best-effort PER COMMAND: a harness that publishes no model or thinking
64
+ * selector answers the verb with an error, and letting that abort the whole
65
+ * delivery left the queued item re-queued forever. The prompt itself is the
66
+ * user's message and still has to go out; the snapshot only re-targets it when
67
+ * the agent can honour it. */
62
68
  export async function applyModelSnapshot(
63
69
  send: (command: Record<string, unknown>) => Promise<unknown>,
64
70
  model: QueuedMessageModel | null,
65
71
  ): Promise<void> {
66
72
  if (!model) return;
67
- await send({ type: 'set_model', provider: model.provider, modelId: model.modelId });
73
+ await send({ type: 'set_model', provider: model.provider, modelId: model.modelId }).catch(() => undefined);
68
74
  // 'auto' thinking leaves omp's level alone: the snapshot records "no pick",
69
75
  // not a level named auto.
70
76
  if (model.thinkingLevel !== 'auto') {
71
- await send({ type: 'set_thinking_level', level: model.thinkingLevel });
77
+ await send({ type: 'set_thinking_level', level: model.thinkingLevel }).catch(() => undefined);
72
78
  }
73
79
  }
@@ -0,0 +1,99 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The signal registry must survive a module re-evaluation.
8
+ *
9
+ * This is the bug the `globalThis` slot exists for: `bun --hot` re-evaluates
10
+ * `signals.server.ts` while `initRealtimeTopics` — guarded by its own
11
+ * `globalThis` flag — never runs again, so the one surviving subscriber is never
12
+ * re-registered. With the registry in module scope the reload left an EMPTY set
13
+ * behind and `emitRealtimeSignal` from the new instance reached nobody: measured
14
+ * on a long-running dev server, `session_stream_state` writes stopped
15
+ * publishing entirely (`sidebar:status`'s sequence never advanced) while topics
16
+ * published by a direct call kept moving — no sidebar spinner, no terminal
17
+ * badge, no activity stamp.
18
+ *
19
+ * A fresh evaluation is simulated the way `bun --hot` produces one: a second
20
+ * module instance, which shares only `globalThis`. The specifier is held in a
21
+ * variable because TypeScript refuses to resolve a query string, and the
22
+ * distinctness assertions below are what prove the two instances really are two
23
+ * (`bun` returns the cached namespace for the bare specifier).
24
+ */
25
+
26
+ import { beforeEach, describe, expect, test } from 'bun:test';
27
+ import type * as Signals from '@/server/lib/realtime/signals.server';
28
+ import {
29
+ clearRealtimeSignalListeners,
30
+ emitRealtimeSignal,
31
+ onRealtimeSignal,
32
+ } from '@/server/lib/realtime/signals.server';
33
+
34
+ const RELOADED_SPECIFIER = '@/server/lib/realtime/signals.server?reload=1';
35
+
36
+ async function reloadSignals(): Promise<typeof Signals> {
37
+ // The dynamic specifier is the point of this helper, not an accident: a static
38
+ // import cannot produce a second evaluation of the module.
39
+ return (await import(RELOADED_SPECIFIER)) as typeof Signals;
40
+ }
41
+
42
+ beforeEach(() => {
43
+ clearRealtimeSignalListeners();
44
+ });
45
+
46
+ describe('realtime signal registry', () => {
47
+ test('a reloaded instance is a genuinely separate evaluation', async () => {
48
+ const reloaded = await reloadSignals();
49
+
50
+ // Both instances share one registry, but they are not the same module.
51
+ expect(reloaded.emitRealtimeSignal).not.toBe(emitRealtimeSignal);
52
+ expect(reloaded.onRealtimeSignal).not.toBe(onRealtimeSignal);
53
+ });
54
+
55
+ test('delivers to a listener registered before a module re-evaluation', async () => {
56
+ const seen: string[] = [];
57
+ onRealtimeSignal((event) => seen.push(event.signal));
58
+
59
+ const reloaded = await reloadSignals();
60
+ reloaded.emitRealtimeSignal('stream-status');
61
+
62
+ expect(seen).toEqual(['stream-status']);
63
+ });
64
+
65
+ test('both instances subscribe to and read from one list', async () => {
66
+ const calls: string[] = [];
67
+ onRealtimeSignal((event) => calls.push(`first:${event.signal}`));
68
+
69
+ const reloaded = await reloadSignals();
70
+ const unsubscribe = reloaded.onRealtimeSignal((event) => calls.push(`second:${event.signal}`));
71
+
72
+ emitRealtimeSignal('sidebar-structure');
73
+ reloaded.emitRealtimeSignal('schedule-changed');
74
+ unsubscribe();
75
+ reloaded.emitRealtimeSignal('panels-changed');
76
+
77
+ // One subscription list, and an unsubscribe from either instance removes
78
+ // the listener for both.
79
+ expect(calls).toEqual([
80
+ 'first:sidebar-structure',
81
+ 'second:sidebar-structure',
82
+ 'first:schedule-changed',
83
+ 'second:schedule-changed',
84
+ 'first:panels-changed',
85
+ ]);
86
+ });
87
+
88
+ test('a throwing listener never stops the others', () => {
89
+ const seen: string[] = [];
90
+ onRealtimeSignal(() => {
91
+ throw new Error('boom');
92
+ });
93
+ onRealtimeSignal((event) => seen.push(event.signal));
94
+
95
+ emitRealtimeSignal('models-changed');
96
+
97
+ expect(seen).toEqual(['models-changed']);
98
+ });
99
+ });
@@ -87,12 +87,32 @@ export interface RealtimeSignalEvent {
87
87
 
88
88
  type SignalListener = (event: RealtimeSignalEvent) => void;
89
89
 
90
- const listeners = new Set<SignalListener>();
90
+ declare global {
91
+ // eslint-disable-next-line no-var
92
+ var __kabmoRealtimeSignalListeners: Set<SignalListener> | undefined;
93
+ }
94
+
95
+ /**
96
+ * The subscriber set lives on `globalThis`, for the reason the hub and the
97
+ * publish state do: `bun --hot` re-evaluates this module (and `topics.server.ts`
98
+ * with it) while `initRealtimeTopics`'s one-shot guard does not re-run, and the
99
+ * writers are imported by whichever instance is current. A module-level Set is
100
+ * therefore a NEW, EMPTY set after the first hot reload that the one surviving
101
+ * subscriber never re-registers into — every signal then reached nobody, and
102
+ * `session_stream_state` writes stopped publishing: measured on a dev server
103
+ * that had been reloading for hours, `sidebar:status`'s sequence never advanced
104
+ * (no sidebar spinner, no terminal badge, no activity stamp, no workspace or
105
+ * schedule refresh) while topics published by a DIRECT call kept moving.
106
+ */
107
+ function listeners(): Set<SignalListener> {
108
+ return (globalThis.__kabmoRealtimeSignalListeners ??= new Set());
109
+ }
91
110
 
92
111
  /** Subscribe to every signal. Returns an unsubscribe. */
93
112
  export function onRealtimeSignal(listener: SignalListener): () => void {
94
- listeners.add(listener);
95
- return () => listeners.delete(listener);
113
+ const set = listeners();
114
+ set.add(listener);
115
+ return () => set.delete(listener);
96
116
  }
97
117
 
98
118
  /**
@@ -105,7 +125,7 @@ export function emitRealtimeSignal(signal: RealtimeSignal, sessionId?: string, r
105
125
  sessionId === undefined && root === undefined
106
126
  ? { signal }
107
127
  : { signal, ...(sessionId !== undefined ? { sessionId } : {}), ...(root !== undefined ? { root } : {}) };
108
- for (const listener of [...listeners]) {
128
+ for (const listener of [...listeners()]) {
109
129
  try {
110
130
  listener(event);
111
131
  } catch {
@@ -116,5 +136,5 @@ export function emitRealtimeSignal(signal: RealtimeSignal, sessionId?: string, r
116
136
 
117
137
  /** Test seam. */
118
138
  export function clearRealtimeSignalListeners(): void {
119
- listeners.clear();
139
+ listeners().clear();
120
140
  }
@@ -25,6 +25,10 @@ import { mockSessionTodos, mockSessionPlans } from '@/server/lib/omp/session/dat
25
25
  import { listQueue } from '@/server/lib/queue/store.server';
26
26
  import { loadSessionSource } from '@/server/lib/chat/session-store.server';
27
27
  import { computeRealSessionTelemetry } from '@/server/lib/omp/session/telemetry';
28
+ import { getLiveSession, harnessOfSession } from '@/server/lib/omp/rpc/session-registry';
29
+ import { loadAcpSessions } from '@/server/lib/harness/session-store.server';
30
+ import { buildAcpTelemetry, loadAcpUsage, type AcpTelemetrySession } from '@/server/lib/harness/acp/acp-telemetry.server';
31
+ import { buildAcpTodos } from '@/server/lib/harness/acp/acp-todos.server';
28
32
  import { isMockMode } from '@/server/mock.server';
29
33
  import type { SessionTodosPayload } from '@/shared/types/todo';
30
34
  import type { SessionPlanPayload } from '@/shared/types/plan';
@@ -40,6 +44,16 @@ function todosDescriptor(sessionId: string): TopicDescriptor {
40
44
  return {
41
45
  resolve: async (): Promise<SessionTodosPayload> => {
42
46
  const isMock = isMockMode();
47
+ const live = isMock ? undefined : getLiveSession(sessionId);
48
+ if (live && harnessOfSession(live) !== 'omp-rpc') {
49
+ const entries = (live as unknown as { planEntries?: unknown[] }).planEntries ?? [];
50
+ return {
51
+ sessionId,
52
+ ...buildAcpTodos(entries),
53
+ generatedAt: new Date().toISOString(),
54
+ isMock,
55
+ };
56
+ }
43
57
  return {
44
58
  sessionId,
45
59
  ...(isMock ? mockSessionTodos() : await readSessionTodos(sessionId)),
@@ -80,6 +94,21 @@ function telemetryDescriptor(sessionId: string): TopicDescriptor {
80
94
  return {
81
95
  resolve: async () => {
82
96
  if (isMockMode()) return null;
97
+ // A live ACP session reports usage itself; there is no transcript to
98
+ // compute from, and returning null left the ring and the Context panel
99
+ // saying "not started" over a running chat.
100
+ const live = getLiveSession(sessionId);
101
+ if (live && harnessOfSession(live) !== 'omp-rpc') {
102
+ const row = (await loadAcpSessions().catch(() => [])).find((entry) => entry.sessionId === sessionId);
103
+ return buildAcpTelemetry(live as unknown as AcpTelemetrySession, row?.title);
104
+ }
105
+ // The process is gone, but the last usage it reported is on disk. omp
106
+ // recomputes from its JSONL; this is the ACP equivalent.
107
+ const stored = await loadAcpUsage(sessionId);
108
+ if (stored) {
109
+ const row = (await loadAcpSessions().catch(() => [])).find((entry) => entry.sessionId === sessionId);
110
+ if (row) return buildAcpTelemetry(stored, row.title);
111
+ }
83
112
  const source = await loadSessionSource(sessionId);
84
113
  // The real computation reads the session's JSONL; the in-memory source
85
114
  // has no file to point at, so those sessions answer nothing here and the
@@ -30,7 +30,7 @@ import {
30
30
  fetchPeerSessionSnapshot,
31
31
  peerOriginForSession,
32
32
  } from '@/server/lib/omp/rpc/peer-proxy.server';
33
- import { getRpcSession } from '@/server/lib/omp/rpc/manager';
33
+ import { getLiveSession } from '@/server/lib/omp/rpc/session-registry';
34
34
  import { attachPeerSession } from '@/server/lib/realtime/topics/peer-relay.server';
35
35
  import { isRecord } from '@/shared/lib/util/guards';
36
36
 
@@ -91,7 +91,7 @@ function relayOwnerStream(sessionId: string, isCancelled: () => boolean): () =>
91
91
  export function sessionDescriptor(sessionId: string): TopicDescriptor {
92
92
  return {
93
93
  resolve: async (): Promise<AgentSnapshot> => {
94
- const session = getRpcSession(sessionId);
94
+ const session = getLiveSession(sessionId);
95
95
  if (session?.isAlive()) return buildAgentSnapshot(sessionId);
96
96
  // Not ours: answer with the OWNER's payload, the way the HTTP route does.
97
97
  // A session that is free (no owner) keeps the local answer.
@@ -102,7 +102,7 @@ export function sessionDescriptor(sessionId: string): TopicDescriptor {
102
102
  },
103
103
 
104
104
  attach: () => {
105
- const session = getRpcSession(sessionId);
105
+ const session = getLiveSession(sessionId);
106
106
  if (session?.isAlive()) {
107
107
  return session.onEvent((event) => {
108
108
  getRealtimeHub().publish(sessionTopic(sessionId), event);
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
7
+ import { sendCommand } from '@/server/routes/agent/command';
8
+ import { saveHarnessConfig } from '@/server/lib/harness/config.server';
9
+ import { saveHarnessSession } from '@/server/lib/harness/session-store.server';
10
+ import { EMPTY_HARNESS_CONFIG } from '@/shared/lib/harness/config';
11
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
12
+
13
+ function post(sessionId: string, body: Record<string, unknown>): Promise<Response> {
14
+ return sendCommand({
15
+ params: { sessionId },
16
+ request: new Request(`http://localhost/api/agent/${sessionId}`, {
17
+ method: 'POST',
18
+ headers: { 'Content-Type': 'application/json' },
19
+ body: JSON.stringify(body),
20
+ }),
21
+ } as never) as Promise<Response>;
22
+ }
23
+
24
+ async function payload(response: Response): Promise<Record<string, unknown>> {
25
+ return (await response.json()) as Record<string, unknown>;
26
+ }
27
+
28
+ /**
29
+ * Continuing a chat whose agent writes no session file.
30
+ *
31
+ * `acpRowsFor` LISTS those chats, and every command sent to one answered
32
+ * `{"error":"Session not found"}` after a restart: this route resumes over RPC,
33
+ * which resolves a `.jsonl` path — and an ACP agent writes none. Measured on a
34
+ * `claude` chat whose row was in the sidebar: both `prompt` and `get_state`
35
+ * answered 404. Its own agent can restore the conversation, so the route
36
+ * respawns it on that harness and dispatches there.
37
+ */
38
+ describe('resuming a recorded non-omp chat', () => {
39
+ const RETIRED = 'resume-retired-harness';
40
+ const UNLAUNCHABLE = 'resume-unlaunchable-harness';
41
+ const MISSING = '/nonexistent/kabmo-test-agent';
42
+
43
+ beforeEach(async () => {
44
+ await isolateDb();
45
+ });
46
+
47
+ afterEach(async () => {
48
+ await releaseDb();
49
+ });
50
+
51
+ test('a retired harness id spawns NOTHING and keeps the 404', async () => {
52
+ // `opencode2` is out of this build's catalog: a stale row must not be
53
+ // guessed at, and there is no other producer to ask.
54
+ await saveHarnessSession({ sessionId: RETIRED, harness: 'opencode2', agentSessionId: RETIRED, cwd: '/tmp' });
55
+ const response = await post(RETIRED, { type: 'prompt', message: 'hello' });
56
+ expect(response.status).toBe(404);
57
+ expect(await payload(response)).toMatchObject({ error: 'Session not found' });
58
+ });
59
+
60
+ test('a recorded non-omp chat is respawned on ITS OWN harness', async () => {
61
+ await saveHarnessSession({ sessionId: UNLAUNCHABLE, harness: 'pi', agentSessionId: 'agent-7', cwd: '/tmp' });
62
+ // A launch line that cannot exist, so the case is deterministic on a machine
63
+ // where `pi` IS installed: what it proves is WHICH path ran, not that a
64
+ // binary is missing.
65
+ await saveHarnessConfig('pi', { ...EMPTY_HARNESS_CONFIG, command: MISSING });
66
+
67
+ const response = await post(UNLAUNCHABLE, { type: 'prompt', message: 'hello' });
68
+
69
+ // 400 from the spawn attempt, not the locator's 404: the command reached the
70
+ // recorded harness instead of looking for a session file that never existed.
71
+ expect(response.status).toBe(400);
72
+ const body = await payload(response);
73
+ const message = typeof body.error === 'string' ? body.error : '';
74
+ expect(message).not.toContain('Session not found');
75
+ expect(message).toContain(MISSING);
76
+ });
77
+ });