@kabmo-labs/kabmo 0.24.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +585 -512
  3. package/dist/client/static/js/{index-jcr5twtp.js → index-95b3n20k.js} +1105 -1207
  4. package/dist/client/static/js/index-p2yw9ywf.css +1 -0
  5. package/package.json +2 -4
  6. package/src/cli/lib/args.js +24 -1
  7. package/src/cli/lib/args.test.js +16 -0
  8. package/src/cli/lib/commands/session.js +233 -0
  9. package/src/cli/lib/commands/session.test.js +103 -0
  10. package/src/cli/main.js +1 -1
  11. package/src/client/components/common/ComposerPicker.tsx +3 -0
  12. package/src/client/components/common/code-surface/shiki.test.ts +82 -0
  13. package/src/client/components/common/code-surface/shiki.ts +28 -7
  14. package/src/client/components/common/session-actions-menu/index.tsx +59 -2
  15. package/src/client/components/common/session-branch/BranchGuides.tsx +93 -0
  16. package/src/client/components/common/session-branch/SubagentRow.tsx +77 -0
  17. package/src/client/components/common/session-branch/index.tsx +169 -0
  18. package/src/client/components/common/session-branch/session-branch.test.tsx +240 -0
  19. package/src/client/components/common/session-branch/style.ts +29 -0
  20. package/src/client/components/common/session-row/StatusSlot.tsx +17 -5
  21. package/src/client/components/common/session-row/index.tsx +28 -3
  22. package/src/client/components/common/session-row/session-row.test.tsx +11 -0
  23. package/src/client/components/common/session-state-provider/index.tsx +1 -1
  24. package/src/client/components/layout/desktop-layout/resizer/separator-drag.ts +3 -3
  25. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +70 -61
  26. package/src/client/components/layout/session-sidebar/SessionItem.batch.test.ts +3 -3
  27. package/src/client/components/layout/session-sidebar/SessionItem.test.ts +25 -2
  28. package/src/client/components/layout/session-sidebar/SessionItem.tsx +35 -7
  29. package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +261 -0
  30. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +39 -198
  31. package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +114 -0
  32. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.test.tsx +130 -0
  33. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +128 -0
  34. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +56 -0
  35. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +44 -36
  36. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +62 -47
  37. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +63 -50
  38. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +5 -0
  39. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +37 -12
  40. package/src/client/components/settings/Sidebar.tsx +1 -1
  41. package/src/client/components/settings/categories/NotificationSettings.test.tsx +92 -0
  42. package/src/client/components/settings/categories/NotificationSettings.tsx +112 -2
  43. package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +1 -1
  44. package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +94 -0
  45. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +31 -5
  46. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +64 -70
  47. package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +35 -0
  48. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +128 -122
  49. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +22 -1
  50. package/src/client/components/workspace/chat-timeline/MessageList.tsx +11 -5
  51. package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +10 -0
  52. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +12 -3
  53. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +3 -0
  54. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +2 -0
  55. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +15 -1
  56. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +85 -0
  57. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +84 -0
  58. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +2 -0
  59. package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +5 -0
  60. package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +155 -0
  61. package/src/client/components/workspace/chat-timeline/index.tsx +11 -20
  62. package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +115 -0
  63. package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +173 -0
  64. package/src/client/components/workspace/chat-timeline/target-picker/parent-session-options.test.ts +49 -0
  65. package/src/client/components/workspace/terminal-panel/KeyBar.tsx +10 -8
  66. package/src/client/components/workspace/terminal-panel/{RealtimeXtermView.tsx → RealtimeTerminalView.tsx} +51 -58
  67. package/src/client/components/workspace/terminal-panel/fit.test.ts +37 -0
  68. package/src/client/components/workspace/terminal-panel/fit.ts +64 -0
  69. package/src/client/components/workspace/terminal-panel/fonts.test.ts +161 -0
  70. package/src/client/components/workspace/terminal-panel/fonts.ts +164 -0
  71. package/src/client/components/workspace/terminal-panel/grid.test.ts +52 -0
  72. package/src/client/components/workspace/terminal-panel/grid.ts +118 -0
  73. package/src/client/components/workspace/terminal-panel/index.tsx +25 -21
  74. package/src/client/components/workspace/terminal-panel/mount.ts +247 -223
  75. package/src/client/components/workspace/terminal-panel/navigation.test.ts +54 -0
  76. package/src/client/components/workspace/terminal-panel/navigation.ts +47 -0
  77. package/src/client/data/settings/omp-schema.json +1 -1
  78. package/src/client/data/theme/terminal.test.ts +25 -0
  79. package/src/client/data/theme/terminal.ts +96 -79
  80. package/src/client/hooks/chat/composer/items.test.ts +31 -26
  81. package/src/client/hooks/chat/composer/pick-mapping.test.ts +42 -0
  82. package/src/client/hooks/chat/omp/folder-auto-expand.ts +1 -1
  83. package/src/client/hooks/chat/omp/pending-adoption.ts +51 -0
  84. package/src/client/hooks/chat/omp/pending-child.test.ts +73 -0
  85. package/src/client/hooks/chat/omp/pending-entry.ts +59 -0
  86. package/src/client/hooks/chat/omp/pending-rows.ts +6 -2
  87. package/src/client/hooks/chat/omp/pending-sessions.test.ts +1 -2
  88. package/src/client/hooks/chat/omp/pending-sessions.ts +45 -69
  89. package/src/client/hooks/chat/omp/pending-waiting.ts +1 -1
  90. package/src/client/hooks/chat/omp/prompt-send.test.ts +7 -7
  91. package/src/client/hooks/chat/omp/prompt-send.ts +26 -14
  92. package/src/client/hooks/chat/omp/run-switch.ts +1 -1
  93. package/src/client/hooks/chat/omp/session-list.tsx +4 -0
  94. package/src/client/hooks/chat/subagents/roster.ts +122 -0
  95. package/src/client/hooks/chat/timeline/child-spawn.test.ts +55 -0
  96. package/src/client/hooks/chat/timeline/child-spawn.ts +45 -0
  97. package/src/client/hooks/chat/timeline/fork-request.test.ts +54 -0
  98. package/src/client/hooks/chat/timeline/fork-request.ts +43 -0
  99. package/src/client/hooks/chat/timeline/mode-availability.test.ts +1 -1
  100. package/src/client/hooks/chat/timeline/mode-availability.ts +33 -0
  101. package/src/client/hooks/chat/timeline/mode-markers.ts +7 -1
  102. package/src/client/hooks/chat/timeline/mode-post.ts +15 -3
  103. package/src/client/hooks/chat/timeline/modes-contract.ts +9 -4
  104. package/src/client/hooks/chat/timeline/modes.test.ts +56 -18
  105. package/src/client/hooks/chat/timeline/modes.ts +42 -29
  106. package/src/client/hooks/chat/timeline/pending-branch.ts +205 -0
  107. package/src/client/hooks/chat/timeline/pending-dispatch.ts +253 -0
  108. package/src/client/hooks/chat/timeline/prompt-text.test.ts +34 -1
  109. package/src/client/hooks/chat/timeline/prompt-text.ts +47 -20
  110. package/src/client/hooks/chat/timeline/send-execute.test.ts +39 -0
  111. package/src/client/hooks/chat/timeline/send-helpers.ts +30 -1
  112. package/src/client/hooks/chat/timeline/send-steer.test.ts +3 -1
  113. package/src/client/hooks/chat/timeline/send.test-util.ts +7 -1
  114. package/src/client/hooks/chat/timeline/send.test.ts +3 -1
  115. package/src/client/hooks/chat/timeline/send.ts +48 -133
  116. package/src/client/hooks/chat/timeline/session-harness.ts +6 -0
  117. package/src/client/hooks/chat/timeline/stop-with-queue.ts +42 -0
  118. package/src/client/hooks/chat/timeline/use-fork-session.ts +58 -0
  119. package/src/client/hooks/models/use-harness-update.test.ts +286 -0
  120. package/src/client/hooks/models/use-harness-update.ts +250 -0
  121. package/src/client/hooks/ui/input-required-alert.ts +12 -5
  122. package/src/client/hooks/ui/notifications.ts +45 -0
  123. package/src/client/hooks/ui/run-outcome-alert.ts +48 -0
  124. package/src/client/hooks/workspace/expanded-sessions.ts +36 -7
  125. package/src/client/hooks/workspace/terminal/index.ts +17 -3
  126. package/src/client/hooks/workspace/terminal/socket.ts +9 -4
  127. package/src/client/lib/native/open-session.ts +33 -0
  128. package/src/client/lib/notifications/os.test.ts +125 -0
  129. package/src/client/lib/notifications/os.ts +130 -0
  130. package/src/client/lib/plugins/sidebar-bridge.ts +2 -20
  131. package/src/client/lib/router/open-session.test.ts +75 -0
  132. package/src/client/lib/router/open-session.ts +34 -0
  133. package/src/client/lib/session-tree.test.ts +50 -0
  134. package/src/client/lib/session-tree.ts +59 -0
  135. package/src/client/lib/signals.ts +5 -1
  136. package/src/client/main.tsx +6 -0
  137. package/src/client/tailwind.css +17 -11
  138. package/src/server/index.ts +2 -0
  139. package/src/server/lib/auth/guard.ts +10 -0
  140. package/src/server/lib/btw/session-copy.server.ts +6 -44
  141. package/src/server/lib/btw/session-copy.test.ts +2 -1
  142. package/src/server/lib/db/schema.ts +5 -0
  143. package/src/server/lib/db/seed-terminal.test.ts +1 -1
  144. package/src/server/lib/db/seed.test.ts +1 -1
  145. package/src/server/lib/harness/acp/background-work.test.ts +262 -0
  146. package/src/server/lib/harness/acp/background-work.ts +320 -0
  147. package/src/server/lib/harness/acp/calls.ts +15 -1
  148. package/src/server/lib/harness/acp/client-capabilities.test.ts +55 -0
  149. package/src/server/lib/harness/acp/client-capabilities.ts +61 -0
  150. package/src/server/lib/harness/acp/client-fs.test.ts +135 -0
  151. package/src/server/lib/harness/acp/client-fs.ts +131 -0
  152. package/src/server/lib/harness/acp/client-initialize.test.ts +70 -0
  153. package/src/server/lib/harness/acp/client-initialize.ts +84 -0
  154. package/src/server/lib/harness/acp/client.ts +33 -23
  155. package/src/server/lib/harness/acp/commands.test.ts +5 -5
  156. package/src/server/lib/harness/acp/commands.ts +14 -2
  157. package/src/server/lib/harness/acp/frames-timing.test.ts +68 -0
  158. package/src/server/lib/harness/acp/frames-v2.test.ts +85 -0
  159. package/src/server/lib/harness/acp/frames.ts +71 -158
  160. package/src/server/lib/harness/acp/gateway-env.test.ts +64 -0
  161. package/src/server/lib/harness/acp/gateway-env.ts +70 -0
  162. package/src/server/lib/harness/acp/mapper.test.ts +40 -0
  163. package/src/server/lib/harness/acp/mapper.ts +12 -0
  164. package/src/server/lib/harness/acp/permissions.ts +6 -0
  165. package/src/server/lib/harness/acp/prompt.test.ts +20 -0
  166. package/src/server/lib/harness/acp/prompt.ts +19 -3
  167. package/src/server/lib/harness/acp/protocol.ts +41 -2
  168. package/src/server/lib/harness/acp/session-background.test.ts +129 -0
  169. package/src/server/lib/harness/acp/session-exit.ts +31 -0
  170. package/src/server/lib/harness/acp/session-facts.ts +1 -1
  171. package/src/server/lib/harness/acp/session-handshake.test.ts +197 -0
  172. package/src/server/lib/harness/acp/session-handshake.ts +110 -7
  173. package/src/server/lib/harness/acp/session-idle.ts +7 -6
  174. package/src/server/lib/harness/acp/session-listeners.ts +31 -0
  175. package/src/server/lib/harness/acp/session-notifications.ts +41 -2
  176. package/src/server/lib/harness/acp/session-observers.test.ts +63 -0
  177. package/src/server/lib/harness/acp/session-permissions.test.ts +29 -0
  178. package/src/server/lib/harness/acp/session-permissions.ts +36 -0
  179. package/src/server/lib/harness/acp/session-requests.test.ts +92 -0
  180. package/src/server/lib/harness/acp/session-requests.ts +89 -0
  181. package/src/server/lib/harness/acp/session-turns.ts +28 -8
  182. package/src/server/lib/harness/acp/session-usage.ts +4 -0
  183. package/src/server/lib/harness/acp/session-web-state.ts +30 -2
  184. package/src/server/lib/harness/acp/session.test-util.ts +42 -2
  185. package/src/server/lib/harness/acp/session.ts +115 -115
  186. package/src/server/lib/harness/acp/tool-calls.ts +223 -0
  187. package/src/server/lib/harness/acp/turn.test.ts +183 -0
  188. package/src/server/lib/harness/acp/turn.ts +102 -10
  189. package/src/server/lib/harness/acp/v2.test.ts +144 -0
  190. package/src/server/lib/harness/acp/v2.ts +220 -0
  191. package/src/server/lib/harness/acp/verbs.ts +58 -8
  192. package/src/server/lib/harness/launch.test.ts +25 -0
  193. package/src/server/lib/harness/launch.ts +24 -10
  194. package/src/server/lib/harness/session.ts +3 -0
  195. package/src/server/lib/harness/spawn.server.ts +15 -2
  196. package/src/server/lib/harness/update-job-store.test.ts +151 -0
  197. package/src/server/lib/harness/update-job-store.ts +115 -0
  198. package/src/server/lib/harness/update-job.server.ts +94 -0
  199. package/src/server/lib/harness/update-queue.server.ts +292 -0
  200. package/src/server/lib/harness/update-queue.test.ts +265 -0
  201. package/src/server/lib/harness/update-spawn.server.ts +96 -0
  202. package/src/server/lib/harness/update-worker.test.ts +153 -0
  203. package/src/server/lib/harness/update-worker.ts +202 -0
  204. package/src/server/lib/lifecycle/after-listen.ts +9 -0
  205. package/src/server/lib/lifecycle/paths.ts +28 -0
  206. package/src/server/lib/omp/rpc/manager.ts +5 -5
  207. package/src/server/lib/omp/rpc/prewarm-pool.ts +12 -3
  208. package/src/server/lib/omp/rpc/run-settle.server.ts +10 -1
  209. package/src/server/lib/omp/rpc/session-registry.ts +14 -2
  210. package/src/server/lib/omp/rpc/subagent-liveness.ts +5 -5
  211. package/src/server/lib/omp/rpc/terminal-settle.ts +58 -6
  212. package/src/server/lib/omp/session/delete-flow.server.ts +48 -0
  213. package/src/server/lib/omp/session/delete.server.ts +5 -0
  214. package/src/server/lib/omp/session/rewind-file.ts +39 -21
  215. package/src/server/lib/omp/session/sidebar-data.server.ts +16 -18
  216. package/src/server/lib/omp/session/transcript-copy.ts +123 -0
  217. package/src/server/lib/sessions/agent-token.server.test.ts +64 -0
  218. package/src/server/lib/sessions/agent-token.server.ts +134 -0
  219. package/src/server/lib/sessions/answers.server.test.ts +33 -0
  220. package/src/server/lib/sessions/answers.server.ts +37 -0
  221. package/src/server/lib/sessions/dispatch.server.test.ts +143 -0
  222. package/src/server/lib/sessions/dispatch.server.ts +128 -0
  223. package/src/server/lib/sessions/fork.server.test.ts +277 -0
  224. package/src/server/lib/sessions/fork.server.ts +329 -0
  225. package/src/server/lib/sessions/lifecycle.server.test.ts +75 -0
  226. package/src/server/lib/sessions/lifecycle.server.ts +71 -0
  227. package/src/server/lib/sessions/notify.server.test.ts +112 -0
  228. package/src/server/lib/sessions/notify.server.ts +212 -0
  229. package/src/server/lib/sessions/relation-types.ts +76 -0
  230. package/src/server/lib/sessions/relations.server.test.ts +207 -0
  231. package/src/server/lib/sessions/relations.server.ts +337 -0
  232. package/src/server/lib/sessions/resolve.server.ts +106 -0
  233. package/src/server/lib/sessions/schema.server.ts +82 -0
  234. package/src/server/lib/sessions/sidebar-relations.server.test.ts +61 -0
  235. package/src/server/lib/sessions/sidebar-relations.server.ts +47 -0
  236. package/src/server/lib/sessions/spawn.server.test.ts +237 -0
  237. package/src/server/lib/sessions/spawn.server.ts +335 -0
  238. package/src/server/lib/terminal/attach-replay.test.ts +2 -2
  239. package/src/server/lib/terminal/output.test.ts +2 -2
  240. package/src/server/lib/terminal/output.ts +1 -1
  241. package/src/server/lib/terminal/resize.test.ts +99 -0
  242. package/src/server/lib/terminal/runtime.server.ts +26 -6
  243. package/src/server/lib/terminal/send-result.test.ts +18 -1
  244. package/src/server/lib/terminal/send-result.ts +26 -2
  245. package/src/server/lib/terminal/session.server.ts +6 -6
  246. package/src/server/lib/usage/new-api.test.ts +92 -0
  247. package/src/server/lib/usage/new-api.ts +131 -0
  248. package/src/server/lib/usage/provider-endpoint.test.ts +106 -0
  249. package/src/server/lib/usage/provider-key.ts +33 -0
  250. package/src/server/lib/usage/providers.server.ts +10 -3
  251. package/src/server/lib/usage/vendor-balance.server.ts +4 -53
  252. package/src/server/lib/usage/vendor-http.ts +41 -0
  253. package/src/server/lib/usage/window.ts +55 -0
  254. package/src/server/routes/agent/command.ts +14 -1
  255. package/src/server/routes/agent/harness-command.ts +12 -5
  256. package/src/server/routes/agent/new.ts +15 -0
  257. package/src/server/routes/chat/stream.ts +7 -2
  258. package/src/server/routes/harness/add-provider.test.ts +9 -1
  259. package/src/server/routes/harness/import-action.ts +4 -0
  260. package/src/server/routes/harness/import.test.ts +1 -1
  261. package/src/server/routes/harness/index.ts +5 -1
  262. package/src/server/routes/harness/update-status.ts +32 -0
  263. package/src/server/routes/harness/update.test.ts +156 -0
  264. package/src/server/routes/harness/update.ts +64 -147
  265. package/src/server/routes/sessions/answer.ts +24 -0
  266. package/src/server/routes/sessions/batch-delete.ts +11 -5
  267. package/src/server/routes/sessions/body-readers.ts +43 -0
  268. package/src/server/routes/sessions/delete.ts +4 -2
  269. package/src/server/routes/sessions/fork.ts +89 -0
  270. package/src/server/routes/sessions/index.ts +14 -0
  271. package/src/server/routes/sessions/relations.ts +85 -0
  272. package/src/server/routes/sessions/routes.test.ts +1 -2
  273. package/src/server/routes/sessions/session.ts +23 -0
  274. package/src/server/routes/sessions/spawn.ts +137 -0
  275. package/src/server/routes/terminal/ws.ts +3 -3
  276. package/src/shared/lib/chat/composer/client.ts +31 -2
  277. package/src/shared/lib/chat/composer/delegation.test.ts +93 -0
  278. package/src/shared/lib/chat/composer/delegation.ts +206 -0
  279. package/src/shared/lib/chat/notice-text.ts +1 -1
  280. package/src/shared/lib/chat/omp/agent-events.ts +11 -0
  281. package/src/shared/lib/chat/omp/session-modes-signal.test.ts +41 -0
  282. package/src/shared/lib/chat/tool/summary-wait.test.ts +11 -0
  283. package/src/shared/lib/code/ansi.ts +1 -1
  284. package/src/shared/lib/fonts/nerd-symbols.css +4 -3
  285. package/src/shared/lib/fonts/nerd-symbols.test.ts +9 -9
  286. package/src/shared/lib/harness/mode-signal.ts +20 -0
  287. package/src/shared/lib/harness/provider-facts.test.ts +27 -0
  288. package/src/shared/lib/harness/providers.ts +35 -1
  289. package/src/shared/lib/harness/session-modes.ts +24 -0
  290. package/src/shared/lib/harness/update-job.ts +80 -0
  291. package/src/shared/lib/harness/update-plan.test.ts +21 -6
  292. package/src/shared/lib/harness/update-plan.ts +12 -4
  293. package/src/shared/lib/icons/tint-hues.generated.ts +34 -34
  294. package/src/shared/lib/notifications/outcomes.test.ts +96 -0
  295. package/src/shared/lib/notifications/outcomes.ts +64 -0
  296. package/src/shared/lib/notifications/settings.test.ts +49 -0
  297. package/src/shared/lib/notifications/settings.ts +34 -0
  298. package/src/shared/lib/omp/session/default-title.ts +5 -4
  299. package/src/shared/lib/omp/session/prewarm-misc.test.ts +3 -2
  300. package/src/shared/lib/omp/session/schema-migrations.ts +4 -0
  301. package/src/shared/lib/omp/session/stream-state.server.test.ts +19 -0
  302. package/src/shared/lib/omp/session/stream-state.server.ts +24 -4
  303. package/src/shared/lib/omp/session/wait-idle.test.ts +11 -0
  304. package/src/shared/lib/omp/session/wait-idle.ts +12 -2
  305. package/src/shared/lib/settings/defaults.ts +3 -0
  306. package/src/shared/lib/theme/catalog.test.ts +13 -9
  307. package/src/shared/lib/theme/color.test.ts +2 -2
  308. package/src/shared/lib/theme/color.ts +4 -4
  309. package/src/shared/lib/theme/theme.test.ts +1 -1
  310. package/src/shared/lib/workspace/terminal/input.test.ts +27 -0
  311. package/src/shared/lib/workspace/terminal/input.ts +33 -0
  312. package/src/shared/lib/workspace/terminal/keys.test.ts +1 -1
  313. package/src/shared/lib/workspace/terminal/keys.ts +7 -7
  314. package/src/shared/types/chat.ts +1 -1
  315. package/src/shared/types/harness-update.ts +89 -0
  316. package/src/shared/types/omp/agent.ts +19 -2
  317. package/src/shared/types/realtime.ts +2 -0
  318. package/src/shared/types/settings/state.ts +10 -0
  319. package/src/shared/types/workspace.ts +8 -0
  320. package/src/test-support/fake-omp-fork.ts +16 -2
  321. package/src/test-support/harness-table.test-util.ts +31 -1
  322. package/dist/client/static/js/index-z3w7n85q.css +0 -1
  323. package/src/client/components/common/subagent-list/index.tsx +0 -165
  324. package/src/client/components/workspace/terminal-panel/webgl.test.ts +0 -75
  325. package/src/client/components/workspace/terminal-panel/webgl.ts +0 -108
@@ -0,0 +1,261 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * ONE harness line in the About card: state, version, and the one action that
8
+ * harness can do — plus whatever its own update record says.
9
+ *
10
+ * Split out of `HarnessTable` when per-harness update records arrived: the row
11
+ * now reads three things (the catalog entry, the version row, and ITS OWN
12
+ * update record), and keeping that next to the section's tally and heading
13
+ * pushed the file past the 350-line ceiling. The section owns the list; this owns
14
+ * one line of it.
15
+ *
16
+ * Everything a row states, and why, is in `HarnessTable.tsx`'s header: this file
17
+ * is that row's markup and its three-column grid.
18
+ */
19
+
20
+ import { Download, Loader2 } from 'lucide-preact';
21
+ import { HarnessGlyph, HARNESS_GLYPH_SIZE } from '@/client/components/common/harness-glyph';
22
+ import { UpdateLogLine } from '@/client/components/layout/session-sidebar/about-modal/UpdateLogLine';
23
+ import { jobQueued, jobRunning, runningStepOf } from '@/shared/lib/harness/update-job';
24
+ import { harnessStatus, type HarnessState } from '@/shared/lib/harness/status';
25
+ import type { HarnessSummary } from '@/shared/types/harness';
26
+ import type { HarnessUpdateJob } from '@/shared/types/harness-update';
27
+ import type { HarnessVersionRow } from '@/shared/types/harness-version';
28
+
29
+ export interface HarnessRowProps {
30
+ entry: HarnessSummary;
31
+ version: HarnessVersionRow | null;
32
+ /** This harness's own update record — installing, waiting, or settled. */
33
+ job: HarnessUpdateJob | null;
34
+ /** A refusal from a press on THIS row, or null. */
35
+ problem: string | null;
36
+ onOpenHarness: () => void;
37
+ /** Starts this harness's update. */
38
+ onUpdate: () => void;
39
+ onOpenLog?: () => void;
40
+ }
41
+
42
+ /** The state mark. Shape carries the state, so tone is reinforcement only. */
43
+ function StateMark({ state }: { state: HarnessState }) {
44
+ if (state === 'ready') return <span aria-hidden="true" className="h-1.5 w-1.5 rounded-full bg-success" />;
45
+ if (state === 'not-installed') return <span aria-hidden="true" className="h-1.5 w-1.5 rounded-full border border-ink/35" />;
46
+ if (state === 'needs-setup') return <span aria-hidden="true" className="h-1.5 w-1.5 rounded-full bg-ink/45" />;
47
+ return <span aria-hidden="true" className="h-1.5 w-1.5 rounded-full bg-ink/15" />;
48
+ }
49
+
50
+ /**
51
+ * The three-column grid every data row uses.
52
+ *
53
+ * The widths are the point, and every earlier guess was wrong:
54
+ *
55
+ * - the ACTION column held `7rem` for a single icon, stealing space from the
56
+ * version cell — so `0.100.0 → 0.101.0` truncated while the action cell sat
57
+ * mostly empty. It is `1.75rem` now: one 24px button and nothing else.
58
+ * - the VERSION column held `7.5rem` (120px), which clipped the widest thing
59
+ * it ever holds — an adapter's `adapter 0.100.0 → 0.101.0` line, measured at
60
+ * 151px in this face. It is `9.5rem` (152px), the content's own width.
61
+ * - on a PHONE it is `7rem`: the About card is 512px at most, and the 152px
62
+ * track left the agent's own name ~130px, so `command-code` and
63
+ * `deepseek-harness` were the cells that truncated while the name is the one
64
+ * thing a reader is scanning for. The version line ellipsizes instead, and
65
+ * carries its full text in `title`.
66
+ *
67
+ * It stays a FIXED track rather than `auto`: every row is its own grid, so an
68
+ * `auto` track is measured per row and the version numbers stop lining up in a
69
+ * column (measured: a name cell of 352px on one row and 208px on the next).
70
+ *
71
+ * The name takes the slack and ellipsizes. The card's own width is FIXED
72
+ * (`md:w-[880px]`), so the name track cannot collapse the dialog — that only
73
+ * happened while the card was `w-auto`.
74
+ *
75
+ * `items-start`, not `items-center`: each cell holds two lines whose heights
76
+ * differ from row to row (a version cell is 16px alone and 31px with an
77
+ * `adapter …` line under it), and centering measured the number 7.5px BELOW the
78
+ * name it belongs to. Top-aligned, line one of every cell shares one baseline.
79
+ */
80
+ const COLUMNS = 'grid grid-cols-[minmax(0,1fr)_7rem_1.75rem] items-start gap-x-2 md:grid-cols-[minmax(0,1fr)_9.5rem_1.75rem]';
81
+
82
+ export function HarnessRow({
83
+ entry, version, job, problem, onOpenHarness, onUpdate, onOpenLog,
84
+ }: HarnessRowProps) {
85
+ const status = harnessStatus(entry);
86
+ // Three states, three answers: a worker is installing this one, this one is
87
+ // WAITING for the install ahead of it, or nothing is running and the record is
88
+ // the run that settled.
89
+ const isUpdating = jobRunning(job);
90
+ const isQueued = jobQueued(job);
91
+ const busy = isUpdating || isQueued;
92
+ const progress = isUpdating ? runningStepOf(job) : null;
93
+ // The row that owns the record gets the log line: while it waits or installs,
94
+ // and after it settles so the output is not lost with it.
95
+ const showLogLine = busy || job?.finishedAt != null;
96
+ // The number a reader calls "the version": the CLI when the harness is an
97
+ // adapter, otherwise the agent itself. Each part carries its own `latest` and
98
+ // its own ability to move, so the two are never compared across each other.
99
+ //
100
+ // A CLI part EXISTS for every adapter even when its `--version` could not be
101
+ // read (the binary is absent, or its launcher is broken). Taking that empty
102
+ // part as the lead painted `—` over a known adapter number: measured on
103
+ // `zcode` (adapter 0.82.3 probed, no `zcode` runtime) and `claude`
104
+ // (`claude --version` fails while the adapter answers). The part that HAS a
105
+ // number leads.
106
+ const cli = version?.cli ?? null;
107
+ const agent = version?.agent ?? null;
108
+ const lead = cli?.version ? cli : agent;
109
+ const showAdapterLine = Boolean(
110
+ cli?.version && agent?.version && agent.version !== cli.version,
111
+ );
112
+ // What the press would install, named: an adapter and a CLI are two different
113
+ // products, so the accessible name says which is moving.
114
+ const targets = version
115
+ ? [
116
+ version.agent.updateAvailable && version.agent.latest
117
+ ? version.cli ? `adapter ${version.agent.latest}` : version.agent.latest
118
+ : null,
119
+ version.cli?.updateAvailable && version.cli.latest
120
+ ? `${version.cli.name} ${version.cli.latest}`
121
+ : null,
122
+ ].filter((target): target is string => Boolean(target))
123
+ : [];
124
+ const updateLabel = `Update ${entry.label}${targets.length > 0 ? ` to ${targets.join(' + ')}` : ''}`;
125
+ // While the background worker runs, the button names the STEP it is on: one
126
+ // press can be an adapter install and then `claude update`, and "Updating…"
127
+ // alone would hide which half is moving. A run that is WAITING says so — it
128
+ // started when it was accepted, it installs when the queue reaches it.
129
+ const actionLabel = isQueued
130
+ ? `Queued: ${entry.label} update starts after the install that is running`
131
+ : isUpdating && progress ? `Updating ${entry.label}: ${progress}` : updateLabel;
132
+
133
+ return (
134
+ <div className={`${COLUMNS} border-b border-ink/5 py-1.5`}>
135
+ {/* The name is the link: one target per row, and the row's other
136
+ cells stay selectable text.
137
+ TWO lines per cell, and the same two line boxes on both
138
+ sides: the name and its version share row one (16px), the
139
+ state label and the adapter line share row two (15px). Every
140
+ cell is a flex COLUMN of those two rows, which is what makes
141
+ `ready` sit exactly under `2.1.318` and beside
142
+ `adapter 0.100.0 →` (measured 8px apart when the cells were
143
+ centered independently). */}
144
+ <button
145
+ type="button"
146
+ onClick={onOpenHarness}
147
+ title={status.detail ?? undefined}
148
+ aria-label={`${entry.label} — ${status.label}. Open its settings.`}
149
+ className="flex min-w-0 cursor-pointer items-start gap-1.5 text-left"
150
+ >
151
+ {/* The glyph rides the FIRST row, not the middle of the pair:
152
+ centered on both rows it landed between the name and the
153
+ state label. */}
154
+ <span className="flex h-4 shrink-0 items-center">
155
+ <HarnessGlyph harness={entry.id} size={HARNESS_GLYPH_SIZE.compact} />
156
+ </span>
157
+ {/* The state mark sits in the label's TOP-RIGHT CORNER, not in
158
+ the flow: as a trailing child it took a column of its own and
159
+ every agent name lost ~14px to a 6px dot. Positioned, the
160
+ label keeps its width and the mark still reads as a status
161
+ light on that name. */}
162
+ <span className="flex min-w-0 flex-1 flex-col">
163
+ {/* The mark sits at the top-right of the NAME ITSELF, so the
164
+ wrapper must HUG the text — a `flex-1` wrapper anchored the
165
+ dot to the column's edge instead, which read as a marker on
166
+ the version beside it. `max-w-full` keeps it on the name and
167
+ still allows the truncation. */}
168
+ <span className="flex max-w-full items-center gap-1.5">
169
+ <span className={`truncate text-[11px] leading-4 ${status.state === 'ready' ? 'font-medium text-ink' : 'text-ink/70'}`}>
170
+ {entry.label}
171
+ </span>
172
+ <StateMark state={status.state} />
173
+ </span>
174
+ <span className="block truncate text-[10px] leading-[15px] text-ink/40">{status.label}</span>
175
+ </span>
176
+ </button>
177
+
178
+ {/* TWO number lines, each with its OWN arrow.
179
+ A harness can be an adapter over a CLI, and the two move
180
+ independently: the row leads with the CLI's `2.1.318` and states
181
+ `adapter 0.101.0` underneath, so `→` may only ever join the two
182
+ numbers on ITS line. Joining `2.1.318` with the adapter's latest
183
+ would compare two different products — the fiction this cell
184
+ exists to prevent. */}
185
+ <span
186
+ className="flex min-w-0 flex-col items-end text-right font-mono text-[11px] leading-4 text-ink/70"
187
+ title={version?.note ?? undefined}
188
+ >
189
+ <span className="block max-w-full truncate">
190
+ {/* The CLI's version leads when the harness is an ADAPTER: it
191
+ is the number a user recognises (`claude --version` →
192
+ 2.1.318). */}
193
+ {lead?.version ?? <span className="text-ink/30">—</span>}
194
+ {lead?.updateAvailable && lead.latest && (
195
+ <>
196
+ <span aria-hidden="true" className="ml-1 text-ink/35">→</span>
197
+ <span className="ml-1 text-ink">{lead.latest}</span>
198
+ </>
199
+ )}
200
+ </span>
201
+ {/* The adapter's own number and its own move. It lives INSIDE
202
+ the version cell — as a fourth grid child it shifted every
203
+ row one track and moved the action button onto its own line. */}
204
+ {showAdapterLine && version && (
205
+ <span
206
+ className="block max-w-full truncate text-[10px] leading-[15px] text-ink/35"
207
+ title={`${version.cli?.name ?? 'CLI'} ${version.cli?.version ?? 'unknown'} · adapter ${version.agent.version}`}
208
+ >
209
+ adapter {version.agent.version}
210
+ {version.agent.updateAvailable && version.agent.latest
211
+ ? ` → ${version.agent.latest}`
212
+ : ''}
213
+ </span>
214
+ )}
215
+ </span>
216
+
217
+ <div className="flex min-w-0 justify-end">
218
+ {/* ICON ONLY, and only when there is something to move to.
219
+ A row with no newer version shows nothing: a permanent action
220
+ button claims work that does not exist. The label lives in
221
+ `title` + `aria-label`, so the meaning is not lost — it is just
222
+ not spent on every row. The icon is a DOWNLOAD arrow because
223
+ that is what the press does; it used to be `ArrowUpRight`, which
224
+ reads as "open this elsewhere". */}
225
+ {version?.updateAvailable ? (
226
+ <button
227
+ type="button"
228
+ onClick={onUpdate}
229
+ // Disabled for BOTH halves: a second press for a harness
230
+ // that is already waiting would only be refused, and the
231
+ // button's own state is the answer.
232
+ disabled={busy}
233
+ aria-label={actionLabel}
234
+ title={actionLabel}
235
+ className="inline-flex cursor-pointer items-center justify-center rounded border border-ink/25 p-1 text-ink transition-colors hover:border-ink/50 hover:bg-ink/5 disabled:cursor-not-allowed disabled:opacity-50"
236
+ >
237
+ {busy
238
+ ? <Loader2 size={11} className="animate-spin motion-reduce:animate-none" />
239
+ : <Download size={11} />}
240
+ </button>
241
+ ) : (
242
+ <span className="text-[10px] text-ink/25">—</span>
243
+ )}
244
+ </div>
245
+
246
+ {problem && (
247
+ <span className="col-span-3 pb-1 text-[10px] text-ink/70">{problem}</span>
248
+ )}
249
+
250
+ {showLogLine && (
251
+ <UpdateLogLine
252
+ running={isUpdating}
253
+ queued={isQueued}
254
+ progress={progress}
255
+ message={job?.message ?? null}
256
+ onOpenLog={onOpenLog}
257
+ />
258
+ )}
259
+ </div>
260
+ );
261
+ }
@@ -26,14 +26,18 @@
26
26
  * A row is a LINK first: clicking it opens that harness's settings page. Editing
27
27
  * lives there; About is where you learn which page to open and whether anything
28
28
  * needs doing first.
29
+ *
30
+ * The mark*up* of one row lives in `HarnessRow.tsx`; this file owns the heading,
31
+ * the tally, and the list. It also owns the one handler a press goes through, so
32
+ * a refusal is shown under the row it belongs to and never under a neighbour.
29
33
  */
30
34
 
31
35
  import { useState } from 'preact/hooks';
32
- import { Download, Loader2 } from 'lucide-preact';
33
- import { HarnessGlyph, HARNESS_GLYPH_SIZE } from '@/client/components/common/harness-glyph';
34
- import { harnessStatus, type HarnessState } from '@/shared/lib/harness/status';
36
+ import { HarnessRow } from '@/client/components/layout/session-sidebar/about-modal/HarnessRow';
37
+ import { harnessStatus } from '@/shared/lib/harness/status';
35
38
  import { harnessCategoryId } from '@/shared/lib/harness/menu';
36
39
  import type { HarnessSummary } from '@/shared/types/harness';
40
+ import type { HarnessUpdateJob } from '@/shared/types/harness-update';
37
41
  import type { HarnessVersionRow } from '@/shared/types/harness-version';
38
42
 
39
43
  interface HarnessTableProps {
@@ -41,58 +45,34 @@ interface HarnessTableProps {
41
45
  versions: HarnessVersionRow[];
42
46
  loading?: boolean;
43
47
  onOpenHarness: (id: string) => void;
44
- /** Runs one npm harness's update; resolves to a refusal, or null. */
48
+ /** Starts one harness's update as a background job and follows it; resolves
49
+ * to a refusal (a busy server, an unknown harness), or null when it began —
50
+ * immediately, or queued behind the install already running. */
45
51
  onUpdate: (id: string) => Promise<string | null>;
46
- /** Which harness is mid-update. */
47
- updating: string | null;
48
- }
49
-
50
- /** The state mark. Shape carries the state, so tone is reinforcement only. */
51
- function StateMark({ state }: { state: HarnessState }) {
52
- if (state === 'ready') return <span aria-hidden="true" className="h-1.5 w-1.5 rounded-full bg-success" />;
53
- if (state === 'not-installed') return <span aria-hidden="true" className="h-1.5 w-1.5 rounded-full border border-ink/35" />;
54
- if (state === 'needs-setup') return <span aria-hidden="true" className="h-1.5 w-1.5 rounded-full bg-ink/45" />;
55
- return <span aria-hidden="true" className="h-1.5 w-1.5 rounded-full bg-ink/15" />;
52
+ /**
53
+ * The last known update record PER HARNESS: waiting its turn, installing, or
54
+ * the run that settled.
55
+ *
56
+ * Per harness, not one: two presses are two records, and a row may only ever
57
+ * show its own run (`jobQueued`, `jobRunning`, `runningStepOf`).
58
+ */
59
+ jobs?: HarnessUpdateJob[];
60
+ /**
61
+ * Opens the log of ONE harness's record. It takes the id because there can be
62
+ * a waiting run and an installing one at the same time; the row names its own.
63
+ */
64
+ onOpenLog?: (harness: string) => void;
56
65
  }
57
66
 
58
- /**
59
- * The three-column grid every data row uses.
60
- *
61
- * The widths are the point, and every earlier guess was wrong:
62
- *
63
- * - the ACTION column held `7rem` for a single icon, stealing space from the
64
- * version cell — so `0.100.0 → 0.101.0` truncated while the action cell sat
65
- * mostly empty. It is `1.75rem` now: one 24px button and nothing else.
66
- * - the VERSION column held `7.5rem` (120px), which clipped the widest thing
67
- * it ever holds — an adapter's `adapter 0.100.0 → 0.101.0` line, measured at
68
- * 151px in this face. It is `9.5rem` (152px), the content's own width.
69
- * - on a PHONE it is `7rem`: the About card is 512px at most, and the 152px
70
- * track left the agent's own name ~130px, so `command-code` and
71
- * `deepseek-harness` were the cells that truncated while the name is the one
72
- * thing a reader is scanning for. The version line ellipsizes instead, and
73
- * carries its full text in `title`.
74
- *
75
- * It stays a FIXED track rather than `auto`: every row is its own grid, so an
76
- * `auto` track is measured per row and the version numbers stop lining up in a
77
- * column (measured: a name cell of 352px on one row and 208px on the next).
78
- *
79
- * The name takes the slack and ellipsizes. The card's own width is FIXED
80
- * (`md:w-[880px]`), so the name track cannot collapse the dialog — that only
81
- * happened while the card was `w-auto`.
82
- *
83
- * `items-start`, not `items-center`: each cell holds two lines whose heights
84
- * differ from row to row (a version cell is 16px alone and 31px with an
85
- * `adapter …` line under it), and centering measured the number 7.5px BELOW the
86
- * name it belongs to. Top-aligned, line one of every cell shares one baseline.
87
- */
88
- const COLUMNS = 'grid grid-cols-[minmax(0,1fr)_7rem_1.75rem] items-start gap-x-2 md:grid-cols-[minmax(0,1fr)_9.5rem_1.75rem]';
89
-
90
67
  export function HarnessTable({
91
- harnesses, versions, loading = false, onOpenHarness, onUpdate, updating,
68
+ harnesses, versions, loading = false, onOpenHarness, onUpdate, jobs = [],
69
+ onOpenLog,
92
70
  }: HarnessTableProps) {
93
71
  const [problem, setProblem] = useState<{ id: string; message: string } | null>(null);
94
72
 
95
73
  const byId = new Map(versions.map((row) => [row.id, row]));
74
+ // ONE record per harness: the row renders its own run, never a neighbour's.
75
+ const jobById = new Map(jobs.map((job) => [job.harness, job]));
96
76
  // The built-in transport is the default every discovered session runs on, with
97
77
  // nothing to install, probe or update; listing it would inflate the count with
98
78
  // the one entry nobody has to decide about.
@@ -147,159 +127,20 @@ export function HarnessTable({
147
127
  // scrollers, and the inner one had no reason to exist. The About panel's
148
128
  // own body is the single scroller now, so the list simply grows.
149
129
  <div data-harness-rows="" className="grid grid-cols-1 gap-x-6 md:grid-cols-2">
150
- {entries.map((entry) => {
151
- const status = harnessStatus(entry);
152
- const version = byId.get(entry.id);
153
- const isUpdating = updating === entry.id;
154
- // The number a reader calls "the version": the CLI when the harness is
155
- // an adapter, otherwise the agent itself. Each part carries its own
156
- // `latest` and its own ability to move, so the two are never compared
157
- // across each other.
158
- //
159
- // A CLI part EXISTS for every adapter even when its `--version` could
160
- // not be read (the binary is absent, or its launcher is broken). Taking
161
- // that empty part as the lead painted `—` over a known adapter number:
162
- // measured on `zcode` (adapter 0.82.3 probed, no `zcode` runtime) and
163
- // `claude` (`claude --version` fails while the adapter answers). The
164
- // part that HAS a number leads.
165
- const cli = version?.cli ?? null;
166
- const agent = version?.agent ?? null;
167
- const lead = cli?.version ? cli : agent;
168
- const showAdapterLine = Boolean(
169
- cli?.version && agent?.version && agent.version !== cli.version,
170
- );
171
- // What the press would install, named: an adapter and a CLI are two
172
- // different products, so the accessible name says which is moving.
173
- const targets = version
174
- ? [
175
- version.agent.updateAvailable && version.agent.latest
176
- ? version.cli ? `adapter ${version.agent.latest}` : version.agent.latest
177
- : null,
178
- version.cli?.updateAvailable && version.cli.latest
179
- ? `${version.cli.name} ${version.cli.latest}`
180
- : null,
181
- ].filter((target): target is string => Boolean(target))
182
- : [];
183
- const updateLabel = `Update ${entry.label}${targets.length > 0 ? ` to ${targets.join(' + ')}` : ''}`;
184
- return (
185
- <div key={entry.id} className={`${COLUMNS} border-b border-ink/5 py-1.5`}>
186
- {/* The name is the link: one target per row, and the row's other
187
- cells stay selectable text.
188
- TWO lines per cell, and the same two line boxes on both
189
- sides: the name and its version share row one (16px), the
190
- state label and the adapter line share row two (15px). Every
191
- cell is a flex COLUMN of those two rows, which is what makes
192
- `ready` sit exactly under `2.1.318` and beside
193
- `adapter 0.100.0 →` (measured 8px apart when the cells were
194
- centered independently). */}
195
- <button
196
- type="button"
197
- onClick={() => onOpenHarness(entry.id)}
198
- title={status.detail ?? undefined}
199
- aria-label={`${entry.label} — ${status.label}. Open its settings.`}
200
- className="flex min-w-0 cursor-pointer items-start gap-1.5 text-left"
201
- >
202
- {/* The glyph rides the FIRST row, not the middle of the pair:
203
- centered on both rows it landed between the name and the
204
- state label. */}
205
- <span className="flex h-4 shrink-0 items-center">
206
- <HarnessGlyph harness={entry.id} size={HARNESS_GLYPH_SIZE.compact} />
207
- </span>
208
- {/* The state mark sits in the label's TOP-RIGHT CORNER, not in
209
- the flow: as a trailing child it took a column of its own and
210
- every agent name lost ~14px to a 6px dot. Positioned, the
211
- label keeps its width and the mark still reads as a status
212
- light on that name. */}
213
- <span className="flex min-w-0 flex-1 flex-col">
214
- {/* The mark sits at the top-right of the NAME ITSELF, so the
215
- wrapper must HUG the text — a `flex-1` wrapper anchored the
216
- dot to the column's edge instead, which read as a marker on
217
- the version beside it. `max-w-full` keeps it on the name and
218
- still allows the truncation. */}
219
- <span className="flex max-w-full items-center gap-1.5">
220
- <span className={`truncate text-[11px] leading-4 ${status.state === 'ready' ? 'font-medium text-ink' : 'text-ink/70'}`}>
221
- {entry.label}
222
- </span>
223
- <StateMark state={status.state} />
224
- </span>
225
- <span className="block truncate text-[10px] leading-[15px] text-ink/40">{status.label}</span>
226
- </span>
227
- </button>
228
-
229
- {/* TWO number lines, each with its OWN arrow.
230
- A harness can be an adapter over a CLI, and the two move
231
- independently: the row leads with the CLI's `2.1.318` and states
232
- `adapter 0.101.0` underneath, so `→` may only ever join the two
233
- numbers on ITS line. Joining `2.1.318` with the adapter's latest
234
- would compare two different products — the fiction this cell
235
- exists to prevent. */}
236
- <span
237
- className="flex min-w-0 flex-col items-end text-right font-mono text-[11px] leading-4 text-ink/70"
238
- title={version?.note ?? undefined}
239
- >
240
- <span className="block max-w-full truncate">
241
- {/* The CLI's version leads when the harness is an ADAPTER: it
242
- is the number a user recognises (`claude --version` →
243
- 2.1.318). */}
244
- {lead?.version ?? <span className="text-ink/30">—</span>}
245
- {lead?.updateAvailable && lead.latest && (
246
- <>
247
- <span aria-hidden="true" className="ml-1 text-ink/35">→</span>
248
- <span className="ml-1 text-ink">{lead.latest}</span>
249
- </>
250
- )}
251
- </span>
252
- {/* The adapter's own number and its own move. It lives INSIDE
253
- the version cell — as a fourth grid child it shifted every
254
- row one track and moved the action button onto its own line. */}
255
- {showAdapterLine && version && (
256
- <span
257
- className="block max-w-full truncate text-[10px] leading-[15px] text-ink/35"
258
- title={`${version.cli?.name ?? 'CLI'} ${version.cli?.version ?? 'unknown'} · adapter ${version.agent.version}`}
259
- >
260
- adapter {version.agent.version}
261
- {version.agent.updateAvailable && version.agent.latest
262
- ? ` → ${version.agent.latest}`
263
- : ''}
264
- </span>
265
- )}
266
- </span>
267
-
268
- <div className="flex min-w-0 justify-end">
269
- {/* ICON ONLY, and only when there is something to move to.
270
- A row with no newer version shows nothing: a permanent action
271
- button claims work that does not exist. The label lives in
272
- `title` + `aria-label`, so the meaning is not lost — it is just
273
- not spent on every row. The icon is a DOWNLOAD arrow because
274
- that is what the press does; it used to be `ArrowUpRight`, which
275
- reads as "open this elsewhere". */}
276
- {version?.updateAvailable ? (
277
- <button
278
- type="button"
279
- onClick={() => void runUpdate(entry.id)}
280
- disabled={isUpdating}
281
- aria-label={updateLabel}
282
- title={updateLabel}
283
- className="inline-flex cursor-pointer items-center justify-center rounded border border-ink/25 p-1 text-ink transition-colors hover:border-ink/50 hover:bg-ink/5 disabled:cursor-not-allowed disabled:opacity-50"
284
- >
285
- {isUpdating
286
- ? <Loader2 size={11} className="animate-spin motion-reduce:animate-none" />
287
- : <Download size={11} />}
288
- </button>
289
- ) : (
290
- <span className="text-[10px] text-ink/25">—</span>
291
- )}
292
- </div>
293
-
294
- {problem?.id === entry.id && (
295
- <span className="col-span-3 pb-1 text-[10px] text-ink/70">{problem.message}</span>
296
- )}
297
- </div>
298
- );
299
- })}
130
+ {entries.map((entry) => (
131
+ <HarnessRow
132
+ key={entry.id}
133
+ entry={entry}
134
+ version={byId.get(entry.id) ?? null}
135
+ job={jobById.get(entry.id) ?? null}
136
+ problem={problem?.id === entry.id ? problem.message : null}
137
+ onOpenHarness={() => onOpenHarness(entry.id)}
138
+ onUpdate={() => void runUpdate(entry.id)}
139
+ onOpenLog={onOpenLog ? () => onOpenLog(entry.id) : undefined}
140
+ />
141
+ ))}
300
142
  </div>
301
143
  )}
302
-
303
144
  </section>
304
145
  );
305
146
  }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The row's link to its update log, in the three states a record can be in.
8
+ *
9
+ * A harness update runs in a background worker, so the row can only show *that*
10
+ * something is installing — never what it printed. That output lives in the job
11
+ * record, and these cases pin the row's half of the deal: while the worker runs
12
+ * the row names the step and offers `View log`; a run WAITING behind another one
13
+ * says so instead of claiming to install; once a run settles the row keeps
14
+ * offering the log with the run's own sentence; and a record never leaks onto a
15
+ * row that does not own it.
16
+ */
17
+
18
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
19
+ import { act } from 'preact/test-utils';
20
+ import { render } from 'preact';
21
+
22
+ import {
23
+ harnessRows,
24
+ installHarnessTableDom,
25
+ mountHarnessTable,
26
+ restoreHarnessTableDom,
27
+ summary,
28
+ updateJob,
29
+ version,
30
+ } from '@/test-support/harness-table.test-util';
31
+
32
+ let container: HTMLElement;
33
+
34
+ beforeAll(() => {
35
+ installHarnessTableDom();
36
+ });
37
+
38
+ beforeEach(() => {
39
+ container = document.createElement('div');
40
+ document.body.appendChild(container);
41
+ });
42
+
43
+ afterEach(() => {
44
+ render(null, container);
45
+ container.remove();
46
+ });
47
+
48
+ afterAll(() => {
49
+ restoreHarnessTableDom();
50
+ });
51
+
52
+ /** The claude row, with update records attached. */
53
+ function mountClaude(state: Parameters<typeof mountHarnessTable>[5]): HTMLElement {
54
+ return mountHarnessTable(
55
+ container,
56
+ [summary()],
57
+ [version({ updateAvailable: true, agent: { version: '0.100.0', latest: '0.102.0', updateAvailable: true } })],
58
+ undefined,
59
+ undefined,
60
+ state,
61
+ );
62
+ }
63
+
64
+ describe('harness row update log', () => {
65
+ test('while the worker runs, the row names the step and offers the log', () => {
66
+ const opened: string[] = [];
67
+ const el = mountClaude({
68
+ jobs: [updateJob()],
69
+ onOpenLog: (harness) => { opened.push(harness); },
70
+ });
71
+ const row = harnessRows(el)[0];
72
+ expect(row.textContent).toContain('Installing adapter…');
73
+ const log = row.querySelector<HTMLButtonElement>('[data-update-log]');
74
+ expect(log?.textContent).toBe('View log');
75
+ act(() => log!.click());
76
+ // The opener names the harness: two records can be on screen at once.
77
+ expect(opened).toEqual(['claude']);
78
+ });
79
+
80
+ test('a run waiting behind another one says it is queued, and does not spin', () => {
81
+ const el = mountClaude({
82
+ jobs: [updateJob({ pid: null, queuedAt: Date.now() })],
83
+ onOpenLog: () => {},
84
+ });
85
+ const row = harnessRows(el)[0];
86
+ expect(row.textContent).toContain('Queued — starts when the install running now finishes');
87
+ expect(row.textContent).not.toContain('Installing');
88
+ const button = row.querySelector<HTMLButtonElement>('button[aria-label^="Queued:"]');
89
+ expect(button).not.toBeNull();
90
+ expect(button?.disabled).toBe(true);
91
+ });
92
+
93
+ test('after the run settles the log stays, with the run’s sentence', () => {
94
+ const el = mountClaude({
95
+ jobs: [updateJob({
96
+ pid: null,
97
+ finishedAt: Date.now(),
98
+ ok: false,
99
+ applied: true,
100
+ message: 'claude update failed (exit 3)',
101
+ steps: [{ part: 'adapter', command: 'npm install -g x', argv: ['npm'], state: 'failed', code: 3 }],
102
+ })],
103
+ onOpenLog: () => {},
104
+ });
105
+ const row = harnessRows(el)[0];
106
+ expect(row.textContent).toContain('claude update failed (exit 3)');
107
+ expect(row.querySelector('[data-update-log]')).not.toBeNull();
108
+ });
109
+
110
+ test('a record for another harness does not appear on this row', () => {
111
+ const el = mountClaude({ jobs: [updateJob({ harness: 'codex', label: 'codex', message: 'codex updated' })] });
112
+ expect(harnessRows(el)[0].querySelector('[data-update-log]')).toBeNull();
113
+ });
114
+ });