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
@@ -13,14 +13,19 @@ import { prepareChatAttachments, type ChatSendOptions, type PreparedAttachments
13
13
  import { useLayoutEffect } from 'react'
14
14
  import { useQueryClient, type QueryClient } from '@tanstack/react-query'
15
15
  import { toast } from '@/client/components/ui/toast'
16
- import { selectedSessionKey } from '@/client/features/chat/sessions/useSelectedSession'
16
+ import {
17
+ selectedSessionForTab,
18
+ selectedSessionKey
19
+ } from '@/client/features/chat/sessions/use-selected-session'
17
20
  import { useCollabEnabled } from '@/client/features/collab'
18
21
  import { useLatestRef } from '@/client/lib/use-latest-ref'
19
- import type { SelectedSessionScope, SelectedSessionState } from '@/lib/types'
20
- import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
22
+ import type { SelectedSessionScope, WorkspaceSessionSelection, WorkspaceTabId } from '@/lib/types'
23
+ import { useCurrentTabId } from './sessions/use-selected-session'
24
+ import { useWorkspaceId } from '@/client/features/workspace/workspace-context'
21
25
  import type { AgentAvailability } from '@/client/lib/agent-availability'
22
26
 
23
27
  type UseAppletChatMessageOptions = {
28
+ tabId: WorkspaceTabId
24
29
  sessionId: string | null
25
30
  send: (draft: string, options?: ChatSendOptions) => void
26
31
  // Bring the chat on screen before the run starts. On a view tab in
@@ -39,7 +44,7 @@ export function appletSendBlockedReason(availability: AgentAvailability): string
39
44
  if (availability.status === 'checking') {
40
45
  return 'The agent is still connecting'
41
46
  }
42
- if (availability.status === 'disconnected') return 'This workspace is disconnected from moi'
47
+ if (availability.status === 'disconnected') return 'This workspace is disconnected from Moi'
43
48
  if (availability.status === 'login-required') {
44
49
  return 'Sign in to the agent to send this message'
45
50
  }
@@ -57,9 +62,21 @@ export function createAppletMessageHandler(
57
62
  ) {
58
63
  const pending = new Set<() => void>()
59
64
  let disposed = false
60
- const selectedSession = () =>
61
- queryClient.getQueryData<SelectedSessionState>(selectedSessionKey(workspaceId, scope))
62
- ?.sessionId ?? null
65
+ const selectedSession = () => {
66
+ const state = queryClient.getQueryData<WorkspaceSessionSelection>(
67
+ selectedSessionKey(workspaceId, scope)
68
+ )
69
+ const shared = queryClient.getQueryData<WorkspaceSessionSelection>(
70
+ selectedSessionKey(workspaceId)
71
+ )
72
+ return (
73
+ selectedSessionForTab(
74
+ shared,
75
+ getOptions().tabId,
76
+ scope === 'browser-tab' ? state : undefined
77
+ ) ?? null
78
+ )
79
+ }
63
80
 
64
81
  async function handle(event: AppletChatMessage): Promise<void> {
65
82
  if (disposed) return
@@ -67,7 +84,7 @@ export function createAppletMessageHandler(
67
84
  toast.add({ title: 'Couldn’t send message', description: message, type: 'error' })
68
85
  reportAppletError(workspaceId, {
69
86
  source: 'runtime',
70
- message: `sendChatMessage() from ${event.source}: ${message}`
87
+ message: `sendChatMessage() from ${event.applet.kind}:${event.applet.id}: ${message}`
71
88
  })
72
89
  }
73
90
  const blocked = appletSendBlockedReason(getOptions().agentAvailability)
@@ -77,6 +94,7 @@ export function createAppletMessageHandler(
77
94
  }
78
95
 
79
96
  const sessionId = selectedSession()
97
+ const tabId = getOptions().tabId
80
98
  let active = true
81
99
  let loadingToast: string | undefined
82
100
  const finish = () => {
@@ -95,7 +113,7 @@ export function createAppletMessageHandler(
95
113
  })
96
114
  }
97
115
  const unsubscribe = queryClient.getQueryCache().subscribe(() => {
98
- if (selectedSession() !== sessionId) cancel()
116
+ if (selectedSession() !== sessionId || getOptions().tabId !== tabId) cancel()
99
117
  })
100
118
  pending.add(cancel)
101
119
  // A selection change can reach the cache before React has replaced the
@@ -116,7 +134,7 @@ export function createAppletMessageHandler(
116
134
  const options = getOptions()
117
135
  const blocked = appletSendBlockedReason(options.agentAvailability)
118
136
  if (blocked) throw new Error(blocked)
119
- if (options.sessionId !== sessionId) {
137
+ if (options.sessionId !== sessionId || options.tabId !== tabId) {
120
138
  cancel()
121
139
  return
122
140
  }
@@ -130,7 +148,7 @@ export function createAppletMessageHandler(
130
148
  // Stop watching before sending: a new chat gets its first session ID here.
131
149
  finish()
132
150
  try {
133
- getOptions().send(event.message, { applet: { source: event.source }, preparedAttachments })
151
+ getOptions().send(event.message, { applet: event.applet, preparedAttachments })
134
152
  } catch (error) {
135
153
  reportFailure(
136
154
  error instanceof Error ? error.message : 'Something went wrong while sending this message'
@@ -147,11 +165,12 @@ export function createAppletMessageHandler(
147
165
  }
148
166
  }
149
167
 
150
- export function useAppletChatMessage(options: UseAppletChatMessageOptions): void {
168
+ export function useAppletChatMessage(options: Omit<UseAppletChatMessageOptions, 'tabId'>): void {
151
169
  const workspaceId = useWorkspaceId()
152
170
  const queryClient = useQueryClient()
171
+ const tabId = useCurrentTabId()
153
172
  const collabEnabled = useCollabEnabled()
154
- const latest = useLatestRef(options)
173
+ const latest = useLatestRef({ ...options, tabId })
155
174
  useLayoutEffect(() => {
156
175
  const handler = createAppletMessageHandler(
157
176
  workspaceId,
@@ -166,7 +185,7 @@ export function useAppletChatMessage(options: UseAppletChatMessageOptions): void
166
185
  unsubscribe()
167
186
  handler.dispose()
168
187
  }
169
- }, [workspaceId, queryClient, latest, collabEnabled])
188
+ }, [workspaceId, queryClient, latest, tabId, collabEnabled])
170
189
  }
171
190
 
172
191
  export function useAppletChatAttachment(sessionId: string | null, revealChat: () => void): void {
@@ -1,49 +1,48 @@
1
1
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react'
2
+ import { useRouter } from 'wouter'
2
3
 
3
- import { IconChevronDown, IconChevronsRight, IconX } from '@tabler/icons-react'
4
+ import { IconArrowBackUp, IconChevronDown, IconChevronsRight, IconX } from '@tabler/icons-react'
5
+ import { draftSessionId } from '@/lib/session-drafts'
6
+ import { resolveUrl } from '@/lib/navigation'
7
+ import { useCurrentTabId } from './sessions/use-selected-session'
4
8
 
5
- import { canSubmitComposerAction, focusComposer } from '@/client/components/shared/Composer'
6
- import { AgentBlobatar } from '@/client/components/shared/AgentBlobatar'
7
- import { useStickToBottom } from '@/client/features/chat/messages/useStickToBottom'
9
+ import { canSubmitComposerAction, focusComposer } from '@/client/components/shared/composer'
10
+ import { AgentBlobatar } from '@/client/components/shared/agent-blobatar'
11
+ import { useStickToBottom } from '@/client/features/chat/messages/use-stick-to-bottom'
8
12
  import { appendPreviewTurn, groupTurns } from '@/client/features/chat/messages/group-turns'
9
13
  import {
10
14
  chatNoticeLabel,
11
15
  interleaveNotices
12
16
  } from '@/client/features/chat/messages/interleave-notices'
13
17
  import { attachmentKey, useLive } from '@/client/features/chat/chat-store'
14
- import type { ChatPromptBubble } from '@/client/features/chat/messages/ChatPromptBubbles'
18
+ import type { ChatPromptBubble } from '@/client/features/chat/messages/chat-prompt-bubbles'
15
19
  import type { ChatSendOptions } from '@/client/features/chat/chat-send'
16
- import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
20
+ import { useWorkspaceId } from '@/client/features/workspace/workspace-context'
17
21
  import type { AgentTheme, SystemNotice, Turn, ViewState } from '@/lib/types'
18
22
 
19
- import type { ComposerBanner } from './composer/banners/ComposerBanner'
20
- import { ChatComposer, type ComposerAnnotationControls } from './composer/ChatComposer'
23
+ import type { ComposerBanner } from './composer/banners/composer-banner'
24
+ import { ChatComposer, type ComposerAnnotationControls } from './composer/chat-composer'
21
25
  import {
22
26
  ChatEmptyState,
23
27
  type WelcomeDestination,
24
28
  resolveChatEmptyState
25
- } from './messages/ChatEmptyState'
26
- import { ChatSelector } from './sessions/ChatSelector'
27
- import { TurnView } from './messages/TurnView'
29
+ } from './messages/chat-empty-state'
30
+ import { ChatSelector } from './sessions/chat-selector'
31
+ import { useWorkspaceSessions } from './sessions/api'
32
+ import { TurnView } from './messages/turn-view'
28
33
  import { Button } from '@/client/components/ui/button'
29
34
  import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
30
35
  import { cn } from '@/client/lib/cn'
31
36
  import type { AgentAvailability } from '@/client/lib/agent-availability'
32
37
  import { useUiStore } from '@/client/store/ui'
33
38
 
34
- export type ViewBuilderChatDraft = {
39
+ export type ViewChatDraft = {
35
40
  sessionId: string
36
- builderId: string
37
- // Server-saved requirements the composer falls back to; the live draft text
38
- // is subscribed from the UI store by builder id inside ChatComposer, so
39
- // typing never re-renders this panel or the screen hosting it.
40
- initialValue: string
41
- onChange: (value: string) => void
42
41
  onRemoveDrawing: (localId: string) => void
43
- onSubmit: (value: string) => Promise<void>
44
42
  }
45
43
 
46
44
  type ChatPanelProps = {
45
+ forkedFromSessionId?: string
47
46
  agent: AgentTheme
48
47
  active?: boolean
49
48
  focusRequest?: number
@@ -55,25 +54,23 @@ type ChatPanelProps = {
55
54
  // into the trailing assistant run so a thinking-only
56
55
  // preview folds into the current tool group. See client/lib/preview-turn.ts.
57
56
  previewTurn?: Turn | null
58
- // Selected session id — used only as the scroll reset key (jump to bottom on
59
- // session switch).
60
57
  sessionId?: string | null
61
58
  processing: boolean
62
59
  composerBanner?: ComposerBanner
63
60
  agentAvailability: AgentAvailability
64
61
  annotation?: ComposerAnnotationControls
65
- send: (text: string, options?: ChatSendOptions) => void
62
+ send: (text: string, options?: ChatSendOptions) => Promise<void>
66
63
  stop: () => void
67
64
  onNavigateFromWelcome: (destination: WelcomeDestination) => void
68
- // Chat on a separate tab doesn't have a close button
69
- onClose?: () => void
70
- builderDraft?: ViewBuilderChatDraft
65
+ onClose: () => void
66
+ viewDraft?: ViewChatDraft
71
67
  }
72
68
 
73
69
  const EMPTY_TURNS: Turn[] = []
74
70
  const EMPTY_NOTICES: SystemNotice[] = []
75
71
 
76
72
  export function ChatPanel({
73
+ forkedFromSessionId,
77
74
  agent,
78
75
  active = true,
79
76
  focusRequest = 0,
@@ -91,14 +88,18 @@ export function ChatPanel({
91
88
  stop,
92
89
  onNavigateFromWelcome,
93
90
  onClose,
94
- builderDraft
91
+ viewDraft
95
92
  }: ChatPanelProps) {
96
93
  const workspaceId = useWorkspaceId()
94
+ const { base } = useRouter()
95
+ const { data: sessions } = useWorkspaceSessions(workspaceId)
96
+ const sourceName = sessions?.find(session => session.sessionId === forkedFromSessionId)?.summary
97
+ const tabId = useCurrentTabId()
97
98
  const composerRef = useRef<HTMLTextAreaElement>(null)
98
99
  const scrollRef = useRef<HTMLDivElement>(null)
99
- const effectiveSessionId = builderDraft?.sessionId ?? sessionId ?? null
100
- const modelSessionId = builderDraft ? null : (sessionId ?? null)
101
- const turns = builderDraft ? EMPTY_TURNS : view.turns
100
+ const effectiveSessionId = viewDraft?.sessionId ?? sessionId ?? draftSessionId(tabId)
101
+ const modelSessionId = viewDraft ? null : (sessionId ?? null)
102
+ const turns = viewDraft ? EMPTY_TURNS : view.turns
102
103
  const hasSentMessageFromMoi = useUiStore(state => state.hasSentMessageFromMoi)
103
104
  const isWorkspacePendingAnalysis = useUiStore(state =>
104
105
  (state.workspaceIdsPendingAnalysis ?? []).includes(workspaceId)
@@ -108,14 +109,16 @@ export function ChatPanel({
108
109
  attachment => attachment.kind !== 'text' && attachment.status === 'uploading'
109
110
  )
110
111
  )
111
- const promptDisabled = !canSubmitComposerAction(true, attachmentsUploading, agentAvailability)
112
+ const chatReady = chatLoaded || !!viewDraft
113
+ const promptDisabled =
114
+ !chatReady || !canSubmitComposerAction(true, attachmentsUploading, agentAvailability)
112
115
  // Visual grouping: fold consecutive tool-only assistant turns into one
113
116
  // synthetic turn so OpenAI Codex–style traces (which serialize one
114
117
  // assistant message per agent step) don't render with the wider
115
118
  // inter-turn gap between every tool call. See `dev/turn-spacing.md`.
116
119
  // Group saved history once, then merge previews into just the trailing run.
117
- const effectivePreviewTurn = builderDraft ? null : previewTurn
118
- const notices = builderDraft ? EMPTY_NOTICES : view.notices
120
+ const effectivePreviewTurn = viewDraft ? null : previewTurn
121
+ const notices = viewDraft ? EMPTY_NOTICES : view.notices
119
122
  const savedGroups = useMemo(() => groupTurns(turns), [turns])
120
123
  const groupedTurns = useMemo(
121
124
  () => appendPreviewTurn(savedGroups, effectivePreviewTurn),
@@ -126,12 +129,14 @@ export function ChatPanel({
126
129
  // a notice never splits a tool-only run apart.
127
130
  const timeline = useMemo(() => interleaveNotices(groupedTurns, notices), [groupedTurns, notices])
128
131
  const lastTurnId = groupedTurns.length > 0 ? groupedTurns[groupedTurns.length - 1].id : null
129
- const effectiveProcessing = builderDraft ? false : processing
132
+ const effectiveProcessing = viewDraft ? false : processing
130
133
  const showEmptyState =
131
- !!builderDraft || (chatLoaded && timeline.length === 0 && !effectiveProcessing)
134
+ !!viewDraft ||
135
+ (!forkedFromSessionId && chatLoaded && timeline.length === 0 && !effectiveProcessing)
132
136
  const showTranscript = chatLoaded && !showEmptyState
133
137
  const emptyStateKind = resolveChatEmptyState({
134
- isViewBuilderDraft: !!builderDraft,
138
+ tabId,
139
+ isViewDraft: !!viewDraft,
135
140
  hasSentMessageFromMoi,
136
141
  isWorkspacePendingAnalysis
137
142
  })
@@ -140,7 +145,8 @@ export function ChatPanel({
140
145
  const { atBottom, scrollToBottom, scrollToTop } = useStickToBottom(scrollRef, effectiveSessionId)
141
146
 
142
147
  useLayoutEffect(() => {
143
- if (showEmptyState && emptyStateKind !== 'empty') scrollToTop()
148
+ if (showEmptyState && emptyStateKind !== 'overview-empty' && emptyStateKind !== 'tab-empty')
149
+ scrollToTop()
144
150
  }, [showEmptyState, emptyStateKind, scrollToTop])
145
151
 
146
152
  // The active chat surface owns initial focus. A monotonically increasing
@@ -153,11 +159,10 @@ export function ChatPanel({
153
159
  // they expect to see their message and the reply.
154
160
  const handleSend = useCallback(
155
161
  async (text: string, options?: ChatSendOptions) => {
156
- if (builderDraft) await builderDraft.onSubmit(text)
157
- else send(text, options)
162
+ await send(text, options)
158
163
  scrollToBottom()
159
164
  },
160
- [builderDraft, send, scrollToBottom]
165
+ [send, scrollToBottom]
161
166
  )
162
167
 
163
168
  const handlePromptSelect = useCallback(
@@ -170,23 +175,23 @@ export function ChatPanel({
170
175
 
171
176
  return (
172
177
  <div className="flex min-h-0 flex-1 flex-col pt-2 pb-3">
173
- <header className="mx-auto flex w-full max-w-[calc(var(--chat-max-container)+40px)] min-w-0 items-center justify-between pr-2 pb-2 pl-2">
174
- <div className="min-w-0 flex-1">
175
- <ChatSelector isViewBuilder={!!builderDraft} />
178
+ <header className="flex w-full min-w-0 items-center justify-between pr-2 pb-2 pl-2">
179
+ <div className="flex h-7 min-w-0 flex-1">
180
+ <ChatSelector className={cn('text-foreground', docked && 'text-muted-foreground')} />
176
181
  </div>
177
- {onClose && docked && (
182
+ {docked && (
178
183
  <Tooltip>
179
184
  <TooltipTrigger
180
185
  render={
181
- <Button variant="ghost" size="icon-sm" onClick={onClose} aria-label="Undock agent">
186
+ <Button variant="ghost" size="icon-sm" onClick={onClose} aria-label="Undock chat">
182
187
  <IconChevronsRight className="size-5! text-muted-foreground" stroke={1.5} />
183
188
  </Button>
184
189
  }
185
190
  />
186
- <TooltipContent>Undock agent</TooltipContent>
191
+ <TooltipContent>Undock chat</TooltipContent>
187
192
  </Tooltip>
188
193
  )}
189
- {!builderDraft && onClose && !docked && (
194
+ {!viewDraft && !docked && (
190
195
  <Button variant="ghost" size="icon-sm" onClick={onClose} aria-label="Close chat">
191
196
  <IconX stroke={2} />
192
197
  </Button>
@@ -199,6 +204,30 @@ export function ChatPanel({
199
204
  className="flex scrollbar-thin flex-1 scroll-fade flex-col overflow-y-auto overscroll-contain px-5 pt-4 pb-8 [--scroll-fade-reveal:8px]"
200
205
  >
201
206
  <div className="mx-auto flex w-full max-w-(--chat-max-container) flex-1 flex-col gap-6">
207
+ {forkedFromSessionId && (
208
+ <a
209
+ href={resolveUrl(`moi:/chats/${encodeURIComponent(forkedFromSessionId)}`, {
210
+ workspaceId,
211
+ base
212
+ })}
213
+ className="block text-sm outline-none focus-visible:ring-3 focus-visible:ring-ring/50"
214
+ >
215
+ <div className="flex items-center gap-3">
216
+ <IconArrowBackUp
217
+ size={20}
218
+ stroke={1.5}
219
+ aria-hidden="true"
220
+ className="shrink-0 text-muted-foreground"
221
+ />
222
+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">
223
+ <span className="text-muted-foreground">Started from another chat</span>
224
+ <span className="truncate font-medium" title={sourceName}>
225
+ {sourceName || 'Another chat'}
226
+ </span>
227
+ </div>
228
+ </div>
229
+ </a>
230
+ )}
202
231
  {showEmptyState && (
203
232
  <ChatEmptyState
204
233
  agent={agent}
@@ -268,19 +297,11 @@ export function ChatPanel({
268
297
  sessionId={effectiveSessionId}
269
298
  modelSessionId={modelSessionId}
270
299
  availability={agentAvailability}
271
- annotation={builderDraft ? undefined : annotation}
272
- onRemoveDrawing={builderDraft?.onRemoveDrawing ?? annotation?.onRemove}
273
- allowFiles={!builderDraft}
274
- placeholder={builderDraft ? 'Drop in the details' : undefined}
275
- draft={
276
- builderDraft
277
- ? {
278
- id: builderDraft.builderId,
279
- initialValue: builderDraft.initialValue,
280
- onChange: builderDraft.onChange
281
- }
282
- : undefined
283
- }
300
+ chatReady={chatReady}
301
+ annotation={viewDraft ? undefined : annotation}
302
+ onRemoveDrawing={viewDraft?.onRemoveDrawing ?? annotation?.onRemove}
303
+ allowFiles={!viewDraft}
304
+ placeholder={viewDraft ? 'Drop in the details' : undefined}
284
305
  />
285
306
  </div>
286
307
  </div>
@@ -0,0 +1,171 @@
1
+ import { useCallback, useRef, useState } from 'react'
2
+ import type { ComponentProps, ReactNode } from 'react'
3
+
4
+ import { motion } from 'motion/react'
5
+ import { Resizable } from 'react-resizable'
6
+
7
+ import { AgentBlobatar } from '@/client/components/shared/agent-blobatar'
8
+ import { Popover, PopoverContent, PopoverTrigger } from '@/client/components/ui/popover'
9
+ import { cn } from '@/client/lib/cn'
10
+ import { useUiStore } from '@/client/store/ui'
11
+ import type { AgentTheme } from '@/lib/types'
12
+
13
+ type ChatPopupProps = {
14
+ agent: AgentTheme
15
+ loading: boolean
16
+ open: boolean
17
+ onOpenChange: (open: boolean) => void
18
+ onOpenChangeComplete: (open: boolean) => void
19
+ children: (onClose: () => void) => ReactNode
20
+ }
21
+
22
+ export function ChatPopup({
23
+ agent,
24
+ loading,
25
+ open,
26
+ onOpenChange,
27
+ onOpenChangeComplete,
28
+ children
29
+ }: ChatPopupProps) {
30
+ const popupRef = useRef<HTMLDivElement>(null)
31
+ const popupChatWidth = useUiStore(state => state.popupChatWidth)
32
+ const setPopupChatWidth = useUiStore(state => state.setPopupChatWidth)
33
+ const [size, setSize] = useState({ width: popupChatWidth, min: 0, max: popupChatWidth })
34
+
35
+ const setPopupRef = useCallback(
36
+ (popup: HTMLDivElement | null) => {
37
+ popupRef.current = popup
38
+ if (!popup) return
39
+ popup.style.setProperty('--chat-popup-width', `${popupChatWidth}px`)
40
+ // Report the rendered width, including viewport clamping of the saved preference.
41
+ const observer = new ResizeObserver(([entry]) => {
42
+ if (!entry) return
43
+ const { minWidth, maxWidth } = getComputedStyle(popup)
44
+ setSize({
45
+ width: Math.round(entry.contentRect.width),
46
+ min: parseFloat(minWidth),
47
+ max: parseFloat(maxWidth)
48
+ })
49
+ })
50
+ observer.observe(popup)
51
+ return () => {
52
+ observer.disconnect()
53
+ popupRef.current = null
54
+ }
55
+ },
56
+ [popupChatWidth]
57
+ )
58
+
59
+ const resize = (width: number) => {
60
+ if (!popupRef.current) return
61
+ const { minWidth, maxWidth } = getComputedStyle(popupRef.current)
62
+ setPopupChatWidth(
63
+ Math.round(Math.min(parseFloat(maxWidth), Math.max(parseFloat(minWidth), width)))
64
+ )
65
+ }
66
+ const onClose = () => onOpenChange(false)
67
+ const handleOpenChange: NonNullable<ComponentProps<typeof Popover>['onOpenChange']> = (
68
+ nextOpen,
69
+ eventDetails
70
+ ) => {
71
+ // Applet actions move focus outside before their click handler runs.
72
+ // Keep chat open so adding context only refocuses the existing composer.
73
+ if (
74
+ !nextOpen &&
75
+ (eventDetails.reason === 'outside-press' || eventDetails.reason === 'focus-out')
76
+ ) {
77
+ eventDetails.cancel()
78
+ return
79
+ }
80
+ onOpenChange(nextOpen)
81
+ }
82
+
83
+ return (
84
+ <Popover
85
+ open={open}
86
+ onOpenChange={handleOpenChange}
87
+ onOpenChangeComplete={onOpenChangeComplete}
88
+ >
89
+ {/* Floating over a themed workspace — use the card pair so it stays
90
+ legible regardless of the active theme background. */}
91
+ <PopoverTrigger
92
+ render={
93
+ <div className="fixed right-3 bottom-3">
94
+ <motion.div
95
+ variants={{
96
+ from: { opacity: 0, scale: 0.8, filter: 'blur(4px)' },
97
+ to: { opacity: 1, scale: 1, filter: 'blur(0px)' },
98
+ invisible: { opacity: 0, scale: 1, filter: 'blur(4px)' }
99
+ }}
100
+ initial="from"
101
+ animate={open ? 'invisible' : 'to'}
102
+ transition={{ type: 'spring', duration: 0.3, delay: 0.2, bounce: 0 }}
103
+ >
104
+ <button
105
+ type="button"
106
+ className="group block cursor-pointer p-0 drop-shadow-[0_0_4px_var(--background)] outline-none focus-visible:ring-3 focus-visible:ring-ring/50"
107
+ aria-label="Agent"
108
+ >
109
+ <AgentBlobatar
110
+ preset={agent}
111
+ color="primary"
112
+ animated={loading}
113
+ size={loading ? 80 : 64}
114
+ expression={loading ? 'thinking' : undefined}
115
+ className={cn(
116
+ 'drop-shadow-md drop-shadow-primary/25',
117
+ 'group-hover:drop-shadow-lg group-hover:drop-shadow-primary/40',
118
+ 'transition-[width,height,filter] duration-300 ease-in-out motion-reduce:transition-none'
119
+ )}
120
+ />
121
+ </button>
122
+ </motion.div>
123
+ </div>
124
+ }
125
+ />
126
+ <Resizable
127
+ axis="x"
128
+ width={size.width}
129
+ height={0}
130
+ resizeHandles={['w']}
131
+ minConstraints={[size.min, 0]}
132
+ maxConstraints={[size.max, 0]}
133
+ onResize={(_event, { size }) => setPopupChatWidth(Math.round(size.width))}
134
+ handle={
135
+ <div
136
+ role="separator"
137
+ aria-label="Resize chat popup"
138
+ aria-orientation="vertical"
139
+ aria-valuemin={size.min}
140
+ aria-valuemax={size.max}
141
+ aria-valuenow={size.width}
142
+ aria-valuetext={`${size.width} pixels wide`}
143
+ tabIndex={0}
144
+ className="absolute inset-y-6 -left-1 w-2 cursor-ew-resize touch-none rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50"
145
+ onKeyDown={event => {
146
+ const width = popupRef.current?.offsetWidth ?? popupChatWidth
147
+ const step = event.shiftKey ? 32 : 16
148
+ if (event.key === 'ArrowLeft') resize(width + step)
149
+ else if (event.key === 'ArrowRight') resize(width - step)
150
+ else if (event.key === 'Home') resize(-Infinity)
151
+ else if (event.key === 'End') resize(Infinity)
152
+ else return
153
+ event.preventDefault()
154
+ }}
155
+ />
156
+ }
157
+ >
158
+ <PopoverContent
159
+ ref={setPopupRef}
160
+ side="top"
161
+ sideOffset={({ anchor }) => -anchor.height}
162
+ align="end"
163
+ className="relative flex h-[calc(100vh-2rem)] w-(--chat-popup-width) max-w-[calc(100vw-1.5rem)] min-w-[min(440px,calc(100vw-1.5rem))] flex-col gap-0 rounded-3xl p-0 transition-[opacity,transform] sm:h-[calc(100vh-8rem)]"
164
+ keepMounted
165
+ >
166
+ {children(onClose)}
167
+ </PopoverContent>
168
+ </Resizable>
169
+ </Popover>
170
+ )
171
+ }
@@ -8,10 +8,12 @@ import type {
8
8
  } from '@/lib/types'
9
9
  import { uploadChatFile } from './composer/attachments/uploads'
10
10
  import { attachmentPart } from '@/lib/moi-attachments'
11
+ import { composerDraftKey } from '@/lib/session-drafts'
11
12
  import type { QueryClient } from '@tanstack/react-query'
12
13
 
13
14
  import { workspaceKeys } from '@/client/api/workspace-keys'
14
15
  import { attachmentKey, liveStore } from '@/client/features/chat/chat-store'
16
+ import { useUiStore } from '@/client/store/ui'
15
17
  import type { StagedAttachment } from '@/client/features/chat/composer/attachments/types'
16
18
  import { resolveSelectedModel } from '@/client/features/chat/composer/model-order'
17
19
  import type { MoiUserMessageOptions } from '@/client/features/workspace/moi-context'
@@ -161,6 +163,7 @@ export function startOptimisticTurn({
161
163
  }
162
164
 
163
165
  type StartOptimisticSessionInput = {
166
+ tabId?: SessionInfo['tabId']
164
167
  queryClient: QueryClient
165
168
  workspaceId: string
166
169
  sessionId: string
@@ -169,6 +172,7 @@ type StartOptimisticSessionInput = {
169
172
  }
170
173
 
171
174
  export function startOptimisticSession({
175
+ tabId,
172
176
  queryClient,
173
177
  workspaceId,
174
178
  sessionId,
@@ -178,7 +182,7 @@ export function startOptimisticSession({
178
182
  const summary = formatChatTitle(text, filenames)
179
183
  if (!summary) return
180
184
  queryClient.setQueryData<SessionInfo[]>(workspaceKeys.sessions(workspaceId), current => [
181
- { sessionId, summary, lastModified: Date.now() },
185
+ { sessionId, summary, lastModified: Date.now(), ...(tabId ? { tabId } : {}) },
182
186
  ...(current ?? []).filter(session => session.sessionId !== sessionId)
183
187
  ])
184
188
  }
@@ -221,3 +225,31 @@ export function resolveChatRunOptions(
221
225
  stream
222
226
  }
223
227
  }
228
+
229
+ export function moveChatDraft(workspaceId: string, from: string, to: string) {
230
+ liveStore.getState().renameSession(workspaceId, from, to)
231
+ useUiStore
232
+ .getState()
233
+ .moveComposerDraft(composerDraftKey(workspaceId, from), composerDraftKey(workspaceId, to))
234
+ }
235
+
236
+ export function prepareOptimisticSend(
237
+ input: Omit<StartOptimisticTurnInput, 'parts'> & { text: string },
238
+ ready: readonly StagedAttachment[],
239
+ prepared = prepareDraftAttachments(ready)
240
+ ) {
241
+ const parts: Part[] = [...prepared.parts]
242
+ if (input.text) parts.push({ type: 'text', text: input.text })
243
+ return {
244
+ attachments: prepared.attachments,
245
+ optimisticId: startOptimisticTurn({ ...input, parts })
246
+ }
247
+ }
248
+
249
+ export function finishComposerSend(workspaceId: string, sent: readonly StagedAttachment[]) {
250
+ // Local IDs survive native session renames. Remove only this send's snapshot,
251
+ // preserving files staged while an HTTP submission was in flight.
252
+ for (const attachment of sent)
253
+ liveStore.getState().removeAttachment(workspaceId, attachment.localId)
254
+ useUiStore.getState().markMessageSentFromMoi(workspaceId)
255
+ }
@@ -247,6 +247,16 @@ export const liveStore = createStore<LiveStore>()(set => ({
247
247
  set(s => {
248
248
  const fromKey = attachmentKey(workspaceId, from)
249
249
  const toKey = key(workspaceId, to)
250
+ if (fromKey === toKey) return s
251
+ if (
252
+ !(fromKey in s.activity) &&
253
+ !(fromKey in s.errors) &&
254
+ !(fromKey in s.attachments) &&
255
+ !Object.values(s.previews).some(
256
+ preview => preview.workspaceId === workspaceId && preview.sessionId === from
257
+ )
258
+ )
259
+ return s
250
260
  const activity = { ...s.activity }
251
261
  const errors = { ...s.errors }
252
262
  if (fromKey in activity) {
@@ -1,7 +1,7 @@
1
1
  import { IconScribble } from '@tabler/icons-react'
2
2
  import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/client/components/ui/hover-card'
3
3
  import type { StagedAttachment } from './types'
4
- import { AttachmentChip } from './AttachmentChip'
4
+ import { AttachmentChip } from './attachment-chip'
5
5
 
6
6
  type DrawingAttachmentChipProps = {
7
7
  attachment: Extract<StagedAttachment, { kind: 'drawing' }>
@@ -1,6 +1,6 @@
1
1
  import { IconFile } from '@tabler/icons-react'
2
2
  import type { StagedAttachment } from './types'
3
- import { AttachmentChip } from './AttachmentChip'
3
+ import { AttachmentChip } from './attachment-chip'
4
4
 
5
5
  type FileAttachmentChipProps = {
6
6
  attachment: Extract<StagedAttachment, { kind: 'file' }>