@kabmo-labs/kabmo 0.23.0 → 0.25.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 +805 -736
  3. package/dist/client/static/js/index-bc9aa4mx.css +1 -0
  4. package/dist/client/static/js/{index-ph0q59rs.js → index-ga8cbpt4.js} +1071 -1171
  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/Modal.tsx +2 -6
  13. package/src/client/components/common/code-surface/shiki.test.ts +82 -0
  14. package/src/client/components/common/code-surface/shiki.ts +28 -7
  15. package/src/client/components/common/session-actions-menu/NewChildSessionDialog.tsx +113 -0
  16. package/src/client/components/common/session-actions-menu/index.tsx +33 -2
  17. package/src/client/components/common/session-row/StatusSlot.tsx +4 -4
  18. package/src/client/components/common/session-row/index.tsx +27 -1
  19. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +7 -1
  20. package/src/client/components/layout/desktop-layout/resizer/separator-drag.ts +3 -3
  21. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +25 -12
  22. package/src/client/components/layout/session-sidebar/ChildSessionList.tsx +66 -0
  23. package/src/client/components/layout/session-sidebar/SessionItem.tsx +28 -3
  24. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.test.tsx +20 -0
  25. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +59 -12
  26. package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +94 -0
  27. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.test.tsx +130 -0
  28. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +120 -0
  29. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +47 -0
  30. package/src/client/components/layout/session-sidebar/about-modal/index.test.tsx +122 -0
  31. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +55 -46
  32. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +18 -5
  33. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +21 -4
  34. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +27 -5
  35. package/src/client/components/settings/categories/harness-settings/EnvProviderForm.tsx +31 -0
  36. package/src/client/components/settings/categories/harness-settings/provider-panel.test.tsx +49 -0
  37. package/src/client/components/workspace/chat-timeline/ChatOverlays.tsx +5 -2
  38. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +64 -70
  39. package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +35 -0
  40. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +135 -118
  41. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +22 -1
  42. package/src/client/components/workspace/chat-timeline/MessageList.test.ts +14 -0
  43. package/src/client/components/workspace/chat-timeline/MessageList.tsx +4 -0
  44. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +3 -0
  45. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +4 -3
  46. package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +155 -0
  47. package/src/client/components/workspace/chat-timeline/index.tsx +5 -2
  48. package/src/client/components/workspace/chat-timeline/pending-harness.test.tsx +1 -1
  49. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +11 -20
  50. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx +1 -1
  51. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +1 -1
  52. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +1 -1
  53. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -1
  54. package/src/client/components/workspace/file-explorer/index.test.ts +25 -0
  55. package/src/client/components/workspace/file-explorer/index.tsx +9 -3
  56. package/src/client/components/workspace/model-dropdown/harness-models.test.ts +17 -0
  57. package/src/client/components/workspace/model-dropdown/harness-models.ts +33 -18
  58. package/src/client/components/workspace/model-dropdown/index.tsx +3 -3
  59. package/src/client/components/workspace/model-dropdown/popover-metrics.ts +4 -1
  60. package/src/client/components/workspace/terminal-panel/KeyBar.tsx +10 -8
  61. package/src/client/components/workspace/terminal-panel/{RealtimeXtermView.tsx → RealtimeTerminalView.tsx} +51 -58
  62. package/src/client/components/workspace/terminal-panel/fit.test.ts +37 -0
  63. package/src/client/components/workspace/terminal-panel/fit.ts +64 -0
  64. package/src/client/components/workspace/terminal-panel/fonts.test.ts +161 -0
  65. package/src/client/components/workspace/terminal-panel/fonts.ts +164 -0
  66. package/src/client/components/workspace/terminal-panel/grid.test.ts +52 -0
  67. package/src/client/components/workspace/terminal-panel/grid.ts +118 -0
  68. package/src/client/components/workspace/terminal-panel/index.tsx +25 -21
  69. package/src/client/components/workspace/terminal-panel/mount.ts +247 -223
  70. package/src/client/components/workspace/terminal-panel/navigation.test.ts +54 -0
  71. package/src/client/components/workspace/terminal-panel/navigation.ts +47 -0
  72. package/src/client/data/settings/omp-schema.json +5 -5
  73. package/src/client/data/theme/terminal.test.ts +25 -0
  74. package/src/client/data/theme/terminal.ts +96 -79
  75. package/src/client/hooks/chat/composer/items.test.ts +12 -26
  76. package/src/client/hooks/chat/composer/pick-mapping.test.ts +42 -0
  77. package/src/client/hooks/chat/omp/prompt-send.test.ts +7 -7
  78. package/src/client/hooks/chat/omp/prompt-send.ts +26 -14
  79. package/src/client/hooks/chat/timeline/actions.ts +2 -2
  80. package/src/client/hooks/chat/timeline/ask-frames.ts +5 -4
  81. package/src/client/hooks/chat/timeline/new-chat-open.test.ts +86 -0
  82. package/src/client/hooks/chat/timeline/new-chat-open.ts +23 -5
  83. package/src/client/hooks/chat/timeline/new-chat.test.ts +32 -4
  84. package/src/client/hooks/chat/timeline/new-chat.ts +18 -6
  85. package/src/client/hooks/chat/timeline/prompt-text.test.ts +34 -1
  86. package/src/client/hooks/chat/timeline/prompt-text.ts +47 -20
  87. package/src/client/hooks/chat/timeline/rewind-actions.test.ts +24 -1
  88. package/src/client/hooks/chat/timeline/rewind-actions.ts +15 -11
  89. package/src/client/hooks/chat/timeline/run-identity.test.ts +52 -0
  90. package/src/client/hooks/chat/timeline/run-identity.ts +23 -11
  91. package/src/client/hooks/chat/timeline/send-execute.test.ts +56 -0
  92. package/src/client/hooks/chat/timeline/send-helpers.ts +30 -1
  93. package/src/client/hooks/chat/timeline/send-props.ts +5 -3
  94. package/src/client/hooks/chat/timeline/send-steer.test.ts +4 -4
  95. package/src/client/hooks/chat/timeline/send.test-util.ts +8 -2
  96. package/src/client/hooks/chat/timeline/send.test.ts +4 -4
  97. package/src/client/hooks/chat/timeline/send.ts +59 -53
  98. package/src/client/hooks/chat/timeline/session-load.test-util.ts +6 -2
  99. package/src/client/hooks/chat/timeline/session-load.test.ts +31 -0
  100. package/src/client/hooks/chat/timeline/session-load.ts +6 -14
  101. package/src/client/hooks/chat/timeline/session-shapes.ts +32 -0
  102. package/src/client/hooks/chat/timeline/use-fork-session.ts +49 -0
  103. package/src/client/hooks/models/harness-catalog.ts +114 -0
  104. package/src/client/hooks/models/provider-writes.test.ts +81 -0
  105. package/src/client/hooks/models/provider-writes.ts +10 -3
  106. package/src/client/hooks/models/use-harness-update.test.ts +193 -0
  107. package/src/client/hooks/models/use-harness-update.ts +202 -0
  108. package/src/client/hooks/models/use-harnesses-controller.ts +57 -0
  109. package/src/client/hooks/models/use-harnesses-signal.test.ts +128 -0
  110. package/src/client/hooks/models/use-harnesses.test.ts +2 -1
  111. package/src/client/hooks/models/use-harnesses.ts +48 -114
  112. package/src/client/hooks/workspace/child-expansion.ts +33 -0
  113. package/src/client/hooks/workspace/terminal/index.ts +17 -3
  114. package/src/client/hooks/workspace/terminal/socket.ts +9 -4
  115. package/src/client/lib/session-tree.test.ts +50 -0
  116. package/src/client/lib/session-tree.ts +59 -0
  117. package/src/client/tailwind.css +26 -12
  118. package/src/server/index.ts +2 -0
  119. package/src/server/lib/auth/guard.ts +10 -0
  120. package/src/server/lib/btw/session-copy.server.ts +6 -44
  121. package/src/server/lib/btw/session-copy.test.ts +2 -1
  122. package/src/server/lib/db/schema.ts +4 -0
  123. package/src/server/lib/db/seed-terminal.test.ts +1 -1
  124. package/src/server/lib/db/seed.test.ts +1 -1
  125. package/src/server/lib/harness/acp/activation.test.ts +81 -0
  126. package/src/server/lib/harness/acp/activation.ts +72 -0
  127. package/src/server/lib/harness/acp/background-work.test.ts +262 -0
  128. package/src/server/lib/harness/acp/background-work.ts +320 -0
  129. package/src/server/lib/harness/acp/client.ts +2 -2
  130. package/src/server/lib/harness/acp/frames.test.ts +50 -1
  131. package/src/server/lib/harness/acp/frames.ts +17 -5
  132. package/src/server/lib/harness/acp/gateway-env.test.ts +64 -0
  133. package/src/server/lib/harness/acp/gateway-env.ts +70 -0
  134. package/src/server/lib/harness/acp/mapper.ts +6 -4
  135. package/src/server/lib/harness/acp/prompt.test.ts +20 -0
  136. package/src/server/lib/harness/acp/prompt.ts +19 -3
  137. package/src/server/lib/harness/acp/session-background.test.ts +129 -0
  138. package/src/server/lib/harness/acp/session-config.test.ts +73 -0
  139. package/src/server/lib/harness/acp/session-config.ts +87 -6
  140. package/src/server/lib/harness/acp/session-exit.ts +31 -0
  141. package/src/server/lib/harness/acp/session-handshake.test.ts +108 -0
  142. package/src/server/lib/harness/acp/session-handshake.ts +36 -3
  143. package/src/server/lib/harness/acp/session-idle.ts +51 -0
  144. package/src/server/lib/harness/acp/session-listeners.ts +31 -0
  145. package/src/server/lib/harness/acp/session-notifications.ts +19 -3
  146. package/src/server/lib/harness/acp/session-observers.test.ts +9 -0
  147. package/src/server/lib/harness/acp/session-options.ts +33 -0
  148. package/src/server/lib/harness/acp/session-reaper.test.ts +96 -0
  149. package/src/server/lib/harness/acp/session-requests.ts +47 -0
  150. package/src/server/lib/harness/acp/session-turns.ts +20 -5
  151. package/src/server/lib/harness/acp/session.test-util.ts +54 -3
  152. package/src/server/lib/harness/acp/session.test.ts +65 -3
  153. package/src/server/lib/harness/acp/session.ts +79 -79
  154. package/src/server/lib/harness/acp/turn.test.ts +81 -0
  155. package/src/server/lib/harness/acp/turn.ts +54 -13
  156. package/src/server/lib/harness/acp/verbs.ts +12 -2
  157. package/src/server/lib/harness/auto-probe.server.test.ts +121 -0
  158. package/src/server/lib/harness/auto-probe.server.ts +178 -0
  159. package/src/server/lib/harness/config.server.test.ts +1 -1
  160. package/src/server/lib/harness/config.server.ts +1 -1
  161. package/src/server/lib/harness/launch-table.ts +195 -0
  162. package/src/server/lib/harness/launch.test.ts +37 -0
  163. package/src/server/lib/harness/launch.ts +16 -116
  164. package/src/server/lib/harness/provider-entry.ts +32 -0
  165. package/src/server/lib/harness/provider-file.server.ts +3 -0
  166. package/src/server/lib/harness/provider-sources.server.test.ts +45 -0
  167. package/src/server/lib/harness/provider-sources.server.ts +26 -2
  168. package/src/server/lib/harness/provider-write.server.ts +21 -32
  169. package/src/server/lib/harness/provider-zcode.server.test.ts +270 -0
  170. package/src/server/lib/harness/provider-zcode.server.ts +324 -0
  171. package/src/server/lib/harness/spawn.server.ts +15 -2
  172. package/src/server/lib/harness/update-job-store.test.ts +126 -0
  173. package/src/server/lib/harness/update-job-store.ts +109 -0
  174. package/src/server/lib/harness/update-job.server.ts +203 -0
  175. package/src/server/lib/harness/update-state.server.ts +15 -20
  176. package/src/server/lib/harness/update-worker.test.ts +153 -0
  177. package/src/server/lib/harness/update-worker.ts +197 -0
  178. package/src/server/lib/lifecycle/after-listen.ts +7 -0
  179. package/src/server/lib/lifecycle/paths.ts +23 -0
  180. package/src/server/lib/models/registry-refresh.server.test.ts +87 -0
  181. package/src/server/lib/models/registry-refresh.server.ts +98 -0
  182. package/src/server/lib/omp/rpc/child-config.ts +5 -4
  183. package/src/server/lib/omp/rpc/constants.test.ts +2 -1
  184. package/src/server/lib/omp/rpc/forked-resume.test.ts +14 -3
  185. package/src/server/lib/omp/rpc/manager.ts +5 -5
  186. package/src/server/lib/omp/rpc/prewarm-pool.ts +12 -3
  187. package/src/server/lib/omp/rpc/session-registry.ts +14 -2
  188. package/src/server/lib/omp/rpc/terminal-settle.ts +53 -5
  189. package/src/server/lib/omp/session/delete-flow.server.ts +62 -8
  190. package/src/server/lib/omp/session/delete.server.ts +17 -0
  191. package/src/server/lib/omp/session/rewind-file.ts +39 -21
  192. package/src/server/lib/omp/session/sidebar-data.server.ts +6 -6
  193. package/src/server/lib/omp/session/transcript-copy.ts +123 -0
  194. package/src/server/lib/sessions/agent-token.server.test.ts +64 -0
  195. package/src/server/lib/sessions/agent-token.server.ts +134 -0
  196. package/src/server/lib/sessions/answers.server.test.ts +33 -0
  197. package/src/server/lib/sessions/answers.server.ts +37 -0
  198. package/src/server/lib/sessions/dispatch.server.test.ts +143 -0
  199. package/src/server/lib/sessions/dispatch.server.ts +128 -0
  200. package/src/server/lib/sessions/fork.server.test.ts +209 -0
  201. package/src/server/lib/sessions/fork.server.ts +304 -0
  202. package/src/server/lib/sessions/lifecycle.server.test.ts +75 -0
  203. package/src/server/lib/sessions/lifecycle.server.ts +71 -0
  204. package/src/server/lib/sessions/notify.server.test.ts +112 -0
  205. package/src/server/lib/sessions/notify.server.ts +212 -0
  206. package/src/server/lib/sessions/relation-types.ts +76 -0
  207. package/src/server/lib/sessions/relations.server.test.ts +207 -0
  208. package/src/server/lib/sessions/relations.server.ts +337 -0
  209. package/src/server/lib/sessions/resolve.server.ts +106 -0
  210. package/src/server/lib/sessions/schema.server.ts +82 -0
  211. package/src/server/lib/sessions/sidebar-relations.server.test.ts +61 -0
  212. package/src/server/lib/sessions/sidebar-relations.server.ts +47 -0
  213. package/src/server/lib/sessions/spawn.server.test.ts +196 -0
  214. package/src/server/lib/sessions/spawn.server.ts +310 -0
  215. package/src/server/lib/terminal/attach-replay.test.ts +2 -2
  216. package/src/server/lib/terminal/output.test.ts +2 -2
  217. package/src/server/lib/terminal/output.ts +1 -1
  218. package/src/server/lib/terminal/resize.test.ts +99 -0
  219. package/src/server/lib/terminal/runtime.server.ts +26 -6
  220. package/src/server/lib/terminal/send-result.test.ts +18 -1
  221. package/src/server/lib/terminal/send-result.ts +26 -2
  222. package/src/server/lib/terminal/session.server.ts +6 -6
  223. package/src/server/lib/usage/new-api.test.ts +92 -0
  224. package/src/server/lib/usage/new-api.ts +131 -0
  225. package/src/server/lib/usage/provider-endpoint.test.ts +106 -0
  226. package/src/server/lib/usage/provider-key.ts +33 -0
  227. package/src/server/lib/usage/providers.server.ts +10 -3
  228. package/src/server/lib/usage/vendor-balance.server.ts +4 -53
  229. package/src/server/lib/usage/vendor-http.ts +41 -0
  230. package/src/server/lib/usage/window.ts +55 -0
  231. package/src/server/routes/agent/command.ts +14 -1
  232. package/src/server/routes/agent/harness-command.ts +6 -0
  233. package/src/server/routes/agent/new.ts +15 -0
  234. package/src/server/routes/chat/rewind.test.ts +147 -0
  235. package/src/server/routes/chat/rewind.ts +29 -7
  236. package/src/server/routes/chat/session.test.ts +165 -10
  237. package/src/server/routes/chat/session.ts +60 -7
  238. package/src/server/routes/harness/add-provider.test.ts +9 -1
  239. package/src/server/routes/harness/import-action.ts +22 -4
  240. package/src/server/routes/harness/import.test.ts +1 -1
  241. package/src/server/routes/harness/index.ts +5 -1
  242. package/src/server/routes/harness/root.ts +8 -49
  243. package/src/server/routes/harness/toggle.test.ts +20 -0
  244. package/src/server/routes/harness/update-status.ts +26 -0
  245. package/src/server/routes/harness/update.test.ts +119 -0
  246. package/src/server/routes/harness/update.ts +67 -113
  247. package/src/server/routes/harness/versions.ts +5 -1
  248. package/src/server/routes/sessions/answer.ts +24 -0
  249. package/src/server/routes/sessions/batch-delete.ts +11 -5
  250. package/src/server/routes/sessions/delete-acp.test.ts +227 -0
  251. package/src/server/routes/sessions/delete.ts +4 -2
  252. package/src/server/routes/sessions/fork.ts +74 -0
  253. package/src/server/routes/sessions/index.ts +14 -0
  254. package/src/server/routes/sessions/relations.ts +85 -0
  255. package/src/server/routes/sessions/session.ts +4 -0
  256. package/src/server/routes/sessions/spawn.ts +134 -0
  257. package/src/server/routes/settings/model-override.ts +5 -2
  258. package/src/server/routes/settings/provider-entry.ts +2 -2
  259. package/src/server/routes/settings/provider-model.ts +2 -2
  260. package/src/server/routes/settings/provider-models.ts +2 -2
  261. package/src/server/routes/settings/provider-refresh.ts +6 -4
  262. package/src/server/routes/settings/providers.ts +3 -1
  263. package/src/server/routes/settings/settings-config-routes.test.ts +10 -2
  264. package/src/server/routes/terminal/ws.ts +3 -3
  265. package/src/shared/lib/chat/ask-form/fields.ts +76 -0
  266. package/src/shared/lib/chat/ask-form/index.ts +323 -0
  267. package/src/shared/lib/chat/ask-form/tokens.ts +199 -0
  268. package/src/shared/lib/chat/ask-form/types.ts +43 -0
  269. package/src/shared/lib/chat/ask-form.test.ts +137 -0
  270. package/src/shared/lib/chat/ask-questions.test.ts +65 -1
  271. package/src/shared/lib/chat/ask-questions.ts +51 -145
  272. package/src/shared/lib/chat/ask-results.ts +198 -0
  273. package/src/shared/lib/chat/composer/client.ts +31 -2
  274. package/src/shared/lib/chat/composer/delegation.test.ts +93 -0
  275. package/src/shared/lib/chat/composer/delegation.ts +206 -0
  276. package/src/shared/lib/chat/notice-text.ts +1 -1
  277. package/src/shared/lib/chat/timeline/omp-callbacks.ts +13 -1
  278. package/src/shared/lib/chat/timeline/prompt-error.test.ts +146 -0
  279. package/src/shared/lib/chat/timeline/prompt-error.ts +88 -0
  280. package/src/shared/lib/chat/tool/summary-wait.test.ts +11 -0
  281. package/src/shared/lib/code/ansi.ts +1 -1
  282. package/src/shared/lib/fonts/nerd-symbols.css +4 -3
  283. package/src/shared/lib/fonts/nerd-symbols.test.ts +9 -9
  284. package/src/shared/lib/harness/catalog.test.ts +1 -1
  285. package/src/shared/lib/harness/config-fields.test.ts +4 -0
  286. package/src/shared/lib/harness/config-fields.ts +19 -4
  287. package/src/shared/lib/harness/dialects.test.ts +8 -0
  288. package/src/shared/lib/harness/dialects.ts +12 -0
  289. package/src/shared/lib/harness/provider-facts.test.ts +59 -8
  290. package/src/shared/lib/harness/provider-facts.ts +46 -11
  291. package/src/shared/lib/harness/providers.ts +44 -1
  292. package/src/shared/lib/harness/rewind.ts +24 -0
  293. package/src/shared/lib/harness/update-job.ts +33 -0
  294. package/src/shared/lib/harness/update-plan.test.ts +69 -4
  295. package/src/shared/lib/harness/update-plan.ts +57 -9
  296. package/src/shared/lib/harness/updates.test.ts +22 -0
  297. package/src/shared/lib/harness/updates.ts +24 -1
  298. package/src/shared/lib/models/client.ts +10 -1
  299. package/src/shared/lib/omp/dialog-methods.ts +4 -3
  300. package/src/shared/lib/omp/session/wait-idle.test.ts +11 -0
  301. package/src/shared/lib/omp/session/wait-idle.ts +12 -2
  302. package/src/shared/lib/theme/catalog.test.ts +13 -9
  303. package/src/shared/lib/theme/color.test.ts +2 -2
  304. package/src/shared/lib/theme/color.ts +4 -4
  305. package/src/shared/lib/theme/css.ts +2 -0
  306. package/src/shared/lib/theme/ink-scale.ts +21 -1
  307. package/src/shared/lib/theme/theme.test.ts +26 -10
  308. package/src/shared/lib/ui/safe-area.test.ts +28 -0
  309. package/src/shared/lib/ui/safe-area.ts +42 -0
  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 +65 -0
  316. package/src/shared/types/harness.ts +30 -4
  317. package/src/shared/types/omp/agent.ts +19 -2
  318. package/src/shared/types/workspace.ts +4 -0
  319. package/src/test-support/fake-omp-fork.ts +16 -2
  320. package/src/test-support/file-explorer-render.test-util.ts +37 -0
  321. package/src/test-support/file-explorer.test-util.ts +20 -18
  322. package/src/test-support/harness-table.test-util.ts +21 -4
  323. package/dist/client/static/js/index-jhmg4w91.css +0 -1
  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
@@ -51,6 +51,13 @@ export interface HarnessUpdateFacts {
51
51
  * refused, because a vendor installer is not Kabmo's to run.
52
52
  */
53
53
  command?: string;
54
+ /**
55
+ * The binary the ADAPTER's own package installs, when the launch line prefers
56
+ * a pinned `npx` run of that package. A global install writes this name onto
57
+ * PATH; the update route points the harness at it so the install is the one
58
+ * that actually runs (see `routes/harness/update.ts`).
59
+ */
60
+ agentBin?: string;
54
61
  /** Where the command must run, when it is not the agent's own cwd. */
55
62
  note?: string;
56
63
  }
@@ -71,6 +78,9 @@ export const HARNESS_UPDATE_FACTS: Readonly<Partial<Record<HarnessId, HarnessUpd
71
78
  // fabricated comparison, measured on a real probe.
72
79
  kind: 'npm',
73
80
  pkg: '@agentclientprotocol/claude-agent-acp',
81
+ // The launch line runs `npx -y …@0.100.0`; the install writes this binary,
82
+ // and the route repoints the harness at it after a successful update.
83
+ agentBin: 'claude-agent-acp',
74
84
  // The CLI underneath has its own updater (`claude update`), and the adapter
75
85
  // pins the CLI version it bridges — so the adapter install alone can leave a
76
86
  // stale CLI behind. Both lines are named.
@@ -83,6 +93,7 @@ export const HARNESS_UPDATE_FACTS: Readonly<Partial<Record<HarnessId, HarnessUpd
83
93
  // is compared against.
84
94
  kind: 'npm',
85
95
  pkg: '@agentclientprotocol/codex-acp',
96
+ agentBin: 'codex-acp',
86
97
  cli: { bin: 'codex', name: 'codex' },
87
98
  note: 'The row reports the ADAPTER; `codex --version` is the CLI underneath.',
88
99
  },
@@ -104,6 +115,7 @@ export const HARNESS_UPDATE_FACTS: Readonly<Partial<Record<HarnessId, HarnessUpd
104
115
  pi: {
105
116
  kind: 'npm',
106
117
  pkg: 'pi-acp',
118
+ agentBin: 'pi-acp',
107
119
  cli: { bin: 'pi', name: 'pi' },
108
120
  // The ADAPTER is on npm; the agent it drives is not, so the note names both.
109
121
  note: 'The row reports the ADAPTER; the `pi` binary it drives versions separately.',
@@ -111,7 +123,17 @@ export const HARNESS_UPDATE_FACTS: Readonly<Partial<Record<HarnessId, HarnessUpd
111
123
  qwen: { kind: 'npm', pkg: '@qwen-code/qwen-code' },
112
124
  kimi: { kind: 'npm', pkg: '@moonshot-ai/kimi-code' },
113
125
  minimax: { kind: 'npm', pkg: '@minimax-ai/code' },
114
- dsh: { kind: 'npm', pkg: '@deepseek-ai/dsh' },
126
+ dsh: {
127
+ kind: 'npm',
128
+ // The PROBE reports the ACP surface inside `dsh` (measured: agent
129
+ // `deepseek-harness-acp` 0.0.1), which is NOT the installed CLI's version
130
+ // (`dsh --version` is 0.2.2-rc.1). Comparing 0.0.1 against the package's
131
+ // 0.2.2 planned an install of the version already on disk on every press.
132
+ // The CLI is therefore the part that carries the package and the comparison;
133
+ // the agent line stays report-only.
134
+ cli: { bin: 'dsh', name: 'deepseek-harness', pkg: '@deepseek-ai/dsh' },
135
+ note: 'The row reports the `dsh` CLI; the ACP server it hosts reports its own version underneath.',
136
+ },
115
137
  cursor: { kind: 'own', command: 'cursor-agent update', note: 'Cursor moves through its own installer.' },
116
138
  // The ADAPTER is the npm package the probe reports; the `zcode` CLI it drives
117
139
  // ships with the desktop app (or the vendor's own installer), so its version
@@ -119,6 +141,7 @@ export const HARNESS_UPDATE_FACTS: Readonly<Partial<Record<HarnessId, HarnessUpd
119
141
  zcode: {
120
142
  kind: 'npm',
121
143
  pkg: 'zcode-acp-server',
144
+ agentBin: 'zcode-acp-server',
122
145
  cli: { bin: 'zcode', name: 'ZCode' },
123
146
  note: 'The row reports the ACP bridge; the ZCode CLI it drives installs with the desktop app.',
124
147
  },
@@ -56,7 +56,16 @@ export function notifyModelsUpdated(): void {
56
56
  /**
57
57
  * Observe the `models` topic. The callback fires when the catalog changed, so
58
58
  * the caller can re-project its own view from `fetchModelsData`.
59
+ *
60
+ * The local cache is dropped BEFORE the handler runs: the event exists because
61
+ * the server's answer changed, and a 60s answer cached before it would otherwise
62
+ * be handed straight back to a handler that is trying to re-read the catalog
63
+ * (measured: adding a provider left the composer's picker on the old list until
64
+ * the page was reloaded, even though the topic had fired).
59
65
  */
60
66
  export function subscribeModelsUpdated(handler: () => void): () => void {
61
- return realtimeClient.subscribe(TOPIC_MODELS, handler);
67
+ return realtimeClient.subscribe(TOPIC_MODELS, () => {
68
+ invalidateModelsCache();
69
+ handler();
70
+ });
62
71
  }
@@ -21,9 +21,10 @@
21
21
  * fire-and-forget and must never be listed here: remembering one would offer a
22
22
  * later client a modal nothing is waiting on.
23
23
  *
24
- * `'ask'` belongs here because omp's `ask` tool awaits the rich dialog when the
25
- * host opts in (`set_ask_dialog`), and the per-question `select` loop it falls
26
- * back to otherwise — both park the tool call until an answer arrives.
24
+ * `'ask'` belongs here because a grouped ask dialog parks the agent until an
25
+ * answer arrives: omp's own `ask` tool took that path before 18.18.3, and
26
+ * extensions and the ratchet still open it. The tool's current form-driven walk
27
+ * parks on an ordinary `select`/`input`/`editor`, which is listed too.
27
28
  */
28
29
 
29
30
  import type { ExtensionUiDialogMethod, ExtensionUiDialogRequest } from '@/shared/types/omp/agent';
@@ -25,6 +25,17 @@ describe('the idle ladder', () => {
25
25
  expect(waitIdleOf('No service finished within 30s. Read proc:// for status.')).toEqual({ windowMs: 30_000 });
26
26
  });
27
27
 
28
+ test('reads the 18.18.6 sentence, which names the next rung instead of ending', () => {
29
+ // 18.18.6 appends a back-to-back hint after a semicolon, and words a
30
+ // timeout that watched jobs the same way (`No job finished …`). A regex
31
+ // demanding the period stopped matching, so both cards lost the idle chip.
32
+ expect(waitIdleOf('No reply within 5.0s; a back-to-back wait allows up to 10s.')).toEqual({ windowMs: 5_000 });
33
+ expect(waitIdleOf('No service finished within 10s; a back-to-back wait allows up to 30s. Read proc:// for status.'))
34
+ .toEqual({ windowMs: 10_000 });
35
+ expect(waitIdleOf('1 background job still running.\n\nNo job finished within 30s; a back-to-back wait allows up to 60s.'))
36
+ .toEqual({ windowMs: 30_000 });
37
+ });
38
+
28
39
  test('reads the streak omp names from the second idle wait on', () => {
29
40
  // `WAIT_NOTICE_RUNG` appends the notice whose span is the RUNNING TOTAL:
30
41
  // 5 s + 10 s, then + 30 s, then + 60 s, then + 300 s.
@@ -17,6 +17,12 @@
17
17
  * omp's prose, which is what this module parses. It lives beside `wait.ts`
18
18
  * rather than inside it because the card's parser (jobs, agents, messages) and
19
19
  * the outcomes omp words are separate subjects, and the file ceiling is real.
20
+ *
21
+ * 18.18.6 ends that sentence with the ladder's next rung — `No reply within
22
+ * 5.0s; a back-to-back wait allows up to 10s.` — and words a job-timeout return
23
+ * the same way (`No job finished within …`). The parser accepts both the old
24
+ * period and the new semicolon, because persisted sessions carry the older
25
+ * sentence.
20
26
  */
21
27
 
22
28
  import { formatToolMs } from '@/shared/lib/chat/tool/labels';
@@ -29,8 +35,12 @@ export const WAIT_LADDER_MS = [5_000, 10_000, 30_000, 60_000, 300_000] as const;
29
35
  /** A span in omp's `formatDuration` spelling: `250ms`, `5.0s`, `30s`, `1m45s`, `5m`, `2h5m`. */
30
36
  const OMP_DURATION = String.raw`(?:\d+d)?(?:\d+h)?(?:\d+m)?(?:[\d.]+s)?(?:\d+ms)?`;
31
37
 
32
- /** `No reply within 5.0s.` / `No service finished within 30s. Read proc:// for status.` */
33
- const WAIT_WINDOW_TEXT = new RegExp(`^No (?:reply|service finished) within (${OMP_DURATION})\\.`, 'm');
38
+ /** `No reply within 5.0s.` (≤18.18.3) and the 18.18.6 form
39
+ * `No job finished within 5.0s; a back-to-back wait allows up to 10s.` */
40
+ const WAIT_WINDOW_TEXT = new RegExp(
41
+ `^No (?:reply|job finished|service finished) within (${OMP_DURATION})(?:\\.|;)`,
42
+ 'm',
43
+ );
34
44
 
35
45
  /** `Nothing new after 15.0s of back-to-back waits.` — appended from the SECOND
36
46
  * consecutive idle wait, inside a `<system-notice>` block, and the only place
@@ -23,7 +23,7 @@ import {
23
23
  } from '@/shared/lib/theme/catalog';
24
24
  import { themeStyleSheet } from '@/shared/lib/theme/css';
25
25
  import { mixHex, parseHexColor } from '@/shared/lib/theme/color';
26
- import { getXtermTheme } from '@/client/data/theme/terminal';
26
+ import { getTerminalTheme } from '@/client/data/theme/terminal';
27
27
 
28
28
  const COLOR_KEYS = ['canvas', 'paper', 'ink', 'error', 'success', 'info', 'warning', 'meta'] as const;
29
29
  const COLOR_VALUE = /^(#[0-9a-f]{3}|#[0-9a-f]{6}|#[0-9a-f]{8})$/i;
@@ -143,24 +143,28 @@ describe('color math', () => {
143
143
 
144
144
  describe('terminal palette', () => {
145
145
  test('follows the active theme rather than a fixed light/dark pair', () => {
146
- const nord = getXtermTheme('nord-dark');
147
- const paper = getXtermTheme('paper');
148
- expect(nord.background).toBe('#1F2430');
146
+ const nord = getTerminalTheme('nord-dark');
147
+ const paper = getTerminalTheme('paper');
148
+ // No surface of its own: the terminal paints nothing behind the cells, so
149
+ // the panel's chrome (and the glass plane under it) shows through.
150
+ expect(nord.background).toBe('transparent');
151
+ expect(paper.background).toBe('transparent');
149
152
  expect(nord.foreground).toBe('#E5E9F0');
150
- expect(paper.background).toBe('#f4f1ea');
151
153
  expect(paper.foreground).toBe('#141310');
152
154
  });
153
155
 
154
- test('emits literal colors — xterm cannot parse color-mix()', () => {
156
+ test('emits literal colors — the canvas cannot parse color-mix()', () => {
155
157
  for (const theme of THEMES) {
156
- for (const value of Object.values(getXtermTheme(theme.id))) {
157
- expect(value).toMatch(COLOR_VALUE);
158
+ for (const value of Object.values(getTerminalTheme(theme.id))) {
159
+ // `transparent` is a CSS keyword `fillStyle` does accept, and it is the
160
+ // only non-hex value the palette is allowed to carry.
161
+ expect(value).toMatch(value === 'transparent' ? /^transparent$/ : COLOR_VALUE);
158
162
  }
159
163
  }
160
164
  });
161
165
 
162
166
  test('takes its signal colors from the palette', () => {
163
- const dracula = getXtermTheme('dracula-dark');
167
+ const dracula = getTerminalTheme('dracula-dark');
164
168
  expect(dracula.red).toBe('#FF5555');
165
169
  expect(dracula.green).toBe('#50FA7B');
166
170
  expect(dracula.yellow).toBe('#FFB86C');
@@ -6,8 +6,8 @@
6
6
  /**
7
7
  * Hex color arithmetic for the terminal palette.
8
8
  *
9
- * xterm cannot parse `color-mix()`, so blends are computed here and handed over
10
- * as literal hex — a wrong blend is a wrong-looking terminal, and a wrong
9
+ * The terminal renderer cannot resolve `color-mix()`, so blends are computed
10
+ * here and handed over as literal hex — a wrong blend is a wrong-looking terminal, and a wrong
11
11
  * fallback (returning a broken string instead of the base color) would blank a
12
12
  * palette entry. The parser must handle all three spellings the ported palettes
13
13
  * use (`#rgb`, `#rrggbb`, and 8-digit `#rrggbbaa`, including OpenChamber's
@@ -6,10 +6,10 @@
6
6
  /**
7
7
  * Hex color arithmetic for the places that cannot use CSS.
8
8
  *
9
- * `color-mix()` covers every blend inside the document, but xterm parses theme
10
- * colors itself (it accepts `#rgb`, `#rrggbb`, `rgb()`, `hsl()` and named
11
- * colors — not `color-mix()`, in either the DOM or the WebGL renderer), so the
12
- * terminal palette has to be computed here and handed over as literal hex.
9
+ * `color-mix()` covers every blend inside the document, but the terminal
10
+ * renderer takes only literal colors (it hands them to `ctx.fillStyle`, which
11
+ * does not resolve `color-mix()`), so the terminal palette has to be computed
12
+ * here and handed over as hex.
13
13
  *
14
14
  * The palette values are ported verbatim from OpenChamber and are therefore not
15
15
  * uniform: `#FFF` (jetbrains-light) and 8-digit alpha (`#dbd7caee`,
@@ -58,6 +58,8 @@ function paletteBlock(theme: ThemePalette): string {
58
58
  ` --theme-ink: ${theme.ink};`,
59
59
  // Fifteen distinct values: the ink at N% over this palette's paper.
60
60
  ...scale.ladder.map((value, index) => ` --theme-ink-${MUTED_STEPS[index]}: ${value};`),
61
+ // The inline-code chip's OWN fill, opaque (see `CODE_FILL_PERCENT`).
62
+ ` --theme-code-fill: ${scale.codeFill};`,
61
63
  // Muted text on an inverted surface: an alpha reads 2.91:1 on `solarized-light`.
62
64
  ` --theme-on-ink-muted: ${onInkTextColor(theme)};`,
63
65
  // The one level that clears AA on THIS palette. No single rung can be legal
@@ -11,6 +11,18 @@ export const MUTED_STEPS = [20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80,
11
11
  * `/60` is 4.46:1, so the boundary sits where it is needed, not safely above it. */
12
12
  export const TEXT_CONTRAST_FLOOR = 65;
13
13
 
14
+ /**
15
+ * Strength of the inline-code chip's fill, as a percentage of ink over paper.
16
+ *
17
+ * The chip is SOLVED, not an alpha: `color-mix(… 8%, transparent)` composites
18
+ * with whatever is painted behind the chip, so a hovered block's tint showed
19
+ * through it and the code changed colour mid-hover (measured on a real session
20
+ * in the browser: the same `/Applications/Obsidian.app` chip read `#e4e9ed` at
21
+ * rest and `#dce2e5` with the hover tint behind it). An opaque value also pins
22
+ * the contrast between the code and its chip, which an alpha cannot.
23
+ */
24
+ export const CODE_FILL_PERCENT = 8;
25
+
14
26
  /** AA for small text. Named so the floor above can be read as a contrast. */
15
27
  export const MUTED_CONTRAST_FLOOR = 4.5;
16
28
 
@@ -39,6 +51,8 @@ export interface InkScale {
39
51
  ladder: readonly string[];
40
52
  /** The lightest step that clears AA on both surfaces; the OS shells read it. */
41
53
  muted: string;
54
+ /** The inline-code chip's fill: opaque ink over this palette's paper. */
55
+ codeFill: string;
42
56
  }
43
57
 
44
58
  /** Cached per palette object, so a render pass costs no arithmetic. */
@@ -58,7 +72,13 @@ export function inkScale(palette: ThemePalette): InkScale {
58
72
  ladder.find((color) => worstTextContrast(color, palette) >= MUTED_CONTRAST_FLOOR) ??
59
73
  palette.ink;
60
74
 
61
- const scale: InkScale = { ink: palette.ink, ladder, muted };
75
+ const scale: InkScale = {
76
+ ink: palette.ink,
77
+ ladder,
78
+ muted,
79
+ // Opaque: the paper base is what makes the chip independent of its backdrop.
80
+ codeFill: mixHex(palette.paper, palette.ink, CODE_FILL_PERCENT / 100),
81
+ };
62
82
  cache.set(palette, scale);
63
83
  return scale;
64
84
  }
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * Why each case is risky:
12
12
  *
13
- * - `rgbaToHex` feeds xterm, which rejects anything but literal hex. An
13
+ * - `rgbaToHex` feeds the terminal palette, which takes only literal hex. An
14
14
  * out-of-range or unrounded channel emits `#ff0-10`, a color no consumer can
15
15
  * parse, so clamping/rounding is pinned here.
16
16
  * - `mixHex` composites the blend's own alpha. A palette that carries 8-digit
@@ -28,7 +28,7 @@ import { describe, expect, test } from 'bun:test';
28
28
 
29
29
  import { mixHex, parseHexColor, relativeLuminance, rgbaToHex } from '@/shared/lib/theme/color';
30
30
  import { THEME_STYLE_ELEMENT_ID, themeStyleSheet } from '@/shared/lib/theme/css';
31
- import { MUTED_STEPS, inkScale, onInkTextColor, signalTextColor } from '@/shared/lib/theme/ink-scale';
31
+ import { CODE_FILL_PERCENT, MUTED_STEPS, inkScale, onInkTextColor, signalTextColor } from '@/shared/lib/theme/ink-scale';
32
32
  import { KABMO_PALETTES } from '@/shared/lib/theme/palettes/kabmo';
33
33
  import { DARK_PALETTES } from '@/shared/lib/theme/palettes/dark';
34
34
  import { DARK_EXTENDED_PALETTES } from '@/shared/lib/theme/palettes/dark-extended';
@@ -141,6 +141,9 @@ describe('generated stylesheet', () => {
141
141
  // the ink cannot clear AA on every one (`ink-scale.ts`). One token per
142
142
  // step: bucketing them onto four collapsed the ladder.
143
143
  ...MUTED_STEPS.map((step, index) => ` --theme-ink-${step}: ${inkScale(paper).ladder[index]};`),
144
+ // The inline-code chip's own opaque fill (never an alpha: see the
145
+ // `--theme-code-fill` rule in `tailwind.css`).
146
+ ` --theme-code-fill: ${inkScale(paper).codeFill};`,
144
147
  // Muted text for an inverted surface (`bg-ink`).
145
148
  ` --theme-on-ink-muted: ${onInkTextColor(paper)};`,
146
149
  ` --theme-muted: ${inkScale(paper).muted};`,
@@ -166,19 +169,32 @@ describe('generated stylesheet', () => {
166
169
 
167
170
  test('names every slot --theme-* and nothing else', () => {
168
171
  const names = [...css.matchAll(/--theme-[a-z0-9-]+:/g)].map((match) => match[0]);
169
- // Eight palette slots, fifteen muted steps, the inverted-surface level, the
170
- // palette's own AA level (`--theme-muted`), the five solved signal levels,
171
- // and the two hover mixes.
172
- expect(new Set(names).size).toBe(32);
172
+ // Eight palette slots, fifteen muted steps, the inline-code chip's fill,
173
+ // the inverted-surface level, the palette's own AA level (`--theme-muted`),
174
+ // the five solved signal levels, and the two hover mixes.
175
+ expect(new Set(names).size).toBe(33);
173
176
  expect(names[0]).toBe('--theme-paper:');
174
177
  // Slot order is the swatch order the appearance cards render.
175
178
  expect(names[2]).toBe('--theme-ink:');
176
179
  expect(names[3]).toBe('--theme-ink-20:');
177
180
  expect(names[17]).toBe('--theme-ink-90:');
178
- expect(names[18]).toBe('--theme-on-ink-muted:');
179
- expect(names[19]).toBe('--theme-muted:');
180
- expect(names[24]).toBe('--theme-meta:');
181
- expect(names[25]).toBe('--theme-error-text:');
181
+ expect(names[18]).toBe('--theme-code-fill:');
182
+ expect(names[19]).toBe('--theme-on-ink-muted:');
183
+ expect(names[20]).toBe('--theme-muted:');
184
+ expect(names[25]).toBe('--theme-meta:');
185
+ expect(names[26]).toBe('--theme-error-text:');
186
+ });
187
+
188
+ test('states the inline-code chip fill as an opaque colour, per palette', () => {
189
+ // The chip must NOT be an alpha: a translucent fill composites with whatever
190
+ // is painted behind it, so a hovered block changed the code's colour.
191
+ expect(css).not.toContain('--theme-code-fill: color-mix');
192
+ for (const palette of [KABMO_PALETTES[0], DARK_PALETTES[0]]) {
193
+ const fill = inkScale(palette).codeFill;
194
+ expect(fill).toBe(mixHex(palette.paper, palette.ink, CODE_FILL_PERCENT / 100));
195
+ expect(fill).toMatch(/^#[0-9a-f]{6}$/);
196
+ expect(css).toContain(`--theme-code-fill: ${fill};`);
197
+ }
182
198
  });
183
199
 
184
200
  test('is cached for the life of the process', () => {
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { describe, expect, test } from 'bun:test';
7
+ import { DIALOG_GUTTER_REM, safeAreaPadding } from '@/shared/lib/ui/safe-area';
8
+
9
+ describe('safeAreaPadding', () => {
10
+ test('every edge takes the LARGER of the gutter and the device inset', () => {
11
+ // `max()`, never a sum: a notched phone would otherwise get gutter + inset,
12
+ // which is twice the clearance the dialog needs.
13
+ const style = safeAreaPadding();
14
+ expect(style.paddingTop).toBe(`max(${DIALOG_GUTTER_REM}rem, env(safe-area-inset-top, 0px))`);
15
+ expect(style.paddingBottom).toBe(`max(${DIALOG_GUTTER_REM}rem, env(safe-area-inset-bottom, 0px))`);
16
+ expect(style.paddingLeft).toBe(`max(${DIALOG_GUTTER_REM}rem, env(safe-area-inset-left, 0px))`);
17
+ expect(style.paddingRight).toBe(`max(${DIALOG_GUTTER_REM}rem, env(safe-area-inset-right, 0px))`);
18
+ });
19
+
20
+ test('a caller with its own gutter keeps it on all four edges', () => {
21
+ const style = safeAreaPadding(1);
22
+ expect(style.paddingTop).toBe('max(1rem, env(safe-area-inset-top, 0px))');
23
+ expect(style.paddingBottom).toBe('max(1rem, env(safe-area-inset-bottom, 0px))');
24
+ // Both horizontal edges, because a landscape phone's notch is on a SIDE.
25
+ expect(style.paddingLeft).toBe('max(1rem, env(safe-area-inset-left, 0px))');
26
+ expect(style.paddingRight).toBe('max(1rem, env(safe-area-inset-right, 0px))');
27
+ });
28
+ });
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The padding a fixed overlay keeps clear of a phone's own chrome.
8
+ *
9
+ * A `fixed inset-0` frame reaches the viewport's physical edges, and on a
10
+ * `viewport-fit: cover` surface those edges run UNDER the status bar and the
11
+ * home indicator. Every dialog in this console states the same four declarations
12
+ * inline (the shared `Modal` shell, the About card, …); stated twice, one of them
13
+ * eventually forgets, and the symptom is a header nobody can tap.
14
+ *
15
+ * `env()` is 0 on a desktop, so a single rule serves both surfaces — no
16
+ * media query, and no second copy for the desktop.
17
+ */
18
+
19
+ /** The gutter a dialog keeps from every edge when no safe area applies. */
20
+ export const DIALOG_GUTTER_REM = 0.75;
21
+
22
+ export type SafeAreaPadding = {
23
+ paddingTop: string;
24
+ paddingBottom: string;
25
+ paddingLeft: string;
26
+ paddingRight: string;
27
+ };
28
+
29
+ /**
30
+ * @param gutterRem the edge gutter used when `env()` reports no inset.
31
+ * `max()`, not a sum: on a notched device the safe area is the LARGER of the
32
+ * two, and adding them would inset a dialog twice as far as the device needs.
33
+ */
34
+ export function safeAreaPadding(gutterRem: number = DIALOG_GUTTER_REM): SafeAreaPadding {
35
+ const gutter = `${gutterRem}rem`;
36
+ return {
37
+ paddingTop: `max(${gutter}, env(safe-area-inset-top, 0px))`,
38
+ paddingBottom: `max(${gutter}, env(safe-area-inset-bottom, 0px))`,
39
+ paddingLeft: `max(${gutter}, env(safe-area-inset-left, 0px))`,
40
+ paddingRight: `max(${gutter}, env(safe-area-inset-right, 0px))`,
41
+ };
42
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { describe, expect, test } from 'bun:test';
7
+ import { terminalInputFrame } from '@/shared/lib/workspace/terminal/input';
8
+
9
+ describe('terminalInputFrame', () => {
10
+ test('keeps ordinary text on the text channel', () => {
11
+ expect(terminalInputFrame('echo ok\r')).toEqual({ text: 'echo ok\r' });
12
+ expect(terminalInputFrame('ả 漢')).toEqual({ text: 'ả 漢' });
13
+ });
14
+
15
+ test('routes an X10 mouse report as latin-1 bytes, including values above 127', () => {
16
+ // ESC [ M, button 0, column 188 (+32 = 220), row 3 (+32 = 35).
17
+ const frame = terminalInputFrame('\x1b[M\x20\xdc\x23');
18
+ expect(frame.text).toBeUndefined();
19
+ expect([...(frame.bytes ?? [])]).toEqual([27, 91, 77, 32, 220, 35]);
20
+ expect(frame.bytes?.length).toBe(6);
21
+ });
22
+
23
+ test('does not treat a truncated prefix as a mouse report', () => {
24
+ expect(terminalInputFrame('\x1b[M')).toEqual({ text: '\x1b[M' });
25
+ expect(terminalInputFrame('\x1b[M\x20')).toEqual({ text: '\x1b[M\x20' });
26
+ });
27
+ });
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Split one ghostty-web `onData` payload into the channel the PTY needs.
8
+ *
9
+ * ghostty-web has no `onBinary` (xterm's separate channel for non-UTF-8
10
+ * payloads). Its legacy X10 mouse report is built with `String.fromCharCode`
11
+ * from values up to 255, so `TextEncoder` would turn a 6-byte report into 7+
12
+ * bytes and the shell would receive the wrong sequence. SGR mouse reports are
13
+ * printable ASCII and stay on the text path.
14
+ *
15
+ * X10 is exactly `ESC [ M` followed by three bytes; a payload with that prefix
16
+ * is forwarded through the byte channel unchanged otherwise.
17
+ */
18
+
19
+ const X10_MOUSE_PREFIX = '\x1b[M';
20
+ const X10_MOUSE_LENGTH = X10_MOUSE_PREFIX.length + 3;
21
+
22
+ export type TerminalInputFrame = { text: string; bytes?: undefined } | { text?: undefined; bytes: Uint8Array };
23
+
24
+ export function terminalInputFrame(data: string): TerminalInputFrame {
25
+ if (!data.startsWith(X10_MOUSE_PREFIX) || data.length < X10_MOUSE_LENGTH) {
26
+ return { text: data };
27
+ }
28
+ const bytes = new Uint8Array(data.length);
29
+ for (let index = 0; index < data.length; index += 1) {
30
+ bytes[index] = data.charCodeAt(index) & 0xff;
31
+ }
32
+ return { bytes };
33
+ }
@@ -7,7 +7,7 @@
7
7
  * The bytes the terminal key bar sends.
8
8
  *
9
9
  * Every expectation here is copied from xterm's own `evaluateKeyboardEvent`
10
- * (`@xterm/xterm/src/common/input/Keyboard.ts`), because the shell cannot tell a
10
+ * (`Keyboard.ts`), because the shell cannot tell a
11
11
  * bar button from a physical key: a sequence that merely looks plausible works
12
12
  * in bash and breaks in vim. Three of those rules are the ones this file exists
13
13
  * to pin — a modifier is a CSI PARAMETER and not an ESC prefix, application
@@ -9,8 +9,8 @@
9
9
  * A phone's soft keyboard has no Ctrl, no Alt, no arrows, no Esc and no `|`, so
10
10
  * a shell on a phone is unusable without a strip of buttons that emit the raw
11
11
  * bytes those keys would. Every sequence here is what xterm's own
12
- * `evaluateKeyboardEvent` sends for the same physical key
13
- * (`@xterm/xterm/src/common/input/Keyboard.ts`) — the shell on the far end
12
+ * `evaluateKeyboardEvent` sends for the same physical key (xterm.js's
13
+ * `Keyboard.ts`) — the shell on the far end
14
14
  * cannot tell the two apart, so a bar key that invented its own encoding would
15
15
  * work in bash and break in vim.
16
16
  *
@@ -23,11 +23,11 @@
23
23
  * - Ctrl has no literal spelling: it folds a typed character into a control
24
24
  * character (Ctrl+C is `0x03`), so a literal button keeps its own byte.
25
25
  *
26
- * There is deliberately no Cmd key. macOS reports it as `metaKey` and xterm
27
- * discards it — `if (ev.metaKey) break;` in the cursor-key branches — because
28
- * Cmd is the browser's modifier, not the terminal's: in a terminal Cmd+C and
29
- * Cmd+V mean copy and paste, which is why those are actions in `KeyBar.tsx`
30
- * rather than bytes here.
26
+ * There is deliberately no Cmd key. macOS reports it as `metaKey`, and the
27
+ * renderer treats it as the host's modifier rather than the terminal's: a
28
+ * printable Cmd chord sends nothing, and Cmd+C / Cmd+V are its own copy and
29
+ * paste — which is why those are actions in `KeyBar.tsx` rather than bytes
30
+ * here.
31
31
  */
32
32
 
33
33
  export type TerminalModifier = 'ctrl' | 'alt';
@@ -258,7 +258,7 @@ export interface QueuedMessage {
258
258
  /** Trigger group that opened the composer autocomplete: `@` → mention, `/` → command. */
259
259
  export type ComposerPickKind = 'mention' | 'command';
260
260
  /** Origin of a pickable item: an `@` mention is an agent or a workspace file. */
261
- export type ComposerPickSource = 'agent' | 'file' | 'command' | 'skill';
261
+ export type ComposerPickSource = 'agent' | 'harness' | 'file' | 'command' | 'skill';
262
262
 
263
263
  /**
264
264
  * Which part of a slash invocation the popup is completing. oh-my-pi splits
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * One harness update, as a BACKGROUND job.
8
+ *
9
+ * The update used to run inside the POST that asked for it: the request held
10
+ * open for minutes, a reload forgot it, and the five-minute child timeout could
11
+ * kill `npm install -g` halfway through writing the package tree — a corrupt
12
+ * install that the dialog still reported as a failure it could retry. The run is
13
+ * now a detached worker (`update-worker.ts`) that owns its steps and writes this
14
+ * record to disk, so the request can answer immediately, the page can close, and
15
+ * the next open reads what actually happened.
16
+ *
17
+ * Stated once, here, because three places read it: the worker writes it, the
18
+ * route answers it, and the About card polls it.
19
+ */
20
+
21
+ import type { HarnessUpdateStep } from '@/shared/lib/harness/update-plan';
22
+
23
+ /** Where one step is in its life. `pending` exists on the record before the
24
+ * worker reaches it, so a reader sees the whole plan from the first poll. */
25
+ export type HarnessUpdateStepState = 'pending' | 'running' | 'ok' | 'failed';
26
+
27
+ /** A planned step plus what running it produced. */
28
+ export interface HarnessUpdateJobStep extends HarnessUpdateStep {
29
+ state: HarnessUpdateStepState;
30
+ /** Exit code, or null while it has not run (or was killed). */
31
+ code: number | null;
32
+ }
33
+
34
+ export interface HarnessUpdateJob {
35
+ harness: string;
36
+ label: string;
37
+ startedAt: number;
38
+ /** Null while running: this is the field that says whether to poll. */
39
+ finishedAt: number | null;
40
+ /** The WORKER process, used to tell a run that is still alive from one that
41
+ * died without writing its result (a crash, a kill, a reboot). */
42
+ pid: number | null;
43
+ steps: HarnessUpdateJobStep[];
44
+ /** The tail of everything the commands printed. */
45
+ output: string;
46
+ /** Null while running; true/false once the worker has decided. */
47
+ ok: boolean | null;
48
+ /** The sentence the dialog shows. Null while running. */
49
+ message: string | null;
50
+ /** True once the SERVER applied the post-install side effects (forget the
51
+ * probe and CLI version caches, repoint the launch line). The worker cannot
52
+ * do those: they read the database, which the server owns. */
53
+ applied: boolean;
54
+ /** The launch command a successful install left behind, when it moved it. */
55
+ repointed: string | null;
56
+ }
57
+
58
+ /** What a step needs to run: the plan, and where the worker reads and writes. */
59
+ export interface HarnessUpdateJobSpec {
60
+ harness: string;
61
+ label: string;
62
+ steps: HarnessUpdateStep[];
63
+ statusPath: string;
64
+ lockPath: string;
65
+ }