moi-computer 0.11.0 → 0.11.1-dev.be1ed10
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/app/AppRouter.tsx +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +7 -9
- 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 +1 -1
- package/client/features/applets/applet-cache.ts +3 -3
- package/client/features/applets/applet-runtime.ts +147 -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 +170 -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/useChat.ts +42 -24
- package/client/features/dev/ChatStatesPage.tsx +8 -7
- package/client/features/dev/DevIndexPage.tsx +5 -0
- package/client/features/dev/DevRoutes.tsx +2 -0
- 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 +25 -22
- package/client/features/views/api.ts +36 -2
- package/client/features/views/useViewBuilderActions.ts +8 -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 +4 -7
- package/client/features/workspace/WorkspaceScreen.tsx +210 -162
- package/client/features/workspace/WorkspaceSplitLayout.tsx +7 -2
- package/client/features/workspace/WorkspaceTabs.tsx +2 -0
- package/client/features/workspace/api.ts +2 -30
- package/client/features/workspace/moi-context.ts +8 -9
- package/client/features/workspace/tab-resolution.ts +10 -33
- package/client/features/workspace/useWorkspaceNavigation.ts +164 -101
- package/client/index.css +23 -30
- 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-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
- package/dist/chunk-691pqsj6.js +2 -0
- package/dist/chunk-7a5nm4k9.css +1 -0
- package/dist/chunk-amb8y04y.js +1 -0
- package/dist/chunk-cf3pgy7j.js +546 -0
- package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
- package/dist/chunk-mzrgr577.js +5 -0
- package/dist/chunk-nf2wkvf9.js +14 -0
- package/dist/chunk-q6a0g26x.js +1 -0
- package/dist/chunk-twgdemkc.js +74 -0
- package/dist/chunk-x90k0f5c.js +2 -0
- package/dist/chunk-yq00csvd.js +2 -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/default-widgets.ts +32 -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 +20 -35
- package/lib/navigation.ts +84 -0
- package/lib/themes.ts +6 -6
- package/lib/types.ts +91 -34
- package/lib/workspace-icon.ts +20 -0
- package/lib/workspace-layout.ts +22 -2
- package/lib/workspace-tabs.ts +9 -33
- package/package.json +42 -32
- package/registry.json +656 -0
- package/server/AGENTS.md +2 -0
- package/server/agent.ts +1 -1
- package/server/api.ts +139 -66
- package/server/applet-typecheck.ts +95 -0
- package/server/applets/applet-css.ts +55 -0
- package/server/{bundler → applets}/build-applet.ts +13 -242
- 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/cli-ui-components.ts +28 -33
- package/server/cli.ts +169 -108
- 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 +9 -14
- 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 +48 -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 +46 -13
- 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 +90 -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/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
- /package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +0 -0
|
@@ -1,43 +1,58 @@
|
|
|
1
1
|
# moi applet design
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
while staying related to the calm host. This guide owns design decisions, `SKILL.md` owns
|
|
5
|
-
implementation, and the host owns fonts and semantic color values.
|
|
3
|
+
Applets should feel useful, clear, and at home in the workspace. Let their content give them character while keeping familiar typography, colors, and interactions.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
This guide is the highest-priority visual contract for widgets and views inside a moi workspace.
|
|
6
|
+
Follow generic design guidance only where it agrees with this guide.
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
proportion to its purpose and space. Dense information needs hierarchy, alignment, and stable lanes.
|
|
8
|
+
## Content and layout
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
state change. Keep the rest restrained. Avoid decorative clutter and competing effects.
|
|
10
|
+
**Make the purpose clear at a glance.** Lead with the information or activity people came for. Use contrast to create clear levels of emphasis without making the interface feel washed out. Keep the main action easy to find.
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
labels, obvious readiness badges, redundant helper copy, decorative status pills, and meaningless
|
|
17
|
-
icons. Relate a workspace's applets through typography, palette, spacing, or interaction patterns.
|
|
12
|
+
**Choose content before adding structure.** Include the information and controls the task needs. Add summaries, metrics, filters, and explanations when they help people understand or act. Available space is not a reason to add content. A sparse screen can be complete.
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
**Consider the screen as a whole.** Individually useful elements can still compete or repeat one another. Consolidate related information and reveal secondary details when needed. Keep essential information and frequent actions readily available.
|
|
15
|
+
|
|
16
|
+
**Give expression a clear focus.** Use typography, composition, color, imagery, texture, or a small content-linked metaphor to give the applet character. A visual detail may support the subject or mood without carrying data or enabling an action. Keep the treatment focused so the content remains easy to scan. Expand a focal region only when added working space helps the task.
|
|
17
|
+
|
|
18
|
+
**Group through spacing and alignment.** Start with an open layout. Prefer spacing and alignment over separators. Add a divider only when adjacent regions need a visible boundary. Use surfaces only for interactive objects, independent scrolling regions, distinct states, or a dedicated work area. Keep ordinary headings, tabs, summaries, metrics, and sections unboxed. Avoid large rounded page frames and decorative rows of cards or nested cards.
|
|
19
|
+
|
|
20
|
+
**Keep a consistent rhythm.** Use a 4 px spacing rhythm, with smaller gaps inside groups and larger gaps between them. Apply outer padding once. Align repeated values and actions so content changes do not move them around. When removing a container, remove its unnecessary padding and radius and realign its contents.
|
|
21
|
+
|
|
22
|
+
**Keep the layout comfortable.** Give content enough room to scan without making it unnecessarily dense or stretching it to fill the frame. Use natural height for simple tasks and extra space for tables, boards, canvases, and other work areas that benefit from it. When everything fits comfortably, keep essential information and actions within one viewport. Adapt to narrow widths, long content, and chat sharing the workspace. Avoid horizontal page scrolling; wide content may scroll within its own bounded region.
|
|
23
|
+
|
|
24
|
+
**Keep layers simple.** Prefer normal document order and bundled overlays with their existing portal and stacking behavior. Custom overlays must preserve applet scope and theme by using the closest `[data-applet]` root. Add minimal local z-index only when document order and a scoped portal cannot resolve the overlap.
|
|
22
25
|
|
|
23
26
|
## Shared system
|
|
24
27
|
|
|
28
|
+
### Typography
|
|
29
|
+
|
|
30
|
+
**Use a small, consistent set of styles.** Establish clear roles for headings, ordinary content, and supporting information. Text with the same role and importance shares the same typography.
|
|
31
|
+
|
|
32
|
+
Inherit the workspace font and use sentence case. Use regular weight for most text and medium for emphasis, including focal prompts or values when weight helps establish hierarchy. Reserve other weights for explicit user customization.
|
|
33
|
+
|
|
34
|
+
**Choose readable defaults.** Use `text-sm` for controls and general UI, and `text-base` for focused content when space allows. Sizes below `text-sm` should be rare, limited to unusually tight controls. Use larger text for headings or a focal value.
|
|
35
|
+
|
|
36
|
+
Reserve `font-mono` for code, commands, and code-like identifiers. Numeric values, measurements, percentages, timers, timestamps, prices, counts, labels, keyboard shortcuts, and key names use the workspace font. Add `tabular-nums` when stable widths or alignment help.
|
|
37
|
+
|
|
38
|
+
### Controls
|
|
39
|
+
|
|
40
|
+
**Use familiar controls.** Follow the [UI component guidelines](UI-COMPONENTS.md) and use bundled components with their existing variants, sizes, and shapes. Controls with the same role and importance share component variants. Keep feedback near the action that caused it.
|
|
41
|
+
|
|
42
|
+
### Icons
|
|
43
|
+
|
|
44
|
+
Use Tabler icons when they clarify meaning, identify a familiar action, or reinforce a focused visual metaphor. Avoid adding an icon to every label or control. Set stroke explicitly: `1.75` at 12–16 px and `1.5` at 20–24 px. Let components control icon size when provided.
|
|
45
|
+
|
|
25
46
|
### Color and surfaces
|
|
26
47
|
|
|
27
|
-
Use `h-full w-full bg-background text-foreground
|
|
28
|
-
meaning while the host resolves their values differently:
|
|
48
|
+
**Follow the workspace theme.** Use semantic tokens and their matching foregrounds. The default root is `h-full w-full bg-background text-foreground`.
|
|
29
49
|
|
|
30
|
-
|
|
31
|
-
local `primary` pair becomes a derived light action surface. The transparent host frame requires
|
|
32
|
-
an opaque root or an opaque fallback behind a full-bleed image or visualization.
|
|
33
|
-
- **Views:** tokens inherit the workspace page theme, so the default root matches the page.
|
|
34
|
-
- **Floating UI:** menus, tooltips, and popovers use `bg-popover text-popover-foreground` inside
|
|
35
|
-
the applet scope.
|
|
50
|
+
For widgets, the host sets the `background` token to the workspace’s `primary`, supplies a readable `foreground`, and derives a light local `primary` action surface. The host wrapper is transparent: each widget must paint its own opaque root, normally with `bg-background`, or provide an opaque fallback behind full-bleed media. Views inherit the page theme.
|
|
36
51
|
|
|
37
52
|
| Intent | Classes and guidance |
|
|
38
53
|
| --- | --- |
|
|
39
|
-
| Main content | `text-foreground` for
|
|
40
|
-
| Supporting content | `text-muted-foreground` for
|
|
54
|
+
| Main content | `text-foreground` for primary content and controls |
|
|
55
|
+
| Supporting content | `text-muted-foreground` for secondary emphasis |
|
|
41
56
|
| Inset surface | `bg-card text-card-foreground`, used only for a distinct functional region |
|
|
42
57
|
| Quiet fill | `bg-muted` for inset regions, skeletons, and disabled structure |
|
|
43
58
|
| Control state | `bg-accent text-accent-foreground` for hover, active, and selected controls |
|
|
@@ -46,164 +61,97 @@ meaning while the host resolves their values differently:
|
|
|
46
61
|
| Object edge | `ring-1 ring-border` for complete container and control outlines |
|
|
47
62
|
| Focus | `focus-visible:ring-2 focus-visible:ring-ring` |
|
|
48
63
|
| Separator | A one-sided border such as `border-b border-border` between adjacent regions |
|
|
64
|
+
| Floating content | `bg-popover text-popover-foreground` for menus, tooltips, and popovers inside the applet scope |
|
|
49
65
|
|
|
50
|
-
Use
|
|
51
|
-
contrast. Saturated surfaces need an explicit readable light or dark foreground. Never rely on
|
|
52
|
-
color alone.
|
|
53
|
-
|
|
54
|
-
Use rings for complete outlines and one-sided borders for separators; never combine both. Keep
|
|
55
|
-
edges subtle and avoid raw high-contrast colors. Derive tonal colors and custom gradients from
|
|
56
|
-
local tokens with `color-mix()`. Tailwind palette colors need a content, data, brand, or user reason.
|
|
57
|
-
Explain consistent data mappings with labels, legends, shapes, or values. Never use palette colors
|
|
58
|
-
for generic decoration or unrelated widget backgrounds. Purple, violet, and fuchsia also need a
|
|
59
|
-
reason and never act as a default creativity or technology cue.
|
|
66
|
+
Use `text-foreground` and `text-muted-foreground` together to create clear hierarchy. Keep every level comfortably readable and avoid letting muted text dominate the screen. Communicate meaning through wording, symbols, or shapes as well as color.
|
|
60
67
|
|
|
61
|
-
Use
|
|
62
|
-
only around an interactive object, independent scroller, distinct state, or self-contained work
|
|
63
|
-
area. Standard controls keep their surfaces; headers, tabs, summaries, metrics, and ordinary
|
|
64
|
-
sections stay unboxed.
|
|
68
|
+
Use additional colors for meaningful data, imagery, brands, a content-linked visual accent, or an explicit user preference. Keep data mappings consistent and understandable. Derive custom tonal treatments from local tokens.
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
to shared edges or grid columns. Apply outer padding once, then use gaps. Removing a surface also
|
|
68
|
-
means removing its card-like padding and radius and realigning its children.
|
|
70
|
+
**Keep surface treatment restrained.** Use the shared radius scale and existing control shapes. Reserve `rounded-full` for pills, circles, avatars, and status dots; do not turn rectangular controls into capsules. For custom regions, use rings for complete outlines and one-sided borders for separators; avoid doubling them.
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
**Let texture support readability.** Texture is optional, limited to the root, and backed by an opaque semantic color. Available treatments are `texture-checker`, `texture-grid`, `texture-noise`, `texture-gradient-linear`, and `texture-inset-shadow`.
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
ordinary layout. When floating UI must escape clipping or a local stacking context, portal it into
|
|
74
|
-
the closest `[data-applet]` root to preserve applet scope and theme tokens. Never portal applet UI
|
|
75
|
-
to `document.body`.
|
|
74
|
+
For dense root content, use plain `bg-background`, `texture-gradient-linear`, or `texture-inset-shadow`. Checker, grid, and noise may surround dense content only when it already needs an opaque work area. Choose a quieter texture before adding containers. Avoid stacking or tuning textures, and omit them behind full-bleed imagery or visualizations. Coordinate related widgets and views.
|
|
76
75
|
|
|
77
|
-
|
|
78
|
-
Several layers or escalating values mean the layout structure needs reconsideration.
|
|
76
|
+
### Interaction and states
|
|
79
77
|
|
|
80
|
-
|
|
78
|
+
**Make every action usable.** Controls need clear names, comfortable targets, keyboard support, and visible focus. Charts need understandable labels or equivalent information. Preserve accessibility when simplifying the screen.
|
|
81
79
|
|
|
82
|
-
|
|
83
|
-
clear, use at most one, and pair it with an opaque semantic base such as
|
|
84
|
-
`bg-background text-foreground texture-checker`.
|
|
80
|
+
**Show the states the applet can reach.**
|
|
85
81
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
the
|
|
82
|
+
- **Loading:** preserve the expected content shape with a skeleton; use spinners for compact or shapeless work.
|
|
83
|
+
- **Empty:** explain the absence and offer a relevant next step when one exists.
|
|
84
|
+
- **Error:** explain the problem plainly and provide recovery.
|
|
85
|
+
- **Refreshing:** keep existing content visible and show progress near the refresh action.
|
|
86
|
+
- **Stale:** identify outdated information near the affected content.
|
|
87
|
+
- **Disabled:** keep the control recognizable and make its unavailability understandable.
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
`texture-gradient-linear`, or `texture-inset-shadow`; sparse content may use any readable texture.
|
|
92
|
-
Checker, grid, or noise may surround dense content only when it already needs an opaque or tonal
|
|
93
|
-
work surface. Full-bleed images, maps, canvases, and visualizations use no texture.
|
|
89
|
+
Keep the main work surface in the same position and size as states change. Feedback must fit the applet’s available space.
|
|
94
90
|
|
|
95
|
-
|
|
96
|
-
controls, or text regions, stack textures, or add tuning variables. Check nearby applets: unrelated
|
|
97
|
-
applets use different textures, while a widget representing a view shares its texture. Any texture
|
|
98
|
-
should become easy to ignore while reading.
|
|
91
|
+
Use brief, interruptible motion to explain changes or acknowledge input. Respect reduced motion, avoid looping decoration and animation on frequently changing numbers, and make audio and video user-initiated.
|
|
99
92
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
Inherit the workspace font and use sentence case. Use regular weight for most text and medium for
|
|
103
|
-
emphasis; other weights are reserved for owner hand-tuning. `text-sm` (14 px) is the UI default.
|
|
104
|
-
Use smaller text for compact metadata and larger text for headings or one display value. Keep at
|
|
105
|
-
most two clear type roles and avoid near-identical label styles.
|
|
106
|
-
|
|
107
|
-
Reserve `font-mono` for code, commands, and code-like identifiers. Numeric values, measurements,
|
|
108
|
-
percentages, timers, timestamps, prices, counts, and labels use the workspace font. Add
|
|
109
|
-
`tabular-nums` when stable widths or alignment help.
|
|
110
|
-
|
|
111
|
-
### Icons
|
|
112
|
-
|
|
113
|
-
Set `stroke` explicitly on every Tabler icon; the package default of `2` is heavier than the
|
|
114
|
-
workspace chrome. Use `1.75` for 12–16 px icons and `1.5` for 20–24 px icons. When a component sets
|
|
115
|
-
the icon size, omit `size` and use the stroke that matches its rendered size.
|
|
116
|
-
|
|
117
|
-
### Spacing and shape
|
|
118
|
-
|
|
119
|
-
Follow a 4 px spacing rhythm: 4–8 px within a tight group, 12–16 px between groups in a region, and
|
|
120
|
-
24 px or more at section changes in larger applets. Prefer spacing over dividers. Keep repeated
|
|
121
|
-
rows, chart labels, status markers, counters, and trailing actions in stable lanes so changing
|
|
122
|
-
values do not shift the layout.
|
|
123
|
-
|
|
124
|
-
Use the shared radius scale and default control radii. Use `rounded-lg` or `rounded-xl` for
|
|
125
|
-
ordinary regions, `rounded-2xl` or `rounded-3xl` for one focal surface, and `rounded-full` only for
|
|
126
|
-
real pills, circles, avatars, and status dots. Rectangular controls must not become capsules.
|
|
127
|
-
|
|
128
|
-
### Interaction, motion, and states
|
|
93
|
+
## Widgets
|
|
129
94
|
|
|
130
|
-
|
|
131
|
-
named. Use Tabler icons with consistent visual weight. Keep charts understandable through labels,
|
|
132
|
-
legends, patterns, or direct values as needed.
|
|
95
|
+
**Widgets support a quick glance or immediate action.** Choose the smallest footprint that presents the content clearly. Keep the main information prominent and supporting controls limited to the immediate task. Put tabs, deeper navigation, and multi-step work in a view. Keep hover feedback on controls; leave the widget surface unchanged.
|
|
133
96
|
|
|
134
|
-
|
|
135
|
-
motion and prefer transform and opacity. Avoid looping decoration and animation on frequently
|
|
136
|
-
updating numbers. Audio and video must be user-initiated.
|
|
97
|
+
The host owns the widget’s outer shape, clipping, and elevation. Its wrapper is transparent. Set an opaque background on the widget’s full-size root without adding another outer card.
|
|
137
98
|
|
|
138
|
-
|
|
99
|
+
The grid has four columns, 160 px rows, 8 px gaps, and a maximum width of 640 px. Widgets span one to four rows and columns. Width is flexible; height is fixed:
|
|
139
100
|
|
|
140
|
-
|
|
141
|
-
for compact inline work or work without a meaningful content shape.
|
|
142
|
-
- **Error:** explain the problem in one human sentence and offer retry or a clear recovery action.
|
|
143
|
-
- **Empty:** explain the absence briefly and provide a useful next step; never leave a data region
|
|
144
|
-
blank.
|
|
145
|
-
- **Refreshing:** keep current data visible and show progress on the refresh control.
|
|
146
|
-
- **Stale:** show a quiet, current timestamp or status near the affected data.
|
|
147
|
-
- **Disabled:** preserve the label and structure while making unavailability clear without color
|
|
148
|
-
alone.
|
|
101
|
+
`rowSpan × 160 + (rowSpan − 1) × 8`
|
|
149
102
|
|
|
150
|
-
|
|
151
|
-
same position and size through those states. Errors and empty states must fit the configured Widget
|
|
152
|
-
height or the View's normal content frame.
|
|
103
|
+
Fit content and reachable states within that height without accidental scrolling or clipped controls.
|
|
153
104
|
|
|
154
|
-
##
|
|
105
|
+
## Views
|
|
155
106
|
|
|
156
|
-
|
|
157
|
-
clear in a quick scan. Larger footprints may add charts, lists, metadata, filters, and direct
|
|
158
|
-
actions while preserving one first reading.
|
|
107
|
+
**Views support sustained work.** Each view represents one screen and owns its layout, padding, and scrolling. Establish clear context, a primary work area, and relevant actions. A title is useful when the content does not already establish context.
|
|
159
108
|
|
|
160
|
-
|
|
161
|
-
transparent. Fill it with an opaque `h-full w-full` root and add no outer card chrome. Use `p-4` as
|
|
162
|
-
the compact padding default or `p-5` for larger footprints when content still fits. Use a column
|
|
163
|
-
layout when content needs a footer or timestamp and keep lower-priority information at the bottom.
|
|
109
|
+
Prefer one main scroller. Add bounded internal scrolling only when independent scroll positions help the task. Internal tabs, filters, and master-detail layouts may organize the current task. Cross-screen navigation belongs to the workspace; do not add a client-side router.
|
|
164
110
|
|
|
165
|
-
|
|
166
|
-
one to four rows and columns. Width shrinks with the workspace; height remains fixed by row span:
|
|
111
|
+
## UI copy
|
|
167
112
|
|
|
168
|
-
|
|
113
|
+
Words appear in a design for one reason: to make it easier to understand and use. They are design
|
|
114
|
+
content, not decoration. Bring the same intentionality and minimalism to copywriting that you would
|
|
115
|
+
bring to spacing and color. Before writing anything, ask what the design needs to say, and how it can
|
|
116
|
+
best be said to help the person navigate the experience.
|
|
169
117
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
and accidental inner page scrolling.
|
|
118
|
+
Write from the end user's perspective. Name things in simple language people understand, not by how
|
|
119
|
+
the system is built. Describe what something is or does in plain terms rather than selling it.
|
|
120
|
+
Prefer specific, clear wording over clever wording.
|
|
174
121
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
multi-step workflows, and deep navigation belong in a View.
|
|
122
|
+
Use active voice by default. An action says exactly what will happen: "Save changes," not "Submit."
|
|
123
|
+
Keep the same action name through the whole flow, so a button labeled "Publish" produces a
|
|
124
|
+
confirmation that says "Published." Interface vocabulary helps people find their way around, and
|
|
125
|
+
consistency helps them learn it.
|
|
180
126
|
|
|
181
|
-
|
|
127
|
+
Treat failure and empty states as moments for direction, not mood. Explain what went wrong and how
|
|
128
|
+
to fix it in the interface's voice. Errors do not apologize, and they are never vague. An empty state
|
|
129
|
+
is an invitation to act.
|
|
182
130
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
width, including when chat shares the workspace.
|
|
131
|
+
Keep the tone conversational: plain verbs, sentence case, no filler. Let each written element do
|
|
132
|
+
exactly one job.
|
|
186
133
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
router.
|
|
134
|
+
Omit terminal periods in headings, labels, metadata, and short standalone UI lines. Use sentence
|
|
135
|
+
punctuation for paragraphs or multiple complete sentences.
|
|
190
136
|
|
|
191
|
-
|
|
192
|
-
obvious place for the main action. A title with an optional subtitle or action is a useful default;
|
|
193
|
-
a canvas, map, or immersive visualization may establish context another way.
|
|
137
|
+
## Design slop
|
|
194
138
|
|
|
195
|
-
|
|
196
|
-
readable maximum width. Let tables, boards, maps, and visual workspaces use more of the frame when
|
|
197
|
-
the task benefits.
|
|
139
|
+
Design slop is a repeated visual shortcut that makes an interface feel generic or agent-made. Avoid decorative patterns added by habit instead of because they suit the content.
|
|
198
140
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
141
|
+
- **Decorative accent lines:** Do not place short colored lines, partial borders, or a single colored edge beside headings, prompts, or values as generic decoration. Choose a visual treatment connected to the content, or leave the area open.
|
|
142
|
+
- **SaaS card kit:** Use repeated cards when they represent a real repeated unit, such as comparable
|
|
143
|
+
metrics, records, or actions. Avoid turning unrelated sections into identical rounded containers
|
|
144
|
+
with the same radius, border, and shadow. Surface treatment should reflect hierarchy and function.
|
|
145
|
+
- **Template chrome:** Avoid stock decoration: all-caps eyebrows, middle-dot metadata,
|
|
146
|
+
`LABEL — fragment` headings, monospace labels, and arrows on every action. Use these patterns only
|
|
147
|
+
when they clarify hierarchy, state, or sequence.
|
|
203
148
|
|
|
204
149
|
## Final review
|
|
205
150
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
151
|
+
- **Focus:** Identify what people notice first and what they can do next. Reduce competing emphasis.
|
|
152
|
+
- **Subtract:** Temporarily remove secondary groups, helper copy, badges, icons, and wrappers. Restore an element when its absence creates a specific problem with the task, a decision, a state, or recovery. A single deliberate visual metaphor may remain when it gives the content recognizable character without adding copy, controls, or containers. Preserve useful content and accessible labels.
|
|
153
|
+
- **Deduplicate:** Read all visible copy together and compare meaning, not wording. When two elements communicate the same context or instruction, keep the clearer one closest to the relevant action.
|
|
154
|
+
- **Character:** Identify the applet’s visual idea. If it relies only on text and standard controls, consider one content-linked accent, metaphor, image, or expressive composition. Keep it subordinate to the main content.
|
|
155
|
+
- **Unify:** Compare text styles and control variants by role, then check their combined emphasis. Merge unnecessary differences in typography, color, spacing, and shape.
|
|
156
|
+
- **Contrast:** Check that contrast creates clear levels of emphasis and the screen does not feel washed out.
|
|
157
|
+
- **Verify:** Check realistic content, narrow widths, reachable states, keyboard use, and whether content that should fit requires scrolling. For widgets, also review how the result sits beside other applets.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Applet intents
|
|
2
|
+
|
|
3
|
+
Intents let an applet act beyond its own UI: open another view, add context to chat, or ask the
|
|
4
|
+
agent to do something. Import these functions from `moi` and call them from user event handlers,
|
|
5
|
+
such as a button click; moi handles the action in the workspace.
|
|
6
|
+
|
|
7
|
+
## Navigation: `navigate(href)` and `resolveHref(href)`
|
|
8
|
+
|
|
9
|
+
Use the shared [workspace navigation convention](../SKILL.md#workspace-navigation) for addresses
|
|
10
|
+
and query params. Applets navigate through these functions:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
function navigate(href: string): void
|
|
14
|
+
function resolveHref(href: string): string
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { navigate, resolveHref } from 'moi'
|
|
19
|
+
|
|
20
|
+
const query = new URLSearchParams({ order: 'o-1024' })
|
|
21
|
+
const href = `moi:/views/orders?${query}`
|
|
22
|
+
|
|
23
|
+
// Prefer anchors for links: copy, middle-click, and new browser tabs work.
|
|
24
|
+
<a href={resolveHref(href)}>Open order</a>
|
|
25
|
+
|
|
26
|
+
// Use the same address from an event handler.
|
|
27
|
+
<button onClick={() => navigate(href)}>Open order</button>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### View params and history
|
|
31
|
+
|
|
32
|
+
The host passes query values to the view's `params` prop. Missing keys are absent. Decode numbers
|
|
33
|
+
and booleans explicitly, and render sensibly with empty params.
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
type Params = {
|
|
37
|
+
// Order id to open; omit to show the list.
|
|
38
|
+
order?: string
|
|
39
|
+
}
|
|
40
|
+
type OrdersProps = { params?: Params }
|
|
41
|
+
|
|
42
|
+
export default function Orders({ params = {} }: OrdersProps) {
|
|
43
|
+
const selectedOrder = params.order ?? null
|
|
44
|
+
return <button onClick={() => navigate('moi:/views/orders')}>Close order</button>
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
See [Views](../SKILL.md#views) for which state belongs in the URL.
|
|
49
|
+
|
|
50
|
+
Normal navigation adds browser history. Back, Forward, reload, and copied links restore the address.
|
|
51
|
+
Tab clicks restore each tab's last address in browser memory. An explicit root link clears params.
|
|
52
|
+
Inactive views keep their own params. Widgets receive no params.
|
|
53
|
+
|
|
54
|
+
## `addChatAttachment(input)`
|
|
55
|
+
|
|
56
|
+
Use this when the action may need the user's input or modification before sending. It adds
|
|
57
|
+
an attachment to the current draft, opens chat, and focuses the composer, keeping existing
|
|
58
|
+
text intact. The user can revise their message, add or remove attachments, or send attachments
|
|
59
|
+
on their own. Staging works while the agent is busy or unavailable.
|
|
60
|
+
|
|
61
|
+
### API
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
type AttachmentInput =
|
|
65
|
+
| { type: 'text'; label: string; text: string }
|
|
66
|
+
| { type: 'file'; file: File; path?: never }
|
|
67
|
+
| { type: 'file'; path: string; file?: never }
|
|
68
|
+
|
|
69
|
+
function addChatAttachment(input: AttachmentInput): void
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- Text requires a non-empty `label` (up to 120 characters) and non-blank `text` (up to 5,000
|
|
73
|
+
characters). Text is preserved exactly and can contain prose, Markdown, or formatted JSON.
|
|
74
|
+
- Files accept exactly one browser `File` or workspace-root-relative `path`. The filename is
|
|
75
|
+
the label. The existing upload limit is 32 MB; images use the existing image processing.
|
|
76
|
+
- Paths must point to regular files inside the workspace. Absolute paths, traversal, hidden
|
|
77
|
+
path segments, and symlinks escaping the workspace are rejected.
|
|
78
|
+
- A message can contain up to 10 attachments.
|
|
79
|
+
|
|
80
|
+
### Examples
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import { addChatAttachment } from 'moi'
|
|
84
|
+
|
|
85
|
+
// Capture selected applet data as text.
|
|
86
|
+
addChatAttachment({
|
|
87
|
+
type: 'text',
|
|
88
|
+
label: 'Order #1042',
|
|
89
|
+
text: 'Order: 1042\nStatus: delayed'
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
// Attach an existing workspace document.
|
|
93
|
+
addChatAttachment({ type: 'file', path: 'reports/september.pdf' })
|
|
94
|
+
|
|
95
|
+
// Attach a browser-generated file, including an exported drawing.
|
|
96
|
+
addChatAttachment({ type: 'file', file: generatedFile })
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Limits
|
|
100
|
+
|
|
101
|
+
Call from user event handlers. Text is captured immediately; workspace files are copied when
|
|
102
|
+
the server reads them during staging. Later changes do not update the attachment. Text appears
|
|
103
|
+
as a labelled chip; files use the existing file or image representation.
|
|
104
|
+
|
|
105
|
+
Invalid arguments reject the call without staging anything. File preparation failures remove
|
|
106
|
+
the attachment and show an error toast. File loading blocks sending until it finishes. Errors are recorded in
|
|
107
|
+
`moi debug logs`.
|
|
108
|
+
|
|
109
|
+
Identical text from the same applet with the same label is skipped. Attachments stay with their
|
|
110
|
+
chat in memory and are lost on page reload. Text attachments have no preview or editing UI.
|
|
111
|
+
|
|
112
|
+
## `sendChatMessage({ message, attachments? })`
|
|
113
|
+
|
|
114
|
+
Use this for a complete, ready-to-run action when the user is not expected to add or change
|
|
115
|
+
anything before it starts. It opens chat, prepares its attachments, and sends automatically.
|
|
116
|
+
The user's draft text and staged attachments stay untouched. Use action copy that makes the
|
|
117
|
+
immediate send clear.
|
|
118
|
+
|
|
119
|
+
### API
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
function sendChatMessage(input: { message: string; attachments?: AttachmentInput[] }): void
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
- `message`: required user-visible message, trimmed, non-empty, and at most 1,000 characters.
|
|
126
|
+
- `attachments`: optional list of `AttachmentInput` values, defined above under
|
|
127
|
+
`addChatAttachment`. The same limits and snapshot behavior apply. Supplied order is preserved.
|
|
128
|
+
|
|
129
|
+
### Example
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import { sendChatMessage } from 'moi'
|
|
133
|
+
;<button
|
|
134
|
+
onClick={() =>
|
|
135
|
+
sendChatMessage({
|
|
136
|
+
message: 'Review this order',
|
|
137
|
+
attachments: [
|
|
138
|
+
{ type: 'text', label: 'Order #1042', text: 'Status: delayed' },
|
|
139
|
+
{ type: 'file', path: 'reports/order-1042.pdf' }
|
|
140
|
+
]
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
>
|
|
144
|
+
Review order
|
|
145
|
+
</button>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Limits
|
|
149
|
+
|
|
150
|
+
Invalid arguments or a failed attachment reject the entire send. File preparation shows a
|
|
151
|
+
loading notice; failures show an error and are recorded in `moi debug logs`. Switching chats
|
|
152
|
+
or workspaces while files are preparing cancels the send, even if the user switches back.
|
|
153
|
+
|
|
154
|
+
Identical messages from the same applet within two seconds are dropped; the workspace allows
|
|
155
|
+
up to 10 applet sends per minute. Calls are dropped when the agent is unavailable, including
|
|
156
|
+
if it becomes unavailable during preparation.
|