@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,115 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The draft-target row above a not-yet-started chat: where it runs, in which
8
+ * checkout, under which parent, and what it waits for.
9
+ *
10
+ * One row because these are one question — the context the first prompt is born
11
+ * into — and splitting it back into the composer would put four independent
12
+ * placements in two files. Extracted from `EmptyWorkspacePrompt` for the
13
+ * per-file ceiling.
14
+ */
15
+
16
+ import { WorkspacePicker } from '@/client/components/workspace/chat-timeline/target-picker/WorkspacePicker';
17
+ import { WorktreePicker } from '@/client/components/workspace/chat-timeline/target-picker/WorktreePicker';
18
+ import { ParentSessionPicker } from '@/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker';
19
+ import {
20
+ WaitingDependencyPicker,
21
+ type WaitingCandidate,
22
+ } from '@/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker';
23
+ import type { SpawnTarget } from '@/client/hooks/chat/timeline/spawn-target';
24
+ import type { WorkspaceFolderData } from '@/shared/types';
25
+
26
+ export interface DraftTargetRowProps {
27
+ folders: WorkspaceFolderData[];
28
+ selectedFolderId: number | null;
29
+ setSelectedFolderId: (id: number | null) => void;
30
+ spawnTarget?: SpawnTarget | null;
31
+ onSpawnTargetChange?: (next: SpawnTarget | null) => void;
32
+ /** Reports a worktree the composer created or failed to create. */
33
+ onWorktreeReport?: (message: string) => void;
34
+ /** The session this chat runs under, or null for a top-level chat. */
35
+ parentSessionId?: string | null;
36
+ onParentSessionChange?: (sessionId: string | null) => void;
37
+ /** "Parent session" for a child, "Fork from" for a fork. */
38
+ branchLabel?: string;
39
+ /** False when the pending chat must have a source (a fork). */
40
+ branchAllowNone?: boolean;
41
+ waitingFor?: WaitingCandidate | null;
42
+ onWaitingForChange?: (candidate: WaitingCandidate | null) => void;
43
+ streamStatusMap?: Record<string, string | undefined>;
44
+ /** A name for a streaming session the sidebar has not scanned yet. */
45
+ titleForSession?: (id: string) => string | undefined;
46
+ candidates: WaitingCandidate[];
47
+ }
48
+
49
+ export function DraftTargetRow({
50
+ folders,
51
+ selectedFolderId,
52
+ setSelectedFolderId,
53
+ spawnTarget = null,
54
+ onSpawnTargetChange,
55
+ onWorktreeReport,
56
+ parentSessionId = null,
57
+ onParentSessionChange,
58
+ branchLabel = 'Parent session',
59
+ branchAllowNone = true,
60
+ waitingFor = null,
61
+ onWaitingForChange,
62
+ streamStatusMap = {},
63
+ titleForSession,
64
+ candidates,
65
+ }: DraftTargetRowProps) {
66
+ return (
67
+ <div className="flex items-center gap-1 flex-wrap">
68
+ {/* Two controls, because they answer two questions: the workspace (which
69
+ project) and the worktree (which checkout of it). The worktree control
70
+ draws itself only for a git repository, and it reads its list on mount
71
+ because its own trigger names the branch the project root holds. */}
72
+ <WorkspacePicker
73
+ folders={folders}
74
+ selectedFolderId={selectedFolderId}
75
+ setSelectedFolderId={setSelectedFolderId}
76
+ onClearWorktree={() => onSpawnTargetChange?.(null)}
77
+ />
78
+ {onSpawnTargetChange && (
79
+ <WorktreePicker
80
+ folders={folders}
81
+ selectedFolderId={selectedFolderId}
82
+ target={spawnTarget}
83
+ setTarget={onSpawnTargetChange}
84
+ onReport={onWorktreeReport}
85
+ />
86
+ )}
87
+ {/* ALL sessions, not just the active one: the composer may have been
88
+ opened from one row and the user may want the chat under another.
89
+ Choosing a parent also moves the workspace to that session's folder. */}
90
+ {onParentSessionChange && (
91
+ <ParentSessionPicker
92
+ folders={folders}
93
+ value={parentSessionId}
94
+ onChange={onParentSessionChange}
95
+ label={branchLabel}
96
+ allowNone={branchAllowNone}
97
+ />
98
+ )}
99
+ {/* The wait picker sits BESIDE the workspace picker, because both answer
100
+ the same question about the chat that has not started: where it runs,
101
+ and what it waits for. It only appears while there is something to
102
+ wait for (or a pick already made). */}
103
+ {onWaitingForChange && (waitingFor || candidates.length > 0) && (
104
+ <WaitingDependencyPicker
105
+ folders={folders}
106
+ streamStatusMap={streamStatusMap}
107
+ sessionId={null}
108
+ titleFor={titleForSession}
109
+ value={waitingFor}
110
+ onChange={onWaitingForChange}
111
+ />
112
+ )}
113
+ </div>
114
+ );
115
+ }
@@ -0,0 +1,173 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * "Parent session" — which session a NEW chat branches under.
8
+ *
9
+ * The composer's draft-target row already answers where a chat runs; this is
10
+ * the other half of the same question for a child: what it runs UNDER. The
11
+ * list is ALL real sessions, not only the active one, because the row that
12
+ * opened the composer may not be the parent the user ends up wanting.
13
+ *
14
+ * A pending chat is never offered (it has no id to parent), and neither is an
15
+ * archived one (the server refuses to spawn under it).
16
+ */
17
+
18
+ import { useCallback, useMemo, useRef, useState } from 'preact/hooks';
19
+ import { Check, ChevronDown, GitBranch, X } from 'lucide-preact';
20
+ import { useOnClickOutside } from '@/client/hooks/ui/on-click-outside';
21
+ import type { WorkspaceFolderData } from '@/shared/types';
22
+
23
+ export interface ParentSessionOption {
24
+ id: string;
25
+ title: string;
26
+ folderId: number | string;
27
+ folderName: string;
28
+ harness?: string;
29
+ }
30
+
31
+ /** Every real session, in sidebar order, excluding the chat being composed. */
32
+ export function parentSessionOptions(
33
+ folders: WorkspaceFolderData[],
34
+ excludeId?: string | null,
35
+ ): ParentSessionOption[] {
36
+ const options: ParentSessionOption[] = [];
37
+ for (const folder of folders) {
38
+ for (const session of folder.sessions ?? []) {
39
+ const id = String(session.id);
40
+ if (id.startsWith('new-') || session.is_archived === 1) continue;
41
+ if (excludeId && id === excludeId) continue;
42
+ options.push({
43
+ id,
44
+ title: session.title || id,
45
+ folderId: folder.id,
46
+ folderName: folder.name,
47
+ ...(session.harness ? { harness: session.harness } : {}),
48
+ });
49
+ }
50
+ }
51
+ return options;
52
+ }
53
+
54
+ export interface ParentSessionPickerProps {
55
+ folders: WorkspaceFolderData[];
56
+ /** The pending chat itself, never offered as its own parent. */
57
+ sessionId?: string | null;
58
+ value: string | null;
59
+ onChange: (sessionId: string | null) => void;
60
+ /** "Parent session" for a child, "Fork from" for a fork. */
61
+ label?: string;
62
+ /** False when the pending chat MUST have a source (a fork). */
63
+ allowNone?: boolean;
64
+ }
65
+
66
+ export function ParentSessionPicker({
67
+ folders,
68
+ sessionId,
69
+ value,
70
+ onChange,
71
+ label = 'Parent session',
72
+ allowNone = true,
73
+ }: ParentSessionPickerProps) {
74
+ const [open, setOpen] = useState(false);
75
+ const ref = useRef<HTMLDivElement>(null);
76
+ const close = useCallback(() => setOpen(false), []);
77
+ useOnClickOutside(ref, close);
78
+ const options = useMemo(() => parentSessionOptions(folders, sessionId), [folders, sessionId]);
79
+ const selected = value ? options.find((option) => option.id === value) : undefined;
80
+ const triggerLabel = selected ? selected.title : value ? value : `${label}: none`;
81
+
82
+ return (
83
+ <div className="relative shrink-0" ref={ref}>
84
+ <button
85
+ type="button"
86
+ data-testid="parent-session-picker"
87
+ onClick={() => setOpen((prev) => !prev)}
88
+ title={selected ? `${label}: ${selected.title}` : `Choose a session for ${label.toLowerCase()}`}
89
+ aria-label={selected ? `${label}: ${selected.title}` : label}
90
+ aria-expanded={open}
91
+ className={`tap-chip group flex items-center gap-1.5 rounded-md px-1.5 py-1 text-xs font-medium transition-all focus-visible:bg-ink/5 cursor-pointer select-none ${
92
+ selected ? 'bg-ink/10 text-ink' : 'text-ink/75 hover:text-ink hover:bg-ink/5'
93
+ }`}
94
+ >
95
+ <GitBranch size={13} className={`flex-shrink-0 ${selected ? 'text-ink/80' : 'text-ink/50 group-hover:text-ink/80'}`} />
96
+ <span className="max-w-[220px] truncate tracking-tight">{triggerLabel}</span>
97
+ <ChevronDown
98
+ size={13}
99
+ className={`flex-shrink-0 text-ink/40 transition-transform duration-150 ${open ? 'rotate-180 text-ink/70' : ''}`}
100
+ />
101
+ </button>
102
+
103
+ {open && (
104
+ <div className="glass-popover absolute bottom-full left-0 mb-1.5 w-80 bg-paper border border-ink/10 rounded-lg shadow-lg z-50 flex flex-col overflow-hidden text-xs py-1">
105
+ <div className="flex items-center justify-between px-3 py-1.5 border-b border-ink/5">
106
+ <span className="text-[10px] uppercase tracking-wider text-ink/40 font-semibold">
107
+ {label}
108
+ </span>
109
+ {value && allowNone && (
110
+ <button
111
+ type="button"
112
+ onClick={() => {
113
+ onChange(null);
114
+ setOpen(false);
115
+ }}
116
+ title="Start a top-level chat"
117
+ aria-label="Clear parent session"
118
+ className="flex items-center gap-1 text-[10px] text-ink/50 hover:text-ink cursor-pointer"
119
+ >
120
+ <X size={10} /> clear
121
+ </button>
122
+ )}
123
+ </div>
124
+ <div className="max-h-64 scrollbar-overlay-container py-1">
125
+ {allowNone && (
126
+ <button
127
+ type="button"
128
+ data-testid="parent-candidate-none"
129
+ onClick={() => {
130
+ onChange(null);
131
+ setOpen(false);
132
+ }}
133
+ className={`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors cursor-pointer hover:bg-ink/5 ${
134
+ value ? 'text-ink/70' : 'text-ink font-medium'
135
+ }`}
136
+ >
137
+ <span className="w-3 shrink-0">{!value && <Check size={11} />}</span>
138
+ <span className="min-w-0 flex-1 truncate">No parent (top-level chat)</span>
139
+ </button>
140
+ )}
141
+ {options.map((option) => {
142
+ const active = option.id === value;
143
+ return (
144
+ <button
145
+ key={option.id}
146
+ type="button"
147
+ data-testid="parent-candidate"
148
+ data-session-id={option.id}
149
+ onClick={() => {
150
+ onChange(option.id);
151
+ setOpen(false);
152
+ }}
153
+ className={`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors cursor-pointer hover:bg-ink/5 ${
154
+ active ? 'text-ink font-medium' : 'text-ink/70'
155
+ }`}
156
+ >
157
+ <span className="w-3 shrink-0">{active && <Check size={11} />}</span>
158
+ <span className="min-w-0 flex-1 truncate">{option.title}</span>
159
+ <span className="shrink-0 max-w-[7rem] truncate text-[10px] text-ink/40">
160
+ {option.folderName}
161
+ </span>
162
+ </button>
163
+ );
164
+ })}
165
+ {options.length === 0 && (
166
+ <div className="px-3 py-2 text-ink/40 italic">No sessions to parent under yet</div>
167
+ )}
168
+ </div>
169
+ </div>
170
+ )}
171
+ </div>
172
+ );
173
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Which sessions the child composer may name as a parent: every REAL session,
8
+ * in sidebar order, never a pending or archived one.
9
+ */
10
+
11
+ import { describe, expect, test } from 'bun:test';
12
+ import { parentSessionOptions } from '@/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker';
13
+ import type { WorkspaceFolderData } from '@/shared/types';
14
+
15
+ const folders = [
16
+ {
17
+ id: 1,
18
+ name: 'one',
19
+ sessions: [
20
+ { id: 'a', folder_id: 1, title: 'Alpha' },
21
+ { id: 'new-123', folder_id: 1, title: 'Pending' },
22
+ { id: 'archived', folder_id: 1, title: 'Old', is_archived: 1 },
23
+ ],
24
+ },
25
+ {
26
+ id: 2,
27
+ name: 'two',
28
+ sessions: [{ id: 'b', folder_id: 2, title: 'Beta', harness: 'claude' }],
29
+ },
30
+ ] as unknown as WorkspaceFolderData[];
31
+
32
+ describe('parentSessionOptions', () => {
33
+ test('lists real sessions in sidebar order with their folder', () => {
34
+ expect(parentSessionOptions(folders)).toEqual([
35
+ { id: 'a', title: 'Alpha', folderId: 1, folderName: 'one' },
36
+ { id: 'b', title: 'Beta', folderId: 2, folderName: 'two', harness: 'claude' },
37
+ ]);
38
+ });
39
+
40
+ test('never offers a pending chat or an archived session', () => {
41
+ const ids = parentSessionOptions(folders).map((option) => option.id);
42
+ expect(ids).not.toContain('new-123');
43
+ expect(ids).not.toContain('archived');
44
+ });
45
+
46
+ test('excludes the chat being composed', () => {
47
+ expect(parentSessionOptions(folders, 'a').map((option) => option.id)).toEqual(['b']);
48
+ });
49
+ });
@@ -47,15 +47,17 @@ const ARMED_CLASS = 'bg-ink text-canvas border-ink';
47
47
  * **Copy and Paste stand in for Cmd+C / Cmd+V**, which is what those chords mean
48
48
  * in a terminal and the one thing a phone genuinely cannot do: it has no
49
49
  * selection to right-click and no paste without a long-press the terminal canvas
50
- * does not offer. There is no raw Cmd button because xterm discards `metaKey`
51
- * on every key but Cmd+A (`if (ev.metaKey) break;`, which routes Cmd+A to
52
- * select-all) — a Cmd button would send nothing, while the Cmd chords the user
53
- * does have keep working untouched. Copy reports when there was no selection
54
- * rather than flashing a check for a clipboard it did not fill.
50
+ * does not offer. There is no raw Cmd button because the renderer treats Cmd as
51
+ * the host's modifier, not the terminal's: a printable character with `metaKey`
52
+ * set sends nothing (`isPrintableCharacter` returns false), and Cmd+C / Cmd+V
53
+ * are its own copy and paste. A Cmd button would therefore send nothing, while
54
+ * the Cmd chords the user does have keep working untouched. Copy reports when
55
+ * there was no selection rather than flashing a check for a clipboard it did not
56
+ * fill.
55
57
  *
56
- * `pointerdown` is swallowed so tapping a key never moves focus out of xterm's
57
- * hidden textarea: blurring it closes the OS keyboard, and a key bar that makes
58
- * the keyboard disappear is worse than no key bar.
58
+ * `pointerdown` is swallowed so tapping a key never moves focus out of the
59
+ * renderer's hidden input: blurring it closes the OS keyboard, and a key bar
60
+ * that makes the keyboard disappear is worse than no key bar.
59
61
  *
60
62
  * Wrapping, not horizontal scrolling. The diff toolbar taught that a
61
63
  * `no-scrollbar` overflow hides actions with nothing on screen to say so
@@ -2,11 +2,10 @@ import { useEffect, useRef, useState, useImperativeHandle, useCallback } from 'p
2
2
  import { forwardRef } from 'preact/compat';
3
3
  import { ArrowDown } from 'lucide-preact';
4
4
  import { useTheme } from '@/client/hooks/ui/theme';
5
- import { getXtermTheme } from '@/client/data/theme/terminal';
6
- import { mountXterm, type XtermMount } from '@/client/components/workspace/terminal-panel/mount';
5
+ import { mountTerminal, type TerminalMount } from '@/client/components/workspace/terminal-panel/mount';
7
6
 
8
- export interface RealtimeXtermHandle {
9
- /** Raw PTY output. Bytes, not text: xterm's decoder reassembles them. */
7
+ export interface RealtimeTerminalHandle {
8
+ /** Raw PTY output. Bytes, not text: the WASM parser reassembles them. */
10
9
  write: (bytes: Uint8Array) => void;
11
10
  /**
12
11
  * Write the retained scrollback at the size it was drawn for, then fit back
@@ -26,40 +25,43 @@ export interface RealtimeXtermHandle {
26
25
  /** The current selection, empty when nothing is selected. */
27
26
  getSelection: () => string;
28
27
  /**
29
- * Feed text in as a paste. Goes through xterm's own `paste`, which is what
30
- * wraps it in the bracketed-paste markers when the shell asked for them —
31
- * writing the bytes directly would make a multi-line paste execute line by
32
- * line in an editor that expects one block.
28
+ * Feed text in as a paste. Goes through the terminal's own `paste`, which is
29
+ * what wraps it in the bracketed-paste markers when the shell asked for
30
+ * them — writing the bytes directly would make a multi-line paste execute
31
+ * line by line in an editor that expects one block.
33
32
  */
34
33
  paste: (text: string) => void;
35
34
  }
36
35
 
37
- interface RealtimeXtermViewProps {
36
+ interface RealtimeTerminalViewProps {
38
37
  /** Keystrokes and paste, raw. */
39
38
  onInput: (data: string) => void;
40
- /** Non-UTF-8 payloads xterm reports separately (some mouse reports). */
41
- onBinaryInput: (data: string) => void;
39
+ /** Non-UTF-8 payloads (legacy X10 mouse reports), as latin-1 bytes. */
40
+ onBinaryInput: (bytes: Uint8Array) => void;
42
41
  /** The grid changed; the PTY must be resized to match. */
43
42
  onGridChange: (cols: number, rows: number) => void;
44
43
  /** The terminal is measurable and knows its size; attach with these. */
45
44
  onReady: (cols: number, rows: number) => void;
46
- /** False while another panel is on screen: the WebGL context is released. */
47
- visible?: boolean;
45
+ /**
46
+ * The theme changed and the terminal was rebuilt with the new palette; the
47
+ * server's retained scrollback has to be requested again.
48
+ */
49
+ onReattach?: () => void;
48
50
  }
49
51
 
50
52
  /**
51
- * xterm view bound to a real PTY.
53
+ * ghostty-web view bound to a real PTY.
52
54
  *
53
55
  * Every keystroke goes to the shell as bytes — line editing, history, tab
54
56
  * completion and Ctrl+C are the shell's job, not this component's. Output is
55
57
  * written as bytes so a character split across two PTY reads is reassembled by
56
- * xterm's own streaming decoder rather than by a decode step here.
58
+ * the WASM parser rather than by a decode step here.
57
59
  */
58
- export const RealtimeXtermView = forwardRef<RealtimeXtermHandle, RealtimeXtermViewProps>(
59
- ({ onInput, onBinaryInput, onGridChange, onReady, visible = true }, ref) => {
60
+ export const RealtimeTerminalView = forwardRef<RealtimeTerminalHandle, RealtimeTerminalViewProps>(
61
+ ({ onInput, onBinaryInput, onGridChange, onReady, onReattach }, ref) => {
60
62
  const { theme } = useTheme();
61
63
  const containerRef = useRef<HTMLDivElement>(null);
62
- const mountRef = useRef<XtermMount | null>(null);
64
+ const mountRef = useRef<TerminalMount | null>(null);
63
65
  const [isScrolledUp, setIsScrolledUp] = useState(false);
64
66
 
65
67
  const inputRef = useRef(onInput);
@@ -70,63 +72,50 @@ export const RealtimeXtermView = forwardRef<RealtimeXtermHandle, RealtimeXtermVi
70
72
  gridChangeRef.current = onGridChange;
71
73
  const readyRef = useRef(onReady);
72
74
  readyRef.current = onReady;
75
+ const reattachRef = useRef(onReattach);
76
+ reattachRef.current = onReattach;
73
77
  const themeRef = useRef(theme);
74
78
  themeRef.current = theme;
75
- // Read when the async mount RESOLVES, not when this effect ran: `mountXterm`
76
- // imports xterm and the WebGL addon, so `mountRef.current` is still null on
77
- // the first pass and an effect that only ran then would leave the context
78
- // held by a panel that was never on screen.
79
- const visibleRef = useRef(visible);
80
- visibleRef.current = visible;
81
-
82
- useEffect(() => {
83
- const term = mountRef.current?.term;
84
- if (!term) return;
85
- term.options.theme = getXtermTheme(theme);
86
- term.refresh(0, term.rows - 1);
87
- }, [theme]);
88
79
 
89
80
  /**
90
- * Hold the WebGL context only while this view is on screen.
91
- *
92
- * The right-panel stack keeps every built-in view MOUNTED and hides the
93
- * inactive ones with CSS; the terminal is the one view that stays live while
94
- * hidden, because it owns a PTY. That made its GPU context permanent: eight
95
- * terminals held eight contexts, and `vmmap` on the desktop shell showed
96
- * `owned unmapped (graphics)` at 541.8 MB of an 817.7 MB footprint while the
97
- * JS heap was 12.6 MB. Releasing on hide drops the context — xterm's DOM
98
- * renderer keeps the buffer readable — and showing the panel re-creates it.
81
+ * The WASM palette is fixed when the terminal is created, so a theme switch
82
+ * is a terminal rebuild plus a scrollback replay, not a repaint. The effect
83
+ * runs before the async mount resolves on first render (`mountRef` is null
84
+ * then); that initial theme is the one `mountTerminal` was called with.
99
85
  */
100
86
  useEffect(() => {
101
- mountRef.current?.setWebgl(visible);
102
- }, [visible]);
87
+ const mount = mountRef.current;
88
+ if (!mount) return;
89
+ mount.setTheme(theme);
90
+ reattachRef.current?.();
91
+ }, [theme]);
103
92
 
104
93
  useImperativeHandle(ref, () => ({
105
94
  write(bytes: Uint8Array) {
106
- mountRef.current?.term.write(bytes);
95
+ mountRef.current?.write(bytes);
107
96
  },
108
97
  writeReplay(bytes: Uint8Array, cols: number, rows: number) {
109
98
  mountRef.current?.writeReplay(bytes, cols, rows);
110
99
  },
111
100
  reset() {
112
- mountRef.current?.term.reset();
101
+ mountRef.current?.reset();
113
102
  },
114
103
  focus() {
115
- mountRef.current?.term.focus();
104
+ mountRef.current?.focus();
116
105
  },
117
106
  applicationCursorKeys() {
118
- return mountRef.current?.term.modes.applicationCursorKeysMode ?? false;
107
+ return mountRef.current?.applicationCursorKeys() ?? false;
119
108
  },
120
109
  getSelection() {
121
- return mountRef.current?.term.getSelection() ?? '';
110
+ return mountRef.current?.getSelection() ?? '';
122
111
  },
123
112
  paste(text: string) {
124
- mountRef.current?.term.paste(text);
113
+ mountRef.current?.paste(text);
125
114
  },
126
115
  }), []);
127
116
 
128
117
  const scrollToBottom = useCallback(() => {
129
- mountRef.current?.term.scrollToBottom();
118
+ mountRef.current?.scrollToBottom();
130
119
  setIsScrolledUp(false);
131
120
  }, []);
132
121
 
@@ -137,12 +126,12 @@ export const RealtimeXtermView = forwardRef<RealtimeXtermHandle, RealtimeXtermVi
137
126
  if (!container) return;
138
127
  let cancelled = false;
139
128
 
140
- void mountXterm(
129
+ void mountTerminal(
141
130
  container,
142
131
  themeRef.current,
143
132
  {
144
133
  onInput: (data) => inputRef.current(data),
145
- onBinaryInput: (data) => binaryInputRef.current(data),
134
+ onBinaryInput: (bytes) => binaryInputRef.current(bytes),
146
135
  onGridChange: (cols, rows) => gridChangeRef.current(cols, rows),
147
136
  onReady: (cols, rows) => readyRef.current(cols, rows),
148
137
  onScrolledUpChange: setIsScrolledUp,
@@ -155,10 +144,9 @@ export const RealtimeXtermView = forwardRef<RealtimeXtermHandle, RealtimeXtermVi
155
144
  return;
156
145
  }
157
146
  mountRef.current = mount;
158
- // The panel can mount while another view is on screen — the stack keeps
159
- // every built-in mounted — so the context is released on arrival rather
160
- // than on the next visibility change.
161
- mount.setWebgl(visibleRef.current);
147
+ // E2E types into the terminal's hidden input. The renderer creates it
148
+ // inside `open`, so the hook cannot be written on the JSX element.
149
+ container.querySelector('textarea')?.setAttribute('data-terminal-input', '');
162
150
  });
163
151
 
164
152
  return () => {
@@ -168,11 +156,16 @@ export const RealtimeXtermView = forwardRef<RealtimeXtermHandle, RealtimeXtermVi
168
156
  };
169
157
  }, []);
170
158
 
159
+ // No background and no padding: the terminal is not a surface of its own,
160
+ // and the panel's paper shows through the strip the fit addon leaves for
161
+ // its in-canvas scrollbar. `p-1.5` also made the grid narrower than the
162
+ // panel, which read as a terminal that was not full width.
171
163
  return (
172
- <div className="relative flex-1 w-full h-full bg-canvas overflow-hidden">
164
+ <div className="relative flex-1 w-full h-full overflow-hidden">
173
165
  <div
174
166
  ref={containerRef}
175
- className="w-full h-full cursor-text p-1.5"
167
+ data-terminal-root=""
168
+ className="kabmo-terminal w-full h-full cursor-text"
176
169
  style={{ height: '100%', width: '100%' }}
177
170
  />
178
171
 
@@ -192,4 +185,4 @@ export const RealtimeXtermView = forwardRef<RealtimeXtermHandle, RealtimeXtermVi
192
185
  }
193
186
  );
194
187
 
195
- RealtimeXtermView.displayName = 'RealtimeXtermView';
188
+ RealtimeTerminalView.displayName = 'RealtimeTerminalView';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { describe, expect, test } from 'bun:test';
7
+ import { gridForContainer } from '@/client/components/workspace/terminal-panel/fit';
8
+
9
+ // The measured cell box at 12 px Fira Code.
10
+ const CELL = { width: 8, height: 16 };
11
+
12
+ describe('gridForContainer', () => {
13
+ test('divides the whole panel, with no scrollbar reservation', () => {
14
+ // 334 × 759 is the host measured in the right panel at 1440 × 900.
15
+ // ghostty-web's own proposal subtracts 15 px first and would answer 39;
16
+ // that shortfall is what read as a terminal that was not full width.
17
+ expect(gridForContainer(334, 759, CELL)).toEqual({ cols: 41, rows: 47 });
18
+ });
19
+
20
+ test('drops the sub-cell remainder instead of overflowing the box', () => {
21
+ // One pixel short of a column still fits 41; the extra 7 px of a 335 box
22
+ // must not become a 42nd cell that hangs outside the panel.
23
+ expect(gridForContainer(335, 767, CELL)).toEqual({ cols: 41, rows: 47 });
24
+ expect(gridForContainer(333, 758, CELL)).toEqual({ cols: 41, rows: 47 });
25
+ });
26
+
27
+ test('keeps a usable grid for a box smaller than a cell', () => {
28
+ // A hidden panel measures 0 while the view stays mounted; the caller guards
29
+ // that, and this floor is the last line of defence against 0 × 0.
30
+ expect(gridForContainer(0, 0, CELL)).toEqual({ cols: 2, rows: 1 });
31
+ });
32
+
33
+ test('refuses to divide by an unmeasured cell', () => {
34
+ expect(gridForContainer(320, 640, { width: 0, height: 16 })).toBeNull();
35
+ expect(gridForContainer(320, 640, { width: 8, height: 0 })).toBeNull();
36
+ });
37
+ });