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.
- package/README.md +27 -27
- package/bin/moi.mjs +2 -2
- package/client/AGENTS.md +7 -4
- package/client/api/app-config.ts +3 -2
- package/client/api/app-ui-keys.ts +1 -1
- package/client/api/workspace-keys.ts +2 -4
- package/client/app/{AppRouter.tsx → app-router.tsx} +4 -4
- package/client/app/routes/{HomeRoute.tsx → home-route.tsx} +2 -2
- package/client/app/routes/{WorkspaceRoute.tsx → workspace-route.tsx} +20 -31
- package/client/app/shell/{SidebarLayout.tsx → sidebar-layout.tsx} +10 -10
- package/client/dev/index.html +43 -0
- package/client/dev/index.ts +15 -0
- package/client/features/applets/{AppletContainer.tsx → applet-container.tsx} +1 -1
- package/client/features/applets/applet-runtime.ts +11 -13
- package/client/features/applets/applet-thumbnail.ts +1 -1
- package/client/features/applets/{useApplet.ts → use-applet.ts} +2 -2
- package/client/features/applets/{WidgetShell.tsx → widget-shell.tsx} +4 -4
- package/client/features/chat/applet-chat-intents.ts +33 -14
- package/client/features/chat/{ChatPanel.tsx → chat-panel.tsx} +80 -59
- package/client/features/chat/chat-popup.tsx +171 -0
- package/client/features/chat/chat-send.ts +33 -1
- package/client/features/chat/chat-store.ts +10 -0
- package/client/features/chat/composer/attachments/{DrawingAttachmentChip.tsx → drawing-attachment-chip.tsx} +1 -1
- package/client/features/chat/composer/attachments/{FileAttachmentChip.tsx → file-attachment-chip.tsx} +1 -1
- package/client/features/chat/composer/attachments/{TextAttachmentChip.tsx → text-attachment-chip.tsx} +1 -1
- package/client/features/chat/composer/banners/{ComposerBanner.tsx → composer-banner.tsx} +0 -14
- package/client/features/chat/composer/banners/{ErrorBanner.tsx → error-banner.tsx} +1 -1
- package/client/features/chat/composer/banners/{SkillUpdateBanner.tsx → skill-update-banner.tsx} +3 -3
- package/client/features/chat/composer/{ChatComposer.tsx → chat-composer.tsx} +31 -33
- package/client/features/chat/composer/{ModelPicker.tsx → model-picker.tsx} +4 -4
- package/client/features/chat/composer/{useWorkspaceComposerState.tsx → use-workspace-composer-state.tsx} +14 -30
- package/client/features/chat/composer/{useWorkspaceSkillUpdates.ts → use-workspace-skill-updates.ts} +1 -1
- package/client/features/chat/connection/chat-frames.ts +15 -8
- package/client/features/chat/messages/{ChatEmptyState.tsx → chat-empty-state.tsx} +37 -23
- package/client/features/chat/messages/fork-history.ts +14 -0
- package/client/features/chat/messages/{MarkdownContent.tsx → markdown-content.tsx} +4 -4
- package/client/features/chat/messages/tool-group/index.ts +1 -1
- package/client/features/chat/messages/tool-group/{ReadImagePreview.tsx → read-image-preview.tsx} +2 -2
- package/client/features/chat/messages/tool-group/{SubagentCard.tsx → subagent-card.tsx} +3 -3
- package/client/features/chat/messages/tool-group/{TimelineRow.tsx → timeline-row.tsx} +1 -1
- package/client/features/chat/messages/tool-group/{ToolCallGroup.tsx → tool-call-group.tsx} +8 -8
- package/client/features/chat/messages/tool-group/{ToolOutput.tsx → tool-output.tsx} +1 -1
- package/client/features/chat/messages/{TurnView.tsx → turn-view.tsx} +4 -4
- package/client/features/chat/sessions/api.ts +109 -19
- package/client/features/chat/sessions/browser-tab-state.ts +30 -7
- package/client/features/chat/sessions/{ChatSelector.tsx → chat-selector.tsx} +139 -80
- package/client/features/chat/sessions/use-selected-session.ts +351 -0
- package/client/features/chat/{useChat.ts → use-chat.ts} +46 -48
- package/client/features/collab/client.ts +10 -11
- package/client/features/collab/hooks.tsx +6 -11
- package/client/features/collab/host-state.ts +57 -128
- package/client/features/collab/provider.tsx +3 -3
- package/client/features/collab/proxy-user.ts +1 -1
- package/client/features/collab/testing/fake-engine.ts +6 -27
- package/client/features/collab/workspace-users-menu.tsx +3 -7
- package/client/features/connectors/mcp-icons.ts +1 -1
- package/client/features/connectors/{McpServerCards.tsx → mcp-server-cards.tsx} +1 -1
- package/client/features/{home/workspace-setup/DemoDialog.tsx → demo/demo-dialog.tsx} +6 -6
- package/client/features/dev/chat-states-fixtures.ts +4 -4
- package/client/features/dev/{ChatStatesPage.tsx → chat-states-page.tsx} +6 -6
- package/client/features/dev/collab/local-user-settings.tsx +4 -4
- package/client/features/dev/{DevIndexPage.tsx → dev-index-page.tsx} +7 -1
- package/client/features/dev/{DevRoutes.tsx → dev-routes.tsx} +8 -6
- package/client/features/dev/workspace-setup-mocks.ts +102 -0
- package/client/features/dev/workspace-setup-page.tsx +11 -0
- package/client/features/dev/workspace-setup-preview.tsx +226 -0
- package/client/features/drawings/{DrawingToolbar.tsx → drawing-toolbar.tsx} +1 -1
- package/client/features/drawings/{useChatAnnotation.ts → use-chat-annotation.ts} +29 -23
- package/client/features/drawings/{useDrawingLayer.ts → use-drawing-layer.ts} +1 -1
- package/client/features/drawings/{useViewBuilderSketch.ts → use-view-sketch.ts} +8 -8
- package/client/features/harness/api.ts +36 -0
- package/client/features/harness/device-login-steps.tsx +97 -0
- package/client/features/home/api.ts +1 -81
- package/client/features/home/{HomeLogo.tsx → home-logo.tsx} +1 -1
- package/client/features/home/{HomePage.tsx → home-page.tsx} +16 -20
- package/client/features/overview/api.ts +2 -2
- package/client/features/overview/default/registry.tsx +3 -5
- package/client/features/overview/default/{ViewsWidget.tsx → views-widget.tsx} +6 -13
- package/client/features/overview/{HiddenPanel.tsx → hidden-panel.tsx} +2 -2
- package/client/features/overview/{Overview.tsx → overview.tsx} +9 -12
- package/client/features/overview/{WidgetCanvas.tsx → widget-canvas.tsx} +1 -1
- package/client/features/overview/{WidgetFrame.tsx → widget-frame.tsx} +1 -1
- package/client/features/overview/workspace-name.tsx +55 -0
- package/client/features/scratchpad/{Scratchpad.tsx → scratchpad.tsx} +7 -7
- package/client/features/scratchpad/{useScratchpadSnapshot.tsx → use-scratchpad-snapshot.tsx} +3 -3
- package/client/features/settings/api.ts +1 -1
- package/client/features/settings/{ConnectorsSettings.tsx → connectors-settings.tsx} +3 -3
- package/client/features/settings/{EnvironmentSettings.tsx → environment-settings.tsx} +3 -3
- package/client/features/settings/{GeneralSettings.tsx → general-settings.tsx} +5 -5
- package/client/features/settings/{useEnvVars.ts → use-env-vars.ts} +1 -1
- package/client/features/settings/{WorkspaceIconPicker.tsx → workspace-icon-picker.tsx} +1 -1
- package/client/features/settings/{WorkspaceSettingsDialog.tsx → workspace-settings-dialog.tsx} +3 -3
- package/client/features/update/api.ts +1 -1
- package/client/features/views/api.ts +64 -131
- package/client/features/views/pending-view-screen.tsx +282 -0
- package/client/features/views/use-view-actions.ts +151 -0
- package/client/features/views/use-view-drafts.ts +88 -0
- package/client/features/views/{ViewManager.tsx → view-manager.tsx} +13 -13
- package/client/features/views/view-presentation.ts +4 -5
- package/client/features/views/view-submission.ts +88 -0
- package/client/features/workspace/add/api.ts +80 -0
- package/client/features/{home/workspace-setup/CreateWorkspaceDialog.tsx → workspace/add/create-workspace-dialog.tsx} +56 -42
- package/client/features/workspace/add/import-workspace-dialog.tsx +81 -0
- package/client/features/{home/workspace-setup/useWorkspaceImport.ts → workspace/add/use-workspace-import.ts} +1 -1
- package/client/features/workspace/add/workspace-agent-options.ts +53 -0
- package/client/features/{home/workspace-setup/WorkspaceAgentStep.tsx → workspace/add/workspace-agent-selector.tsx} +59 -98
- package/client/features/{home/workspace-setup/WorkspaceDialogContent.tsx → workspace/add/workspace-dialog-content.tsx} +1 -1
- package/client/features/workspace/api.ts +24 -15
- package/client/features/workspace/browser-tab-state.ts +16 -9
- package/client/features/workspace/moi-context.ts +14 -16
- package/client/features/workspace/setup/workspace-login-state.tsx +175 -0
- package/client/features/workspace/setup/workspace-recovery-states.tsx +125 -0
- package/client/features/workspace/setup/workspace-setup-panel.tsx +18 -0
- package/client/features/workspace/setup/workspace-setup.tsx +77 -0
- package/client/features/workspace/setup/workspace-welcome-state.tsx +81 -0
- package/client/features/workspace/tab-resolution.ts +16 -29
- package/client/features/workspace/{ThemePanel.tsx → theme-panel.tsx} +3 -3
- package/client/features/workspace/use-workspace-navigation.ts +245 -0
- package/client/features/workspace/workspace-content.tsx +641 -0
- package/client/features/workspace/workspace-identity.tsx +40 -0
- package/client/features/workspace/workspace-menu.tsx +63 -0
- package/client/features/{home → workspace}/workspace-presentation.tsx +10 -3
- package/client/features/workspace/workspace-screen.tsx +28 -0
- package/client/features/workspace/{WorkspaceSplitLayout.tsx → workspace-split-layout.tsx} +1 -1
- package/client/features/workspace/{WorkspaceTabs.tsx → workspace-tabs.tsx} +2 -2
- package/client/index.css +2 -2
- package/client/index.html +1 -1
- package/client/index.tsx +5 -1
- package/client/lib/agent-availability.ts +0 -5
- package/client/main.tsx +1 -1
- package/client/runtime/{useWorkspaceEvents.ts → use-workspace-events.ts} +10 -18
- package/client/store/ui.ts +25 -29
- package/dist/chunk-08ndj2rg.js +2 -0
- package/dist/chunk-2x040tmg.js +68 -0
- package/dist/chunk-3smxq0ts.js +1 -0
- package/dist/chunk-68ch5hs8.js +2 -0
- package/dist/{chunk-z3byfve5.js → chunk-9vg3xa81.js} +2 -2
- package/dist/chunk-c2p00p9j.css +1 -0
- package/dist/chunk-cs833y9j.js +1 -0
- package/dist/{chunk-97eg9mjn.js → chunk-d7cbm65e.js} +1 -1
- package/dist/{chunk-efdyz6xp.js → chunk-hvh9f5h0.js} +1 -1
- package/dist/{chunk-vfpsc75k.js → chunk-jvyvwwv3.js} +1 -1
- package/dist/chunk-nwevqe86.js +10 -0
- package/dist/{chunk-3a48fyf7.js → chunk-q0gbdts4.js} +4 -4
- package/dist/chunk-rt30jbcm.js +1 -0
- package/dist/chunk-y5y3kj67.js +1 -0
- package/dist/index.html +2 -2
- package/lib/format.ts +1 -1
- package/lib/harness-instructions.ts +30 -0
- package/lib/ids.ts +3 -6
- package/lib/moi-context.ts +102 -75
- package/lib/navigation.ts +48 -87
- package/lib/scratchpad-skew.ts +3 -3
- package/lib/session-drafts.ts +10 -0
- package/lib/types.ts +92 -51
- package/lib/update.ts +1 -1
- package/lib/view-build-directives.ts +12 -0
- package/lib/workspace-layout.ts +1 -1
- package/lib/workspace-tabs.ts +12 -7
- package/package.json +7 -2
- package/server/AGENTS.md +10 -4
- package/server/README.md +102 -0
- package/server/agent-launcher.ts +27 -0
- package/server/api/harnesses.ts +56 -0
- package/server/{api.ts → api/index.ts} +197 -299
- package/server/app-config.ts +45 -14
- package/server/app-settings.ts +1 -1
- package/server/applets/applet-css.ts +1 -1
- package/server/applets/build-applet.ts +4 -4
- package/server/applets/build-worker.ts +3 -2
- package/server/applets/config.ts +1 -1
- package/server/{functions-worker.ts → applets/functions-worker.ts} +1 -1
- package/server/{functions.ts → applets/functions.ts} +3 -2
- package/server/applets/index.ts +2 -2
- package/server/{thumbnails.ts → applets/thumbnails.ts} +1 -1
- package/server/{applet-typecheck.ts → applets/typecheck.ts} +4 -4
- package/server/{ui-components.ts → applets/ui-components.ts} +2 -2
- package/server/applets/view-source.ts +7 -1
- package/server/{views.ts → applets/views.ts} +35 -46
- package/server/{widgets.ts → applets/widgets.ts} +2 -2
- package/server/cli/applet-selector.ts +19 -0
- package/server/cli/args.ts +5 -0
- package/server/{cli-colors.ts → cli/colors.ts} +1 -1
- package/server/cli/commands/bundle.ts +119 -0
- package/server/cli/commands/call-server-fn.ts +42 -0
- package/server/cli/commands/check.ts +53 -0
- package/server/cli/commands/config.ts +132 -0
- package/server/cli/commands/debug.ts +119 -0
- package/server/cli/commands/env.ts +162 -0
- package/server/cli/commands/hermes.ts +149 -0
- package/server/cli/commands/init.ts +286 -0
- package/server/cli/commands/navigate.ts +35 -0
- package/server/cli/commands/openclaw.ts +168 -0
- package/server/cli/commands/refresh.ts +39 -0
- package/server/cli/commands/scratch.ts +496 -0
- package/server/cli/commands/service.ts +298 -0
- package/server/cli/commands/skill.ts +122 -0
- package/server/cli/commands/start.ts +138 -0
- package/server/cli/commands/status.ts +80 -0
- package/server/cli/commands/tabs.ts +43 -0
- package/server/cli/commands/theme.ts +192 -0
- package/server/cli/commands/ui-components.ts +15 -0
- package/server/cli/commands/update.ts +192 -0
- package/server/cli/commands/version.ts +9 -0
- package/server/cli/commands/views.ts +87 -0
- package/server/cli/control.ts +89 -0
- package/server/{cli-env.ts → cli/env.ts} +78 -56
- package/server/cli/index.ts +171 -0
- package/server/{cli-pc.ts → cli/pc.ts} +1 -1
- package/server/cli/provider.ts +25 -0
- package/server/cli/server-version.ts +16 -0
- package/server/cli/server.ts +81 -0
- package/server/{cli-ui-components.ts → cli/ui-components.ts} +5 -5
- package/server/cli.ts +2 -3215
- package/server/collab/manager.ts +3 -3
- package/server/collab/skill/index.ts +2 -2
- package/server/control.ts +97 -78
- package/server/data-dir.ts +13 -0
- package/server/harness/README.md +55 -25
- package/server/harness/acp/NOTES.md +11 -11
- package/server/harness/acp/adapter.ts +2 -2
- package/server/harness/acp/archived.ts +3 -3
- package/server/harness/acp/client.ts +4 -3
- package/server/harness/acp/discovery.ts +3 -3
- package/server/harness/acp/run-durations.ts +1 -1
- package/server/harness/acp/session.ts +9 -12
- package/server/harness/auth.ts +303 -0
- package/server/harness/claude-code/NOTES.md +9 -7
- package/server/harness/claude-code/adapter.ts +13 -8
- package/server/harness/claude-code/auth.ts +127 -18
- package/server/harness/claude-code/cli.ts +3 -1
- package/server/harness/claude-code/git-worktree.ts +5 -2
- package/server/harness/claude-code/index.ts +7 -1
- package/server/harness/claude-code/mcp.ts +3 -1
- package/server/harness/claude-code/models.ts +2 -0
- package/server/harness/claude-code/session.ts +13 -39
- package/server/harness/claude-code/sessions.ts +8 -12
- package/server/harness/codex/NOTES.md +35 -16
- package/server/harness/codex/adapter.ts +5 -3
- package/server/harness/codex/auth.ts +86 -19
- package/server/harness/codex/client.ts +30 -34
- package/server/harness/codex/index.ts +20 -1
- package/server/harness/codex/permissions.ts +3 -3
- package/server/harness/codex/probe.ts +3 -5
- package/server/harness/codex/session.ts +20 -25
- package/server/harness/codex/thread-list.ts +74 -0
- package/server/harness/codex/transport.ts +5 -5
- package/server/harness/executable.ts +42 -18
- package/server/harness/fork.ts +12 -0
- package/server/harness/hermes/NOTES.md +70 -70
- package/server/harness/hermes/discovery.ts +1 -1
- package/server/harness/openclaw/NOTES.md +24 -24
- package/server/harness/openclaw/adapter.ts +4 -4
- package/server/harness/openclaw/compat.ts +1 -1
- package/server/harness/openclaw/session.ts +6 -31
- package/server/harness/registry.ts +1 -1
- package/server/harness/session-title.ts +12 -3
- package/server/harness/shell-path.ts +31 -21
- package/server/harness/types.ts +17 -5
- package/server/navigation-relay.ts +1 -1
- package/server/open-browser.ts +7 -0
- package/server/{scratchpad-assets.ts → scratchpad/assets.ts} +4 -4
- package/server/{scratchpad.ts → scratchpad/document.ts} +8 -8
- package/server/{scratchpad-executor.ts → scratchpad/executor.ts} +7 -7
- package/server/{scratchpad-relay.ts → scratchpad/relay.ts} +4 -5
- package/server/{scratchpad-shape-defaults.ts → scratchpad/shape-defaults.ts} +2 -2
- package/server/server-cwd.ts +1 -1
- package/server/service.ts +18 -4
- package/server/sessions/archive.ts +32 -0
- package/server/{attachment-message.ts → sessions/attachment-message.ts} +1 -1
- package/server/sessions/config.ts +41 -0
- package/server/sessions/lifecycle.ts +17 -0
- package/server/sessions/pending-views.ts +164 -0
- package/server/sessions/selected.ts +199 -0
- package/server/sessions/store.ts +127 -0
- package/server/sessions/view-sessions.ts +267 -0
- package/server/{skills-template.ts → skills/template.ts} +1 -1
- package/server/{skill-update.ts → skills/update.ts} +5 -5
- package/server/{skill-version.ts → skills/version.ts} +4 -4
- package/server/static.ts +1 -1
- package/server/status.ts +6 -4
- package/server/web.ts +58 -49
- package/server/{env-apply.ts → workspaces/env-apply.ts} +5 -5
- package/server/{workspace-env.ts → workspaces/env.ts} +30 -3
- package/server/{workspace-import.ts → workspaces/import.ts} +4 -4
- package/server/{workspace-init.ts → workspaces/init.ts} +10 -6
- package/server/{layout.ts → workspaces/layout.ts} +2 -2
- package/server/{preview.ts → workspaces/preview.ts} +1 -1
- package/server/{registry.ts → workspaces/registry.ts} +17 -7
- package/server/{required-env.ts → workspaces/required-env.ts} +3 -3
- package/server/{moi-scaffold.ts → workspaces/scaffold.ts} +4 -3
- package/server/{tabs.ts → workspaces/tabs.ts} +7 -10
- package/ui-components/button.tsx +1 -1
- package/ui-components/docs/attachment.md +2 -2
- package/ui-components/docs/button.md +1 -1
- package/ui-components/docs/calendar.md +1 -1
- package/ui-components/docs/chart.md +4 -4
- package/ui-components/docs/data-table.md +1 -1
- package/ui-components/docs/drawer.md +1 -1
- package/ui-components/docs/field.md +1 -1
- package/ui-components/docs/input.md +2 -2
- package/ui-components/docs/label.md +2 -2
- package/ui-components/docs/table.md +2 -2
- package/workspace/.claude/skills/moi-workspace/SKILL.md +61 -32
- package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +4 -7
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +2 -2
- package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +2 -2
- package/client/features/chat/ChatPopup.tsx +0 -98
- package/client/features/chat/composer/banners/AgentAvailabilityBanner.tsx +0 -101
- package/client/features/chat/sessions/useSelectedSession.ts +0 -185
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +0 -92
- package/client/features/overview/WorkspaceName.tsx +0 -60
- package/client/features/views/ViewBuilder.tsx +0 -239
- package/client/features/views/useViewBuilderActions.ts +0 -103
- package/client/features/views/useViewBuilderDrafts.ts +0 -68
- package/client/features/workspace/WorkspaceScreen.tsx +0 -839
- package/client/features/workspace/useWorkspaceNavigation.ts +0 -203
- package/dist/chunk-2jncyq65.js +0 -1
- package/dist/chunk-e2q5ken7.js +0 -68
- package/dist/chunk-h2kj1ysj.js +0 -1
- package/dist/chunk-jf6czgrz.js +0 -2
- package/dist/chunk-nez8sdta.js +0 -1
- package/dist/chunk-nzwgm8vc.css +0 -1
- package/dist/chunk-ph0h6h86.js +0 -1
- package/dist/chunk-ryg9z3kn.js +0 -10
- package/dist/chunk-tpn177bt.js +0 -2
- package/lib/view-builder-directives.ts +0 -16
- package/server/agent.ts +0 -223
- package/server/chat-selection.ts +0 -22
- package/server/selected-session.ts +0 -152
- package/server/session-config.ts +0 -136
- package/server/view-builders.ts +0 -453
- /package/client/components/shared/{AgentBlobatar.tsx → agent-blobatar.tsx} +0 -0
- /package/client/components/shared/{BottomPanel.tsx → bottom-panel.tsx} +0 -0
- /package/client/components/shared/{Composer.tsx → composer.tsx} +0 -0
- /package/client/components/shared/{LedLogo.tsx → led-logo.tsx} +0 -0
- /package/client/components/shared/{PanelHeader.tsx → panel-header.tsx} +0 -0
- /package/client/components/shared/{ReorderableList.tsx → reorderable-list.tsx} +0 -0
- /package/client/components/shared/{WorkspaceIcon.tsx → workspace-icon.tsx} +0 -0
- /package/client/features/applets/{WidgetErrorBoundary.tsx → widget-error-boundary.tsx} +0 -0
- /package/client/features/chat/composer/attachments/{AttachmentChip.tsx → attachment-chip.tsx} +0 -0
- /package/client/features/chat/messages/{ChatPromptBubbles.tsx → chat-prompt-bubbles.tsx} +0 -0
- /package/client/features/chat/messages/{ShimmerText.tsx → shimmer-text.tsx} +0 -0
- /package/client/features/chat/messages/tool-group/{CodeBlock.tsx → code-block.tsx} +0 -0
- /package/client/features/chat/messages/tool-group/{Collapse.tsx → collapse.tsx} +0 -0
- /package/client/features/chat/messages/{useStickToBottom.ts → use-stick-to-bottom.ts} +0 -0
- /package/client/features/connectors/{IconMcp.tsx → icon-mcp.tsx} +0 -0
- /package/client/features/dev/{BlobatarShapesPage.tsx → blobatar-shapes-page.tsx} +0 -0
- /package/client/features/dev/{HarnessDebugPage.tsx → harness-debug-page.tsx} +0 -0
- /package/client/features/dev/{TextureLabPage.tsx → texture-lab-page.tsx} +0 -0
- /package/client/features/dev/{ToolCallsPage.tsx → tool-calls-page.tsx} +0 -0
- /package/client/features/drawings/{DrawingLayer.tsx → drawing-layer.tsx} +0 -0
- /package/client/features/home/{WorkspacePreview.tsx → workspace-preview.tsx} +0 -0
- /package/client/features/overview/{useGridReconcile.ts → use-grid-reconcile.ts} +0 -0
- /package/client/features/scratchpad/{ScratchpadControls.tsx → scratchpad-controls.tsx} +0 -0
- /package/client/features/settings/{SettingsLayout.tsx → settings-layout.tsx} +0 -0
- /package/client/features/update/{UpdateControl.tsx → update-control.tsx} +0 -0
- /package/client/features/workspace/{UnavailablePage.tsx → unavailable-page.tsx} +0 -0
- /package/client/features/workspace/{useFitsSplitLayout.ts → use-fits-split-layout.ts} +0 -0
- /package/client/features/workspace/{WorkspaceContext.tsx → workspace-context.tsx} +0 -0
- /package/client/features/workspace/{WorkspaceLayoutContext.tsx → workspace-layout-context.tsx} +0 -0
- /package/server/{bundle-queue.ts → applets/bundle-queue.ts} +0 -0
- /package/server/{applet-log.ts → applets/log.ts} +0 -0
- /package/server/{cli-ui.ts → cli/ui.ts} +0 -0
- /package/server/{workspace-config.ts → workspaces/config.ts} +0 -0
- /package/server/{icon.ts → workspaces/icon.ts} +0 -0
- /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 {
|
|
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,
|
|
20
|
-
import {
|
|
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
|
|
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<
|
|
62
|
-
|
|
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.
|
|
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:
|
|
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/
|
|
6
|
-
import { AgentBlobatar } from '@/client/components/shared/
|
|
7
|
-
import { useStickToBottom } from '@/client/features/chat/messages/
|
|
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/
|
|
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/
|
|
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/
|
|
20
|
-
import { ChatComposer, type ComposerAnnotationControls } from './composer/
|
|
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/
|
|
26
|
-
import { ChatSelector } from './sessions/
|
|
27
|
-
import {
|
|
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
|
|
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
|
-
|
|
69
|
-
|
|
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
|
-
|
|
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 =
|
|
100
|
-
const modelSessionId =
|
|
101
|
-
const 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
|
|
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 =
|
|
118
|
-
const 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 =
|
|
132
|
+
const effectiveProcessing = viewDraft ? false : processing
|
|
130
133
|
const showEmptyState =
|
|
131
|
-
!!
|
|
134
|
+
!!viewDraft ||
|
|
135
|
+
(!forkedFromSessionId && chatLoaded && timeline.length === 0 && !effectiveProcessing)
|
|
132
136
|
const showTranscript = chatLoaded && !showEmptyState
|
|
133
137
|
const emptyStateKind = resolveChatEmptyState({
|
|
134
|
-
|
|
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'
|
|
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
|
-
|
|
157
|
-
else send(text, options)
|
|
162
|
+
await send(text, options)
|
|
158
163
|
scrollToBottom()
|
|
159
164
|
},
|
|
160
|
-
[
|
|
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="
|
|
174
|
-
<div className="min-w-0 flex-1">
|
|
175
|
-
<ChatSelector
|
|
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
|
-
{
|
|
182
|
+
{docked && (
|
|
178
183
|
<Tooltip>
|
|
179
184
|
<TooltipTrigger
|
|
180
185
|
render={
|
|
181
|
-
<Button variant="ghost" size="icon-sm" onClick={onClose} aria-label="Undock
|
|
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
|
|
191
|
+
<TooltipContent>Undock chat</TooltipContent>
|
|
187
192
|
</Tooltip>
|
|
188
193
|
)}
|
|
189
|
-
{!
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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 './
|
|
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 './
|
|
3
|
+
import { AttachmentChip } from './attachment-chip'
|
|
4
4
|
|
|
5
5
|
type FileAttachmentChipProps = {
|
|
6
6
|
attachment: Extract<StagedAttachment, { kind: 'file' }>
|