moi-computer 0.12.0 → 0.12.1-next.1

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 (367) hide show
  1. package/README.md +27 -27
  2. package/bin/moi.mjs +2 -2
  3. package/client/AGENTS.md +7 -4
  4. package/client/api/app-config.ts +3 -2
  5. package/client/api/app-ui-keys.ts +1 -1
  6. package/client/api/workspace-keys.ts +2 -4
  7. package/client/app/{AppRouter.tsx → app-router.tsx} +4 -4
  8. package/client/app/routes/{HomeRoute.tsx → home-route.tsx} +2 -2
  9. package/client/app/routes/{WorkspaceRoute.tsx → workspace-route.tsx} +20 -31
  10. package/client/app/shell/{SidebarLayout.tsx → sidebar-layout.tsx} +10 -10
  11. package/client/dev/index.html +43 -0
  12. package/client/dev/index.ts +15 -0
  13. package/client/features/applets/{AppletContainer.tsx → applet-container.tsx} +1 -1
  14. package/client/features/applets/applet-runtime.ts +11 -13
  15. package/client/features/applets/applet-thumbnail.ts +1 -1
  16. package/client/features/applets/{useApplet.ts → use-applet.ts} +2 -2
  17. package/client/features/applets/{WidgetShell.tsx → widget-shell.tsx} +4 -4
  18. package/client/features/chat/applet-chat-intents.ts +33 -14
  19. package/client/features/chat/{ChatPanel.tsx → chat-panel.tsx} +80 -59
  20. package/client/features/chat/chat-popup.tsx +171 -0
  21. package/client/features/chat/chat-send.ts +33 -1
  22. package/client/features/chat/chat-store.ts +10 -0
  23. package/client/features/chat/composer/attachments/{DrawingAttachmentChip.tsx → drawing-attachment-chip.tsx} +1 -1
  24. package/client/features/chat/composer/attachments/{FileAttachmentChip.tsx → file-attachment-chip.tsx} +1 -1
  25. package/client/features/chat/composer/attachments/{TextAttachmentChip.tsx → text-attachment-chip.tsx} +1 -1
  26. package/client/features/chat/composer/banners/{ComposerBanner.tsx → composer-banner.tsx} +0 -14
  27. package/client/features/chat/composer/banners/{ErrorBanner.tsx → error-banner.tsx} +1 -1
  28. package/client/features/chat/composer/banners/{SkillUpdateBanner.tsx → skill-update-banner.tsx} +3 -3
  29. package/client/features/chat/composer/{ChatComposer.tsx → chat-composer.tsx} +31 -33
  30. package/client/features/chat/composer/{ModelPicker.tsx → model-picker.tsx} +4 -4
  31. package/client/features/chat/composer/{useWorkspaceComposerState.tsx → use-workspace-composer-state.tsx} +14 -30
  32. package/client/features/chat/composer/{useWorkspaceSkillUpdates.ts → use-workspace-skill-updates.ts} +1 -1
  33. package/client/features/chat/connection/chat-frames.ts +15 -8
  34. package/client/features/chat/messages/{ChatEmptyState.tsx → chat-empty-state.tsx} +37 -23
  35. package/client/features/chat/messages/fork-history.ts +14 -0
  36. package/client/features/chat/messages/{MarkdownContent.tsx → markdown-content.tsx} +4 -4
  37. package/client/features/chat/messages/tool-group/index.ts +1 -1
  38. package/client/features/chat/messages/tool-group/{ReadImagePreview.tsx → read-image-preview.tsx} +2 -2
  39. package/client/features/chat/messages/tool-group/{SubagentCard.tsx → subagent-card.tsx} +3 -3
  40. package/client/features/chat/messages/tool-group/{TimelineRow.tsx → timeline-row.tsx} +1 -1
  41. package/client/features/chat/messages/tool-group/{ToolCallGroup.tsx → tool-call-group.tsx} +8 -8
  42. package/client/features/chat/messages/tool-group/{ToolOutput.tsx → tool-output.tsx} +1 -1
  43. package/client/features/chat/messages/{TurnView.tsx → turn-view.tsx} +4 -4
  44. package/client/features/chat/sessions/api.ts +109 -19
  45. package/client/features/chat/sessions/browser-tab-state.ts +30 -7
  46. package/client/features/chat/sessions/{ChatSelector.tsx → chat-selector.tsx} +139 -80
  47. package/client/features/chat/sessions/use-selected-session.ts +351 -0
  48. package/client/features/chat/{useChat.ts → use-chat.ts} +46 -48
  49. package/client/features/collab/client.ts +10 -11
  50. package/client/features/collab/hooks.tsx +6 -11
  51. package/client/features/collab/host-state.ts +57 -128
  52. package/client/features/collab/provider.tsx +3 -3
  53. package/client/features/collab/proxy-user.ts +1 -1
  54. package/client/features/collab/testing/fake-engine.ts +6 -27
  55. package/client/features/collab/workspace-users-menu.tsx +3 -7
  56. package/client/features/connectors/mcp-icons.ts +1 -1
  57. package/client/features/connectors/{McpServerCards.tsx → mcp-server-cards.tsx} +1 -1
  58. package/client/features/{home/workspace-setup/DemoDialog.tsx → demo/demo-dialog.tsx} +6 -6
  59. package/client/features/dev/chat-states-fixtures.ts +4 -4
  60. package/client/features/dev/{ChatStatesPage.tsx → chat-states-page.tsx} +6 -6
  61. package/client/features/dev/collab/local-user-settings.tsx +4 -4
  62. package/client/features/dev/{DevIndexPage.tsx → dev-index-page.tsx} +7 -1
  63. package/client/features/dev/{DevRoutes.tsx → dev-routes.tsx} +8 -6
  64. package/client/features/dev/workspace-setup-mocks.ts +102 -0
  65. package/client/features/dev/workspace-setup-page.tsx +11 -0
  66. package/client/features/dev/workspace-setup-preview.tsx +226 -0
  67. package/client/features/drawings/{DrawingToolbar.tsx → drawing-toolbar.tsx} +1 -1
  68. package/client/features/drawings/{useChatAnnotation.ts → use-chat-annotation.ts} +29 -23
  69. package/client/features/drawings/{useDrawingLayer.ts → use-drawing-layer.ts} +1 -1
  70. package/client/features/drawings/{useViewBuilderSketch.ts → use-view-sketch.ts} +8 -8
  71. package/client/features/harness/api.ts +36 -0
  72. package/client/features/harness/device-login-steps.tsx +97 -0
  73. package/client/features/home/api.ts +1 -81
  74. package/client/features/home/{HomeLogo.tsx → home-logo.tsx} +1 -1
  75. package/client/features/home/{HomePage.tsx → home-page.tsx} +16 -20
  76. package/client/features/overview/api.ts +2 -2
  77. package/client/features/overview/default/registry.tsx +3 -5
  78. package/client/features/overview/default/{ViewsWidget.tsx → views-widget.tsx} +6 -13
  79. package/client/features/overview/{HiddenPanel.tsx → hidden-panel.tsx} +2 -2
  80. package/client/features/overview/{Overview.tsx → overview.tsx} +9 -12
  81. package/client/features/overview/{WidgetCanvas.tsx → widget-canvas.tsx} +1 -1
  82. package/client/features/overview/{WidgetFrame.tsx → widget-frame.tsx} +1 -1
  83. package/client/features/overview/workspace-name.tsx +55 -0
  84. package/client/features/scratchpad/{Scratchpad.tsx → scratchpad.tsx} +7 -7
  85. package/client/features/scratchpad/{useScratchpadSnapshot.tsx → use-scratchpad-snapshot.tsx} +3 -3
  86. package/client/features/settings/api.ts +1 -1
  87. package/client/features/settings/{ConnectorsSettings.tsx → connectors-settings.tsx} +3 -3
  88. package/client/features/settings/{EnvironmentSettings.tsx → environment-settings.tsx} +3 -3
  89. package/client/features/settings/{GeneralSettings.tsx → general-settings.tsx} +5 -5
  90. package/client/features/settings/{useEnvVars.ts → use-env-vars.ts} +1 -1
  91. package/client/features/settings/{WorkspaceIconPicker.tsx → workspace-icon-picker.tsx} +1 -1
  92. package/client/features/settings/{WorkspaceSettingsDialog.tsx → workspace-settings-dialog.tsx} +3 -3
  93. package/client/features/update/api.ts +1 -1
  94. package/client/features/views/api.ts +64 -131
  95. package/client/features/views/pending-view-screen.tsx +282 -0
  96. package/client/features/views/use-view-actions.ts +151 -0
  97. package/client/features/views/use-view-drafts.ts +88 -0
  98. package/client/features/views/{ViewManager.tsx → view-manager.tsx} +13 -13
  99. package/client/features/views/view-presentation.ts +4 -5
  100. package/client/features/views/view-submission.ts +88 -0
  101. package/client/features/workspace/add/api.ts +80 -0
  102. package/client/features/{home/workspace-setup/CreateWorkspaceDialog.tsx → workspace/add/create-workspace-dialog.tsx} +56 -42
  103. package/client/features/workspace/add/import-workspace-dialog.tsx +81 -0
  104. package/client/features/{home/workspace-setup/useWorkspaceImport.ts → workspace/add/use-workspace-import.ts} +1 -1
  105. package/client/features/workspace/add/workspace-agent-options.ts +53 -0
  106. package/client/features/{home/workspace-setup/WorkspaceAgentStep.tsx → workspace/add/workspace-agent-selector.tsx} +59 -98
  107. package/client/features/{home/workspace-setup/WorkspaceDialogContent.tsx → workspace/add/workspace-dialog-content.tsx} +1 -1
  108. package/client/features/workspace/api.ts +24 -15
  109. package/client/features/workspace/browser-tab-state.ts +16 -9
  110. package/client/features/workspace/moi-context.ts +14 -16
  111. package/client/features/workspace/setup/workspace-login-state.tsx +175 -0
  112. package/client/features/workspace/setup/workspace-recovery-states.tsx +125 -0
  113. package/client/features/workspace/setup/workspace-setup-panel.tsx +18 -0
  114. package/client/features/workspace/setup/workspace-setup.tsx +77 -0
  115. package/client/features/workspace/setup/workspace-welcome-state.tsx +81 -0
  116. package/client/features/workspace/tab-resolution.ts +16 -29
  117. package/client/features/workspace/{ThemePanel.tsx → theme-panel.tsx} +3 -3
  118. package/client/features/workspace/use-workspace-navigation.ts +245 -0
  119. package/client/features/workspace/workspace-content.tsx +641 -0
  120. package/client/features/workspace/workspace-identity.tsx +40 -0
  121. package/client/features/workspace/workspace-menu.tsx +63 -0
  122. package/client/features/{home → workspace}/workspace-presentation.tsx +10 -3
  123. package/client/features/workspace/workspace-screen.tsx +28 -0
  124. package/client/features/workspace/{WorkspaceSplitLayout.tsx → workspace-split-layout.tsx} +1 -1
  125. package/client/features/workspace/{WorkspaceTabs.tsx → workspace-tabs.tsx} +2 -2
  126. package/client/index.css +2 -2
  127. package/client/index.html +1 -1
  128. package/client/index.tsx +5 -1
  129. package/client/lib/agent-availability.ts +0 -5
  130. package/client/main.tsx +1 -1
  131. package/client/runtime/{useWorkspaceEvents.ts → use-workspace-events.ts} +10 -18
  132. package/client/store/ui.ts +25 -29
  133. package/dist/chunk-08ndj2rg.js +2 -0
  134. package/dist/chunk-2x040tmg.js +68 -0
  135. package/dist/chunk-3smxq0ts.js +1 -0
  136. package/dist/chunk-68ch5hs8.js +2 -0
  137. package/dist/{chunk-z3byfve5.js → chunk-9vg3xa81.js} +2 -2
  138. package/dist/chunk-c2p00p9j.css +1 -0
  139. package/dist/chunk-cs833y9j.js +1 -0
  140. package/dist/{chunk-97eg9mjn.js → chunk-d7cbm65e.js} +1 -1
  141. package/dist/{chunk-efdyz6xp.js → chunk-hvh9f5h0.js} +1 -1
  142. package/dist/{chunk-vfpsc75k.js → chunk-jvyvwwv3.js} +1 -1
  143. package/dist/chunk-nwevqe86.js +10 -0
  144. package/dist/{chunk-3a48fyf7.js → chunk-q0gbdts4.js} +4 -4
  145. package/dist/chunk-rt30jbcm.js +1 -0
  146. package/dist/chunk-y5y3kj67.js +1 -0
  147. package/dist/index.html +2 -2
  148. package/lib/format.ts +1 -1
  149. package/lib/harness-instructions.ts +30 -0
  150. package/lib/ids.ts +3 -6
  151. package/lib/moi-context.ts +102 -75
  152. package/lib/navigation.ts +48 -87
  153. package/lib/scratchpad-skew.ts +3 -3
  154. package/lib/session-drafts.ts +10 -0
  155. package/lib/types.ts +92 -51
  156. package/lib/update.ts +1 -1
  157. package/lib/view-build-directives.ts +12 -0
  158. package/lib/workspace-layout.ts +1 -1
  159. package/lib/workspace-tabs.ts +12 -7
  160. package/package.json +7 -2
  161. package/server/AGENTS.md +10 -4
  162. package/server/README.md +102 -0
  163. package/server/agent-launcher.ts +27 -0
  164. package/server/api/harnesses.ts +56 -0
  165. package/server/{api.ts → api/index.ts} +197 -299
  166. package/server/app-config.ts +45 -14
  167. package/server/app-settings.ts +1 -1
  168. package/server/applets/applet-css.ts +1 -1
  169. package/server/applets/build-applet.ts +4 -4
  170. package/server/applets/build-worker.ts +3 -2
  171. package/server/applets/config.ts +1 -1
  172. package/server/{functions-worker.ts → applets/functions-worker.ts} +1 -1
  173. package/server/{functions.ts → applets/functions.ts} +3 -2
  174. package/server/applets/index.ts +2 -2
  175. package/server/{thumbnails.ts → applets/thumbnails.ts} +1 -1
  176. package/server/{applet-typecheck.ts → applets/typecheck.ts} +4 -4
  177. package/server/{ui-components.ts → applets/ui-components.ts} +2 -2
  178. package/server/applets/view-source.ts +7 -1
  179. package/server/{views.ts → applets/views.ts} +35 -46
  180. package/server/{widgets.ts → applets/widgets.ts} +2 -2
  181. package/server/cli/applet-selector.ts +19 -0
  182. package/server/cli/args.ts +5 -0
  183. package/server/{cli-colors.ts → cli/colors.ts} +1 -1
  184. package/server/cli/commands/bundle.ts +119 -0
  185. package/server/cli/commands/call-server-fn.ts +42 -0
  186. package/server/cli/commands/check.ts +53 -0
  187. package/server/cli/commands/config.ts +132 -0
  188. package/server/cli/commands/debug.ts +119 -0
  189. package/server/cli/commands/env.ts +162 -0
  190. package/server/cli/commands/hermes.ts +149 -0
  191. package/server/cli/commands/init.ts +286 -0
  192. package/server/cli/commands/navigate.ts +35 -0
  193. package/server/cli/commands/openclaw.ts +168 -0
  194. package/server/cli/commands/refresh.ts +39 -0
  195. package/server/cli/commands/scratch.ts +496 -0
  196. package/server/cli/commands/service.ts +298 -0
  197. package/server/cli/commands/skill.ts +122 -0
  198. package/server/cli/commands/start.ts +138 -0
  199. package/server/cli/commands/status.ts +80 -0
  200. package/server/cli/commands/tabs.ts +43 -0
  201. package/server/cli/commands/theme.ts +192 -0
  202. package/server/cli/commands/ui-components.ts +15 -0
  203. package/server/cli/commands/update.ts +192 -0
  204. package/server/cli/commands/version.ts +9 -0
  205. package/server/cli/commands/views.ts +87 -0
  206. package/server/cli/control.ts +89 -0
  207. package/server/{cli-env.ts → cli/env.ts} +78 -56
  208. package/server/cli/index.ts +171 -0
  209. package/server/{cli-pc.ts → cli/pc.ts} +1 -1
  210. package/server/cli/provider.ts +25 -0
  211. package/server/cli/server-version.ts +16 -0
  212. package/server/cli/server.ts +81 -0
  213. package/server/{cli-ui-components.ts → cli/ui-components.ts} +5 -5
  214. package/server/cli.ts +2 -3215
  215. package/server/collab/manager.ts +3 -3
  216. package/server/collab/skill/index.ts +2 -2
  217. package/server/control.ts +97 -78
  218. package/server/data-dir.ts +13 -0
  219. package/server/harness/README.md +55 -25
  220. package/server/harness/acp/NOTES.md +11 -11
  221. package/server/harness/acp/adapter.ts +2 -2
  222. package/server/harness/acp/archived.ts +3 -3
  223. package/server/harness/acp/client.ts +4 -3
  224. package/server/harness/acp/discovery.ts +3 -3
  225. package/server/harness/acp/run-durations.ts +1 -1
  226. package/server/harness/acp/session.ts +9 -12
  227. package/server/harness/auth.ts +303 -0
  228. package/server/harness/claude-code/NOTES.md +9 -7
  229. package/server/harness/claude-code/adapter.ts +13 -8
  230. package/server/harness/claude-code/auth.ts +127 -18
  231. package/server/harness/claude-code/cli.ts +3 -1
  232. package/server/harness/claude-code/git-worktree.ts +5 -2
  233. package/server/harness/claude-code/index.ts +7 -1
  234. package/server/harness/claude-code/mcp.ts +3 -1
  235. package/server/harness/claude-code/models.ts +2 -0
  236. package/server/harness/claude-code/session.ts +13 -39
  237. package/server/harness/claude-code/sessions.ts +8 -12
  238. package/server/harness/codex/NOTES.md +35 -16
  239. package/server/harness/codex/adapter.ts +5 -3
  240. package/server/harness/codex/auth.ts +86 -19
  241. package/server/harness/codex/client.ts +30 -34
  242. package/server/harness/codex/index.ts +20 -1
  243. package/server/harness/codex/permissions.ts +3 -3
  244. package/server/harness/codex/probe.ts +3 -5
  245. package/server/harness/codex/session.ts +20 -25
  246. package/server/harness/codex/thread-list.ts +74 -0
  247. package/server/harness/codex/transport.ts +5 -5
  248. package/server/harness/executable.ts +42 -18
  249. package/server/harness/fork.ts +12 -0
  250. package/server/harness/hermes/NOTES.md +70 -70
  251. package/server/harness/hermes/discovery.ts +1 -1
  252. package/server/harness/openclaw/NOTES.md +24 -24
  253. package/server/harness/openclaw/adapter.ts +4 -4
  254. package/server/harness/openclaw/compat.ts +1 -1
  255. package/server/harness/openclaw/session.ts +6 -31
  256. package/server/harness/registry.ts +1 -1
  257. package/server/harness/session-title.ts +12 -3
  258. package/server/harness/shell-path.ts +31 -21
  259. package/server/harness/types.ts +17 -5
  260. package/server/navigation-relay.ts +1 -1
  261. package/server/open-browser.ts +7 -0
  262. package/server/{scratchpad-assets.ts → scratchpad/assets.ts} +4 -4
  263. package/server/{scratchpad.ts → scratchpad/document.ts} +8 -8
  264. package/server/{scratchpad-executor.ts → scratchpad/executor.ts} +7 -7
  265. package/server/{scratchpad-relay.ts → scratchpad/relay.ts} +4 -5
  266. package/server/{scratchpad-shape-defaults.ts → scratchpad/shape-defaults.ts} +2 -2
  267. package/server/server-cwd.ts +1 -1
  268. package/server/service.ts +18 -4
  269. package/server/sessions/archive.ts +32 -0
  270. package/server/{attachment-message.ts → sessions/attachment-message.ts} +1 -1
  271. package/server/sessions/config.ts +41 -0
  272. package/server/sessions/lifecycle.ts +17 -0
  273. package/server/sessions/pending-views.ts +164 -0
  274. package/server/sessions/selected.ts +199 -0
  275. package/server/sessions/store.ts +127 -0
  276. package/server/sessions/view-sessions.ts +267 -0
  277. package/server/{skills-template.ts → skills/template.ts} +1 -1
  278. package/server/{skill-update.ts → skills/update.ts} +5 -5
  279. package/server/{skill-version.ts → skills/version.ts} +4 -4
  280. package/server/static.ts +1 -1
  281. package/server/status.ts +6 -4
  282. package/server/web.ts +58 -49
  283. package/server/{env-apply.ts → workspaces/env-apply.ts} +5 -5
  284. package/server/{workspace-env.ts → workspaces/env.ts} +30 -3
  285. package/server/{workspace-import.ts → workspaces/import.ts} +4 -4
  286. package/server/{workspace-init.ts → workspaces/init.ts} +10 -6
  287. package/server/{layout.ts → workspaces/layout.ts} +2 -2
  288. package/server/{preview.ts → workspaces/preview.ts} +1 -1
  289. package/server/{registry.ts → workspaces/registry.ts} +17 -7
  290. package/server/{required-env.ts → workspaces/required-env.ts} +3 -3
  291. package/server/{moi-scaffold.ts → workspaces/scaffold.ts} +4 -3
  292. package/server/{tabs.ts → workspaces/tabs.ts} +7 -10
  293. package/ui-components/button.tsx +1 -1
  294. package/ui-components/docs/attachment.md +2 -2
  295. package/ui-components/docs/button.md +1 -1
  296. package/ui-components/docs/calendar.md +1 -1
  297. package/ui-components/docs/chart.md +4 -4
  298. package/ui-components/docs/data-table.md +1 -1
  299. package/ui-components/docs/drawer.md +1 -1
  300. package/ui-components/docs/field.md +1 -1
  301. package/ui-components/docs/input.md +2 -2
  302. package/ui-components/docs/label.md +2 -2
  303. package/ui-components/docs/table.md +2 -2
  304. package/workspace/.claude/skills/moi-workspace/SKILL.md +61 -32
  305. package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +4 -7
  306. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +2 -2
  307. package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +2 -2
  308. package/client/features/chat/ChatPopup.tsx +0 -98
  309. package/client/features/chat/composer/banners/AgentAvailabilityBanner.tsx +0 -101
  310. package/client/features/chat/sessions/useSelectedSession.ts +0 -185
  311. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +0 -92
  312. package/client/features/overview/WorkspaceName.tsx +0 -60
  313. package/client/features/views/ViewBuilder.tsx +0 -239
  314. package/client/features/views/useViewBuilderActions.ts +0 -103
  315. package/client/features/views/useViewBuilderDrafts.ts +0 -68
  316. package/client/features/workspace/WorkspaceScreen.tsx +0 -839
  317. package/client/features/workspace/useWorkspaceNavigation.ts +0 -203
  318. package/dist/chunk-2jncyq65.js +0 -1
  319. package/dist/chunk-e2q5ken7.js +0 -68
  320. package/dist/chunk-h2kj1ysj.js +0 -1
  321. package/dist/chunk-jf6czgrz.js +0 -2
  322. package/dist/chunk-nez8sdta.js +0 -1
  323. package/dist/chunk-nzwgm8vc.css +0 -1
  324. package/dist/chunk-ph0h6h86.js +0 -1
  325. package/dist/chunk-ryg9z3kn.js +0 -10
  326. package/dist/chunk-tpn177bt.js +0 -2
  327. package/lib/view-builder-directives.ts +0 -16
  328. package/server/agent.ts +0 -223
  329. package/server/chat-selection.ts +0 -22
  330. package/server/selected-session.ts +0 -152
  331. package/server/session-config.ts +0 -136
  332. package/server/view-builders.ts +0 -453
  333. /package/client/components/shared/{AgentBlobatar.tsx → agent-blobatar.tsx} +0 -0
  334. /package/client/components/shared/{BottomPanel.tsx → bottom-panel.tsx} +0 -0
  335. /package/client/components/shared/{Composer.tsx → composer.tsx} +0 -0
  336. /package/client/components/shared/{LedLogo.tsx → led-logo.tsx} +0 -0
  337. /package/client/components/shared/{PanelHeader.tsx → panel-header.tsx} +0 -0
  338. /package/client/components/shared/{ReorderableList.tsx → reorderable-list.tsx} +0 -0
  339. /package/client/components/shared/{WorkspaceIcon.tsx → workspace-icon.tsx} +0 -0
  340. /package/client/features/applets/{WidgetErrorBoundary.tsx → widget-error-boundary.tsx} +0 -0
  341. /package/client/features/chat/composer/attachments/{AttachmentChip.tsx → attachment-chip.tsx} +0 -0
  342. /package/client/features/chat/messages/{ChatPromptBubbles.tsx → chat-prompt-bubbles.tsx} +0 -0
  343. /package/client/features/chat/messages/{ShimmerText.tsx → shimmer-text.tsx} +0 -0
  344. /package/client/features/chat/messages/tool-group/{CodeBlock.tsx → code-block.tsx} +0 -0
  345. /package/client/features/chat/messages/tool-group/{Collapse.tsx → collapse.tsx} +0 -0
  346. /package/client/features/chat/messages/{useStickToBottom.ts → use-stick-to-bottom.ts} +0 -0
  347. /package/client/features/connectors/{IconMcp.tsx → icon-mcp.tsx} +0 -0
  348. /package/client/features/dev/{BlobatarShapesPage.tsx → blobatar-shapes-page.tsx} +0 -0
  349. /package/client/features/dev/{HarnessDebugPage.tsx → harness-debug-page.tsx} +0 -0
  350. /package/client/features/dev/{TextureLabPage.tsx → texture-lab-page.tsx} +0 -0
  351. /package/client/features/dev/{ToolCallsPage.tsx → tool-calls-page.tsx} +0 -0
  352. /package/client/features/drawings/{DrawingLayer.tsx → drawing-layer.tsx} +0 -0
  353. /package/client/features/home/{WorkspacePreview.tsx → workspace-preview.tsx} +0 -0
  354. /package/client/features/overview/{useGridReconcile.ts → use-grid-reconcile.ts} +0 -0
  355. /package/client/features/scratchpad/{ScratchpadControls.tsx → scratchpad-controls.tsx} +0 -0
  356. /package/client/features/settings/{SettingsLayout.tsx → settings-layout.tsx} +0 -0
  357. /package/client/features/update/{UpdateControl.tsx → update-control.tsx} +0 -0
  358. /package/client/features/workspace/{UnavailablePage.tsx → unavailable-page.tsx} +0 -0
  359. /package/client/features/workspace/{useFitsSplitLayout.ts → use-fits-split-layout.ts} +0 -0
  360. /package/client/features/workspace/{WorkspaceContext.tsx → workspace-context.tsx} +0 -0
  361. /package/client/features/workspace/{WorkspaceLayoutContext.tsx → workspace-layout-context.tsx} +0 -0
  362. /package/server/{bundle-queue.ts → applets/bundle-queue.ts} +0 -0
  363. /package/server/{applet-log.ts → applets/log.ts} +0 -0
  364. /package/server/{cli-ui.ts → cli/ui.ts} +0 -0
  365. /package/server/{workspace-config.ts → workspaces/config.ts} +0 -0
  366. /package/server/{icon.ts → workspaces/icon.ts} +0 -0
  367. /package/server/{theme.ts → workspaces/theme.ts} +0 -0
@@ -0,0 +1,102 @@
1
+ import type {
2
+ AppEnvironment,
3
+ HarnessAvailability,
4
+ HarnessLoginState,
5
+ WorkspaceAgent
6
+ } from '@/lib/types'
7
+ import type { LoginHarness } from '@/client/features/harness/api'
8
+
9
+ export const PREVIEW_WORKSPACE_ID = 'setup-preview'
10
+ export const MOCK_CODE_SIGN_IN_URL = 'https://example.invalid/moi-code-sign-in'
11
+ export const MOCK_SIGN_IN_URL = 'https://example.invalid/moi-sign-in'
12
+ export const SETUP_SCENARIOS = [
13
+ 'welcome',
14
+ 'login',
15
+ 'missing-agent',
16
+ 'missing-folder',
17
+ 'loading'
18
+ ] as const
19
+ export type SetupScenario = (typeof SETUP_SCENARIOS)[number]
20
+
21
+ export function createSetupMocks(
22
+ environment: AppEnvironment,
23
+ harness: LoginHarness,
24
+ scenario: SetupScenario
25
+ ) {
26
+ let availability: HarnessAvailability =
27
+ scenario === 'missing-agent'
28
+ ? {
29
+ status: 'unavailable',
30
+ code: 'not-installed',
31
+ reason: 'This agent is not installed. Install it, then try again.'
32
+ }
33
+ : { status: 'login-required', reason: 'Sign in to continue.' }
34
+ let login: HarnessLoginState | undefined
35
+ const missingFolder = scenario === 'missing-folder'
36
+
37
+ function complete() {
38
+ availability = { status: 'available' }
39
+ login = undefined
40
+ }
41
+
42
+ async function request(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
43
+ const url = new URL(
44
+ input instanceof Request ? input.url : String(input),
45
+ 'http://preview.invalid'
46
+ )
47
+ const method = init?.method ?? (input instanceof Request ? input.method : 'GET')
48
+ const path = url.pathname
49
+ if (url.origin !== 'http://preview.invalid')
50
+ throw new Error('Sandbox blocked an external request')
51
+ if (path === '/api/config' && method === 'GET') {
52
+ return Response.json({
53
+ environment,
54
+ demo: false,
55
+ experimental: { collab: false },
56
+ demoInstallUrl: ''
57
+ })
58
+ }
59
+ if (path === `/api/workspaces/${PREVIEW_WORKSPACE_ID}` && method === 'DELETE')
60
+ return new Response(null, { status: 204 })
61
+ if (path === `/api/workspaces/${PREVIEW_WORKSPACE_ID}/agent` && method === 'GET') {
62
+ return Response.json({
63
+ provider: harness,
64
+ availability,
65
+ models: [],
66
+ supportsStreaming: true,
67
+ supportsArchiving: true,
68
+ workspaceFolderMissing: missingFolder
69
+ } satisfies WorkspaceAgent)
70
+ }
71
+ const authPath = `/api/harnesses/${harness}/auth`
72
+ if (path === authPath && method === 'GET') return Response.json({ availability, login })
73
+ if (path === `${authPath}/login` && method === 'POST') {
74
+ login = { state: 'starting' }
75
+ await new Promise(resolve => setTimeout(resolve, 500))
76
+ login = {
77
+ state: 'pending',
78
+ id: 'mock-login',
79
+ url:
80
+ harness === 'claude-code' && environment === 'cloud'
81
+ ? MOCK_CODE_SIGN_IN_URL
82
+ : MOCK_SIGN_IN_URL,
83
+ ...(harness === 'claude-code'
84
+ ? { codeUrl: MOCK_CODE_SIGN_IN_URL }
85
+ : environment === 'cloud'
86
+ ? { userCode: 'MOCK-1234' }
87
+ : {})
88
+ }
89
+ return Response.json(login)
90
+ }
91
+ if (path === `${authPath}/login/mock-login/code` && method === 'POST') {
92
+ const body = JSON.parse(String(init?.body)) as { code: string }
93
+ if (body.code !== 'MOCK-AUTH-CODE')
94
+ return new Response('Use MOCK-AUTH-CODE in this sandbox.', { status: 400 })
95
+ complete()
96
+ return new Response(null, { status: 204 })
97
+ }
98
+ throw new Error(`Sandbox blocked an unexpected request: ${method} ${path}`)
99
+ }
100
+
101
+ return { request, complete }
102
+ }
@@ -0,0 +1,11 @@
1
+ export function WorkspaceSetupPage() {
2
+ return (
3
+ <iframe
4
+ title="Workspace setup sandbox"
5
+ src="/dev/workspace-setup/preview"
6
+ allow="clipboard-write"
7
+ sandbox="allow-scripts allow-same-origin allow-forms"
8
+ className="h-dvh w-full border-0"
9
+ />
10
+ )
11
+ }
@@ -0,0 +1,226 @@
1
+ import { useState } from 'react'
2
+ import { createRoot } from 'react-dom/client'
3
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
4
+ import { Router, useLocation } from 'wouter'
5
+ import { memoryLocation } from 'wouter/memory-location'
6
+
7
+ import { loadAppConfig } from '@/client/api/app-config'
8
+ import { Button } from '@/client/components/ui/button'
9
+ import { Input } from '@/client/components/ui/input'
10
+ import {
11
+ Dialog,
12
+ DialogContent,
13
+ DialogDescription,
14
+ DialogTitle
15
+ } from '@/client/components/ui/dialog'
16
+ import { TooltipProvider } from '@/client/components/ui/tooltip'
17
+ import { Toaster } from '@/client/components/ui/toast'
18
+ import { WorkspaceSetupPanel } from '@/client/features/workspace/setup/workspace-setup-panel'
19
+ import { useWorkspaceSetup } from '@/client/features/workspace/setup/workspace-setup'
20
+ import { WorkspaceWelcomeState } from '@/client/features/workspace/setup/workspace-welcome-state'
21
+ import { WorkspaceLoadingState } from '@/client/features/workspace/setup/workspace-recovery-states'
22
+ import type { AppEnvironment } from '@/lib/types'
23
+ import { workspaceTypeLabel } from '@/client/features/workspace/workspace-presentation'
24
+ import { useHarnessAuth, type LoginHarness } from '@/client/features/harness/api'
25
+ import {
26
+ createSetupMocks,
27
+ MOCK_SIGN_IN_URL,
28
+ MOCK_CODE_SIGN_IN_URL,
29
+ PREVIEW_WORKSPACE_ID,
30
+ SETUP_SCENARIOS
31
+ } from './workspace-setup-mocks'
32
+ import type { SetupScenario } from './workspace-setup-mocks'
33
+
34
+ const scenarioLabels: Record<SetupScenario, string> = {
35
+ welcome: 'Welcome',
36
+ login: 'Login',
37
+ 'missing-agent': 'Agent missing',
38
+ 'missing-folder': 'Folder missing',
39
+ loading: 'Loading'
40
+ }
41
+
42
+ type SetupPreviewProps = {
43
+ mocks: ReturnType<typeof createSetupMocks>
44
+ client: QueryClient
45
+ environment: AppEnvironment
46
+ harness: LoginHarness
47
+ scenario: SetupScenario
48
+ }
49
+
50
+ function SetupPreview({ mocks, client, environment, harness, scenario }: SetupPreviewProps) {
51
+ const [provider, setProvider] = useState<'browser' | 'code' | 'closed'>()
52
+ const [deviceCode, setDeviceCode] = useState('')
53
+ const auth = useHarnessAuth(harness)
54
+ const pendingId = auth.data?.login?.state === 'pending' ? auth.data.login.id : undefined
55
+ // Both local harnesses open the browser automatically.
56
+ const providerPage = provider ?? (environment === 'local' && pendingId ? 'browser' : 'closed')
57
+
58
+ function restart(next: Record<string, string> = {}) {
59
+ const params = new URLSearchParams({ environment, harness, scenario, ...next })
60
+ window.location.assign(`?${params.toString()}`)
61
+ }
62
+ function update(action: () => void) {
63
+ action()
64
+ void client.invalidateQueries()
65
+ }
66
+
67
+ return (
68
+ <div
69
+ className="flex h-dvh flex-col bg-background text-foreground"
70
+ onClickCapture={event => {
71
+ const link = (event.target as Element).closest('a')
72
+ if (link?.href === MOCK_SIGN_IN_URL || link?.href === MOCK_CODE_SIGN_IN_URL) {
73
+ event.preventDefault()
74
+ setProvider(link.href === MOCK_CODE_SIGN_IN_URL ? 'code' : 'browser')
75
+ }
76
+ }}
77
+ >
78
+ <header className="flex shrink-0 flex-wrap items-center gap-3 border-b border-border p-3 text-sm">
79
+ <div className="flex flex-wrap gap-2" role="group" aria-label="Environment">
80
+ {(['local', 'cloud'] as const).map(value => (
81
+ <Button
82
+ key={value}
83
+ size="sm"
84
+ variant={environment === value ? 'default' : 'secondary'}
85
+ onClick={() => restart({ environment: value })}
86
+ >
87
+ {value === 'local' ? 'Local' : 'Cloud'}
88
+ </Button>
89
+ ))}
90
+ </div>
91
+ <div className="flex flex-wrap gap-2" role="group" aria-label="Agent">
92
+ {(['claude-code', 'codex'] as const).map(value => (
93
+ <Button
94
+ key={value}
95
+ size="sm"
96
+ variant={harness === value ? 'default' : 'secondary'}
97
+ onClick={() => restart({ harness: value })}
98
+ >
99
+ {workspaceTypeLabel[value]}
100
+ </Button>
101
+ ))}
102
+ </div>
103
+ <div className="flex flex-wrap gap-2" role="group" aria-label="Scenario">
104
+ {SETUP_SCENARIOS.map(value => (
105
+ <Button
106
+ key={value}
107
+ size="sm"
108
+ variant={scenario === value ? 'default' : 'secondary'}
109
+ onClick={() => restart({ scenario: value })}
110
+ >
111
+ {scenarioLabels[value]}
112
+ </Button>
113
+ ))}
114
+ </div>
115
+ </header>
116
+ <main className="flex min-h-0 flex-1 overflow-y-auto">
117
+ {scenario === 'welcome' ? (
118
+ <WorkspaceSetupPanel>
119
+ <WorkspaceWelcomeState name="My workspace" workspaceType={harness} />
120
+ </WorkspaceSetupPanel>
121
+ ) : scenario === 'loading' ? (
122
+ <WorkspaceSetupPanel>
123
+ <WorkspaceLoadingState />
124
+ </WorkspaceSetupPanel>
125
+ ) : (
126
+ <SetupScreen />
127
+ )}
128
+ </main>
129
+ <Dialog
130
+ open={providerPage !== 'closed'}
131
+ onOpenChange={open => !open && setProvider('closed')}
132
+ >
133
+ <DialogContent>
134
+ <DialogTitle>Mock sign-in page</DialogTitle>
135
+ <DialogDescription>
136
+ This simulates the agent’s browser sign-in. No credentials are needed.
137
+ </DialogDescription>
138
+ {providerPage === 'code' ? (
139
+ <>
140
+ <p className="text-sm">
141
+ Copy this authorization code, close this dialog, and submit it in the login screen:
142
+ </p>
143
+ <code>MOCK-AUTH-CODE</code>
144
+ <Button onClick={() => setProvider('closed')}>Back to Moi</Button>
145
+ </>
146
+ ) : (
147
+ <>
148
+ {environment === 'cloud' && (
149
+ <Input
150
+ aria-label="Device code"
151
+ placeholder="Paste MOCK-1234"
152
+ value={deviceCode}
153
+ onChange={event => setDeviceCode(event.target.value)}
154
+ />
155
+ )}
156
+ <Button
157
+ disabled={environment === 'cloud' && deviceCode !== 'MOCK-1234'}
158
+ onClick={() => {
159
+ update(mocks.complete)
160
+ setProvider('closed')
161
+ }}
162
+ >
163
+ Authorize
164
+ </Button>
165
+ </>
166
+ )}
167
+ </DialogContent>
168
+ </Dialog>
169
+ </div>
170
+ )
171
+ }
172
+
173
+ function SetupScreen() {
174
+ const [path] = useLocation()
175
+ const { content, ready } = useWorkspaceSetup(PREVIEW_WORKSPACE_ID)
176
+ if (ready) return null
177
+ return path === '/' ? (
178
+ <div
179
+ role="status"
180
+ className="flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground"
181
+ >
182
+ Workspace removed
183
+ </div>
184
+ ) : (
185
+ <WorkspaceSetupPanel>{content}</WorkspaceSetupPanel>
186
+ )
187
+ }
188
+
189
+ export async function mountSetupPreview(element: HTMLElement) {
190
+ const params = new URLSearchParams(location.search)
191
+ const environment = params.get('environment') === 'cloud' ? 'cloud' : 'local'
192
+ const harness = params.get('harness') === 'codex' ? 'codex' : 'claude-code'
193
+ const scenario = SETUP_SCENARIOS.find(value => value === params.get('scenario')) ?? 'welcome'
194
+ const mocks = createSetupMocks(environment, harness, scenario)
195
+ // Scoped to this separate document. No fallback to the real fetch or socket.
196
+ window.fetch = Object.assign(mocks.request, { preconnect: fetch.preconnect })
197
+ Object.defineProperty(window, 'WebSocket', {
198
+ value: class extends EventTarget {
199
+ static OPEN = 1
200
+ readyState = 0
201
+ send() {}
202
+ close() {}
203
+ }
204
+ })
205
+ await loadAppConfig()
206
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
207
+ const locationHook = memoryLocation({
208
+ path: `/workspace/${PREVIEW_WORKSPACE_ID}`
209
+ })
210
+ createRoot(element).render(
211
+ <QueryClientProvider client={client}>
212
+ <TooltipProvider>
213
+ <Router hook={locationHook.hook}>
214
+ <SetupPreview
215
+ mocks={mocks}
216
+ client={client}
217
+ environment={environment}
218
+ harness={harness}
219
+ scenario={scenario}
220
+ />
221
+ </Router>
222
+ <Toaster />
223
+ </TooltipProvider>
224
+ </QueryClientProvider>
225
+ )
226
+ }
@@ -5,7 +5,7 @@ import { Button } from '@/client/components/ui/button'
5
5
  import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
6
6
  import { cn } from '@/client/lib/cn'
7
7
 
8
- import { type DrawingControls, useDrawingHistoryState } from './useDrawingLayer'
8
+ import { type DrawingControls, useDrawingHistoryState } from './use-drawing-layer'
9
9
 
10
10
  type DrawingToolbarProps = {
11
11
  controls: DrawingControls
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect, useMemo, useRef } from 'react'
1
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react'
2
2
 
3
3
  import { toast } from '@/client/components/ui/toast'
4
4
  import {
@@ -6,11 +6,11 @@ import {
6
6
  stageDrawingDraft
7
7
  } from '@/client/features/chat/composer/attachments/draft-attachments'
8
8
  import { liveStore } from '@/client/features/chat/chat-store'
9
- import type { ComposerAnnotationControls } from '@/client/features/chat/composer/ChatComposer'
9
+ import type { ComposerAnnotationControls } from '@/client/features/chat/composer/chat-composer'
10
10
  import { useLatestRef } from '@/client/lib/use-latest-ref'
11
11
  import type { LayoutMode, WorkspaceTabId } from '@/lib/types'
12
12
 
13
- import { type DrawingController, useDrawingLayer } from './useDrawingLayer'
13
+ import { type DrawingController, useDrawingLayer } from './use-drawing-layer'
14
14
 
15
15
  type AnnotationOrigin = 'docked' | 'popup'
16
16
 
@@ -47,7 +47,6 @@ export function useChatAnnotation({
47
47
  openPopup
48
48
  }: UseChatAnnotationOptions): ChatAnnotationController {
49
49
  const draftRef = useRef<ChatAnnotationDraft | null>(null)
50
- const latestBlobRef = useRef<Blob | null>(null)
51
50
  const uploadRevisionsRef = useRef(new Map<string, number>())
52
51
  const closePopupRef = useLatestRef(closePopup)
53
52
  const openPopupRef = useLatestRef(openPopup)
@@ -59,7 +58,6 @@ export function useChatAnnotation({
59
58
  const draft = draftRef.current
60
59
  if (!draft) return
61
60
 
62
- latestBlobRef.current = blob
63
61
  if (!blob) {
64
62
  liveStore.getState().removeAttachment(draft.workspaceId, draft.attachmentId)
65
63
  return
@@ -75,36 +73,51 @@ export function useChatAnnotation({
75
73
  })
76
74
  }, [])
77
75
 
78
- const upload = useCallback((draft: ChatAnnotationDraft, blob: Blob): Promise<void> => {
76
+ const save = useCallback(async (result: Blob | null | Promise<Blob | null>) => {
77
+ const draft = draftRef.current
78
+ if (!draft) return
79
+ // Claim the draft before awaiting export so finish, cancel, and unmount
80
+ // cannot upload it twice.
81
+ draftRef.current = null
79
82
  const revision = (uploadRevisionsRef.current.get(draft.attachmentId) ?? 0) + 1
80
83
  uploadRevisionsRef.current.set(draft.attachmentId, revision)
81
- return stageDrawing({
84
+ const isCurrent = () => uploadRevisionsRef.current.get(draft.attachmentId) === revision
85
+ const blob = await result
86
+ if (!blob || !isCurrent()) return
87
+ await stageDrawing({
82
88
  workspaceId: draft.workspaceId,
83
89
  sessionId: draft.sourceSessionId,
84
90
  localId: draft.attachmentId,
85
91
  purpose: 'annotation',
86
92
  source: draft.source,
87
93
  blob,
88
- isCurrent: () => uploadRevisionsRef.current.get(draft.attachmentId) === revision
94
+ isCurrent
89
95
  })
90
96
  }, [])
91
97
 
92
98
  const complete = useCallback(
93
99
  async (blob: Blob | null) => {
94
100
  const draft = draftRef.current
95
- draftRef.current = null
96
- latestBlobRef.current = null
97
101
  // Awaited so a send that finishes the drawing only dispatches once the
98
102
  // attachment is uploaded and ready.
99
- if (draft && blob) await upload(draft, blob)
103
+ await save(blob)
100
104
  if (draft?.origin === 'popup') openPopupRef.current()
101
105
  },
102
- [openPopupRef, upload]
106
+ [openPopupRef, save]
103
107
  )
104
108
 
105
109
  const annotation = useDrawingLayer({ onChange: change, onFinish: complete })
106
110
  const { controls } = annotation
107
- const { active, starting, open, finish, cancel: cancelLayer } = controls
111
+ const { active, starting, open, finish, flush, cancel: cancelLayer } = controls
112
+
113
+ useLayoutEffect(
114
+ () => () => {
115
+ // Capture committed strokes before the drawing layer's passive cleanup
116
+ // clears its session. flush() also waits for an export already in progress.
117
+ if (draftRef.current) void save(flush())
118
+ },
119
+ [flush, save]
120
+ )
108
121
 
109
122
  const start = useCallback(
110
123
  async (origin: AnnotationOrigin) => {
@@ -135,16 +148,10 @@ export function useChatAnnotation({
135
148
  )
136
149
 
137
150
  const cancel = useCallback(async () => {
138
- const draft = draftRef.current
151
+ const pendingSave = draftRef.current ? save(flush()) : undefined
139
152
  await cancelLayer()
140
- if (draftRef.current !== draft) return
141
- draftRef.current = null
142
- const blob = latestBlobRef.current
143
- latestBlobRef.current = null
144
- // An implicit cancel (tab/session switch) keeps the drawn-so-far
145
- // annotation as an attachment, so it gets its one deferred upload here.
146
- if (draft && blob) void upload(draft, blob)
147
- }, [cancelLayer, upload])
153
+ await pendingSave
154
+ }, [cancelLayer, flush, save])
148
155
 
149
156
  const remove = useCallback(
150
157
  (localId: string) => {
@@ -153,7 +160,6 @@ export function useChatAnnotation({
153
160
  liveStore.getState().removeAttachment(workspaceId, localId)
154
161
  if (draftRef.current?.attachmentId === localId) {
155
162
  draftRef.current = null
156
- latestBlobRef.current = null
157
163
  void cancelLayer()
158
164
  }
159
165
  },
@@ -16,7 +16,7 @@ import type {
16
16
  import { toast } from '@/client/components/ui/toast'
17
17
  import { useLatestRef } from '@/client/lib/use-latest-ref'
18
18
 
19
- import type { DrawingCanvasPointerProps, DrawingLayerProps } from './DrawingLayer'
19
+ import type { DrawingCanvasPointerProps, DrawingLayerProps } from './drawing-layer'
20
20
  import { captureElement, drawingCaptureScale } from './capture-element'
21
21
 
22
22
  export type DrawingPoint = {
@@ -8,11 +8,11 @@ import { attachmentKey, liveStore } from '@/client/features/chat/chat-store'
8
8
  import { useLatestRef } from '@/client/lib/use-latest-ref'
9
9
  import type { WorkspaceTabId } from '@/lib/types'
10
10
 
11
- import { useDrawingLayer } from './useDrawingLayer'
11
+ import { useDrawingLayer } from './use-drawing-layer'
12
12
 
13
- type UseViewBuilderSketchOptions = {
13
+ type UseViewSketchOptions = {
14
14
  active: boolean
15
- builderId: string
15
+ viewId: string
16
16
  sessionId: string
17
17
  source: WorkspaceTabId
18
18
  workspaceId: string
@@ -20,18 +20,18 @@ type UseViewBuilderSketchOptions = {
20
20
  onContinueInChat: () => void
21
21
  }
22
22
 
23
- export type ViewBuilderSketchController = ReturnType<typeof useViewBuilderSketch>
23
+ export type ViewSketchController = ReturnType<typeof useViewSketch>
24
24
 
25
- export function useViewBuilderSketch({
25
+ export function useViewSketch({
26
26
  active,
27
- builderId,
27
+ viewId,
28
28
  sessionId,
29
29
  source,
30
30
  workspaceId,
31
31
  onEditingStart,
32
32
  onContinueInChat
33
- }: UseViewBuilderSketchOptions) {
34
- const attachmentIdRef = useRef(`sketch:${builderId}`)
33
+ }: UseViewSketchOptions) {
34
+ const attachmentIdRef = useRef(`sketch:${viewId}`)
35
35
  const uploadRevisionRef = useRef(0)
36
36
  const uploadedBlobRef = useRef<Blob | null>(null)
37
37
  const pendingStageRef = useRef<Promise<void> | null>(null)
@@ -0,0 +1,36 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+ import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
3
+ import type {
4
+ HarnessAvailability,
5
+ HarnessLogin,
6
+ HarnessLoginState,
7
+ WorkspaceType
8
+ } from '@/lib/types'
9
+
10
+ export function startHarnessLogin(type: WorkspaceType): Promise<HarnessLogin> {
11
+ return requestJson(
12
+ `/api/harnesses/${type}/auth/login`,
13
+ { method: 'POST' },
14
+ 'Could not start sign-in'
15
+ )
16
+ }
17
+
18
+ export type LoginHarness = 'claude-code' | 'codex'
19
+
20
+ export type HarnessAuth = {
21
+ availability: HarnessAvailability
22
+ login?: HarnessLoginState
23
+ }
24
+
25
+ export function useHarnessAuth(type: WorkspaceType) {
26
+ return useQuery({
27
+ queryKey: ['harness-auth', type],
28
+ queryFn: () => requestJson<HarnessAuth>(`/api/harnesses/${type}/auth`),
29
+ staleTime: 2_000,
30
+ refetchInterval: 2_000
31
+ })
32
+ }
33
+
34
+ export function submitHarnessLoginCode(type: WorkspaceType, id: string, code: string) {
35
+ return requestVoid(`/api/harnesses/${type}/auth/login/${id}/code`, jsonRequest('POST', { code }))
36
+ }
@@ -0,0 +1,97 @@
1
+ import { useEffect, useState } from 'react'
2
+
3
+ import {
4
+ IconChevronRight,
5
+ IconCopy,
6
+ IconCheck,
7
+ IconCircleNumber1,
8
+ IconCircleNumber2,
9
+ IconCircleNumber3
10
+ } from '@tabler/icons-react'
11
+
12
+ import { buttonVariants } from '@/client/components/ui/button'
13
+ import { cn } from '@/client/lib/cn'
14
+
15
+ type DeviceLoginStepsProps = {
16
+ code: string
17
+ url: string
18
+ }
19
+
20
+ export function DeviceLoginSteps({ code, url }: DeviceLoginStepsProps) {
21
+ const [copied, setCopied] = useState(false)
22
+
23
+ useEffect(() => {
24
+ if (!copied) return
25
+ const timer = setTimeout(() => setCopied(false), 3000)
26
+ return () => clearTimeout(timer)
27
+ }, [copied])
28
+
29
+ const copyCode = () => {
30
+ navigator.clipboard
31
+ ?.writeText(code)
32
+ .then(() => setCopied(true))
33
+ .catch(() => {})
34
+ }
35
+
36
+ return (
37
+ <ol className="mx-auto grid w-full max-w-64 gap-6 text-left text-sm lg:max-w-3xl lg:grid-cols-3 lg:text-center">
38
+ <li className="flex flex-col items-start gap-3 lg:items-center">
39
+ <IconCircleNumber1 size={24} stroke={1.5} className="shrink-0" />
40
+ <div className="flex min-w-0 flex-col items-start gap-3 lg:items-center">
41
+ <p>Enable device code sign-in for Codex in ChatGPT settings</p>
42
+ <a
43
+ href="https://chatgpt.com/settings/security"
44
+ target="_blank"
45
+ rel="noopener noreferrer"
46
+ className="inline-flex h-8 flex-wrap items-center gap-1 font-semibold focus-visible:ring-3 focus-visible:ring-ring/50"
47
+ >
48
+ Settings
49
+ <IconChevronRight size={16} stroke={2} aria-hidden="true" />
50
+ Security and login
51
+ </a>
52
+ </div>
53
+ </li>
54
+ <li className="flex flex-col items-start gap-3 lg:items-center">
55
+ <IconCircleNumber2 size={24} stroke={1.5} className="shrink-0" />
56
+ <div className="flex min-w-0 flex-col items-start gap-3 lg:items-center">
57
+ <p>Copy the one-time device code provided below</p>
58
+ <div className="flex h-8 items-center gap-2 rounded-lg border border-input bg-accent pr-2 pl-3">
59
+ <code className="cursor-text text-sm font-medium select-text">{code}</code>
60
+ <button
61
+ type="button"
62
+ className="relative size-4 cursor-pointer text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground"
63
+ aria-label={copied ? 'Code copied' : 'Copy code'}
64
+ onClick={copyCode}
65
+ >
66
+ <IconCopy
67
+ className={cn(
68
+ 'absolute inset-0 transition-[opacity,filter] duration-200 motion-reduce:transition-none',
69
+ copied && 'opacity-0 blur-[2px]'
70
+ )}
71
+ stroke={1.75}
72
+ size={16}
73
+ />
74
+ <IconCheck
75
+ className={cn(
76
+ 'absolute inset-0 transition-[opacity,filter] duration-200 motion-reduce:transition-none',
77
+ !copied && 'opacity-0 blur-[2px]'
78
+ )}
79
+ stroke={1.75}
80
+ size={16}
81
+ />
82
+ </button>
83
+ </div>
84
+ </div>
85
+ </li>
86
+ <li className="flex flex-col items-start gap-3 lg:items-center">
87
+ <IconCircleNumber3 size={24} stroke={1.5} className="shrink-0" />
88
+ <div className="flex min-w-0 flex-col items-start gap-3 lg:items-center">
89
+ <p>Sign-in in browser, paste the code, and then come back to Moi</p>
90
+ <a href={url} target="_blank" rel="noopener noreferrer" className={buttonVariants()}>
91
+ Open browser
92
+ </a>
93
+ </div>
94
+ </li>
95
+ </ol>
96
+ )
97
+ }