moi-computer 0.4.0 → 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 (123) hide show
  1. package/README.md +41 -5
  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 +3 -3
  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 +4 -4
  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/runtime/useWorkspaceEvents.ts +15 -2
  75. package/client/runtime/workspace-theme.ts +115 -0
  76. package/client/store/ui.ts +42 -17
  77. package/client/theme.css +20 -15
  78. package/dist/{chunk-fh2mf6v9.js → chunk-3m1xe1j3.js} +94 -94
  79. package/dist/chunk-5vaevt8z.js +2 -0
  80. package/dist/{chunk-69nhbjhy.js → chunk-7bzpmtxp.js} +4 -4
  81. package/dist/chunk-h0hk61pm.js +9 -0
  82. package/dist/{chunk-35fq49qa.js → chunk-h3evrtyp.js} +1 -1
  83. package/dist/chunk-k5sjx9s5.js +1 -0
  84. package/dist/{chunk-2vaafjp4.js → chunk-m9qja0nx.js} +1 -1
  85. package/dist/chunk-s7za1qsv.css +1 -0
  86. package/dist/{chunk-72atbmh3.js → chunk-tcfa3vt3.js} +1 -1
  87. package/dist/chunk-v797g6ap.js +51 -0
  88. package/dist/chunk-xyrw8318.js +27 -0
  89. package/dist/index.html +1 -1
  90. package/lib/app-icons.ts +73 -0
  91. package/lib/moi-context.ts +104 -3
  92. package/lib/themes.ts +83 -45
  93. package/lib/types.ts +44 -9
  94. package/lib/workspace-tabs.ts +48 -0
  95. package/package.json +4 -1
  96. package/server/api.ts +57 -5
  97. package/server/app-settings.ts +65 -0
  98. package/server/applets.ts +132 -22
  99. package/server/bundler/build-applet.ts +74 -16
  100. package/server/cli.ts +144 -17
  101. package/server/control.ts +53 -7
  102. package/server/data-dir.ts +1 -1
  103. package/server/events.ts +1 -1
  104. package/server/functions-worker.ts +15 -1
  105. package/server/functions.ts +51 -6
  106. package/server/layout.ts +9 -14
  107. package/server/moi-scaffold.ts +37 -3
  108. package/server/registry.ts +1 -1
  109. package/server/skill-update.ts +47 -0
  110. package/server/skill-version.ts +2 -11
  111. package/server/tabs.ts +59 -0
  112. package/server/theme.ts +8 -14
  113. package/server/view-builders.ts +6 -2
  114. package/workspace/.claude/skills/moi-workspace/DESIGN.md +265 -107
  115. package/workspace/.claude/skills/moi-workspace/SKILL.md +85 -11
  116. package/client/features/workspace/useWorkspaceTheme.ts +0 -82
  117. package/dist/chunk-19g80zc9.css +0 -1
  118. package/dist/chunk-7mkv2gr0.js +0 -2
  119. package/dist/chunk-gt7n06ef.js +0 -1
  120. package/dist/chunk-jwmc32rp.js +0 -63
  121. package/dist/chunk-kh24bstm.js +0 -10
  122. package/dist/chunk-sfa4mbmx.js +0 -15
  123. package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +0 -22
@@ -7,21 +7,12 @@
7
7
  import { readdir } from 'node:fs/promises'
8
8
  import { join } from 'node:path'
9
9
 
10
- import type { WorkspaceType } from '@/lib/types'
10
+ import type { WorkspaceSkillStatus, WorkspaceType } from '@/lib/types'
11
11
 
12
12
  import { findWorkspaceForPath, liftToWorkspaceRoot, listWorkspaces } from './registry'
13
13
  import { BUNDLED_SKILLS_DIR } from './skills-template'
14
14
  import { skillsDirFor } from './workspace-init'
15
15
 
16
- export type SkillStatus = {
17
- name: string
18
- // Version stamped in the workspace's copy. `null` means absent — either the
19
- // skill isn't installed or it predates skill versioning (treated as behind).
20
- installed: string | null
21
- // Version shipped with this CLI. `null` only if a bundled skill lacks a stamp.
22
- bundled: string | null
23
- }
24
-
25
16
  // The version is stamped as a self-contained marker in SKILL.md, e.g.
26
17
  // `<moi-skill version="0.1.0" />`, rather than in YAML frontmatter. SKILL.md
27
18
  // frontmatter is NOT reliably strict YAML — the free-text `description` routinely
@@ -99,7 +90,7 @@ export async function bundledSkillNames(): Promise<string[]> {
99
90
  export async function skillStatuses(
100
91
  workspaceRoot: string,
101
92
  type?: WorkspaceType
102
- ): Promise<SkillStatus[]> {
93
+ ): Promise<WorkspaceSkillStatus[]> {
103
94
  const names = await bundledSkillNames()
104
95
  const skillsDir = skillsDirFor(workspaceRoot, type)
105
96
  return Promise.all(
package/server/tabs.ts ADDED
@@ -0,0 +1,59 @@
1
+ // `moi tabs` / `moi tab focus` server logic: assemble the tab listing and
2
+ // validate a focus target. Pure given its inputs — the control handler wires
3
+ // in the workspace lookups (see control.ts), tests pass fakes.
4
+ import type { ViewInfo, WorkspaceTabId } from '@/lib/types'
5
+ import { viewIdFromTab, viewTabId } from '@/lib/workspace-tabs'
6
+
7
+ // One row of `moi tabs`. `isDefault` marks the workspace's saved default tab
8
+ // (`layout.tabs.active`) — where a bare `/workspace/:id` lands.
9
+ export type TabRow = {
10
+ id: WorkspaceTabId
11
+ title: string
12
+ isDefault: boolean
13
+ }
14
+
15
+ // The always-present tabs, titled like the tab bar renders them.
16
+ const STATIC_TABS: { id: WorkspaceTabId; title: string }[] = [
17
+ { id: 'agent', title: 'Agent' },
18
+ { id: 'widgets', title: 'Widgets' },
19
+ { id: 'scratchpad', title: 'Scratchpad' }
20
+ ]
21
+
22
+ // The `moi tabs` listing: static tabs plus each built view, the saved default
23
+ // marked. View builders are transient build-state, not addressable tabs, so
24
+ // they don't list (and a builder default simply marks no row).
25
+ export function assembleTabRows(views: ViewInfo[], defaultTab: WorkspaceTabId): TabRow[] {
26
+ return [
27
+ ...STATIC_TABS,
28
+ ...views.map(view => ({ id: viewTabId(view.id), title: view.config.title || view.id }))
29
+ ].map(row => ({ ...row, isDefault: row.id === defaultTab }))
30
+ }
31
+
32
+ type FocusTabDeps = {
33
+ // Whether a view id exists in the workspace (source or built) — hasViewId.
34
+ hasView: (viewId: string) => Promise<boolean>
35
+ // The built views, for the error message's valid-id list — getViewList.
36
+ viewList: () => Promise<ViewInfo[]>
37
+ }
38
+
39
+ export type FocusTabResult = { ok: true; tab: WorkspaceTabId } | { ok: false; error: string }
40
+
41
+ // Validate a `moi tab focus` target: static ids pass as-is, `view:<id>` must
42
+ // name a real view. Anything else — including view-builder tabs — fails with
43
+ // the list of valid ids. Addressing is by tab id, never by title.
44
+ export async function resolveFocusTab(raw: unknown, deps: FocusTabDeps): Promise<FocusTabResult> {
45
+ const tab = typeof raw === 'string' ? raw.trim() : ''
46
+ if (STATIC_TABS.some(row => row.id === tab)) return { ok: true, tab: tab as WorkspaceTabId }
47
+
48
+ const viewId = tab.startsWith('view:') ? viewIdFromTab(tab as WorkspaceTabId) : null
49
+ if (viewId && (await deps.hasView(viewId))) return { ok: true, tab: tab as WorkspaceTabId }
50
+
51
+ const validIds = [
52
+ ...STATIC_TABS.map(row => row.id),
53
+ ...(await deps.viewList()).map(view => viewTabId(view.id))
54
+ ]
55
+ return {
56
+ ok: false,
57
+ error: `Unknown tab "${tab || String(raw ?? '')}". Valid tabs: ${validIds.join(', ')}`
58
+ }
59
+ }
package/server/theme.ts CHANGED
@@ -8,9 +8,8 @@ export type ThemeUpdateResult =
8
8
  | { ok: true; theme: ThemeShape; applied: { font?: FontTheme; color?: ColorTheme } }
9
9
  | { ok: false; error: string }
10
10
 
11
- // Pure merge + validation for a theme update. Spreads the existing theme so
12
- // setting one axis never wipes the other. 'default' color is stored as
13
- // `undefined` bg/fg, which JSON.stringify drops on save.
11
+ // Pure merge + validation for a theme update. The workspace stores only the
12
+ // selected font and primary; all other color tokens are derived at runtime.
14
13
  export function applyThemeUpdate(
15
14
  current: WorkspaceLayout['theme'],
16
15
  update: ThemeUpdate
@@ -22,15 +21,10 @@ export function applyThemeUpdate(
22
21
  return { ok: false, error: `Unknown color theme: ${update.color}` }
23
22
  }
24
23
 
24
+ const primary = update.color ? COLOR_THEMES[update.color as ColorTheme].primary : current?.primary
25
25
  const theme: ThemeShape = {
26
- ...current,
27
- font: (update.font as FontTheme) ?? current?.font ?? 'default'
28
- }
29
-
30
- if (update.color) {
31
- const preset = COLOR_THEMES[update.color as ColorTheme]
32
- theme.background = preset.background
33
- theme.foreground = preset.foreground
26
+ font: (update.font as FontTheme) ?? current?.font ?? 'default',
27
+ ...(primary ? { primary } : {})
34
28
  }
35
29
 
36
30
  return {
@@ -43,13 +37,13 @@ export function applyThemeUpdate(
43
37
  }
44
38
  }
45
39
 
46
- // Reverse-lookup: resolve stored bg/fg to a preset key, or null for custom colors.
47
- export function matchColorTheme(bg: string | undefined, fg: string | undefined): ColorTheme | null {
40
+ // Reverse-lookup: resolve the stored primary to a preset key, or null for custom colors.
41
+ export function matchColorTheme(primary: string | undefined): ColorTheme | null {
48
42
  for (const [key, preset] of Object.entries(COLOR_THEMES) as [
49
43
  ColorTheme,
50
44
  (typeof COLOR_THEMES)[ColorTheme]
51
45
  ][]) {
52
- if (preset.background === bg && preset.foreground === fg) return key
46
+ if (preset.primary === primary) return key
53
47
  }
54
48
  return null
55
49
  }
@@ -1,6 +1,7 @@
1
1
  import { mkdir, rename } from 'node:fs/promises'
2
2
  import { join } from 'node:path'
3
3
 
4
+ import { APP_ICON_IDS, isAppIconId } from '@/lib/app-icons'
4
5
  import { newBuilderId } from '@/lib/ids'
5
6
  import type { AppletKind, ViewBuilder, ViewInfo } from '@/lib/types'
6
7
 
@@ -193,8 +194,11 @@ export async function setBuilder(
193
194
  if (!/^[a-z0-9][a-z0-9_-]*$/.test(appletId)) {
194
195
  throw new ViewBuilderError('Invalid applet id', 400)
195
196
  }
196
- if (input.icon !== undefined && !/^[a-z0-9][a-z0-9-]*$/.test(input.icon)) {
197
- throw new ViewBuilderError('Invalid view icon id', 400)
197
+ if (input.icon !== undefined && !isAppIconId(input.icon)) {
198
+ throw new ViewBuilderError(
199
+ `Unknown view icon id "${input.icon}". Use one of: ${APP_ICON_IDS.join(', ')}`,
200
+ 400
201
+ )
198
202
  }
199
203
  // Views and widgets are separate applet namespaces, so an id is only unique
200
204
  // within a kind — a view and a widget may both be called "stats".
@@ -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.