moi-computer 0.11.1-next.2 → 0.11.1-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/README.md +2 -2
  2. package/client/app/AppRouter.tsx +2 -2
  3. package/client/app/routes/WorkspaceRoute.tsx +7 -9
  4. package/client/app/shell/SidebarLayout.tsx +18 -15
  5. package/client/components/shared/BottomPanel.tsx +26 -14
  6. package/client/components/shared/PanelHeader.tsx +1 -1
  7. package/client/components/shared/ReorderableList.tsx +7 -2
  8. package/client/components/shared/WorkspaceIcon.tsx +92 -0
  9. package/client/components/ui/alert-dialog.tsx +1 -0
  10. package/client/components/ui/checkbox.tsx +1 -0
  11. package/client/components/ui/inline-input.tsx +84 -0
  12. package/client/components/ui/toast.tsx +2 -2
  13. package/client/features/applets/AppletMount.tsx +1 -1
  14. package/client/features/applets/applet-cache.ts +3 -3
  15. package/client/features/applets/applet-runtime.ts +147 -108
  16. package/client/features/applets/applet-styles.ts +2 -2
  17. package/client/features/applets/applet-thumbnail.ts +6 -8
  18. package/client/features/applets/useApplet.ts +10 -9
  19. package/client/features/chat/ChatPanel.tsx +19 -10
  20. package/client/features/chat/ChatPopup.tsx +7 -2
  21. package/client/features/chat/applet-chat-intents.ts +170 -0
  22. package/client/features/chat/chat-send.ts +103 -62
  23. package/client/features/chat/chat-store.ts +50 -59
  24. package/client/features/chat/composer/ChatComposer.tsx +43 -132
  25. package/client/features/chat/composer/ModelPicker.tsx +1 -1
  26. package/client/features/chat/composer/attachments/AttachmentChip.tsx +99 -0
  27. package/client/features/chat/composer/attachments/DrawingAttachmentChip.tsx +37 -0
  28. package/client/features/chat/composer/attachments/FileAttachmentChip.tsx +22 -0
  29. package/client/features/chat/composer/attachments/TextAttachmentChip.tsx +11 -0
  30. package/client/features/chat/composer/attachments/draft-attachments.ts +168 -0
  31. package/client/features/chat/composer/attachments/types.ts +25 -0
  32. package/client/features/chat/composer/attachments/uploads.ts +26 -0
  33. package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
  34. package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +2 -2
  35. package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
  36. package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
  37. package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +22 -15
  38. package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
  39. package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
  40. package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +1 -1
  41. package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
  42. package/client/features/chat/{api.ts → sessions/api.ts} +1 -1
  43. package/client/features/chat/useChat.ts +32 -15
  44. package/client/features/dev/ChatStatesPage.tsx +5 -6
  45. package/client/features/dev/HarnessDebugPage.tsx +10 -7
  46. package/client/features/dev/ToolCallsPage.tsx +1 -1
  47. package/client/features/dev/UiComponentPreviews.tsx +21 -0
  48. package/client/features/dev/chat-states-fixtures.ts +13 -2
  49. package/client/features/drawings/useChatAnnotation.ts +17 -17
  50. package/client/features/drawings/useDrawingLayer.ts +7 -9
  51. package/client/features/drawings/useViewBuilderSketch.ts +18 -15
  52. package/client/features/home/HomePage.tsx +8 -7
  53. package/client/features/home/WorkspacePreview.tsx +1 -1
  54. package/client/features/home/workspace-presentation.tsx +1 -11
  55. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
  56. package/client/features/overview/HiddenPanel.tsx +109 -0
  57. package/client/features/overview/Overview.tsx +302 -0
  58. package/client/features/overview/WidgetCanvas.tsx +164 -0
  59. package/client/features/{widgets → overview}/WidgetFrame.tsx +24 -16
  60. package/client/features/overview/WorkspaceName.tsx +60 -0
  61. package/client/features/overview/api.ts +30 -0
  62. package/client/features/overview/default/ViewsWidget.tsx +252 -0
  63. package/client/features/overview/default/registry.tsx +36 -0
  64. package/client/features/{widgets → overview}/grid.ts +36 -0
  65. package/client/features/overview/useGridReconcile.ts +94 -0
  66. package/client/features/scratchpad/Scratchpad.tsx +7 -8
  67. package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
  68. package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
  69. package/client/features/settings/GeneralSettings.tsx +55 -58
  70. package/client/features/settings/SettingsLayout.tsx +2 -2
  71. package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
  72. package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
  73. package/client/features/settings/api.ts +48 -24
  74. package/client/features/views/ViewBuilder.tsx +5 -4
  75. package/client/features/views/ViewManager.tsx +11 -13
  76. package/client/features/views/api.ts +36 -2
  77. package/client/features/views/useViewBuilderActions.ts +8 -5
  78. package/client/features/views/useViewBuilderDrafts.ts +23 -21
  79. package/client/features/views/view-presentation.ts +13 -0
  80. package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
  81. package/client/features/workspace/UnavailablePage.tsx +21 -0
  82. package/client/features/workspace/WorkspaceLayoutContext.tsx +4 -7
  83. package/client/features/workspace/WorkspaceScreen.tsx +205 -161
  84. package/client/features/workspace/WorkspaceSplitLayout.tsx +1 -1
  85. package/client/features/workspace/WorkspaceTabs.tsx +2 -0
  86. package/client/features/workspace/api.ts +0 -26
  87. package/client/features/workspace/moi-context.ts +8 -9
  88. package/client/features/workspace/tab-resolution.ts +10 -33
  89. package/client/features/workspace/useWorkspaceNavigation.ts +164 -101
  90. package/client/index.css +1 -1
  91. package/client/lib/app-icon-registry.ts +2 -0
  92. package/client/lib/use-latest-ref.ts +11 -0
  93. package/client/main.tsx +1 -1
  94. package/client/runtime/useWorkspaceEvents.ts +59 -14
  95. package/client/theme.css +5 -5
  96. package/dist/chunk-1pp135b4.js +1 -0
  97. package/dist/chunk-2gs8jjx4.css +1 -0
  98. package/dist/chunk-94m3q9ce.js +1 -0
  99. package/dist/chunk-azkjzc7a.js +68 -0
  100. package/dist/{chunk-w482ew2c.js → chunk-brr0zbeh.js} +73 -73
  101. package/dist/chunk-m1fvqssh.js +2 -0
  102. package/dist/chunk-p34hvqt3.js +1 -0
  103. package/dist/{chunk-4s15axjs.js → chunk-p83f0jnj.js} +2 -2
  104. package/dist/{chunk-j3wvxjr7.js → chunk-tzz101ea.js} +1 -1
  105. package/dist/chunk-xg01f6pn.js +10 -0
  106. package/dist/{chunk-53a7pxcz.js → chunk-zs4mte79.js} +1 -1
  107. package/dist/index.html +1 -1
  108. package/lib/app-icons.ts +1 -0
  109. package/lib/applet-selector.ts +24 -0
  110. package/lib/chat-title.ts +6 -1
  111. package/lib/default-widgets.ts +32 -0
  112. package/lib/format.ts +12 -1
  113. package/lib/message-attachments.ts +40 -0
  114. package/lib/moi-attachments.ts +204 -0
  115. package/lib/moi-context.ts +20 -35
  116. package/lib/navigation.ts +84 -0
  117. package/lib/types.ts +79 -24
  118. package/lib/workspace-icon.ts +20 -0
  119. package/lib/workspace-layout.ts +22 -2
  120. package/lib/workspace-tabs.ts +9 -33
  121. package/package.json +27 -27
  122. package/registry.json +13 -0
  123. package/server/AGENTS.md +1 -0
  124. package/server/api.ts +114 -37
  125. package/server/applet-typecheck.ts +95 -0
  126. package/server/{bundler → applets}/build-applet.ts +13 -246
  127. package/server/applets/config.ts +226 -0
  128. package/server/applets/dependencies.ts +206 -0
  129. package/server/{applets.ts → applets/index.ts} +15 -161
  130. package/server/applets/runtime/base.ts +4 -0
  131. package/server/applets/runtime/moi.ts +42 -0
  132. package/server/applets/runtime/rpc.ts +17 -0
  133. package/server/applets/view-source.ts +67 -0
  134. package/server/attachment-message.ts +95 -0
  135. package/server/cli.ts +163 -97
  136. package/server/control.ts +63 -42
  137. package/server/harness/README.md +4 -2
  138. package/server/harness/acp/adapter.ts +7 -21
  139. package/server/harness/acp/session.ts +31 -50
  140. package/server/harness/claude-code/NOTES.md +8 -2
  141. package/server/harness/claude-code/adapter.ts +8 -25
  142. package/server/harness/claude-code/index.ts +2 -0
  143. package/server/harness/claude-code/session.ts +42 -47
  144. package/server/harness/claude-code/sessions.ts +9 -4
  145. package/server/harness/codex/adapter.ts +8 -7
  146. package/server/harness/codex/index.ts +1 -0
  147. package/server/harness/codex/permissions.ts +1 -1
  148. package/server/harness/codex/session.ts +20 -47
  149. package/server/harness/hermes/NOTES.md +1 -1
  150. package/server/harness/hermes/index.ts +4 -0
  151. package/server/harness/openclaw/NOTES.md +1 -1
  152. package/server/harness/openclaw/adapter.ts +22 -4
  153. package/server/harness/openclaw/gateway.ts +5 -3
  154. package/server/harness/openclaw/session.ts +27 -27
  155. package/server/harness/types.ts +5 -3
  156. package/server/layout.ts +9 -14
  157. package/server/moi-scaffold.ts +21 -13
  158. package/server/navigation-relay.ts +110 -0
  159. package/server/registry.ts +8 -0
  160. package/server/selected-session.ts +24 -4
  161. package/server/skill-update.ts +5 -3
  162. package/server/skill-version.ts +4 -7
  163. package/server/skills-template.ts +48 -9
  164. package/server/tabs.ts +19 -33
  165. package/server/uploads.ts +0 -0
  166. package/server/view-builders.ts +18 -1
  167. package/server/views.ts +126 -6
  168. package/server/web.ts +35 -9
  169. package/server/widgets.ts +12 -5
  170. package/server/workspace-config.ts +13 -9
  171. package/ui-components/button.tsx +2 -2
  172. package/ui-components/docs/kbd.md +191 -0
  173. package/ui-components/dropdown-menu.tsx +1 -1
  174. package/ui-components/kbd.tsx +32 -0
  175. package/ui-components/slider.tsx +1 -1
  176. package/ui-components/switch.tsx +1 -1
  177. package/ui-components/tabs.tsx +1 -1
  178. package/workspace/.claude/skills/moi-workspace/SKILL.md +284 -228
  179. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -153
  180. package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
  181. package/client/features/chat/attachment-staging.ts +0 -153
  182. package/client/features/chat/uploads.ts +0 -18
  183. package/client/features/chat/useAppletChatMessage.ts +0 -68
  184. package/client/features/settings/IconPicker.tsx +0 -442
  185. package/client/features/settings/WorkspaceSettings.tsx +0 -95
  186. package/client/features/settings/render-icon.ts +0 -173
  187. package/client/features/widgets/HiddenPanel.tsx +0 -80
  188. package/client/features/widgets/WidgetGrid.tsx +0 -123
  189. package/client/features/widgets/Widgets.tsx +0 -262
  190. package/client/features/widgets/useGridReconcile.ts +0 -73
  191. package/dist/chunk-245wt82v.css +0 -1
  192. package/dist/chunk-87thzbtw.js +0 -2
  193. package/dist/chunk-a6jad1a6.js +0 -1
  194. package/dist/chunk-dghwstd2.js +0 -9
  195. package/dist/chunk-eg120aca.js +0 -1
  196. package/dist/chunk-j7hh2ab4.js +0 -70
  197. package/dist/chunk-y8eyahwx.js +0 -1
  198. /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
  199. /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
  200. /package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +0 -0
  201. /package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +0 -0
  202. /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
  203. /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
  204. /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
  205. /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
  206. /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
  207. /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
  208. /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
  209. /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
  210. /package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +0 -0
  211. /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
  212. /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
  213. /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
  214. /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
  215. /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
  216. /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
  217. /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
  218. /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.ts} +0 -0
  219. /package/client/features/chat/{session-view.ts → sessions/session-view.ts} +0 -0
  220. /package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +0 -0
  221. /package/server/{bundler → applets}/applet-css.ts +0 -0
  222. /package/server/{bundler → applets}/build-worker.ts +0 -0
@@ -1,43 +1,58 @@
1
1
  # moi applet design
2
2
 
3
- This visual contract covers widgets and views inside a moi workspace. Applets may be expressive
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
- ## Core principles and visual hierarchy
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
- Design around the content and task. Give every applet one clear first reading, then add detail in
10
- proportion to its purpose and space. Dense information needs hierarchy, alignment, and stable lanes.
8
+ ## Content and layout
11
9
 
12
- An applet may have one expressive focal point, such as a visualization, image, strong surface, or
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
- Every visible element must explain content, show a real state, or enable an action. Remove repeated
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
- Lead with the main value, message, or task. Quiet supporting content and make tertiary metadata easy
20
- to ignore. A widget may use one large hero value when its footprint supports it. When two elements
21
- compete, reduce one.
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` for most roots. Widgets and views share token
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
- - **Widgets:** `background` is the workspace `primary`, `foreground` is its readable pair, and the
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 titles, labels, values, and important icons |
40
- | Supporting content | `text-muted-foreground` for descriptions and secondary information |
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,165 +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 lower foreground opacity only for readable tertiary metadata. Important text needs full
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 an open layout. Group with spacing, alignment, type, and occasional separators. Add a surface
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
- Avoid large rounded page frames, adjacent or nested cards, and structural wrappers. Align content
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
- ### Stacking and overlays
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
- Use DOM order for normal stacking: later siblings appear above earlier ones. Avoid z-index for
73
- ordinary layout. Use overlays from the UI components library (`moi ui-components`) with their
74
- existing portal behavior; they preserve applet styles and stay within their intended scope. For
75
- custom floating UI, portal into the closest
76
- `[data-applet]` root to preserve scope and theme tokens, rather than directly 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.
77
75
 
78
- Add a local, minimal z-index only when DOM order and a scoped portal cannot solve the stacking need.
79
- Several layers or escalating values mean the layout structure needs reconsideration.
76
+ ### Interaction and states
80
77
 
81
- ### Textures
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.
82
79
 
83
- Texture is optional and belongs only on the applet root. Choose it after the content layout is
84
- clear, use at most one, and pair it with an opaque semantic base such as
85
- `bg-background text-foreground texture-checker`.
80
+ **Show the states the applet can reach.**
86
81
 
87
- Available treatments are `texture-checker`, `texture-grid`, `texture-noise`,
88
- `texture-gradient-linear`, and `texture-inset-shadow`. They use semantic colors without replacing
89
- the base background color.
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.
90
88
 
91
- Match treatment to density. Dense root content uses plain `bg-background`,
92
- `texture-gradient-linear`, or `texture-inset-shadow`; sparse content may use any readable texture.
93
- Checker, grid, or noise may surround dense content only when it already needs an opaque or tonal
94
- 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.
95
90
 
96
- Never add wrappers to rescue a busy texture; choose a quieter root. Do not texture cards, panels,
97
- controls, or text regions, stack textures, or add tuning variables. Check nearby applets: unrelated
98
- applets use different textures, while a widget representing a view shares its texture. Any texture
99
- 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.
100
92
 
101
- ### Type
102
-
103
- Inherit the workspace font and use sentence case. Use regular weight for most text and medium for
104
- emphasis; other weights are reserved for owner hand-tuning. `text-sm` (14 px) is the UI default.
105
- Use smaller text for compact metadata and larger text for headings or one display value. Keep at
106
- most two clear type roles and avoid near-identical label styles.
107
-
108
- Reserve `font-mono` for code, commands, and code-like identifiers. Numeric values, measurements,
109
- percentages, timers, timestamps, prices, counts, and labels use the workspace font. Add
110
- `tabular-nums` when stable widths or alignment help.
111
-
112
- ### Icons
113
-
114
- Set `stroke` explicitly on every Tabler icon; the package default of `2` is heavier than the
115
- workspace chrome. Use `1.75` for 12–16 px icons and `1.5` for 20–24 px icons. When a component sets
116
- the icon size, omit `size` and use the stroke that matches its rendered size.
117
-
118
- ### Spacing and shape
119
-
120
- Follow a 4 px spacing rhythm: 4–8 px within a tight group, 12–16 px between groups in a region, and
121
- 24 px or more at section changes in larger applets. Prefer spacing over dividers. Keep repeated
122
- rows, chart labels, status markers, counters, and trailing actions in stable lanes so changing
123
- values do not shift the layout.
124
-
125
- Use the shared radius scale and default control radii. Use `rounded-lg` or `rounded-xl` for
126
- ordinary regions, `rounded-2xl` or `rounded-3xl` for one focal surface, and `rounded-full` only for
127
- real pills, circles, avatars, and status dots. Rectangular controls must not become capsules.
128
-
129
- ### Interaction, motion, and states
93
+ ## Widgets
130
94
 
131
- Controls must be obvious, keyboard-operable, comfortably sized, visibly focused, and accessibly
132
- named. Use Tabler icons with consistent visual weight. Keep charts understandable through labels,
133
- 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.
134
96
 
135
- Use short, interruptible motion for meaningful state changes and control feedback. Respect reduced
136
- motion and prefer transform and opacity. Avoid looping decoration and animation on frequently
137
- 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.
138
98
 
139
- Design only states the applet can reach. For data-driven applets, handle these when applicable:
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:
140
100
 
141
- - **Loading:** preserve the final layout and surface with a matching skeleton. Use a spinner only
142
- for compact inline work or work without a meaningful content shape.
143
- - **Error:** explain the problem in one human sentence and offer retry or a clear recovery action.
144
- - **Empty:** explain the absence briefly and provide a useful next step; never leave a data region
145
- blank.
146
- - **Refreshing:** keep current data visible and show progress on the refresh control.
147
- - **Stale:** show a quiet, current timestamp or status near the affected data.
148
- - **Disabled:** preserve the label and structure while making unavailability clear without color
149
- alone.
101
+ `rowSpan × 160 + (rowSpan − 1) × 8`
150
102
 
151
- Keep loading, populated, empty, success, and error layouts stable. A primary surface remains in the
152
- same position and size through those states. Errors and empty states must fit the configured Widget
153
- height or the View's normal content frame.
103
+ Fit content and reachable states within that height without accidental scrolling or clipped controls.
154
104
 
155
- ## Widgets
105
+ ## Views
156
106
 
157
- Widgets are compact dashboard surfaces seen beside other widgets. Their main meaning should be
158
- clear in a quick scan. Larger footprints may add charts, lists, metadata, filters, and direct
159
- 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.
160
108
 
161
- The host card owns outer radius, border, shadow, clipping, and elevation. Its interior is
162
- transparent. Fill it with an opaque `h-full w-full` root and add no outer card chrome. Use `p-4` as
163
- the compact padding default or `p-5` for larger footprints when content still fits. Use a column
164
- 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.
165
110
 
166
- The grid has four columns, 160 px rows, 8 px gaps, and a maximum width of 640 px. A Widget may span
167
- one to four rows and columns. Width shrinks with the workspace; height remains fixed by row span:
111
+ ## UI copy
168
112
 
169
- `rowSpan × 160 + (rowSpan − 1) × 8`
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.
170
117
 
171
- Treat width as flexible and height as the hard constraint. Start with the smallest footprint that
172
- presents the content clearly. Test the narrowest realistic width and longest realistic values.
173
- Clip decorative overflow deliberately, clamp supporting prose, and prevent horizontal page scroll
174
- 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.
175
121
 
176
- A small Widget has one primary element and at most two supporting groups. Larger footprints may
177
- carry more when hierarchy remains clear. Prefer live information over labels that repeat context.
178
- Limit controls to the immediate task: filters, toggles, refresh actions, and links are appropriate.
179
- Keep feedback on the control and leave the Widget surface unchanged on hover. Tabs, wizards,
180
- 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.
181
126
 
182
- ## Views
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.
183
130
 
184
- Views are full app screens for denser information and sustained work. They own page hierarchy,
185
- layout, spacing, chrome, and scrolling. A View must remain complete and usable at the available
186
- 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.
187
133
 
188
- One View represents one screen. Cross-screen navigation belongs to the workspace. Internal tabs,
189
- filters, and master-detail layouts may organize the current task without adding a client-side
190
- router.
134
+ Omit terminal periods in headings, labels, metadata, and short standalone UI lines. Use sentence
135
+ punctuation for paragraphs or multiple complete sentences.
191
136
 
192
- Let content choose the frame. Most Views need clear page context, a primary work area, and an
193
- obvious place for the main action. A title with an optional subtitle or action is a useful default;
194
- a canvas, map, or immersive visualization may establish context another way.
137
+ ## Design slop
195
138
 
196
- Use consistent page padding such as 24 or 32 px. Constrain prose, forms, and narrow task flows to a
197
- readable maximum width. Let tables, boards, maps, and visual workspaces use more of the frame when
198
- 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.
199
140
 
200
- Prefer one main page scroller. Use bounded internal scrolling only where independent position helps,
201
- such as a sticky table body, timeline, or board. Never create horizontal page scroll. Views may use
202
- more sections, controls, and information layers than Widgets while keeping one primary work area;
203
- do not stretch a Widget-like card to fill the page.
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.
204
148
 
205
149
  ## Final review
206
150
 
207
- Remove elements and wrappers that do not improve understanding, action, or state recognition, then
208
- realign what remains. Confirm the first reading is clear; the visual system stays readable and
209
- purposeful; realistic content and reachable states fit without overflow or jumps; controls are
210
- necessary and accessible; and the applet follows its Widget or View contract.
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.
@@ -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
- }