moi-computer 0.11.0 → 0.11.1-dev.1c52199
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 +2 -2
- package/client/AGENTS.md +2 -2
- package/client/api/app-config.ts +2 -1
- package/client/app/AppRouter.tsx +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +33 -27
- package/client/app/shell/SidebarLayout.tsx +18 -15
- package/client/components/shared/BottomPanel.tsx +26 -14
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/components/shared/ReorderableList.tsx +7 -2
- package/client/components/shared/WorkspaceIcon.tsx +92 -0
- package/client/components/ui/alert-dialog.tsx +1 -0
- package/client/components/ui/button.tsx +1 -53
- package/client/components/ui/checkbox.tsx +1 -0
- package/client/components/ui/collapsible.tsx +1 -15
- package/client/components/ui/dialog.tsx +1 -58
- package/client/components/ui/dropdown-menu.tsx +1 -254
- package/client/components/ui/hover-card.tsx +1 -44
- package/client/components/ui/inline-input.tsx +84 -0
- package/client/components/ui/input.tsx +1 -21
- package/client/components/ui/popover.tsx +1 -88
- package/client/components/ui/resizable.tsx +1 -40
- package/client/components/ui/skeleton.tsx +1 -13
- package/client/components/ui/slider.tsx +1 -70
- package/client/components/ui/spinner.tsx +1 -18
- package/client/components/ui/switch.tsx +1 -23
- package/client/components/ui/tabs.tsx +1 -0
- package/client/components/ui/textarea.tsx +1 -18
- package/client/components/ui/toast.tsx +2 -2
- package/client/components/ui/tooltip.tsx +1 -51
- package/client/features/applets/AppletMount.tsx +5 -2
- package/client/features/applets/applet-cache.ts +3 -3
- package/client/features/applets/applet-runtime.ts +158 -108
- package/client/features/applets/applet-styles.ts +2 -2
- package/client/features/applets/applet-thumbnail.ts +6 -8
- package/client/features/applets/useApplet.ts +10 -9
- package/client/features/chat/ChatPanel.tsx +24 -15
- package/client/features/chat/ChatPopup.tsx +9 -5
- package/client/features/chat/applet-chat-intents.ts +179 -0
- package/client/features/chat/chat-send.ts +116 -64
- package/client/features/chat/chat-store.ts +51 -62
- package/client/features/chat/composer/ChatComposer.tsx +43 -128
- package/client/features/chat/composer/ModelPicker.tsx +47 -60
- package/client/features/chat/composer/attachments/AttachmentChip.tsx +99 -0
- package/client/features/chat/composer/attachments/DrawingAttachmentChip.tsx +37 -0
- package/client/features/chat/composer/attachments/FileAttachmentChip.tsx +22 -0
- package/client/features/chat/composer/attachments/TextAttachmentChip.tsx +11 -0
- package/client/features/chat/composer/attachments/draft-attachments.ts +168 -0
- package/client/features/chat/composer/attachments/types.ts +25 -0
- package/client/features/chat/composer/attachments/uploads.ts +26 -0
- package/client/features/chat/composer/banners/ErrorBanner.tsx +20 -12
- package/client/features/chat/composer/model-order.ts +15 -0
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +15 -7
- package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
- package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +10 -8
- package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
- package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
- package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +27 -19
- package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +12 -0
- package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +7 -11
- package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
- package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
- package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +2 -5
- package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +4 -1
- package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
- package/client/features/chat/{api.ts → sessions/api.ts} +5 -14
- package/client/features/chat/sessions/session-view.ts +53 -0
- package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +64 -20
- package/client/features/chat/useChat.ts +46 -24
- package/client/features/collab/DevCollabIdentity.tsx +170 -0
- package/client/features/collab/DevCollabKit.tsx +501 -0
- package/client/features/collab/DevCollabPage.tsx +25 -0
- package/client/features/collab/WorkspaceCollabControls.tsx +313 -0
- package/client/features/collab/client.ts +146 -0
- package/client/features/collab/components.tsx +307 -0
- package/client/features/collab/dev-persona.ts +66 -0
- package/client/features/collab/engine.ts +96 -0
- package/client/features/collab/entry.tsx +35 -0
- package/client/features/collab/facehash-avatar.ts +132 -0
- package/client/features/collab/fake-engine.ts +130 -0
- package/client/features/collab/hooks.tsx +253 -0
- package/client/features/collab/identity.ts +305 -0
- package/client/features/collab/index.ts +45 -0
- package/client/features/collab/people.ts +102 -0
- package/client/features/collab/personal-state.ts +61 -0
- package/client/features/collab/presence-publisher.ts +29 -0
- package/client/features/collab/presence-target.ts +10 -0
- package/client/features/collab/primitives.tsx +398 -0
- package/client/features/collab/proxy-identity.ts +24 -0
- package/client/features/collab/store.ts +156 -0
- package/client/features/dev/ChatStatesPage.tsx +8 -7
- package/client/features/dev/DevIndexPage.tsx +10 -0
- package/client/features/dev/DevRoutes.tsx +16 -1
- package/client/features/dev/HarnessDebugPage.tsx +11 -8
- package/client/features/dev/ToolCallsPage.tsx +1 -1
- package/client/features/dev/UiComponentPreviews.tsx +855 -0
- package/client/features/dev/UiComponentsPage.tsx +60 -0
- package/client/features/dev/chat-states-fixtures.ts +13 -2
- package/client/features/drawings/useChatAnnotation.ts +17 -17
- package/client/features/drawings/useDrawingLayer.ts +7 -9
- package/client/features/drawings/useViewBuilderSketch.ts +18 -15
- package/client/features/home/HomePage.tsx +8 -7
- package/client/features/home/WorkspacePreview.tsx +2 -2
- package/client/features/home/workspace-presentation.tsx +1 -11
- package/client/features/home/workspace-setup/DemoDialog.tsx +3 -2
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +5 -8
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
- package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +7 -20
- package/client/features/overview/HiddenPanel.tsx +109 -0
- package/client/features/overview/Overview.tsx +302 -0
- package/client/features/overview/WidgetCanvas.tsx +164 -0
- package/client/features/{widgets → overview}/WidgetFrame.tsx +25 -17
- package/client/features/overview/WorkspaceName.tsx +60 -0
- package/client/features/overview/api.ts +30 -0
- package/client/features/overview/default/ViewsWidget.tsx +252 -0
- package/client/features/overview/default/registry.tsx +36 -0
- package/client/features/{widgets → overview}/grid.ts +36 -0
- package/client/features/overview/useGridReconcile.ts +94 -0
- package/client/features/scratchpad/Scratchpad.tsx +7 -8
- package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
- package/client/features/settings/GeneralSettings.tsx +55 -58
- package/client/features/settings/SettingsLayout.tsx +2 -2
- package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
- package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
- package/client/features/settings/api.ts +48 -24
- package/client/features/views/ViewBuilder.tsx +5 -4
- package/client/features/views/ViewManager.tsx +28 -22
- package/client/features/views/api.ts +36 -2
- package/client/features/views/useViewBuilderActions.ts +11 -5
- package/client/features/views/useViewBuilderDrafts.ts +23 -21
- package/client/features/views/view-presentation.ts +13 -0
- package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
- package/client/features/workspace/UnavailablePage.tsx +21 -0
- package/client/features/workspace/WorkspaceLayoutContext.tsx +22 -10
- package/client/features/workspace/WorkspaceScreen.tsx +228 -172
- package/client/features/workspace/WorkspaceSplitLayout.tsx +7 -2
- package/client/features/workspace/WorkspaceTabs.tsx +2 -0
- package/client/features/workspace/api.ts +5 -31
- package/client/features/workspace/layout-save.ts +13 -0
- package/client/features/workspace/moi-context.ts +15 -11
- package/client/features/workspace/tab-resolution.ts +10 -33
- package/client/features/workspace/useWorkspaceNavigation.ts +173 -101
- package/client/index.css +23 -30
- package/client/index.tsx +4 -3
- package/client/lib/app-icon-registry.ts +2 -0
- package/client/lib/use-latest-ref.ts +11 -0
- package/client/main.tsx +1 -1
- package/client/runtime/useWorkspaceEvents.ts +59 -14
- package/client/theme.css +5 -5
- package/dist/chunk-1ftessc8.js +2 -0
- package/dist/chunk-3802vh2p.js +2 -0
- package/dist/chunk-542a2m9m.js +1 -0
- package/dist/chunk-5745d83v.js +2 -0
- package/dist/chunk-5zxdsjym.js +1 -0
- package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
- package/dist/chunk-7r4z77ry.js +2 -0
- package/dist/chunk-9cm0wjah.js +79 -0
- package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
- package/dist/chunk-cvgdm1hq.js +2 -0
- package/dist/chunk-gptm4jpd.js +546 -0
- package/dist/chunk-nf2wkvf9.js +14 -0
- package/dist/chunk-wnmf38ta.js +5 -0
- package/dist/chunk-xaehhr1j.css +1 -0
- package/dist/chunk-xpt063fx.js +1 -0
- package/dist/index.html +1 -1
- package/lib/app-icons.ts +1 -0
- package/lib/applet-selector.ts +24 -0
- package/lib/chat-title.ts +6 -1
- package/lib/collab/colors.ts +24 -0
- package/lib/collab/protocol.ts +83 -0
- package/lib/collab/types.ts +63 -0
- package/lib/default-widgets.ts +32 -0
- package/lib/experimental.ts +14 -0
- package/lib/format.ts +67 -7
- package/lib/message-attachments.ts +40 -0
- package/lib/moi-attachments.ts +204 -0
- package/lib/moi-context.ts +27 -35
- package/lib/navigation.ts +84 -0
- package/lib/themes.ts +6 -6
- package/lib/types.ts +103 -40
- package/lib/workspace-icon.ts +20 -0
- package/lib/workspace-layout.ts +22 -2
- package/lib/workspace-tabs.ts +9 -33
- package/package.json +44 -32
- package/registry.json +656 -0
- package/server/AGENTS.md +2 -0
- package/server/agent.ts +1 -1
- package/server/api.ts +162 -68
- package/server/app-config.ts +127 -34
- package/server/applet-typecheck.ts +100 -0
- package/server/applets/applet-css.ts +55 -0
- package/server/{bundler → applets}/build-applet.ts +21 -240
- package/server/applets/build-worker.ts +178 -0
- package/server/applets/config.ts +226 -0
- package/server/applets/dependencies.ts +206 -0
- package/server/{applets.ts → applets/index.ts} +44 -189
- package/server/applets/runtime/base.ts +4 -0
- package/server/applets/runtime/moi.ts +42 -0
- package/server/applets/runtime/rpc.ts +17 -0
- package/server/applets/view-source.ts +67 -0
- package/server/attachment-message.ts +95 -0
- package/server/chat-selection.ts +23 -0
- package/server/cli-ui-components.ts +28 -33
- package/server/cli.ts +226 -120
- package/server/collab/applet-module.ts +50 -0
- package/server/collab/cloudflare-access.ts +77 -0
- package/server/collab/config.ts +18 -0
- package/server/collab/ipc.ts +10 -0
- package/server/collab/manager.ts +407 -0
- package/server/collab/service.ts +137 -0
- package/server/collab/skill/collab-env.d.ts +92 -0
- package/server/collab/skill/index.ts +59 -0
- package/server/collab/worker.ts +52 -0
- package/server/control.ts +63 -42
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +45 -50
- package/server/harness/acp/NOTES.md +426 -0
- package/server/harness/acp/adapter.ts +7 -21
- package/server/harness/acp/discovery.ts +27 -30
- package/server/harness/acp/model-state.ts +57 -0
- package/server/harness/acp/session.ts +49 -56
- package/server/harness/claude-code/NOTES.md +54 -13
- package/server/harness/claude-code/adapter.ts +8 -25
- package/server/harness/claude-code/cli.ts +40 -0
- package/server/harness/claude-code/index.ts +13 -5
- package/server/harness/claude-code/models.ts +72 -19
- package/server/harness/claude-code/session.ts +447 -343
- package/server/harness/claude-code/sessions.ts +9 -4
- package/server/harness/codex/NOTES.md +222 -350
- package/server/harness/codex/adapter.ts +102 -52
- package/server/harness/codex/auth.ts +1 -3
- package/server/harness/codex/client.ts +169 -249
- package/server/harness/codex/discovery.ts +9 -17
- package/server/harness/codex/index.ts +3 -1
- package/server/harness/codex/pagination.ts +24 -0
- package/server/harness/codex/permissions.ts +32 -8
- package/server/harness/codex/probe.ts +10 -13
- package/server/harness/codex/session.ts +567 -181
- package/server/harness/codex/transport.ts +184 -0
- package/server/harness/debug.ts +1 -1
- package/server/harness/hermes/NOTES.md +19 -1
- package/server/harness/hermes/discovery.ts +20 -0
- package/server/harness/hermes/index.ts +13 -0
- package/server/harness/hermes/models.ts +28 -8
- package/server/harness/openclaw/NOTES.md +1 -1
- package/server/harness/openclaw/adapter.ts +22 -4
- package/server/harness/openclaw/gateway.ts +5 -3
- package/server/harness/openclaw/session.ts +27 -27
- package/server/harness/types.ts +9 -5
- package/server/layout.ts +24 -16
- package/server/moi-scaffold.ts +22 -14
- package/server/navigation-relay.ts +110 -0
- package/server/preview.ts +3 -1
- package/server/registry.ts +71 -41
- package/server/scratchpad-executor.ts +79 -56
- package/server/scratchpad-shape-defaults.ts +82 -0
- package/server/selected-session.ts +24 -4
- package/server/skill-update.ts +5 -3
- package/server/skill-version.ts +4 -7
- package/server/skills-template.ts +60 -9
- package/server/tabs.ts +19 -33
- package/server/tldraw-package.d.ts +4 -0
- package/server/ui-components.ts +101 -434
- package/server/uploads.ts +0 -0
- package/server/view-builders.ts +20 -2
- package/server/views.ts +126 -6
- package/server/web.ts +108 -30
- package/server/widgets.ts +12 -5
- package/server/workspace-config.ts +13 -9
- package/server/workspace-env.ts +3 -2
- package/tsconfig.json +0 -1
- package/ui-components/accordion.tsx +71 -0
- package/ui-components/alert-dialog.tsx +165 -0
- package/ui-components/alert.tsx +68 -0
- package/ui-components/attachment.tsx +195 -0
- package/ui-components/avatar.tsx +91 -0
- package/ui-components/badge.tsx +49 -0
- package/ui-components/button-group.tsx +78 -0
- package/ui-components/button.tsx +55 -0
- package/ui-components/calendar.tsx +180 -0
- package/ui-components/card.tsx +84 -0
- package/ui-components/carousel.tsx +235 -0
- package/ui-components/chart.tsx +338 -0
- package/ui-components/checkbox.tsx +28 -0
- package/ui-components/collapsible.tsx +15 -0
- package/ui-components/combobox.tsx +267 -0
- package/ui-components/context-menu.tsx +244 -0
- package/ui-components/dialog.tsx +138 -0
- package/ui-components/docs/accordion.md +463 -0
- package/ui-components/docs/alert-dialog.md +481 -0
- package/ui-components/docs/alert.md +301 -0
- package/ui-components/docs/attachment.md +689 -0
- package/ui-components/docs/avatar.md +495 -0
- package/ui-components/docs/badge.md +258 -0
- package/ui-components/docs/button-group.md +879 -0
- package/ui-components/docs/button.md +26 -0
- package/ui-components/docs/calendar.md +862 -0
- package/ui-components/docs/card.md +265 -0
- package/ui-components/docs/carousel.md +627 -0
- package/ui-components/docs/chart.md +1256 -0
- package/ui-components/docs/checkbox.md +477 -0
- package/ui-components/docs/collapsible.md +446 -0
- package/ui-components/docs/combobox.md +1003 -0
- package/ui-components/docs/context-menu.md +860 -0
- package/ui-components/docs/data-table.md +1580 -0
- package/ui-components/docs/date-picker.md +614 -0
- package/ui-components/docs/dialog.md +414 -0
- package/ui-components/docs/drawer.md +51 -0
- package/ui-components/docs/dropdown-menu.md +1000 -0
- package/ui-components/docs/field.md +1192 -0
- package/ui-components/docs/hover-card.md +275 -0
- package/ui-components/docs/input-group.md +866 -0
- package/ui-components/docs/input.md +456 -0
- package/ui-components/docs/kbd.md +191 -0
- package/ui-components/docs/label.md +295 -0
- package/ui-components/docs/pagination.md +416 -0
- package/ui-components/docs/popover.md +348 -0
- package/ui-components/docs/progress.md +214 -0
- package/ui-components/docs/radio-group.md +389 -0
- package/ui-components/docs/resizable.md +265 -0
- package/ui-components/docs/select.md +616 -0
- package/ui-components/docs/separator.md +216 -0
- package/ui-components/docs/skeleton.md +205 -0
- package/ui-components/docs/slider.md +226 -0
- package/ui-components/docs/spinner.md +332 -0
- package/ui-components/docs/switch.md +236 -0
- package/ui-components/docs/table.md +551 -0
- package/ui-components/docs/tabs.md +379 -0
- package/ui-components/docs/textarea.md +187 -0
- package/ui-components/docs/toggle-group.md +370 -0
- package/ui-components/docs/toggle.md +91 -0
- package/ui-components/docs/tooltip.md +290 -0
- package/ui-components/drawer.tsx +213 -0
- package/ui-components/dropdown-menu.tsx +263 -0
- package/ui-components/field.tsx +224 -0
- package/ui-components/hover-card.tsx +46 -0
- package/ui-components/input-group.tsx +146 -0
- package/ui-components/input.tsx +20 -0
- package/ui-components/kbd.tsx +32 -0
- package/ui-components/label.tsx +17 -0
- package/ui-components/pagination.tsx +124 -0
- package/ui-components/popover.tsx +81 -0
- package/ui-components/progress.tsx +63 -0
- package/ui-components/radio-group.tsx +38 -0
- package/ui-components/resizable.tsx +40 -0
- package/ui-components/scoped-portal.tsx +31 -0
- package/ui-components/select.tsx +195 -0
- package/ui-components/separator.tsx +18 -0
- package/ui-components/skeleton.tsx +15 -0
- package/ui-components/slider.tsx +75 -0
- package/ui-components/spinner.tsx +20 -0
- package/ui-components/switch.tsx +27 -0
- package/ui-components/table.tsx +86 -0
- package/ui-components/tabs.tsx +75 -0
- package/ui-components/textarea.tsx +17 -0
- package/ui-components/toggle-group.tsx +85 -0
- package/ui-components/toggle.tsx +42 -0
- package/ui-components/tooltip.tsx +61 -0
- package/ui-components/utils.ts +8 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +295 -248
- package/workspace/.claude/skills/moi-workspace/references/COLLABORATIVE.md +151 -0
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -152
- package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
- package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +67 -203
- package/client/features/chat/attachment-staging.ts +0 -153
- package/client/features/chat/uploads.ts +0 -18
- package/client/features/chat/useAppletChatMessage.ts +0 -68
- package/client/features/settings/IconPicker.tsx +0 -442
- package/client/features/settings/WorkspaceSettings.tsx +0 -92
- package/client/features/settings/render-icon.ts +0 -173
- package/client/features/widgets/HiddenPanel.tsx +0 -80
- package/client/features/widgets/WidgetGrid.tsx +0 -123
- package/client/features/widgets/Widgets.tsx +0 -264
- package/client/features/widgets/useGridReconcile.ts +0 -73
- package/dist/chunk-104m57qw.js +0 -2
- package/dist/chunk-59zf0m6n.js +0 -1
- package/dist/chunk-bj3akjs2.js +0 -1
- package/dist/chunk-c9pjqx9m.js +0 -14
- package/dist/chunk-j2w2vak4.js +0 -546
- package/dist/chunk-k2r9c95m.js +0 -10
- package/dist/chunk-kmbxhgwv.js +0 -1
- package/dist/chunk-p1yqa71k.js +0 -83
- package/dist/chunk-pcnahct1.js +0 -5
- package/dist/chunk-r5xrenjy.css +0 -1
- package/dist/chunk-tny85yt2.js +0 -2
- package/dist/chunk-v7wr1df4.js +0 -2
- package/server/bundler/applet-css.ts +0 -155
- /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
- /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
- /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
- /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.ts} +0 -0
|
@@ -1,214 +1,78 @@
|
|
|
1
|
-
# UI components
|
|
1
|
+
# UI components
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
relative imports, and overlays patched so applet styling survives portalling. Components land
|
|
6
|
-
in `.moi/ui/` as plain source files you own.
|
|
7
|
-
|
|
8
|
-
This file is the catalog plus the essential usage rules (condensed from the official shadcn
|
|
9
|
-
skill). Read it once; fetch full per-component docs with `moi ui-components docs <name>` **before
|
|
10
|
-
composing a component you haven't used in this workspace** — the parts API is Base UI, not the
|
|
11
|
-
Radix-era shadcn you may know.
|
|
3
|
+
Use bundled components for standard controls. They use Base UI, Tabler icons, and workspace
|
|
4
|
+
theme tokens. Follow [DESIGN.md](DESIGN.md) for visual decisions.
|
|
12
5
|
|
|
13
6
|
## Workflow
|
|
14
7
|
|
|
8
|
+
Run commands from the project root. Check what's available and installed, read the docs
|
|
9
|
+
before using or changing a component, then add all missing components in one call.
|
|
10
|
+
|
|
15
11
|
```sh
|
|
16
|
-
moi ui-components
|
|
17
|
-
moi ui-components
|
|
18
|
-
moi ui-components add
|
|
19
|
-
|
|
20
|
-
# component; --install runs the bun install too
|
|
21
|
-
moi ui-components docs select table # official docs as markdown
|
|
22
|
-
moi bundle # rebuild applets
|
|
12
|
+
moi ui-components # catalog and installed state
|
|
13
|
+
moi ui-components docs select date-picker # usage and examples
|
|
14
|
+
moi ui-components add select date-picker --install
|
|
15
|
+
moi bundle # rebuild after editing applets
|
|
23
16
|
```
|
|
24
17
|
|
|
18
|
+
`add` copies source and support files into `.moi/ui/`. `--install` runs `bun install` in `.moi/`
|
|
19
|
+
and may need network access. Without it, run the dependency command printed by `add`. Rebuilding
|
|
20
|
+
with `moi bundle` is always a separate step.
|
|
21
|
+
|
|
22
|
+
Recipes, ready-made component compositions, use the same `add` and `docs` commands. They install
|
|
23
|
+
their building blocks; follow the recipe docs to compose them.
|
|
24
|
+
|
|
25
|
+
## Imports
|
|
26
|
+
|
|
27
|
+
Use relative imports from applets and shared modules under `.moi/`:
|
|
28
|
+
|
|
25
29
|
```tsx
|
|
26
|
-
// In an applet — always relative, never @/ aliases, never the host app's components:
|
|
27
30
|
import { Button } from '../ui/button'
|
|
28
|
-
import {
|
|
31
|
+
import { cn } from '../ui/utils'
|
|
32
|
+
import { IconSearch } from '@tabler/icons-react'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Adapt aliases in examples to relative imports. Applets cannot use `@/` aliases or import host
|
|
36
|
+
components. Use `moi ui-components` for installation; no `components.json` setup is needed.
|
|
37
|
+
|
|
38
|
+
## Composition
|
|
39
|
+
|
|
40
|
+
Use the anatomy and props in `moi ui-components docs <name>`. Inspect the installed source
|
|
41
|
+
when an example differs or a component has local edits; it defines the supported API.
|
|
42
|
+
Keep required groups, labels, and titles when composing parts.
|
|
43
|
+
|
|
44
|
+
Custom triggers and close controls use the `render` prop:
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
<DialogTrigger render={<Button variant="outline" />}>Open</DialogTrigger>
|
|
29
48
|
```
|
|
30
49
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
`date-picker` (pattern: calendar in a popover — see its docs; installs `calendar` + `popover` +
|
|
61
|
-
`button`)
|
|
62
|
-
|
|
63
|
-
**Overlays (portal-patched):** `dialog` · `alert-dialog` (destructive confirm) · `popover` ·
|
|
64
|
-
`dropdown-menu` · `context-menu` (right-click) · `hover-card` · `tooltip`
|
|
65
|
-
|
|
66
|
-
**Display & feedback:** `alert` (callouts) · `badge` · `avatar` · `skeleton` · `spinner` ·
|
|
67
|
-
`progress` · `table` · `data-table` (pattern on `table` + `@tanstack/react-table` — see its
|
|
68
|
-
docs) · `chart` (Recharts wired to theme tokens) · `attachment` (file/image tile) · `bubble`
|
|
69
|
-
(chat message)
|
|
70
|
-
|
|
71
|
-
**Structure & navigation:** `accordion` · `collapsible` · `tabs` · `carousel` · `pagination` ·
|
|
72
|
-
`resizable` (split panels) · `separator` (divider line)
|
|
73
|
-
|
|
74
|
-
Picking one: quick info on hover → `hover-card` or `tooltip` · contextual panel on click →
|
|
75
|
-
`popover` · focused task needing input → `dialog` · destructive confirmation → `alert-dialog` ·
|
|
76
|
-
option sets of 2–7 → `toggle-group` · long searchable lists → `combobox` · boolean setting →
|
|
77
|
-
`switch`, boolean in a form → `checkbox`.
|
|
78
|
-
|
|
79
|
-
## Composition rules
|
|
80
|
-
|
|
81
|
-
- **Custom triggers use the `render` prop** — this is Base UI, there is no `asChild`. Never wrap
|
|
82
|
-
a trigger in an extra element. Applies to every Trigger and Close part (`DialogTrigger`,
|
|
83
|
-
`PopoverTrigger`, `DropdownMenuTrigger`, `TooltipTrigger`, `CollapsibleTrigger`,
|
|
84
|
-
`DialogClose`, …).
|
|
85
|
-
|
|
86
|
-
```tsx
|
|
87
|
-
<DialogTrigger render={<Button variant="outline" />}>Open</DialogTrigger>
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
- **`render` to a non-button element needs `nativeButton={false}`:**
|
|
91
|
-
|
|
92
|
-
```tsx
|
|
93
|
-
<Button render={<a href="/docs" />} nativeButton={false}>Read the docs</Button>
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
- **Items always live inside their Group**: `SelectItem`/`SelectLabel` → `SelectGroup`;
|
|
97
|
-
`DropdownMenuItem`/`DropdownMenuLabel`/`DropdownMenuSub` → `DropdownMenuGroup`;
|
|
98
|
-
`ContextMenuItem` → `ContextMenuGroup`. A Label outside its Group **crashes the component at
|
|
99
|
-
runtime** (Base UI requires the group context); keep items grouped too.
|
|
100
|
-
- **`Dialog` and `AlertDialog` always need a Title** (`DialogTitle` — use
|
|
101
|
-
`className="sr-only"` to hide it visually).
|
|
102
|
-
- **`TabsTrigger` must be inside `TabsList`**, never directly in `Tabs`.
|
|
103
|
-
- **`Avatar` always needs `AvatarFallback`** for when the image fails.
|
|
104
|
-
- **Button has no `isLoading`** — compose: `<Button disabled><Spinner data-icon="inline-start" />Saving…</Button>`.
|
|
105
|
-
- **Use components, not custom markup**: callout → `Alert` (+`AlertTitle`/`AlertDescription`),
|
|
106
|
-
loading placeholder → `Skeleton` (no custom `animate-pulse` divs), status chip → `Badge` (no
|
|
107
|
-
styled spans), divider → `Separator` (no `<hr>`/border divs), inline loading → `Spinner`.
|
|
108
|
-
|
|
109
|
-
## Base UI API gotchas
|
|
110
|
-
|
|
111
|
-
The biggest source of bugs when you know Radix-era shadcn. When unsure, `moi ui-components docs
|
|
112
|
-
<name>` has the real API.
|
|
113
|
-
|
|
114
|
-
- **Select needs an `items` prop on the root**; the placeholder is a `{ value: null }` item, not
|
|
115
|
-
a `placeholder` prop:
|
|
116
|
-
|
|
117
|
-
```tsx
|
|
118
|
-
const items = [
|
|
119
|
-
{ label: 'Pick a fruit', value: null },
|
|
120
|
-
{ label: 'Apple', value: 'apple' },
|
|
121
|
-
]
|
|
122
|
-
<Select items={items}>
|
|
123
|
-
<SelectTrigger><SelectValue /></SelectTrigger>
|
|
124
|
-
<SelectContent>
|
|
125
|
-
<SelectGroup>
|
|
126
|
-
{items.map(item => (
|
|
127
|
-
<SelectItem key={item.value} value={item.value}>{item.label}</SelectItem>
|
|
128
|
-
))}
|
|
129
|
-
</SelectGroup>
|
|
130
|
-
</SelectContent>
|
|
131
|
-
</Select>
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
Extras: `multiple` + render-function `SelectValue` for multi-select; `itemToStringValue` for
|
|
135
|
-
object values; `alignItemWithTrigger={false}` to position like a plain dropdown.
|
|
136
|
-
- **ToggleGroup**: no `type` prop — single-select by default, `multiple` for multi; `value`/
|
|
137
|
-
`defaultValue` is **always an array** (`defaultValue={["daily"]}`; controlled single value:
|
|
138
|
-
`value={[value]} onValueChange={v => setValue(v[0])}`).
|
|
139
|
-
- **Slider**: plain number for one thumb (`defaultValue={50}`), array only for ranges.
|
|
140
|
-
- **Accordion**: no `type`/`collapsible` props — `defaultValue` is **always an array**
|
|
141
|
-
(`defaultValue={["item-1"]}`), `multiple` to allow several open.
|
|
142
|
-
- **`AlertAction` is absolutely positioned** in the alert's top-right corner, and the alert
|
|
143
|
-
reserves only ~4.5rem of right padding for it. Keep it to one small control (`size="sm"`
|
|
144
|
-
button or icon button); anything wider overlaps the title and description text.
|
|
145
|
-
|
|
146
|
-
## Forms
|
|
147
|
-
|
|
148
|
-
- Lay out forms with `FieldGroup` + `Field` — never raw `div`s with spacing utilities:
|
|
149
|
-
|
|
150
|
-
```tsx
|
|
151
|
-
<FieldGroup>
|
|
152
|
-
<Field>
|
|
153
|
-
<FieldLabel htmlFor="email">Email</FieldLabel>
|
|
154
|
-
<Input id="email" type="email" />
|
|
155
|
-
<FieldDescription>Work email preferred.</FieldDescription>
|
|
156
|
-
</Field>
|
|
157
|
-
</FieldGroup>
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
`Field orientation="horizontal"` for settings rows; `FieldSet` + `FieldLegend` for groups of
|
|
161
|
-
related checkboxes/radios/switches.
|
|
162
|
-
- **Validation and disabled need both attributes**: `data-invalid` on `Field` + `aria-invalid`
|
|
163
|
-
on the control; `data-disabled` on `Field` + `disabled` on the control.
|
|
164
|
-
- **Inside `InputGroup`, use `InputGroupInput`/`InputGroupTextarea`** — never raw
|
|
165
|
-
`Input`/`Textarea`. A button attached to an input is `InputGroup` + `InputGroupAddon`, never
|
|
166
|
-
absolute positioning over an `Input`.
|
|
167
|
-
- **2–7 exclusive options → `ToggleGroup`**, not a loop of `Button`s with manual active state.
|
|
168
|
-
- Control chooser: free text → `input`/`textarea` · predefined options → `select` · searchable →
|
|
169
|
-
`combobox` · boolean setting → `switch` · boolean consent → `checkbox` · one-of-few →
|
|
170
|
-
`radio-group` · numeric range → `slider`.
|
|
171
|
-
|
|
172
|
-
## Styling
|
|
173
|
-
|
|
174
|
-
- **Semantic tokens only, never raw colors**: `bg-primary`, `text-muted-foreground`,
|
|
175
|
-
`text-destructive`, `bg-popover` — not `bg-blue-500` or `text-emerald-600`. Every token pairs
|
|
176
|
-
`name`/`name-foreground` (background / text-on-it): `background`, `card`, `popover`,
|
|
177
|
-
`primary`, `secondary`, `muted`, `accent`, `destructive`, plus `border`, `input`, `ring`,
|
|
178
|
-
`chart-1…5`, and `--radius`. Status colors come from `Badge` variants or `text-destructive`.
|
|
179
|
-
- **Built-in variants before custom classes**: `variant="outline"`, `size="sm"` — not
|
|
180
|
-
hand-rolled border/bg utilities on `Button`.
|
|
181
|
-
- **Prefer each component's default size.** Use smaller variants such as `sm` or `xs` only when a
|
|
182
|
-
real density constraint calls for them and the reduced control remains comfortable to use. When
|
|
183
|
-
using a non-default size, compare it with neighboring controls. Controls in the same group must
|
|
184
|
-
have matching heights and compatible visual weight.
|
|
185
|
-
- **`className` is for layout** (`max-w-md`, `mt-4`, `w-full`) — never for overriding a
|
|
186
|
-
component's colors or typography.
|
|
187
|
-
- **`gap-*`, not `space-x-*`/`space-y-*`** (`flex flex-col gap-4`). **`size-10`, not
|
|
188
|
-
`w-10 h-10`.** **`truncate`**, not the three-class spell.
|
|
189
|
-
- **`cn()` from `../ui/utils` for conditional classes** — no template-literal ternaries. The
|
|
190
|
-
same import works from `_`-prefixed shared modules next to your applets (a
|
|
191
|
-
`.moi/widgets/_utils.tsx` importing `cn` uses `../ui/utils` too) — no need to re-implement
|
|
192
|
-
it.
|
|
193
|
-
- **No manual `z-index` on overlays** — dialog/popover/menu/tooltip handle their own stacking.
|
|
194
|
-
|
|
195
|
-
## Icons
|
|
196
|
-
|
|
197
|
-
- Tabler only: `import { IconSearch } from '@tabler/icons-react'` — every name is
|
|
198
|
-
`Icon`-prefixed. Installed components already come converted.
|
|
199
|
-
- In a `Button`, mark position with `data-icon="inline-start"` / `"inline-end"`; **no sizing
|
|
200
|
-
classes on icons inside components** (Button, DropdownMenuItem, Alert size them via CSS).
|
|
201
|
-
- Pass icons as component objects (`icon={IconCheck}`), never as string keys into a lookup map.
|
|
202
|
-
|
|
203
|
-
## Customization
|
|
204
|
-
|
|
205
|
-
Cheapest first — stop at the first level that works:
|
|
206
|
-
|
|
207
|
-
1. **Workspace theme** (`moi theme`) — fonts, colors, radius flow into every component through
|
|
208
|
-
tokens.
|
|
209
|
-
2. **Built-in variants + `className` layout** at the callsite (merges correctly via `cn`).
|
|
210
|
-
3. **Edit the file in `.moi/ui/`** — e.g. add a `cva` variant to `button.tsx`; propagates to
|
|
211
|
-
every applet using it, and `add` won't overwrite it without `--force`.
|
|
212
|
-
4. **Wrapper components** — compose primitives into app-level pieces (a `ConfirmDialog` wrapping
|
|
213
|
-
`AlertDialog` parts) in a `_`-prefixed shared module (`.moi/widgets/_utils.tsx` — see the
|
|
214
|
-
workspace layout in the skill).
|
|
50
|
+
Don't nest buttons inside triggers. When `render` replaces a button with a non-button
|
|
51
|
+
element, also pass `nativeButton={false}`.
|
|
52
|
+
|
|
53
|
+
## Overlays
|
|
54
|
+
|
|
55
|
+
Use the installed portal and stacking behavior; don't add a second portal or z-index overrides.
|
|
56
|
+
`applet-portal.tsx` preserves applet styles for portalled content. Never edit or remove it.
|
|
57
|
+
|
|
58
|
+
## Styling and icons
|
|
59
|
+
|
|
60
|
+
- Use semantic theme tokens and built-in variants. Reserve `className` for layout;
|
|
61
|
+
avoid overriding component colors or typography and adding manual `dark:` color overrides.
|
|
62
|
+
- Prefer default sizes. Use smaller controls when space calls for them, keeping neighboring
|
|
63
|
+
controls consistent and comfortable to use.
|
|
64
|
+
- Prefer `gap-*` for spacing, `size-*` for equal width and height, and `truncate` for ellipsis.
|
|
65
|
+
- Use `cn()` from `../ui/utils` for conditional classes.
|
|
66
|
+
- Use Tabler icons with explicit `stroke` following [the icon guidance](DESIGN.md#icons).
|
|
67
|
+
Let components size their icons; in buttons, mark position with
|
|
68
|
+
`data-icon="inline-start"` or `data-icon="inline-end"`.
|
|
69
|
+
|
|
70
|
+
## Customization and updates
|
|
71
|
+
|
|
72
|
+
Use `moi theme` for workspace-wide appearance. When variants and layout props aren't enough,
|
|
73
|
+
edit the source in `.moi/ui/`; every importing applet gets the change. Put reusable compositions
|
|
74
|
+
in `_`-prefixed shared modules next to applets.
|
|
75
|
+
|
|
76
|
+
Existing files are skipped by `add`. Use `--force` only for an intended reinstall, after checking
|
|
77
|
+
local edits. Existing support files remain protected even with `--force`; request a dependency
|
|
78
|
+
component explicitly to update it.
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import type { WorkspaceTabId } from '@/lib/types'
|
|
2
|
-
|
|
3
|
-
import { attachmentKey, type ChatAttachment, type DrawingPurpose, liveStore } from './chat-store'
|
|
4
|
-
import { uploadFiles } from './uploads'
|
|
5
|
-
|
|
6
|
-
type ComposerTarget = {
|
|
7
|
-
workspaceId: string
|
|
8
|
-
sessionId: string | null
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function stageComposerFiles(
|
|
12
|
-
{ workspaceId, sessionId }: ComposerTarget,
|
|
13
|
-
files: File[]
|
|
14
|
-
): void {
|
|
15
|
-
if (files.length === 0) return
|
|
16
|
-
|
|
17
|
-
const items: ChatAttachment[] = files.map(file => ({
|
|
18
|
-
kind: 'file',
|
|
19
|
-
localId: crypto.randomUUID(),
|
|
20
|
-
name: file.name || 'file',
|
|
21
|
-
mediaType: file.type || 'application/octet-stream',
|
|
22
|
-
previewUrl: file.type.startsWith('image/') ? URL.createObjectURL(file) : undefined,
|
|
23
|
-
status: 'uploading'
|
|
24
|
-
}))
|
|
25
|
-
liveStore.getState().addAttachments(workspaceId, sessionId, items)
|
|
26
|
-
|
|
27
|
-
items.forEach((item, index) => {
|
|
28
|
-
uploadFiles(workspaceId, [files[index]])
|
|
29
|
-
.then(([upload]) => {
|
|
30
|
-
liveStore.getState().updateAttachment(workspaceId, sessionId, item.localId, {
|
|
31
|
-
status: 'ready',
|
|
32
|
-
upload,
|
|
33
|
-
mediaType: upload.mediaType
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
.catch((error: unknown) => {
|
|
37
|
-
liveStore.getState().updateAttachment(workspaceId, sessionId, item.localId, {
|
|
38
|
-
status: 'error',
|
|
39
|
-
error: error instanceof Error ? error.message : 'Upload failed'
|
|
40
|
-
})
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
type StageDrawingDraftInput = ComposerTarget & {
|
|
46
|
-
localId: string
|
|
47
|
-
purpose: DrawingPurpose
|
|
48
|
-
sourceTab: WorkspaceTabId
|
|
49
|
-
blob: Blob
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Local-only staging while the user is still drawing: the chip shows the
|
|
53
|
-
// latest composite as its preview, but nothing is uploaded until the drawing
|
|
54
|
-
// session ends (stageDrawing).
|
|
55
|
-
export function stageDrawingDraft({
|
|
56
|
-
workspaceId,
|
|
57
|
-
sessionId,
|
|
58
|
-
localId,
|
|
59
|
-
purpose,
|
|
60
|
-
sourceTab,
|
|
61
|
-
blob
|
|
62
|
-
}: StageDrawingDraftInput): void {
|
|
63
|
-
const label = purpose === 'sketch' ? 'Sketch' : 'Annotation'
|
|
64
|
-
const previewUrl = URL.createObjectURL(blob)
|
|
65
|
-
const store = liveStore.getState()
|
|
66
|
-
const existing = store.attachments[attachmentKey(workspaceId, sessionId)]?.some(
|
|
67
|
-
attachment => attachment.localId === localId
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
if (existing) {
|
|
71
|
-
store.updateAttachment(workspaceId, sessionId, localId, {
|
|
72
|
-
previewUrl,
|
|
73
|
-
status: 'draft',
|
|
74
|
-
upload: undefined,
|
|
75
|
-
error: undefined
|
|
76
|
-
})
|
|
77
|
-
} else {
|
|
78
|
-
store.addAttachments(workspaceId, sessionId, [
|
|
79
|
-
{
|
|
80
|
-
kind: 'drawing',
|
|
81
|
-
purpose,
|
|
82
|
-
localId,
|
|
83
|
-
sourceTab,
|
|
84
|
-
name: `${label}.png`,
|
|
85
|
-
mediaType: 'image/png',
|
|
86
|
-
previewUrl,
|
|
87
|
-
status: 'draft'
|
|
88
|
-
}
|
|
89
|
-
])
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
type StageDrawingInput = StageDrawingDraftInput & {
|
|
94
|
-
isCurrent: () => boolean
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Upload a drawing once its editing session ends (finish, send, or an
|
|
98
|
-
// implicit cancel that keeps the attachment). `isCurrent` guards the result:
|
|
99
|
-
// a stale upload must not resurrect an attachment the user has removed.
|
|
100
|
-
export async function stageDrawing({
|
|
101
|
-
workspaceId,
|
|
102
|
-
sessionId,
|
|
103
|
-
localId,
|
|
104
|
-
purpose,
|
|
105
|
-
sourceTab,
|
|
106
|
-
blob,
|
|
107
|
-
isCurrent
|
|
108
|
-
}: StageDrawingInput): Promise<void> {
|
|
109
|
-
const label = purpose === 'sketch' ? 'Sketch' : 'Annotation'
|
|
110
|
-
const previewUrl = URL.createObjectURL(blob)
|
|
111
|
-
const store = liveStore.getState()
|
|
112
|
-
const existing = store.attachments[attachmentKey(workspaceId, sessionId)]?.some(
|
|
113
|
-
attachment => attachment.localId === localId
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
if (existing) {
|
|
117
|
-
store.updateAttachment(workspaceId, sessionId, localId, {
|
|
118
|
-
previewUrl,
|
|
119
|
-
status: 'uploading',
|
|
120
|
-
upload: undefined,
|
|
121
|
-
error: undefined
|
|
122
|
-
})
|
|
123
|
-
} else {
|
|
124
|
-
store.addAttachments(workspaceId, sessionId, [
|
|
125
|
-
{
|
|
126
|
-
kind: 'drawing',
|
|
127
|
-
purpose,
|
|
128
|
-
localId,
|
|
129
|
-
sourceTab,
|
|
130
|
-
name: `${label}.png`,
|
|
131
|
-
mediaType: 'image/png',
|
|
132
|
-
previewUrl,
|
|
133
|
-
status: 'uploading'
|
|
134
|
-
}
|
|
135
|
-
])
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
const [upload] = await uploadFiles(workspaceId, [
|
|
140
|
-
new File([blob], `${label}.png`, { type: 'image/png' })
|
|
141
|
-
])
|
|
142
|
-
if (!isCurrent()) return
|
|
143
|
-
liveStore.getState().updateAttachment(workspaceId, sessionId, localId, {
|
|
144
|
-
status: 'ready',
|
|
145
|
-
upload,
|
|
146
|
-
mediaType: upload.mediaType,
|
|
147
|
-
error: undefined
|
|
148
|
-
})
|
|
149
|
-
} catch {
|
|
150
|
-
if (!isCurrent()) return
|
|
151
|
-
liveStore.getState().removeAttachment(workspaceId, sessionId, localId)
|
|
152
|
-
}
|
|
153
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { UploadInfo } from '@/lib/types'
|
|
2
|
-
|
|
3
|
-
// POST one or more files to a workspace's upload endpoint and return the server's
|
|
4
|
-
// `UploadInfo` for each (in request order). The chat composer calls this as soon
|
|
5
|
-
// as files are added (drop/paste/pick) so the upload ids are ready by send time.
|
|
6
|
-
export async function uploadFiles(workspaceId: string, files: File[]): Promise<UploadInfo[]> {
|
|
7
|
-
const form = new FormData()
|
|
8
|
-
for (const f of files) form.append('files', f)
|
|
9
|
-
const res = await fetch(`/api/workspaces/${workspaceId}/uploads`, {
|
|
10
|
-
method: 'POST',
|
|
11
|
-
body: form
|
|
12
|
-
})
|
|
13
|
-
if (!res.ok) {
|
|
14
|
-
const detail = await res.text().catch(() => '')
|
|
15
|
-
throw new Error(detail || `Upload failed (${res.status})`)
|
|
16
|
-
}
|
|
17
|
-
return res.json()
|
|
18
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// Chat's half of the applet `sendChatMessage` API: turn a validated runtime
|
|
2
|
-
// event into a real send on the active chat.
|
|
3
|
-
//
|
|
4
|
-
// The runtime already did the untrusted work — narrowed the args, stamped the
|
|
5
|
-
// applet's `<kind>:<name>` as `source`, and rate-limited repeats
|
|
6
|
-
// (applet-runtime.ts). What's left is chat policy: reveal the chat, then send
|
|
7
|
-
// the text as an ordinary user message with the applet attribution riding the
|
|
8
|
-
// `<moi-context>` envelope.
|
|
9
|
-
//
|
|
10
|
-
// Sending while a turn is running is fine and deliberate — the composer offers
|
|
11
|
-
// the same ("Queue a follow-up"), and the harness queues the message into the
|
|
12
|
-
// live session rather than rejecting it.
|
|
13
|
-
import { reportAppletError } from '@/client/features/applets/applet-log'
|
|
14
|
-
import { type AppletChatMessage, useAppletEvent } from '@/client/features/applets/applet-runtime'
|
|
15
|
-
import type { ChatSendOptions } from '@/client/features/chat/chat-send'
|
|
16
|
-
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
17
|
-
import type { AgentAvailability } from '@/client/lib/agent-availability'
|
|
18
|
-
|
|
19
|
-
type UseAppletChatMessageOptions = {
|
|
20
|
-
send: (draft: string, options?: ChatSendOptions) => void
|
|
21
|
-
// Bring the chat on screen before the run starts. On a view tab in
|
|
22
|
-
// full-screen mode the chat is a popover that is closed by default, so
|
|
23
|
-
// without this the agent would start working somewhere the user can't see.
|
|
24
|
-
revealChat: () => void
|
|
25
|
-
// Same explicit availability state the composer's send button uses.
|
|
26
|
-
agentAvailability: AgentAvailability
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Why an applet message can't go out right now, or null when it can. The gate
|
|
30
|
-
// is exactly the composer's. Starting a run the visible UI would have refused
|
|
31
|
-
// is worse than dropping a click the user can repeat a moment later.
|
|
32
|
-
export function appletSendBlockedReason(availability: AgentAvailability): string | null {
|
|
33
|
-
if (availability.status === 'available') return null
|
|
34
|
-
if (availability.status === 'checking') {
|
|
35
|
-
return "this workspace's agent availability has not resolved yet"
|
|
36
|
-
}
|
|
37
|
-
if (availability.status === 'disconnected') return 'this workspace is disconnected from moi'
|
|
38
|
-
if (availability.status === 'login-required') {
|
|
39
|
-
return "this workspace's agent needs a login"
|
|
40
|
-
}
|
|
41
|
-
return "this workspace's agent is unavailable"
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function useAppletChatMessage({
|
|
45
|
-
send,
|
|
46
|
-
revealChat,
|
|
47
|
-
agentAvailability
|
|
48
|
-
}: UseAppletChatMessageOptions): void {
|
|
49
|
-
const workspaceId = useWorkspaceId()
|
|
50
|
-
|
|
51
|
-
useAppletEvent(workspaceId, 'sendChatMessage', (event: AppletChatMessage) => {
|
|
52
|
-
const blocked = appletSendBlockedReason(agentAvailability)
|
|
53
|
-
if (blocked) {
|
|
54
|
-
// Journaled rather than dropped quietly: from the applet's side the
|
|
55
|
-
// button did nothing, and this is the only place that says why.
|
|
56
|
-
reportAppletError(workspaceId, {
|
|
57
|
-
source: 'runtime',
|
|
58
|
-
message: `sendChatMessage("${event.message}") was dropped: ${blocked}.`
|
|
59
|
-
})
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
// `message` is the visible chat text; everything else in the event IS the
|
|
63
|
-
// envelope's applet attribution.
|
|
64
|
-
const { message, ...applet } = event
|
|
65
|
-
revealChat()
|
|
66
|
-
send(message, { applet })
|
|
67
|
-
})
|
|
68
|
-
}
|