moi-computer 0.3.1-next.1 → 0.4.1-next.0

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 (130) hide show
  1. package/README.md +85 -12
  2. package/bin/moi.mjs +11 -0
  3. package/client/api/workspace-keys.ts +1 -0
  4. package/client/app/AppRouter.tsx +5 -1
  5. package/client/app/routes/WorkspaceRoute.tsx +9 -5
  6. package/client/app/shell/SidebarLayout.tsx +9 -7
  7. package/client/components/shared/BottomPanel.tsx +24 -5
  8. package/client/components/shared/Composer.tsx +1 -1
  9. package/client/components/shared/PanelHeader.tsx +1 -1
  10. package/client/components/ui/button.tsx +5 -5
  11. package/client/components/ui/dropdown-menu.tsx +6 -6
  12. package/client/components/ui/hover-card.tsx +1 -1
  13. package/client/components/ui/input.tsx +1 -1
  14. package/client/components/ui/popover.tsx +1 -1
  15. package/client/components/ui/skeleton.tsx +1 -1
  16. package/client/components/ui/textarea.tsx +1 -1
  17. package/client/components/ui/tooltip.tsx +1 -1
  18. package/client/features/applets/applet-cache.ts +20 -1
  19. package/client/features/applets/applet-log.ts +10 -30
  20. package/client/features/applets/applet-runtime.ts +272 -0
  21. package/client/features/applets/useApplet.ts +36 -10
  22. package/client/features/chat/ChatComposer.tsx +1 -1
  23. package/client/features/chat/ChatEmptyState.tsx +186 -0
  24. package/client/features/chat/ChatPanel.tsx +95 -54
  25. package/client/features/chat/ChatPopup.tsx +3 -13
  26. package/client/features/chat/ChatPromptBubbles.tsx +74 -0
  27. package/client/features/chat/MarkdownContent.tsx +15 -3
  28. package/client/features/chat/ModelPicker.tsx +1 -1
  29. package/client/features/chat/TurnView.tsx +6 -17
  30. package/client/features/chat/chat-send.ts +26 -1
  31. package/client/features/chat/tool-group/CodeBlock.tsx +1 -1
  32. package/client/features/chat/tool-group/ReadImagePreview.tsx +1 -1
  33. package/client/features/chat/tool-group/SubagentCard.tsx +1 -1
  34. package/client/features/chat/tool-group/TimelineRow.tsx +4 -4
  35. package/client/features/chat/tool-group/ToolCallGroup.tsx +12 -5
  36. package/client/features/chat/tool-group/ToolOutput.tsx +2 -2
  37. package/client/features/chat/tool-group/format.ts +25 -4
  38. package/client/features/chat/useAppletChatMessage.ts +69 -0
  39. package/client/features/chat/useChat.ts +49 -14
  40. package/client/features/chat/useStickToBottom.ts +11 -1
  41. package/client/features/connectors/McpServerCards.tsx +3 -3
  42. package/client/features/dev/HarnessDebugPage.tsx +213 -77
  43. package/client/features/dev/PixelPainter.tsx +1 -1
  44. package/client/features/dev/PlaygroundPage.tsx +1 -1
  45. package/client/features/dev/ToolCallsPage.tsx +2 -2
  46. package/client/features/home/HomePage.tsx +17 -14
  47. package/client/features/home/WorkspacePreview.tsx +12 -13
  48. package/client/features/home/api.ts +8 -5
  49. package/client/features/home/workspace-presentation.tsx +1 -1
  50. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +1 -1
  51. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +21 -8
  52. package/client/features/scratchpad/Scratchpad.tsx +41 -2
  53. package/client/features/scratchpad/ScratchpadControls.tsx +13 -13
  54. package/client/features/scratchpad/useScratchpadSnapshot.tsx +1 -1
  55. package/client/features/settings/EnvironmentSettings.tsx +1 -1
  56. package/client/features/settings/IconPicker.tsx +11 -11
  57. package/client/features/settings/SettingsLayout.tsx +1 -1
  58. package/client/features/settings/WorkspaceSettings.tsx +2 -2
  59. package/client/features/settings/api.ts +33 -1
  60. package/client/features/widgets/HiddenPanel.tsx +4 -3
  61. package/client/features/widgets/Widgets.tsx +1 -0
  62. package/client/features/workspace/CustomizePanel.tsx +96 -82
  63. package/client/features/workspace/WorkspaceScreen.tsx +129 -107
  64. package/client/features/workspace/WorkspaceSkillUpdateBanner.tsx +91 -0
  65. package/client/features/workspace/WorkspaceTabs.tsx +1 -1
  66. package/client/features/workspace/api.ts +52 -0
  67. package/client/features/workspace/moi-context.ts +63 -17
  68. package/client/features/workspace/tab-resolution.ts +75 -0
  69. package/client/features/workspace/useWorkspaceNavigation.ts +128 -0
  70. package/client/features/workspace/useWorkspaceSkillUpdates.ts +160 -0
  71. package/client/index.css +10 -15
  72. package/client/lib/app-icon-registry.ts +77 -70
  73. package/client/lib/rate-limit.ts +77 -0
  74. package/client/main.tsx +10 -2
  75. package/client/runtime/useWorkspaceEvents.ts +15 -2
  76. package/client/runtime/workspace-theme.ts +115 -0
  77. package/client/store/ui.ts +42 -17
  78. package/client/theme.css +20 -15
  79. package/dist/{chunk-1dfbr7n2.js → chunk-3m1xe1j3.js} +94 -94
  80. package/dist/chunk-5vaevt8z.js +2 -0
  81. package/dist/chunk-7bzpmtxp.js +50 -0
  82. package/dist/chunk-h0hk61pm.js +9 -0
  83. package/dist/{chunk-vkvb3hjm.js → chunk-h3evrtyp.js} +1 -1
  84. package/dist/chunk-k5sjx9s5.js +1 -0
  85. package/dist/{chunk-jen6xcm1.js → chunk-m9qja0nx.js} +1 -1
  86. package/dist/chunk-s7za1qsv.css +1 -0
  87. package/dist/{chunk-sxbfh73c.js → chunk-tcfa3vt3.js} +1 -1
  88. package/dist/chunk-v797g6ap.js +51 -0
  89. package/dist/chunk-xyrw8318.js +27 -0
  90. package/dist/index.html +1 -1
  91. package/lib/app-icons.ts +73 -0
  92. package/lib/moi-context.ts +104 -3
  93. package/lib/themes.ts +83 -45
  94. package/lib/types.ts +44 -9
  95. package/lib/workspace-tabs.ts +48 -0
  96. package/package.json +4 -1
  97. package/server/api.ts +57 -5
  98. package/server/app-settings.ts +65 -0
  99. package/server/applets.ts +132 -22
  100. package/server/bundler/build-applet.ts +74 -16
  101. package/server/cli.ts +144 -17
  102. package/server/control.ts +53 -7
  103. package/server/data-dir.ts +1 -1
  104. package/server/events.ts +1 -1
  105. package/server/functions-worker.ts +15 -1
  106. package/server/functions.ts +51 -6
  107. package/server/harness/claude-code/index.ts +2 -1
  108. package/server/harness/codex/adapter.ts +100 -9
  109. package/server/harness/codex/client.ts +34 -1
  110. package/server/harness/codex/index.ts +2 -1
  111. package/server/harness/codex/session.ts +32 -8
  112. package/server/layout.ts +9 -14
  113. package/server/moi-scaffold.ts +37 -3
  114. package/server/registry.ts +1 -1
  115. package/server/skill-update.ts +47 -0
  116. package/server/skill-version.ts +2 -11
  117. package/server/tabs.ts +59 -0
  118. package/server/theme.ts +8 -14
  119. package/server/view-builders.ts +6 -2
  120. package/workspace/.claude/skills/moi-workspace/DESIGN.md +265 -107
  121. package/workspace/.claude/skills/moi-workspace/SKILL.md +85 -11
  122. package/client/features/workspace/useWorkspaceTheme.ts +0 -82
  123. package/dist/chunk-339jds4x.js +0 -15
  124. package/dist/chunk-3xsvsnhr.css +0 -1
  125. package/dist/chunk-6c8cwpzc.js +0 -1
  126. package/dist/chunk-anqmsbjt.js +0 -2
  127. package/dist/chunk-hbvfb6sk.js +0 -63
  128. package/dist/chunk-qwm5f6qk.js +0 -48
  129. package/dist/chunk-yp4srgqt.js +0 -10
  130. package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +0 -22
@@ -1,110 +1,268 @@
1
- Widget design guidelines. Read before creating or modifying any widget.
2
-
3
- ## The one idea
4
-
5
- A widget is **glanceable in under 2 seconds** — and earns **one signature moment**: a single expressive flourish (a live visualization, a 3D flip, a tactile surface, a satisfying state change) that makes it feel alive. Restraint everywhere except that one place. If everything is emphasized, nothing is.
6
-
7
- ## Rules — never break
8
-
9
- - **Content-only root.** The root is a plain `w-full h-full` rectangle. The host card owns the shell — never put `rounded-*`, an outer `border`, `shadow-*`, or a card-surface background on the root. Use `flex flex-col` + `overflow-hidden`; push footers down with `mt-auto`.
10
- - **Three states, always.** Loading → skeleton (never a spinner). Error → one human sentence + a retry. Empty → a short prompt, never blank. (Patterns below.)
11
- - **Height is the hard constraint.** `height = rowSpan×160 + (rowSpan−1)×16`, exact. Width flexes with the viewport. Design for height first; clip risk → `overflow-hidden`, long text → `truncate` / `line-clamp`.
12
- - **Tailwind for static styling.** No custom CSS, no `@apply`, no *static* `style={{}}`. Icons only from `@tabler/icons-react` (no raw `<svg>`, no other icon packs). Use the host project icon rule when present (`.agents/rules/icons.md`) instead of duplicating size/stroke guidance. Widgets import only from their own folder.
13
- - **Font weight.** Use only regular weight (the default, or `font-normal` for an explicit reset) and `font-medium`. Never introduce another font-weight utility; other weights are reserved for owner hand-tuning.
14
- - **No auto-playing audio or video.** Media is always user-initiated.
15
- - **No page-level horizontal scroll.** A deliberate, bounded internal scroller (e.g. a Kanban board) is fine; the widget itself never makes the page scroll sideways.
16
-
17
- ## Sizing
18
-
19
- Grid: 4 columns · 160px row height · 16px gap. `export const config = { colSpan, rowSpan } as const` (each defaults to 1).
20
-
21
- | Config | ~Width | Height | Usable (after p-4/5) |
22
- |--------|--------|--------|----------------------|
23
- | 1×1 | 284px | 160px | ~252 × 128 |
24
- | 2×1 | 584px | 160px | ~552 × 128 |
25
- | 2×2 | 584px | 336px | ~552 × 304 |
26
- | 4×2 | 1184px | 336px | ~1152 × 304 |
27
- | 4×3 | 1184px | 512px | ~1152 × 480 |
28
-
29
- Start at the smallest size that fits; grow only if content demands it. After changing `config` size, rebuild with `moi bundle --force`.
30
-
31
- ## Defaults — break with intent
32
-
33
- These are taste, not law. Break any of them when the widget is genuinely better for it — just know you're doing it.
34
-
35
- - **Background — varies.** Pick a surface that fits the content: a tonal **gradient** (`bg-linear-to-br`, 2–3 stops, one hue family), a **flat metaphor color**, an **image**, or neutral `bg-background`. A soft ambient glow blob (`absolute … rounded-full bg-…/20 blur-3xl`) adds depth. Keep it one family — tonal, not rainbow. Color should mean something (domain, status), not just decorate.
36
- - **Hierarchy.** One hero element your eye hits first (up to `text-5xl`), ≤2 supporting elements (≤`text-sm`), tertiary muted. The size *gap* is the hierarchy. If two things compete, cut one.
37
- - **Type.** ≤2 families. Match the hero font to the workspace personality — serif for warmth, geometric/sans for crisp data. `font-mono tabular-nums` for live/changing numbers. Small labels read well uppercase with wide tracking (e.g. `text-[11px] uppercase tracking-[0.2em] text-foreground/60`).
38
- - **Color tokens.** On neutral surfaces use semantic tokens (`text-foreground`, `text-muted-foreground`, `bg-background`, `border-border`, `text-destructive`). On saturated/gradient surfaces, `text-white` / `text-stone-900` and `white/NN` opacities are correct. Accent colors (a red play button, emerald progress, amber/sky/emerald status dots) signal action or state.
39
- - **Spacing.** 4px scale. Tight (4–8px) = belongs together; medium (12–16px) = grouped; wide (24px+) = section break. Prefer spacing over dividers. `p-4`/`p-5` content padding; never touch the edges.
40
- - **Density.** Every element earns its pixel. Prefer live info over static labels. One binary mode toggle (e.g. card/list) is fine — but no tabs, wizards, or multi-step flows.
41
- - **Family.** Widgets in one workspace should feel related — a shared move (gradient + glow, tracked labels, rounded-pill controls, the same hero font) ties them together.
42
-
43
- ### Color reference
44
-
45
- Starting points, not mandates — use them, tint them, or turn an anchor into a 2–3 stop gradient.
46
-
47
- **Semantic tokens** (for neutral surfaces; auto-resolve to the dark widget theme):
48
-
49
- | Token | Class | Purpose |
50
- |-------|-------|---------|
51
- | Primary text | `text-foreground` | Main content, headings, hero numbers |
52
- | Secondary text | `text-muted-foreground` | Supporting labels, captions, timestamps |
53
- | Subdued text | `text-foreground/50` | Lowest-priority metadata |
54
- | Error text | `text-destructive` | Error messages, destructive states |
55
- | Surface | `bg-background` | Widget surface (dark) |
56
- | Raised surface | `bg-card` | Cards within cards, inset areas |
57
- | Muted surface | `bg-muted` | Subdued backgrounds, skeleton blocks |
58
- | Secondary surface | `bg-secondary` | Tags, badges, inset regions |
59
- | Primary action | `bg-primary text-primary-foreground` | Buttons, key interactive elements |
60
- | Border | `border-border` | Dividers, outlines |
61
-
62
- **Background anchors by domain** (a tonal base — gradient it or pair with a glow):
63
-
64
- | Content domain | Anchor colors | Range |
65
- |----------------|---------------|-------|
66
- | Weather / sky | `sky-500`, `sky-600`, `blue-600`, `blue-700` | 500–700 |
67
- | Night / dark sky | `indigo-900`, `slate-800` | 800–900 |
68
- | Overcast / fog | `slate-500`, `slate-600` | 500–600 |
69
- | Nature / health | `emerald-600`, `green-600` | 500–700 |
70
- | Finance / money | `emerald-700`, `teal-600` | 600–700 |
71
- | Music / audio | `violet-600`, `fuchsia-600` | 500–700 |
72
- | Alerts / urgent | `red-600`, `orange-600` | 500–700 |
73
- | Time / clock | `blue-600`, `indigo-600` | 500–700 |
74
- | Notes / text | `amber-500`, `yellow-500` | 400–600 |
75
- | Social / comms | `pink-500`, `rose-500` | 400–600 |
76
- | Productivity | `cyan-600`, `sky-700` | 500–700 |
77
- | Neutral / generic | `zinc-700`, `neutral-700` | 600–800 |
78
-
79
- ## Motion & interaction
80
-
81
- - **Layered, but ranked.** (1) one **entrance** (`animate-in fade-in-0 zoom-in-95`, may stagger via a dynamic `animationDelay`); (2) **feedback** on every interaction (hover lift, `active:scale-[0.98]`, optimistic toggles, `transition-colors`, `disabled:opacity-50`); (3) **≤1 signature** animation (a waveform, a flip, confetti). Never two signatures in one widget. Don't animate a frequently-updating number — just swap it.
82
- - **Dynamic `style` is allowed — for data only.** Use `style={{}}` solely for genuinely dynamic, computed values: per-frame transforms, data-driven widths/heights, per-index stagger delays, flip rotations. Everything static stays in Tailwind.
83
- - **Tactility (optional, ≤1 per widget).** Interactive surfaces (keys, cards, toggles) may feel physical with an inset top-sheen + soft drop shadow + inset ring, e.g. `shadow-[inset_0_1px_0_rgba(255,255,255,0.4),0_3px_6px_rgba(0,0,0,0.3)] ring-1 ring-inset ring-white/20`. Never on the root.
1
+ # moi applet design
2
+
3
+ This is the visual contract for widgets and views inside a moi workspace. The host app stays calm,
4
+ precise, and quiet. Applets may be more expressive and information-rich while still feeling related
5
+ to the workspace around them.
6
+
7
+ This file owns visual direction, layout, states, and interaction design. `SKILL.md` owns file layout,
8
+ imports, styling syntax, and build instructions. The workspace theme owns fonts and semantic color
9
+ values.
10
+
11
+ ## Visual direction
12
+
13
+ Design around the content and the task. Give every applet a clear first reading, then add detail in
14
+ proportion to its size and purpose. Dense information is welcome when hierarchy and alignment keep
15
+ it easy to scan.
16
+
17
+ An applet may have one expressive focal point: a visualization, strong surface, image, tactile
18
+ interaction, or satisfying state change. It is optional. Use it when it helps the content and keep
19
+ the rest restrained so it remains meaningful. Avoid decorative clutter, competing effects, and a
20
+ different visual system for every section.
21
+
22
+ Every visible element must help the user understand useful content, see a real state, or take an
23
+ action. Do not add category eyebrows that repeat the title, readiness badges for an obvious default
24
+ state, helper copy that repeats nearby text, decorative status pills, or icons with no useful
25
+ meaning. Clear and simple applets contain fewer elements, and each one earns its place.
26
+
27
+ Widgets and views in one workspace should feel like a family through shared typography, palette,
28
+ spacing, or interaction patterns. They do not need to look identical.
29
+
30
+ ## Color
31
+
32
+ Start with the semantic colors supplied by the applet's surface. Widgets use the host's dark card
33
+ theme. Views inherit the workspace surface. Semantic colors keep ordinary text, structure, controls,
34
+ and states readable and consistent.
35
+
36
+ | Intent | Tailwind token | Use |
37
+ | --- | --- | --- |
38
+ | Primary content | `text-foreground` | Headings, values, body text, and important icons |
39
+ | Secondary content | `text-muted-foreground` | Labels, captions, timestamps, and supporting metadata |
40
+ | Main surface | `bg-background text-foreground` | The default applet surface |
41
+ | Inset surface | `bg-card text-card-foreground` | A real contained object or raised region inside the applet |
42
+ | Floating surface | `bg-popover text-popover-foreground` | Menus, tooltips, and other floating content |
43
+ | Primary action | `bg-primary text-primary-foreground` | The most important action in a local region |
44
+ | Subdued surface | `bg-muted` | Skeletons, quiet fills, and disabled structure |
45
+ | Interaction | `bg-accent text-accent-foreground` | Hover, active, selected, and subtle highlighted states |
46
+ | Error or danger | `text-destructive` / `bg-destructive` | Errors, destructive actions, and invalid states |
47
+ | Structure | `ring-1 ring-border`, `border-input`, `ring-ring` | Custom container edges, controls, and visible focus |
48
+
49
+ Use lower foreground opacity only for tertiary metadata that remains readable. Avoid weak alpha text
50
+ for important labels or values. Keep inset surfaces rare so a widget does not become a stack of
51
+ cards.
52
+
53
+ Keep container edges subtle. Use `ring-1 ring-border` for custom container outlines. Do not use a
54
+ bare `border`, black borders, or raw high-contrast border colors as custom container chrome.
55
+
56
+ Custom color is welcome when it carries identity, data, status, or useful emphasis. On a saturated
57
+ surface, choose an explicit light or dark foreground with strong contrast. Keep state colors
58
+ consistent and pair them with text, shape, or an icon when they convey meaning.
59
+
60
+ Use solid filled surfaces by default. A restrained shadow, glow, texture, image, or visualization
61
+ may add depth when it supports the subject. Do not use gradients as generic visual polish. Use a
62
+ gradient only when it encodes information or is essential to the specific content.
63
+
64
+ Use purple, violet, and fuchsia only when the content, brand, or user preference calls for them.
65
+ Never use a purple gradient as a default creativity or technology cue.
66
+
67
+ ### Color starting points
68
+
69
+ These are anchors, not fixed palettes. Tint them or use a single accent.
70
+
71
+ | Content | Useful color families | Typical range |
72
+ | --- | --- | --- |
73
+ | Weather, sky, time | Sky, blue, indigo | 500–700 |
74
+ | Night or dark environments | Indigo, slate | 800–900 |
75
+ | Overcast or neutral data | Slate, zinc, neutral | 500–800 |
76
+ | Nature and health | Emerald, green, teal | 500–700 |
77
+ | Finance and positive movement | Emerald, teal | 600–700 |
78
+ | Music and creative media | Blue, teal, amber, rose | 500–700 |
79
+ | Alerts and urgency | Red, orange | 500–700 |
80
+ | Notes and text | Amber, yellow | 400–600 |
81
+ | Social and communication | Pink, rose | 400–600 |
82
+ | Productivity and systems | Cyan, sky | 500–700 |
83
+
84
+ Use the middle and darker parts of a Tailwind color scale for substantial surfaces, then verify the
85
+ foreground contrast. Brighter values work better as small accents, chart marks, and status signals.
86
+
87
+ ## Typography and hierarchy
88
+
89
+ Inherit the workspace font. Use sentence case for headings, labels, actions, and navigation. Use
90
+ regular weight for most text and medium for emphasis. Other weights are reserved for owner
91
+ hand-tuning.
92
+
93
+ Use a small, consistent type scale. `text-sm` (14 px) is the default for UI text. Use smaller text
94
+ only for genuinely compact metadata and larger text only for clear headings or one meaningful
95
+ display value. Do not create many label styles with slightly different sizes.
96
+
97
+ Keep text contrast clear. Use `text-foreground` for primary content and `text-muted-foreground` for
98
+ genuinely secondary content. Avoid several near-identical text styles that make hierarchy hard to
99
+ read.
100
+
101
+ Reserve `font-mono` for code, command text, and truly code-like identifiers. Do not use monospace for
102
+ numeric UI values, measurements, percentages, timers, timestamps, prices, counts, or labels. Numbers
103
+ inherit the workspace's default font; add `tabular-nums` when stable digit widths or alignment help.
104
+ A stronger display treatment may lead a widget or view when it serves the content, but it should not
105
+ become a separate type system. Keep no more than two clear type roles in one applet.
106
+
107
+ Build hierarchy with a visible size gap. Give the main value, message, or task the strongest
108
+ emphasis, keep supporting content quieter, and make tertiary metadata easy to ignore. A widget may
109
+ use a large hero value when its footprint supports it. If two elements compete for attention, reduce
110
+ one.
111
+
112
+ Use a 4 px spacing rhythm. As a guide:
113
+
114
+ - 4–8 px keeps tightly related items together.
115
+ - 12–16 px separates groups within a region.
116
+ - 24 px or more marks a section change in larger widgets and views.
117
+
118
+ Prefer spacing over dividers. Keep repeated rows, chart labels, status markers, counters, and
119
+ trailing actions in stable lanes so changing values do not shift the layout.
120
+
121
+ ## Shape and radius
122
+
123
+ Use the shared shadcn radius scale and keep its default radius on standard controls. Ordinary cards,
124
+ fields, list rows, and repeated sections should use `rounded-lg` or `rounded-xl`. Reserve
125
+ `rounded-2xl` and `rounded-3xl` for one expressive focal surface, and use `rounded-full` only for
126
+ real pills, circular buttons, avatars, and status dots. Controls and rectangular content regions
127
+ must not look capsule-shaped.
128
+
129
+ ## Interaction and motion
130
+
131
+ Widgets support quick interactions such as a filter, toggle, refresh, or direct action. Multi-step
132
+ workflows and deep navigation belong in a view. Views may use tabs, filters, and master-detail
133
+ layouts when they organize one coherent screen.
134
+
135
+ Every interactive area must be obvious, keyboard-operable, and large enough to use comfortably.
136
+ Controls need a visible focus state and an accessible name. Use Tabler icons with consistent visual
137
+ weight. Do not rely on color alone, and keep charts understandable with labels, legends, patterns,
138
+ or direct values where needed.
139
+
140
+ Rank motion by purpose:
141
+
142
+ 1. Optional entrance motion introduces the applet or a newly revealed region.
143
+ 2. Interaction feedback covers hover, active, loading, disabled, and optimistic states.
144
+ 3. At most one signature animation may act as the expressive focal point.
145
+
146
+ Keep motion short, interruptible, and safe for reduced-motion preferences. Animate transform and
147
+ opacity where possible. Do not loop decorative motion or animate frequently updating numbers. Audio
148
+ and video must be user-initiated.
149
+
150
+ A single interactive surface may use a restrained tactile treatment such as an inset highlight,
151
+ ring, or soft shadow. Keep this away from the widget's outer root because the host owns the card
152
+ shell.
84
153
 
85
154
  ## States
86
155
 
87
- **Loading** — a skeleton that mirrors the real layout (vary block widths), keeping the background:
88
- ```tsx
89
- <div className="h-3 w-20 rounded bg-foreground/20 animate-pulse" />
90
- ```
91
- **Error** — drop to `bg-background`, one sentence, a retry:
92
- ```tsx
93
- <div className="flex h-full w-full flex-col items-center justify-center gap-2 bg-background p-4 text-center">
94
- <Icon size={24} stroke={1.5} className="text-muted-foreground" />
95
- <span className="text-xs text-destructive">Could not load</span>
96
- <button onClick={retry} className="text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground">
97
- Try again
98
- </button>
99
- </div>
100
- ```
101
- **Empty** — a short prompt, never blank. **Refresh** — keep current data visible (use a separate `refreshing` flag, `animate-spin` the button). **Stale** — a `text-foreground/50` timestamp pinned to the bottom with `mt-auto`, re-rendered on an interval.
102
-
103
- ## Helper
104
-
105
- Widgets can't import the project `cn`. Use a local `cx()`; never template-literal ternaries in `className`:
106
- ```tsx
107
- function cx(...classes: (string | false | undefined | null)[]) {
108
- return classes.filter(Boolean).join(' ')
109
- }
110
- ```
156
+ Design every state the applet can actually reach. Static applets do not need invented async states.
157
+ Data-driven applets need the following when applicable:
158
+
159
+ - **Loading:** show a skeleton that mirrors the final layout and preserves its surface. Use a spinner
160
+ only for a compact inline action or work with no meaningful content shape.
161
+ - **Error:** explain the problem in one human sentence and provide a retry or clear recovery action.
162
+ - **Empty:** show a short explanation and a useful next step. Never leave a data region blank.
163
+ - **Refreshing:** keep current data visible and show progress on the refresh action. Do not replace
164
+ useful content with the initial loading state.
165
+ - **Stale:** show a quiet timestamp or status near the affected data and keep it current.
166
+ - **Disabled:** preserve the label and structure while making the unavailable state clear without
167
+ relying on color alone.
168
+
169
+ Keep state layouts stable so loading, success, empty, and error do not cause avoidable jumps. Errors
170
+ and empty states should still fit the configured widget height or the view's normal content frame.
171
+
172
+ ## Widgets
173
+
174
+ Widgets are compact dashboard surfaces seen alongside other widgets. They should reveal their main
175
+ meaning within a quick scan. Larger widgets may add supporting charts, lists, metadata, filters, and
176
+ direct actions while keeping one clear first reading.
177
+
178
+ ### Frame
179
+
180
+ The host card owns the outer radius, border, shadow, clipping, and elevation. A widget owns only its
181
+ content surface. Its root fills the available rectangle and must not add outer card chrome. The
182
+ content may use a semantic background, solid color, image, or visualization.
183
+
184
+ Use a column layout when content needs a footer or timestamp, and keep lower-priority information at
185
+ the bottom. Important content needs safe padding from every edge. Use `p-4` as the compact default;
186
+ `p-5` suits larger footprints when the content still fits.
187
+
188
+ ### Grid and sizing
189
+
190
+ The dashboard grid has four columns, 160 px rows, 8 px gaps, and a maximum width of 640 px. A widget
191
+ may span one to four rows and columns. Width shrinks with the workspace; height stays fixed by the
192
+ selected row span.
193
+
194
+ The exact height is:
195
+
196
+ `rowSpan × 160 + (rowSpan − 1) × 8`
197
+
198
+ Common maximum sizes are:
199
+
200
+ | Footprint | Maximum outer size | Approximate content after `p-4` |
201
+ | --- | --- | --- |
202
+ | 1 × 1 | 154 × 160 px | 122 × 128 px |
203
+ | 2 × 1 | 316 × 160 px | 284 × 128 px |
204
+ | 2 × 2 | 316 × 328 px | 284 × 296 px |
205
+ | 4 × 2 | 640 × 328 px | 608 × 296 px |
206
+ | 4 × 3 | 640 × 496 px | 608 × 464 px |
207
+ | 4 × 4 | 640 × 664 px | 608 × 632 px |
208
+
209
+ Treat width as flexible and height as the hard constraint. Start with the smallest footprint that
210
+ presents the content clearly. Test the narrowest realistic width and the longest realistic values.
211
+ Clip decorative overflow deliberately, clamp supporting prose, and keep the widget itself from
212
+ creating horizontal page scroll or an accidental inner page scroller.
213
+
214
+ ### Composition
215
+
216
+ Give the eye one primary element and no more than two supporting groups in a small widget. Larger
217
+ footprints may carry more information when spacing and alignment preserve the first reading. Prefer
218
+ live information over labels that repeat obvious context.
219
+
220
+ Keep controls limited to the immediate task. A compact mode switch can work; tabs, wizards, and
221
+ multi-step flows usually indicate that the content should become a view.
222
+
223
+ ## Views
224
+
225
+ Views are full app screens for denser information and sustained work. They own their page hierarchy,
226
+ content layout, spacing, chrome, and scrolling. A view should feel complete at the available size and
227
+ remain usable when the chat shares the workspace.
228
+
229
+ One view represents one screen. Cross-screen navigation belongs to the workspace. Internal tabs,
230
+ filters, or a master-detail split may organize the current task without introducing a separate
231
+ client-side routing system.
232
+
233
+ Let the content choose the frame. Most views need clear page context, a primary work area, and an
234
+ obvious place for the main action. A header with a title and optional subtitle or action is a useful
235
+ default. A canvas, map, or immersive data surface may establish context another way.
236
+
237
+ Use generous, consistent page padding such as 24 or 32 px for normal views. Constrain prose, forms,
238
+ and narrow task flows to a readable maximum width. Let tables, boards, maps, and visual workspaces use
239
+ more of the frame when that improves the task.
240
+
241
+ Prefer one main page scroller. Use bounded internal scrolling only for regions that benefit from
242
+ independent position, such as a sticky table body, timeline, or board. The page itself must not
243
+ create horizontal scroll.
244
+
245
+ Views and widgets share the same color, type, motion, and state vocabulary. Views may use more
246
+ sections, controls, and information layers while preserving a clear primary work area. Avoid
247
+ stretching a widget-like card to fill the page.
248
+
249
+ ## Final review
250
+
251
+ After implementation, do a removal pass from top to bottom. For every label, badge, icon, helper
252
+ sentence, container, divider, and decoration, ask which user decision, action, or understanding it
253
+ improves. Remove it when the screen stays equally clear and usable without it.
254
+
255
+ Before finishing an applet, confirm:
256
+
257
+ - Every visible element has a clear purpose.
258
+ - Its purpose and first reading are clear at the intended size.
259
+ - Semantic colors handle structure and custom color has a reason.
260
+ - Surfaces use solid fills by default; gradients have a content-specific reason.
261
+ - Purple appears only for a content, brand, or user reason and never as a default gradient.
262
+ - Type, spacing, density, and expression support the content.
263
+ - Numeric UI values use the default font, with `tabular-nums` when alignment helps.
264
+ - Custom container outlines use a subtle `ring-border`.
265
+ - The layout handles realistic content and deliberate overflow.
266
+ - Every reachable state and interaction is complete and accessible.
267
+ - The widget or view follows its frame, sizing, and scrolling rules.
268
+ - It feels related to the workspace without copying the quieter host shell.
@@ -76,6 +76,7 @@ my-agent-folder/
76
76
  widgets/ <- source code of Widget React components
77
77
  total-users.tsx
78
78
  rps-chart.tsx
79
+ _utils.tsx <- `_`-prefixed files are shared code, not applets (optional)
79
80
  server-metrics.server.ts <- Server-side async functions the widget can call (optional)
80
81
  ...
81
82
  views/
@@ -110,9 +111,13 @@ never from inside `.moi/` itself. You don't pass paths; moi resolves the workspa
110
111
 
111
112
  - `moi bundle` — compile changed applets
112
113
  - `moi bundle --force` — rebuild all applets (use after changing `config`)
113
- - `moi refresh` — re-fetch widget/view data without rebuilding (use after you mutated data the
114
- widgets read — DB rows, files, external API records — so the displayed values catch up)
114
+ - `moi refresh` — re-fetch widget and view data without rebuilding (use after you mutated data the
115
+ applets read — DB rows, files, external API records — so the displayed values catch up);
116
+ `--only widgets` / `--only views` narrows the refresh to one kind
115
117
  - `moi call-server-fn <module>/<fn> '[args]'` — invoke a `.server.ts` function directly (smoke test)
118
+ - `moi tabs` — list the workspace's tabs, their ids and the default tab
119
+ - `moi tab focus <tab-id> [--params '<json-object>']` — switch to a tab, with optional params for
120
+ the target view (see Driving the workspace)
116
121
  - `moi debug logs` — applet runtime errors on record (experimental)
117
122
  - `moi theme --font=<key>` — change font theme (omit `--font` to list options)
118
123
  - `moi theme --color=<key>` — change color preset (omit `--color` to list options)
@@ -133,7 +138,7 @@ For more options, commands, use `moi help`.
133
138
 
134
139
  Every applet — a **Widget** or a **View** — is a default-exported React component in
135
140
  `.moi/<type>/<name>.tsx`, optionally paired with a `<name>.server.ts`. `moi bundle` compiles each
136
- into a live module the browser loads (edits hot-reload). Read `DESIGN.md` / `VIEW-DESIGN.md` first.
141
+ into a live module the browser loads (edits hot-reload). Read `DESIGN.md` first.
137
142
  Write normal React + Tailwind — below is only what's **moi-specific**.
138
143
 
139
144
  ## Anatomy
@@ -155,7 +160,26 @@ export default function Hello() {
155
160
  }
156
161
  ```
157
162
 
158
- Imports resolve from the same folder or `.moi/package.json` deps only — no `@/` aliases.
163
+ Imports resolve relatively (same folder, or elsewhere under `.moi/` — e.g. `../lib/format`) or
164
+ from `.moi/package.json` deps — no `@/` aliases. Files starting with `_` (e.g. `_utils.tsx`) in
165
+ `widgets/` and `views/` are never applet entry points — put code shared between applets there.
166
+ `moi bundle` tracks these local imports: editing a shared module rebuilds every applet using it.
167
+
168
+ ## Applet styling
169
+
170
+ - Use Tailwind for static styling. Do not add custom CSS, `@apply`, or static `style={{}}` values.
171
+ - Use `style={{}}` only for computed data such as chart geometry, progress, per-item delays, or
172
+ per-frame transforms.
173
+ - Use icons from `@tabler/icons-react`. Do not add raw SVG icons or another icon pack. When the
174
+ project provides `.agents/rules/icons.md`, follow its size and stroke policy.
175
+ - Applets cannot import the host project's `cn`. Use a local `cx()` when classes are conditional;
176
+ do not build class names with template-literal ternaries.
177
+
178
+ ```tsx
179
+ function cx(...classes: (string | false | undefined | null)[]) {
180
+ return classes.filter(Boolean).join(' ')
181
+ }
182
+ ```
159
183
 
160
184
  ## Server functions — `<name>.server.ts`
161
185
 
@@ -198,6 +222,54 @@ It's plain Bun — every Bun API is available with no setup: `bun:sqlite`, `Bun.
198
222
  Rule of thumb: small own art → `import`; structured data → `.server.ts` returns it; large/streamable
199
223
  media → `.server.ts` returns the **path**, render with `fileUrl()`.
200
224
 
225
+ ## Driving the workspace — `focusTab` & `sendChatMessage`
226
+
227
+ An applet can move the user to another tab and talk to you, through two functions from the **`moi`**
228
+ package.
229
+
230
+ ```tsx
231
+ import { focusTab, sendChatMessage } from 'moi'
232
+
233
+ // A widget row drilling into a view, and a button that asks you to do something.
234
+ focusTab('view:orders', { order: 'o-1024' })
235
+ sendChatMessage('Chase order o-1024', { order: 'o-1024', carrier: 'dhl' })
236
+ ```
237
+
238
+ - `focusTab(tab, params?)` switches the workspace to a tab. Tab ids are `agent`, `widgets`,
239
+ `scratchpad`, and `view:<id>` — run `moi tabs` for the real list. `params` arrive as the target
240
+ view's `params` prop.
241
+ - `sendChatMessage(message, context?)` sends `message` to the active chat as if the user typed it.
242
+ `context` is structured data you see and the user does not. Call it from event handlers, never
243
+ during render. Context can contain additional instructions not visible to the user, describing how
244
+ the task should be done.
245
+ - `params` and `context` accept JSON serializable values only.
246
+
247
+ ### Params: the type is the contract
248
+
249
+ A view with addressable state declares a local `Params` type in its own file. Every field is
250
+ optional and carries a comment, because the view must render sensibly with `{}` — a fresh mount, a
251
+ plain tab-bar click, or a new browser tab all deliver nothing.
252
+
253
+ ```tsx
254
+ // .moi/views/orders.tsx
255
+ // The view's addressable state — what `focusTab('view:orders', …)` can set.
256
+ type Params = {
257
+ // Order id to open in the detail pane; omit to show the list.
258
+ order?: string
259
+ }
260
+
261
+ export default function Orders({ params = {} }: { params?: Params }) {
262
+ // Values arrive from navigation state, so narrow before trusting them.
263
+ const openOrder = typeof params.order === 'string' ? params.order : null
264
+ …
265
+ }
266
+ ```
267
+
268
+ **Applets never import from each other, not even types.** Before wiring a `focusTab` call, read the
269
+ target view's source, mirror the shape you find there, and note where you read it. That file is the
270
+ contract; the type is documentation, not a shared module. Widgets are never navigation targets —
271
+ their `params` is always `{}`.
272
+
201
273
  ## Environment & secrets
202
274
 
203
275
  Each workspace has an effective env: keys from the project's `.env` / `.env.local` (when
@@ -254,8 +326,9 @@ export const config = {
254
326
  ```
255
327
 
256
328
  Render **content only**: a plain `h-full w-full` region with no card chrome (`rounded-*`,
257
- `shadow-*`, outer `border`, or a card-like background) — the dashboard owns the shell, spacing, and
258
- elevation. Changing `colSpan`/`rowSpan` needs `moi bundle --force`. See `DESIGN.md`.
329
+ `shadow-*`, or outer `border`) — the dashboard owns the shell, spacing, and elevation. It does not
330
+ own the fill, so the widget must set its own opaque background.
331
+ Changing `colSpan`/`rowSpan` needs `moi bundle --force`. See `DESIGN.md`.
259
332
 
260
333
  Typical loop: check/`bun install` deps → write `.moi/widgets/<name>.tsx` → `moi bundle` → it appears
261
334
  on the dashboard → change it and re-`bundle`, or `moi refresh` after mutating data, or any other `moi`
@@ -285,7 +358,8 @@ surfaces on its own.
285
358
 
286
359
  # Views
287
360
 
288
- Full-screen apps, one per nav tab — the user switches tabs; there is no routing inside a view.
361
+ Full-screen apps, one per nav tab — the user switches tabs. A view has no router of its own, but it
362
+ can be addressed: see Driving the workspace for `focusTab` and the `params` prop.
289
363
 
290
364
  ## View builder requests
291
365
 
@@ -314,7 +388,7 @@ export const config = {
314
388
  ```
315
389
 
316
390
  The inverse of a widget: a view **owns its whole page** — its own `h-full w-full` layout, scrolling
317
- (`overflow-auto`), padding, and chrome. Build it to read like an app screen. See `VIEW-DESIGN.md`.
391
+ (`overflow-auto`), padding, and chrome. Build it to read like an app screen. See `DESIGN.md`.
318
392
 
319
393
  # Keeping this skill current
320
394
 
@@ -323,9 +397,9 @@ This skill is installed with moi (via the CLI or the UI) and can fall behind whe
323
397
  - **You'll know** — `moi` commands warn you when this skill is behind.
324
398
  - **To update** — run `moi skill update`. Never mid-task: finish first, or do it at the end.
325
399
  - **Re-read after updating** — `moi skill update` rewrites `SKILL.md` and its companion docs
326
- (`DESIGN.md`, `VIEW-DESIGN.md`, `SCRATCHPAD.md`) on disk, so the copy already in your context is
327
- stale. Re-read this `SKILL.md` before you rely on it again — don't act on the old version.
400
+ (`DESIGN.md` and `SCRATCHPAD.md`) on disk, so the copy already in your context is stale. Re-read
401
+ this `SKILL.md` before you rely on it again — don't act on the old version.
328
402
  - **Then** — if you updated, mention it.
329
403
 
330
404
  <!-- moi skill version marker — read by `moi skill` to detect drift; do not edit by hand -->
331
- <moi-skill version="0.7.0" />
405
+ <moi-skill version="0.9.0" />
@@ -1,82 +0,0 @@
1
- import { type RefObject, useEffect } from 'react'
2
-
3
- import { FONT_THEMES } from '@/lib/themes'
4
- import type { WorkspaceLayout } from '@/lib/types'
5
-
6
- const COLOR_OVERRIDES = ['background', 'foreground'] as const
7
- const FONT_LINK_ID = 'mei-fonts'
8
-
9
- // Applies the workspace theme (font + color overrides) to a target element —
10
- // the workspace panel, NOT :root — so the sidebar and other pages keep the
11
- // default tokens. CSS custom properties inherit and every Tailwind token is a
12
- // `var(--…)` reference, so `bg-background` / `text-foreground` / `font-sans`
13
- // inside the subtree resolve the scoped values (the element re-declares
14
- // `font-family: var(--font-sans)` via the `font-sans` class so the font
15
- // re-resolves locally rather than inheriting the already-resolved root font).
16
- //
17
- // Everything is torn down on unmount: the inline vars are removed (the element
18
- // usually unmounts with the page anyway) and the injected Google Fonts <link>
19
- // is dropped, so leaving the workspace leaves no global residue.
20
- export function useWorkspaceTheme(
21
- theme: WorkspaceLayout['theme'],
22
- target: RefObject<HTMLElement | null>
23
- ) {
24
- const font = theme?.font ?? 'default'
25
- // Read the scoped color overrides up front so the color effect below depends
26
- // on these exact values rather than the whole `theme` object (it accesses
27
- // them via a dynamic key, which the deps linter can't see through).
28
- const background = theme?.background
29
- const foreground = theme?.foreground
30
-
31
- useEffect(() => {
32
- const el = target.current
33
- if (!el) return
34
- const config = FONT_THEMES[font] ?? FONT_THEMES.default
35
-
36
- el.style.setProperty('--font-sans', config.sans)
37
- el.style.setProperty('--font-mono', config.mono)
38
-
39
- // Ensure the font files are available (the <link> is global; applying the
40
- // font is what's scoped, via the vars above).
41
- const existing = document.getElementById(FONT_LINK_ID) as HTMLLinkElement | null
42
- if (!config.googleFontsQuery) {
43
- existing?.remove()
44
- } else {
45
- const url = `https://fonts.googleapis.com/css2?family=${config.googleFontsQuery}&display=swap`
46
- if (existing) {
47
- existing.href = url
48
- } else {
49
- const link = document.createElement('link')
50
- link.id = FONT_LINK_ID
51
- link.rel = 'stylesheet'
52
- link.href = url
53
- document.head.appendChild(link)
54
- }
55
- }
56
-
57
- return () => {
58
- el.style.removeProperty('--font-sans')
59
- el.style.removeProperty('--font-mono')
60
- }
61
- }, [font, target])
62
-
63
- useEffect(() => {
64
- const el = target.current
65
- if (!el) return
66
- const overrides = { background, foreground }
67
- for (const key of COLOR_OVERRIDES) {
68
- const value = overrides[key]
69
- if (value) {
70
- el.style.setProperty(`--${key}`, value)
71
- } else {
72
- el.style.removeProperty(`--${key}`)
73
- }
74
- }
75
- return () => {
76
- for (const key of COLOR_OVERRIDES) el.style.removeProperty(`--${key}`)
77
- }
78
- }, [background, foreground, target])
79
-
80
- // Drop the shared font <link> when the workspace unmounts.
81
- useEffect(() => () => document.getElementById(FONT_LINK_ID)?.remove(), [])
82
- }