@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
@@ -0,0 +1,336 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The composer's harness tabs.
8
+ *
9
+ * The behaviour that matters is what a user is TOLD, because the alternative is
10
+ * a control that looks available and refuses:
11
+ *
12
+ * - a harness that cannot run here is disabled AND carries the agent's own
13
+ * reason (`mcode login`, `executable not found (command: pi)`);
14
+ * - a chat that already has a transcript cannot change harness — the tab says
15
+ * "start a new chat" instead of switching the transport under a live run;
16
+ * - the active tab is marked for assistive tech, not by colour alone.
17
+ */
18
+
19
+ import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
20
+ import { Window } from 'happy-dom';
21
+ import { h, render } from 'preact';
22
+ import { act } from 'preact/test-utils';
23
+
24
+ import { HarnessTabs, harnessBlock, harnessBlockedReason, harnessTabTitle } from '@/client/components/workspace/model-dropdown/HarnessTabs';
25
+ import { HARNESS_GLYPH_SIZE } from '@/client/components/common/harness-glyph';
26
+ import type { HarnessSummary } from '@/shared/types/harness';
27
+
28
+ const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event', 'MouseEvent', 'KeyboardEvent'] as const;
29
+ const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
30
+
31
+ let container: HTMLElement;
32
+
33
+ beforeAll(() => {
34
+ const win = new Window({ url: 'http://localhost' });
35
+ const target = globalThis as unknown as Record<string, unknown>;
36
+ for (const key of DOM_GLOBALS) {
37
+ if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
38
+ target[key] = (win as unknown as Record<string, unknown>)[key];
39
+ }
40
+ });
41
+
42
+ afterAll(() => {
43
+ const target = globalThis as unknown as Record<string, unknown>;
44
+ for (const key of DOM_GLOBALS) {
45
+ if (nativeGlobals[key] === undefined) delete target[key];
46
+ else target[key] = nativeGlobals[key];
47
+ }
48
+ });
49
+
50
+ afterEach(() => {
51
+ if (container) render(null, container);
52
+ container?.remove();
53
+ });
54
+
55
+ function summary(id: string, overrides: Partial<HarnessSummary> = {}): HarnessSummary {
56
+ return { id, label: id, transport: 'acp', canLaunch: true, enabled: true, probe: null, ...overrides };
57
+ }
58
+
59
+ const probeBlocked = (reason: string) => ({
60
+ harness: 'claude',
61
+ capabilities: {
62
+ configModel: 0, configThinking: 0, configMode: 0, modeValues: [],
63
+ loadSession: false, listSessions: false, forkSession: false, deleteSession: false,
64
+ resumeSession: false, closeSession: false, hasUsage: false, hasPlan: false,
65
+ steerMode: null, blocked: reason,
66
+ },
67
+ models: [], thinking: [], modes: [], probedAt: Date.now(),
68
+ });
69
+
70
+ async function mount(node: preact.ComponentChild) {
71
+ container = document.createElement('div');
72
+ document.body.appendChild(container);
73
+ await act(async () => {
74
+ render(node, container);
75
+ });
76
+ return container;
77
+ }
78
+
79
+ describe('harness tabs', () => {
80
+ test('a runnable harness is a selectable tab', async () => {
81
+ const picked: string[] = [];
82
+ const el = await mount(h(HarnessTabs, {
83
+ harnesses: [summary('omp-rpc'), summary('claude')],
84
+ active: 'omp-rpc',
85
+ editable: true,
86
+ onSelect: (id: string) => picked.push(id),
87
+ }));
88
+ const tabs = el.querySelectorAll('[role="tab"]');
89
+ expect(tabs).toHaveLength(2);
90
+ expect(tabs[0]?.getAttribute('aria-selected')).toBe('true');
91
+ await act(async () => {
92
+ (tabs[1] as HTMLElement).click();
93
+ });
94
+ expect(picked).toEqual(['claude']);
95
+ });
96
+
97
+ test('an uninstalled harness is marked unusable, keeps its reason, and opens the fix', async () => {
98
+ const fixes: string[] = [];
99
+ const el = await mount(h(HarnessTabs, {
100
+ harnesses: [summary('pi', { canLaunch: false, unavailable: '`pi` is not installed', install: 'npm i -g pi-acp' })],
101
+ active: null,
102
+ editable: true,
103
+ onSelect: () => {},
104
+ onFix: (id: string) => fixes.push(id),
105
+ }));
106
+ const tab = el.querySelector('[role="tab"]') as HTMLButtonElement;
107
+ // `aria-disabled`, never the native attribute: measured in Chromium, a
108
+ // `<button disabled>` never shows its `title` and never delivers a click, so
109
+ // the reason — the whole point of a blocked tab — was unreachable.
110
+ expect(tab.disabled).toBe(false);
111
+ expect(tab.getAttribute('aria-disabled')).toBe('true');
112
+ expect(tab.getAttribute('title')).toContain('not installed');
113
+ expect(tab.getAttribute('title')).toContain('npm i -g pi-acp');
114
+ await act(async () => {
115
+ tab.click();
116
+ });
117
+ expect(fixes).toEqual(['pi']);
118
+ });
119
+
120
+ test("a probe's own refusal becomes the tab's reason", async () => {
121
+ const blocked = summary('claude', { probe: probeBlocked('Authentication required: Run `mcode login` and try again.') });
122
+ expect(harnessBlockedReason(blocked)).toContain('mcode login');
123
+ });
124
+
125
+ test('the built-in transport is never blocked, even with a cached refusal', () => {
126
+ // `omp` over RPC is the default every session already runs on. A probe of it
127
+ // can only answer "no launch command is configured" — there is no agent to
128
+ // spawn — and that record, once cached, painted a ⚠ over the tab and
129
+ // DISABLED it, so the default harness could not be selected at all.
130
+ const poisoned = summary('omp-rpc', {
131
+ builtIn: true,
132
+ probe: probeBlocked('No launch command is configured for this harness'),
133
+ });
134
+ expect(harnessBlockedReason(poisoned)).toBeNull();
135
+ });
136
+
137
+ test('the built-in tab stays clickable and carries no warning mark', async () => {
138
+ const picked: string[] = [];
139
+ const el = await mount(h(HarnessTabs, {
140
+ harnesses: [
141
+ summary('omp-rpc', { builtIn: true, probe: probeBlocked('No launch command is configured for this harness') }),
142
+ summary('claude'),
143
+ ],
144
+ active: 'claude',
145
+ editable: true,
146
+ onSelect: (id: string) => picked.push(id),
147
+ }));
148
+ const tab = el.querySelectorAll('[role="tab"]')[0] as HTMLButtonElement;
149
+ expect(tab.disabled).toBe(false);
150
+ expect(tab.getAttribute('aria-disabled')).toBe('false');
151
+ expect(tab.textContent).not.toContain('⚠');
152
+ await act(async () => {
153
+ tab.click();
154
+ });
155
+ expect(picked).toEqual(['omp-rpc']);
156
+ });
157
+
158
+ test('a chat with a transcript cannot switch harness', async () => {
159
+ const picked: string[] = [];
160
+ const el = await mount(h(HarnessTabs, {
161
+ harnesses: [summary('omp-rpc', { label: 'omp' }), summary('claude')],
162
+ active: 'omp-rpc',
163
+ editable: false,
164
+ onSelect: (id: string) => picked.push(id),
165
+ }));
166
+ const tabs = el.querySelectorAll('[role="tab"]');
167
+ const claude = tabs[1] as HTMLButtonElement;
168
+ // The sentence has to name the agent the chat ALREADY started on. "Start a
169
+ // new chat to use claude" was true and useless: it never said which agent
170
+ // held the chat, so a user could not tell a lock from their own mistake.
171
+ expect(claude.getAttribute('title')).toContain('this chat already started on omp');
172
+ expect(claude.getAttribute('title')).toContain('Start a new chat to use claude');
173
+ // The same sentence on the accessible path: an `aria-disabled` tab is still
174
+ // focusable, and a screen reader would otherwise hear "claude, tab, dimmed"
175
+ // with no reason attached.
176
+ expect(claude.getAttribute('aria-description')).toBe(claude.getAttribute('title'));
177
+ // The active tab is not offered as an alternative to itself.
178
+ expect(tabs[0]?.getAttribute('title')).toContain('already started on');
179
+ expect(tabs[0]?.getAttribute('title')).not.toContain('Cannot switch');
180
+ // Unusable, but still pressable: `title` is unreachable on a native
181
+ // `disabled` button (measured in Chromium), and this tab's whole job here is
182
+ // to explain itself.
183
+ expect(claude.disabled).toBe(false);
184
+ expect(claude.getAttribute('aria-disabled')).toBe('true');
185
+ await act(async () => {
186
+ claude.click();
187
+ });
188
+ expect(picked).toEqual([]);
189
+ });
190
+
191
+ test('a tab with nothing wrong answers with the agent it would start', () => {
192
+ const probed = summary('claude', {
193
+ probe: {
194
+ ...probeBlocked(''),
195
+ capabilities: { ...probeBlocked('').capabilities, blocked: undefined, agentName: 'claude-code', agentVersion: '2.0.1' },
196
+ },
197
+ });
198
+ expect(harnessTabTitle(probed, { block: null, editable: true, active: null })).toBe('claude · claude-code 2.0.1');
199
+ // No probe yet: the label, not a fabricated build string.
200
+ expect(harnessTabTitle(summary('codex'), { block: null, editable: true, active: null })).toBe('codex');
201
+ });
202
+
203
+ test('a blocked tab states the block, never the label', () => {
204
+ const blocked = summary('pi', { canLaunch: false, unavailable: '`pi` is not installed', install: 'npm i -g pi-acp' });
205
+ const title = harnessTabTitle(blocked, { block: { reason: '`pi` is not installed', fix: 'npm i -g pi-acp' }, editable: false, active: 'omp-rpc' });
206
+ // The block comes FIRST: a tab can be both unusable and owned by another
207
+ // agent, and only the block means anything about this harness.
208
+ expect(title.startsWith('pi: `pi` is not installed')).toBe(true);
209
+ expect(title).toContain('npm i -g pi-acp');
210
+ });
211
+
212
+ test('an agent that answered with a refusal is never told to install itself', () => {
213
+ // Measured in the running picker: `codex` was blocked with "Authentication
214
+ // required" and the tab appended `npm i -g @agentclientprotocol/codex-acp`
215
+ // — telling the user to install a program that had just replied. A probe
216
+ // refusal means the binary RAN, so only a missing launch gets install advice.
217
+ const refused = summary('codex', {
218
+ canLaunch: true,
219
+ install: 'npm i -g @agentclientprotocol/codex-acp',
220
+ probe: probeBlocked('Authentication required'),
221
+ });
222
+ const title = harnessTabTitle(refused, { block: harnessBlock(refused), editable: true, active: null });
223
+ expect(title).toContain('Authentication required');
224
+ expect(title).not.toContain('install');
225
+ });
226
+
227
+ test('a tab is the mark alone, so the mark carries the name', async () => {
228
+ const el = await mount(h(HarnessTabs, {
229
+ harnesses: [summary('codex')],
230
+ active: 'codex',
231
+ editable: true,
232
+ onSelect: () => {},
233
+ }));
234
+ const tab = el.querySelector('[role="tab"]') as HTMLElement;
235
+ // No visible label: the tab's textContent is empty, and the accessible name
236
+ // is the harness's own label. Asserting only "the glyph is there" would pass
237
+ // with a label beside it, which is the state this replaced.
238
+ expect(tab.textContent?.trim()).toBe('');
239
+ expect(tab.getAttribute('aria-label')).toBe('codex');
240
+ expect(el.querySelector('[data-harness="codex"]')).not.toBeNull();
241
+ });
242
+
243
+ test('the tab mark is sized as a control, not as a row ornament', async () => {
244
+ const el = await mount(h(HarnessTabs, {
245
+ harnesses: [summary('codex')],
246
+ active: 'codex',
247
+ editable: true,
248
+ onSelect: () => {},
249
+ }));
250
+ // The tab is the only control whose mark is the WHOLE target, so it is drawn
251
+ // larger than the dense-list sizes it shares a component with.
252
+ expect(el.querySelector('svg')?.getAttribute('width')).toBe(String(HARNESS_GLYPH_SIZE.tab));
253
+ expect(HARNESS_GLYPH_SIZE.tab).toBeGreaterThan(HARNESS_GLYPH_SIZE.touch);
254
+ });
255
+
256
+ test('the mark inside a tab is DECORATION, so the tab keeps its own tooltip', async () => {
257
+ // Measured: hovering a locked tab announced the glyph's generic "Session runs
258
+ // on claude" and never the explanation — a nested `title` is the one the
259
+ // browser shows, and it sits INSIDE the button.
260
+ const el = await mount(h(HarnessTabs, {
261
+ harnesses: [summary('omp-rpc', { label: 'omp' }), summary('claude')],
262
+ active: 'omp-rpc',
263
+ editable: false,
264
+ onSelect: () => {},
265
+ }));
266
+ const claude = el.querySelectorAll('[role="tab"]')[1] as HTMLElement;
267
+ const mark = claude.querySelector('[data-harness="claude"]') as HTMLElement;
268
+ expect(mark.getAttribute('title')).toBeNull();
269
+ expect(mark.getAttribute('role')).toBeNull();
270
+ expect(mark.getAttribute('aria-hidden')).toBe('true');
271
+ // The reason, and the agent that owns the chat, live on the BUTTON.
272
+ expect(claude.getAttribute('title')).toContain('already started on omp');
273
+ });
274
+
275
+ test('a tab that cannot switch shows the prohibition cursor', async () => {
276
+ // Reported from use: a locked tab did nothing on press but showed no cursor
277
+ // signal at all. The prohibition sign is the affordance that says "not here"
278
+ // BEFORE the click; `cursor-help` was drawn as a QUESTION MARK on macOS and
279
+ // read as a stray icon.
280
+ const el = await mount(h(HarnessTabs, {
281
+ harnesses: [
282
+ summary('omp-rpc', { label: 'omp' }),
283
+ summary('pi', { canLaunch: false, unavailable: 'not installed' }),
284
+ summary('claude'),
285
+ ],
286
+ active: 'omp-rpc',
287
+ editable: false,
288
+ onSelect: () => {},
289
+ }));
290
+ const [owner, blocked, locked] = [...el.querySelectorAll('[role="tab"]')].map(
291
+ (tab) => tab.className,
292
+ );
293
+ // The chat runs on omp, so every OTHER tab refuses the switch.
294
+ expect(locked).toContain('cursor-not-allowed');
295
+ // A blocked tab opens its settings page, so it still earns the pointer.
296
+ expect(blocked).toContain('cursor-pointer');
297
+ expect(blocked).not.toContain('cursor-not-allowed');
298
+ // The current selection is not a refusal.
299
+ expect(owner).toContain('cursor-default');
300
+ expect(owner).not.toContain('cursor-not-allowed');
301
+ for (const cls of [owner, blocked, locked]) expect(cls).not.toContain('cursor-help');
302
+ });
303
+
304
+ test('a selectable tab keeps the pointer, never the prohibition', async () => {
305
+ const el = await mount(h(HarnessTabs, {
306
+ harnesses: [summary('omp-rpc', { label: 'omp' }), summary('claude')],
307
+ active: 'omp-rpc',
308
+ editable: true,
309
+ onSelect: () => {},
310
+ }));
311
+ for (const tab of el.querySelectorAll('[role="tab"]')) {
312
+ expect(tab.className).toContain('cursor-pointer');
313
+ expect(tab.className).not.toContain('cursor-not-allowed');
314
+ }
315
+ });
316
+
317
+ test('a blocked tab is dimmed and keeps its name, since no word is left to mute', async () => {
318
+ const el = await mount(h(HarnessTabs, {
319
+ harnesses: [summary('pi', { canLaunch: false, unavailable: '`pi` is not installed' })],
320
+ active: null,
321
+ editable: true,
322
+ onSelect: () => {},
323
+ }));
324
+ const tab = el.querySelector('[role="tab"]') as HTMLElement;
325
+ expect(tab.getAttribute('aria-label')).toBe('pi');
326
+ // Opacity, not a colour: the colour mode's brand hue outranks any `text-ink`
327
+ // class on the mark, so a hue-only mute would look ready under `color`.
328
+ expect(tab.querySelector('span[data-harness]')?.className).toContain('opacity-40');
329
+ expect(tab.textContent).toContain('⚠');
330
+ });
331
+
332
+ test('no harnesses draws nothing rather than an empty strip', async () => {
333
+ const el = await mount(h(HarnessTabs, { harnesses: [], active: null, editable: true, onSelect: () => {} }));
334
+ expect(el.querySelector('[role="tablist"]')).toBeNull();
335
+ });
336
+ });
@@ -1,16 +1,21 @@
1
- import type { TargetedMouseEvent } from 'preact';
2
1
  import { useMemo, useRef, useState } from 'preact/hooks';
3
2
  import { ChevronDown, Sparkles } from 'lucide-preact';
4
- import type { AIModelOption, ModelPreferences } from '@/shared/types';
3
+ import type { AIModelOption } from '@/shared/types';
5
4
  import { useOnClickOutside } from '@/client/hooks/ui/on-click-outside';
6
5
  import { invalidateModelsCache } from '@/shared/lib/models/client';
7
6
  import { ModelDropdownPanel } from '@/client/components/workspace/model-dropdown/Panel';
8
7
  import { ProviderIconPlate } from '@/client/components/common/provider-icon/Plate';
9
8
  import { useModelCatalog } from '@/client/components/workspace/model-dropdown/use-catalog';
10
9
  import { useCollapsedSections } from '@/client/components/workspace/model-dropdown/collapsed';
10
+ import { useHarnesses } from '@/client/hooks/models/use-harnesses';
11
+ import { harnessCategoryId } from '@/shared/lib/harness/menu';
12
+ import { useFullscreenPicker } from '@/client/components/workspace/model-dropdown/fullscreen-picker';
13
+ import { harnessModels, pickerHarnesses } from '@/client/components/workspace/model-dropdown/harness-models';
14
+ import { useRowMutations } from '@/client/components/workspace/model-dropdown/row-mutations';
15
+ import { HarnessGlyph, HARNESS_GLYPH_SIZE } from '@/client/components/common/harness-glyph';
11
16
  import { buildPickerGroups, type PickerRow } from '@/client/components/workspace/model-dropdown/groups';
12
17
  import { modelKey } from '@/shared/lib/models/identity';
13
- import { RECENT_MODELS_LIMIT, filterKnownKeys, readModelPreferences, recordRecentKey, toggleFavoriteKey } from '@/shared/lib/models/preferences';
18
+ import { RECENT_MODELS_LIMIT, filterKnownKeys, recordRecentKey } from '@/shared/lib/models/preferences';
14
19
 
15
20
  interface ModelDropdownProps {
16
21
  selectedModel?: AIModelOption;
@@ -18,6 +23,17 @@ interface ModelDropdownProps {
18
23
  onOpenAddProvider?: () => void;
19
24
  onThinkingLevelChange?: (level: string) => void;
20
25
  className?: string;
26
+ /** The session's harness (`omp-rpc`, `claude`, …). Undefined for a chat that
27
+ * has not spawned: the picker then shows the user's last choice. */
28
+ harness?: string;
29
+ /** Picked a tab for a chat that has no transcript yet. */
30
+ onSelectHarness?: (harness: string) => void;
31
+ /** False while the open chat has messages; the tabs explain instead of
32
+ * switching. */
33
+ harnessEditable?: boolean;
34
+ /** The SHELL's layout verdict. When omitted the picker answers for itself from
35
+ * the pointer — which is what the New Chat modal's preview does. */
36
+ isMobile?: boolean;
21
37
  }
22
38
 
23
39
  export function ModelDropdown({
@@ -26,8 +42,28 @@ export function ModelDropdown({
26
42
  onOpenAddProvider,
27
43
  onThinkingLevelChange,
28
44
  className = '',
45
+ harness,
46
+ onSelectHarness,
47
+ harnessEditable = true,
48
+ isMobile,
29
49
  }: ModelDropdownProps) {
50
+ const { harnesses, liveModels } = useHarnesses();
51
+ /**
52
+ * The harness whose list is on screen.
53
+ *
54
+ * Seeded from the SESSION's harness; before a chat exists the user moves it
55
+ * with the tab strip and the pick rides the spawn. It lives here rather than
56
+ * in the parent because the list it selects is this component's whole
57
+ * content.
58
+ */
59
+ const [viewHarness, setViewHarness] = useState<string>(harness ?? 'omp-rpc');
60
+ const activeHarness = harness ?? viewHarness;
30
61
  const [isOpen, setIsOpen] = useState(false);
62
+ // One answer to "which placement", used by BOTH the frame and the click-outside
63
+ // guard: a portalled full-screen picker is outside `containerRef` by
64
+ // construction, so an armed outside-press listener would close it on the very
65
+ // press that was meant to choose a row.
66
+ const fullscreen = useFullscreenPicker(isMobile);
31
67
  const [search, setSearch] = useState('');
32
68
  const [focusedIndex, setFocusedIndex] = useState<number>(-1);
33
69
  // Hover is a ROW, not a model: one model can be drawn twice (its rail and its
@@ -45,6 +81,20 @@ export function ModelDropdown({
45
81
  applyPreferences,
46
82
  } = useModelCatalog(externalSelectedModel);
47
83
 
84
+ /**
85
+ * The rows this tab renders. `harnessModels` returns omp's registry untouched
86
+ * for omp's tab and the agent's OWN `configOptions[model]` list for every
87
+ * other — never a merge, because a row the active agent cannot run would fail
88
+ * at the first prompt.
89
+ */
90
+ const harnessList = useMemo(
91
+ () => harnessModels(harnesses, activeHarness, models, liveModels[activeHarness]),
92
+ [harnesses, activeHarness, models, liveModels],
93
+ );
94
+ /** The tabs this picker may offer, from the same rule the model rows use. */
95
+ const tabsForPicker = pickerHarnesses(harnesses, activeHarness);
96
+ const visibleModels = harnessList.models;
97
+
48
98
  /**
49
99
  * The selected model's mark, resolved against the CATALOG when the value the
50
100
  * composer handed us is a bare `{provider, id}` pair.
@@ -57,7 +107,7 @@ export function ModelDropdown({
57
107
  */
58
108
  const selectedMark = useMemo(() => {
59
109
  if (!selectedModel) return null;
60
- const fromCatalog = models.find(
110
+ const fromCatalog = visibleModels.find(
61
111
  (model) => model.provider === selectedModel.provider
62
112
  && (model.id === selectedModel.id || !selectedModel.id),
63
113
  );
@@ -69,14 +119,14 @@ export function ModelDropdown({
69
119
  ? { iconUrl: selectedModel.providerIconUrl ?? fromCatalog?.providerIconUrl }
70
120
  : {}),
71
121
  };
72
- }, [selectedModel, models]);
122
+ }, [selectedModel, visibleModels]);
73
123
 
74
124
  const containerRef = useRef<HTMLDivElement>(null);
75
125
  useOnClickOutside(containerRef, () => {
76
126
  setIsOpen(false);
77
127
  setHoveredRow(null);
78
128
  setFocusedIndex(-1);
79
- });
129
+ }, !fullscreen);
80
130
 
81
131
  const {
82
132
  filtered: filteredModels,
@@ -87,8 +137,8 @@ export function ModelDropdown({
87
137
  visibleFlatList,
88
138
  index: modelIndex,
89
139
  } = useMemo(
90
- () => buildPickerGroups(models, search, collapsedSections, preferences.favorites, preferences.recentKeys),
91
- [models, search, collapsedSections, preferences],
140
+ () => buildPickerGroups(visibleModels, search, collapsedSections, preferences.favorites, preferences.recentKeys),
141
+ [visibleModels, search, collapsedSections, preferences],
92
142
  );
93
143
 
94
144
  const selectedModelKey = modelKey(selectedModel);
@@ -107,78 +157,10 @@ export function ModelDropdown({
107
157
  }
108
158
  };
109
159
 
110
- /**
111
- * Flip one row's star. The optimistic stamp and the rollback both go through
112
- * the preference pair — the flag on a row is derived state, so patching the
113
- * row alone would be undone by the next `applyModelPreferences` (every reload
114
- * re-stamps rows from the store).
115
- */
116
- const handleToggleFavorite = async (model: AIModelOption, e: TargetedMouseEvent<HTMLElement>) => {
117
- e.stopPropagation();
118
- const key = modelKey(model);
119
- const previous = preferences;
120
- const optimistic: ModelPreferences = {
121
- ...previous,
122
- favorites: toggleFavoriteKey(previous.favorites, key),
123
- };
124
- applyPreferences(optimistic);
125
- try {
126
- const response = await fetch('/api/models', {
127
- method: 'POST',
128
- headers: { 'Content-Type': 'application/json' },
129
- body: JSON.stringify({ actionType: 'toggleFavorite', provider: model.provider, modelId: model.id }),
130
- });
131
- if (!response.ok) throw new Error(`toggleFavorite failed: ${response.status}`);
132
- const data = await response.json() as { modelPreferences?: unknown };
133
- // The server is the authority on the resulting list — it also drops keys
134
- // the registry no longer serves. An absent/malformed payload keeps the
135
- // optimistic list rather than blanking the rail.
136
- if (data.modelPreferences) {
137
- applyPreferences(readModelPreferences(data.modelPreferences));
138
- }
139
- } catch {
140
- // A failed write must not leave the star lit: the next reload would show
141
- // it unlit anyway, so the rollback keeps the panel honest immediately.
142
- applyPreferences(previous);
143
- }
144
- };
145
-
146
- const cycleThinkingLevel = (model: AIModelOption) => {
147
- const ladder = model.thinkingLevels ?? [];
148
- if (ladder.length === 0) return;
149
- const current = model.thinkingLevel ?? ladder[0];
150
- const idx = ladder.indexOf(current);
151
- const nextThinking = ladder[(idx + 1) % ladder.length];
152
-
153
- const key = modelKey(model);
154
- setModels(prev => prev.map(m => modelKey(m) === key ? { ...m, thinkingLevel: nextThinking } : m));
155
- // Only the active model's preset may reach the live session — cycling
156
- // another provider's row (or a non-selected model) must not push its
157
- // thinking level onto this session.
158
- if (selectedModelKey === key && selectedModel) {
159
- const nextSelected = { ...selectedModel, thinkingLevel: nextThinking };
160
- setSelectedModel(nextSelected);
161
- onSelectModel?.(nextSelected);
162
- onThinkingLevelChange?.(nextThinking);
163
- }
164
- };
165
-
166
- const toggleAgentCmd = async (model: AIModelOption) => {
167
- const nextCmd = !model.isCmdAgent;
168
- const key = modelKey(model);
169
-
170
- setModels(prev => prev.map(m => modelKey(m) === key ? { ...m, isCmdAgent: nextCmd } : m));
171
- if (selectedModelKey === key && selectedModel) {
172
- setSelectedModel({ ...selectedModel, isCmdAgent: nextCmd });
173
- }
174
- try {
175
- await fetch('/api/models', {
176
- method: 'POST',
177
- headers: { 'Content-Type': 'application/json' },
178
- body: JSON.stringify({ actionType: 'toggleCmd', provider: model.provider, modelId: model.id }),
179
- });
180
- } catch {}
181
- };
160
+ const { toggleFavorite, cycleThinking, toggleAgentCmd } = useRowMutations({
161
+ preferences, applyPreferences, setModels, selectedModel, setSelectedModel,
162
+ selectedModelKey, onSelectModel, onThinkingLevelChange,
163
+ });
182
164
 
183
165
  const handleSelect = async (model: AIModelOption) => {
184
166
  setSelectedModel(model);
@@ -235,12 +217,21 @@ export function ModelDropdown({
235
217
  if (activeRow) toggleAgentCmd(activeRow.model);
236
218
  } else if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
237
219
  e.preventDefault();
238
- if (activeRow) cycleThinkingLevel(activeRow.model);
220
+ if (activeRow) cycleThinking(activeRow.model);
239
221
  }
240
222
  };
241
223
 
242
224
  return (
243
- <div className={`relative ${className}`} ref={containerRef} onKeyDown={handleKeyDown}>
225
+ // `data-model-dropdown-root` is the popover's measuring anchor: the panel
226
+ // sizes itself to the space above THIS element, and picking the element by
227
+ // attribute is exact where `parentElement.parentElement` would be a guess
228
+ // that breaks the first time the markup gains a wrapper.
229
+ <div
230
+ className={`relative ${className}`}
231
+ ref={containerRef}
232
+ data-model-dropdown-root=""
233
+ onKeyDown={handleKeyDown}
234
+ >
244
235
  {/* Trigger Button */}
245
236
  <button
246
237
  type="button"
@@ -254,6 +245,13 @@ export function ModelDropdown({
254
245
  >
255
246
  {selectedModel ? (
256
247
  <>
248
+ {/* Harness MARK, then the provider plate: the same two-mark order
249
+ the rows use, so the trigger and the list cannot describe two
250
+ different things. `decorative` for the same measured reason as
251
+ the tabs: a nested `title` is the one the browser shows, so this
252
+ component's "Session runs on omp" replaced the trigger's own
253
+ `provider • model`. */}
254
+ <HarnessGlyph harness={activeHarness} size={HARNESS_GLYPH_SIZE.compact} decorative />
257
255
  {selectedModel.isCmdAgent ? (
258
256
  <span className="inline-flex items-center justify-center w-[16px] h-[16px] rounded-[4px] border border-ink/20 bg-ink/5 text-ink/70 flex-shrink-0 font-mono text-[10px] font-bold">
259
257
  ⌘
@@ -291,7 +289,7 @@ export function ModelDropdown({
291
289
  search={search}
292
290
  onSearchChange={setSearch}
293
291
  onAddProvider={handleAddProviderClick}
294
- isLoading={isLoading}
292
+ isLoading={isLoading && visibleModels.length === 0}
295
293
  filteredModels={filteredModels}
296
294
  favoriteModels={favoriteModels}
297
295
  recentModels={recentModels}
@@ -304,8 +302,8 @@ export function ModelDropdown({
304
302
  focusedIndex={focusedIndex}
305
303
  hoveredRow={hoveredRow}
306
304
  onSelect={handleSelect}
307
- onToggleFavorite={handleToggleFavorite}
308
- onCycleThinking={cycleThinkingLevel}
305
+ onToggleFavorite={toggleFavorite}
306
+ onCycleThinking={cycleThinking}
309
307
  onHoverItem={(idx) => {
310
308
  setFocusedIndex(idx);
311
309
  // The flat list is the one order the panel renders, so an index is
@@ -314,6 +312,37 @@ export function ModelDropdown({
314
312
  setHoveredRow(visibleFlatList[idx] ?? null);
315
313
  }}
316
314
  onMouseLeave={() => setHoveredRow(null)}
315
+ harnesses={tabsForPicker}
316
+ activeHarness={activeHarness}
317
+ harnessEditable={harnessEditable}
318
+ unprobedHarness={harnessList.unprobed}
319
+ harnessBlocked={harnessList.blocked}
320
+ onSelectHarness={(id) => {
321
+ // The tab changes WHICH LIST this picker shows, in place. The pick
322
+ // reaches the spawn through `onSelectHarness`; the picker stays open
323
+ // so the user can then choose one of that harness's models.
324
+ setViewHarness(id);
325
+ setHoveredRow(null);
326
+ setFocusedIndex(-1);
327
+ setSearch('');
328
+ onSelectHarness?.(id);
329
+ }}
330
+ onClose={() => {
331
+ setIsOpen(false);
332
+ setHoveredRow(null);
333
+ }}
334
+ fullscreen={fullscreen}
335
+ // A blocked tab opens THAT agent's settings page — the block is a
336
+ // login or a missing binary, and both are fixed there. It used to fire
337
+ // a probe and `console.warn` the answer, which reported the problem to
338
+ // the devtools console instead of to the person clicking.
339
+ onFixHarness={(id) => {
340
+ setIsOpen(false);
341
+ setHoveredRow(null);
342
+ window.dispatchEvent(
343
+ new CustomEvent('omp:open-settings', { detail: { category: harnessCategoryId(id) } }),
344
+ );
345
+ }}
317
346
  />
318
347
  )}
319
348
  </div>