moi-computer 0.10.1-next.1 → 0.10.1-next.2

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 (47) hide show
  1. package/client/components/shared/AgentBlobatar.tsx +93 -0
  2. package/client/features/chat/ChatEmptyState.tsx +110 -80
  3. package/client/features/chat/ChatPanel.tsx +19 -11
  4. package/client/features/chat/ChatPopup.tsx +23 -11
  5. package/client/features/chat/ChatPromptBubbles.tsx +1 -1
  6. package/client/features/chat/TurnView.tsx +0 -17
  7. package/client/features/chat/useStickToBottom.ts +1 -1
  8. package/client/features/dev/ChatStatesPage.tsx +17 -9
  9. package/client/features/workspace/CustomizePanel.tsx +33 -4
  10. package/client/features/workspace/WorkspaceScreen.tsx +11 -5
  11. package/client/features/workspace/WorkspaceTabs.tsx +5 -8
  12. package/client/index.css +22 -12
  13. package/client/index.tsx +1 -0
  14. package/client/theme.css +9 -0
  15. package/dist/{chunk-efdyz6xp.js → chunk-0pcdwjkp.js} +1 -1
  16. package/dist/chunk-4xmcsjjv.js +1 -0
  17. package/dist/{chunk-5t06zksf.js → chunk-8jh75pjg.js} +2 -2
  18. package/dist/{chunk-97eg9mjn.js → chunk-9y2zbzqz.js} +1 -1
  19. package/dist/chunk-dfs36zgc.js +1 -0
  20. package/dist/chunk-e4e993yf.js +83 -0
  21. package/dist/chunk-ek8w9tsp.css +1 -0
  22. package/dist/chunk-vq8ga42s.js +1 -0
  23. package/dist/{chunk-ht1f95h9.js → chunk-yhj9bg1s.js} +2 -2
  24. package/dist/{chunk-0set7tmf.js → chunk-yt2qjn3m.js} +2 -2
  25. package/dist/chunk-yz743a75.js +10 -0
  26. package/dist/index.html +1 -1
  27. package/lib/themes.ts +21 -3
  28. package/lib/types.ts +1 -1
  29. package/package.json +4 -2
  30. package/server/bundler/build-applet.ts +30 -0
  31. package/server/cli-ui-components.ts +258 -0
  32. package/server/cli.ts +48 -5
  33. package/server/control.ts +5 -3
  34. package/server/moi-scaffold.ts +9 -1
  35. package/server/skills-template.ts +5 -0
  36. package/server/theme.ts +17 -5
  37. package/server/ui-components.ts +545 -0
  38. package/workspace/.claude/skills/moi-workspace/SKILL.md +27 -6
  39. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +10 -2
  40. package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +211 -0
  41. package/client/components/shared/IconGhost.tsx +0 -127
  42. package/dist/chunk-10knptd0.css +0 -1
  43. package/dist/chunk-b4qp3p42.js +0 -83
  44. package/dist/chunk-dfe7qnrp.js +0 -1
  45. package/dist/chunk-h2kj1ysj.js +0 -1
  46. package/dist/chunk-nek4ec05.js +0 -1
  47. package/dist/chunk-qtc5a8qa.js +0 -10
@@ -0,0 +1,211 @@
1
+ # UI components cheat sheet
2
+
3
+ `moi ui-components` installs standard controls from a selected subset of the shadcn registry,
4
+ pre-tuned for moi applets: **Base UI** primitives, **Tabler** icons, workspace theme tokens,
5
+ relative imports, and overlays patched so applet styling survives portalling. Components land
6
+ in `.moi/ui/` as plain source files you own.
7
+
8
+ This file is the catalog plus the essential usage rules (condensed from the official shadcn
9
+ skill). Read it once; fetch full per-component docs with `moi ui-components docs <name>` **before
10
+ composing a component you haven't used in this workspace** — the parts API is Base UI, not the
11
+ Radix-era shadcn you may know.
12
+
13
+ ## Workflow
14
+
15
+ ```sh
16
+ moi ui-components # catalog + what's installed
17
+ moi ui-components add select # → .moi/ui/select.tsx (+ any support files)
18
+ moi ui-components docs select # official docs as markdown
19
+ bun install <deps> # in .moi/ — only when `add` prints extra deps
20
+ moi bundle # rebuild applets
21
+ ```
22
+
23
+ ```tsx
24
+ // In an applet — always relative, never @/ aliases, never the host app's components:
25
+ import { Button } from '../ui/button'
26
+ import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from '../ui/select'
27
+ ```
28
+
29
+ - `add` writes source files and nothing else — installing the deps it prints and rebuilding is
30
+ your job.
31
+ - **If the build fails on a missing package** (happens in workspaces scaffolded before this
32
+ feature — `.moi/package.json` may lack the deps ui components need): check
33
+ `.moi/package.json` and install what's missing. Every ui component needs the baseline
34
+
35
+ ```sh
36
+ bun install @base-ui/react class-variance-authority clsx tailwind-merge
37
+ ```
38
+
39
+ (run in `.moi/`), plus whatever `add` printed for the specific component (`recharts`,
40
+ `embla-carousel-react`, `react-day-picker` + `date-fns`, `react-resizable-panels`,
41
+ `@tanstack/react-table`).
42
+ - Files in `.moi/ui/` are yours to customize; `add` refuses to overwrite them without `--force`.
43
+ - Support files appear without being asked for (`utils.ts` with `cn`, `applet-portal.tsx`, and
44
+ registry dependencies like `separator`, `card`, `toggle`) — normal; use them if handy.
45
+ `applet-portal.tsx` is auto-generated machinery: never edit or remove it.
46
+
47
+ ## Catalog
48
+
49
+ Import from `../ui/<name>` (same as the component name).
50
+
51
+ **Form & input:** `button` (variants, sizes, icons) · `button-group` (segmented buttons) ·
52
+ `input` · `textarea` · `input-group` (input with addons) · `field` (label + control +
53
+ description + error) · `label` · `checkbox` · `radio-group` · `switch` · `slider` · `select` ·
54
+ `combobox` (type-to-filter for long lists) · `toggle-group` (2–7 option sets) · `calendar` ·
55
+ `date-picker` (pattern: calendar in a popover — see its docs; installs `calendar` + `popover` +
56
+ `button`)
57
+
58
+ **Overlays (portal-patched):** `dialog` · `alert-dialog` (destructive confirm) · `popover` ·
59
+ `dropdown-menu` · `context-menu` (right-click) · `hover-card` · `tooltip`
60
+
61
+ **Display & feedback:** `alert` (callouts) · `badge` · `avatar` · `skeleton` · `spinner` ·
62
+ `progress` · `table` · `data-table` (pattern on `table` + `@tanstack/react-table` — see its
63
+ docs) · `chart` (Recharts wired to theme tokens) · `attachment` (file/image tile) · `bubble`
64
+ (chat message)
65
+
66
+ **Structure & navigation:** `accordion` · `collapsible` · `tabs` · `carousel` · `pagination` ·
67
+ `resizable` (split panels)
68
+
69
+ Picking one: quick info on hover → `hover-card` or `tooltip` · contextual panel on click →
70
+ `popover` · focused task needing input → `dialog` · destructive confirmation → `alert-dialog` ·
71
+ option sets of 2–7 → `toggle-group` · long searchable lists → `combobox` · boolean setting →
72
+ `switch`, boolean in a form → `checkbox`.
73
+
74
+ ## Composition rules
75
+
76
+ - **Custom triggers use the `render` prop** — this is Base UI, there is no `asChild`. Never wrap
77
+ a trigger in an extra element. Applies to every Trigger and Close part (`DialogTrigger`,
78
+ `PopoverTrigger`, `DropdownMenuTrigger`, `TooltipTrigger`, `CollapsibleTrigger`,
79
+ `DialogClose`, …).
80
+
81
+ ```tsx
82
+ <DialogTrigger render={<Button variant="outline" />}>Open</DialogTrigger>
83
+ ```
84
+
85
+ - **`render` to a non-button element needs `nativeButton={false}`:**
86
+
87
+ ```tsx
88
+ <Button render={<a href="/docs" />} nativeButton={false}>Read the docs</Button>
89
+ ```
90
+
91
+ - **Items always live inside their Group**: `SelectItem`/`SelectLabel` → `SelectGroup`;
92
+ `DropdownMenuItem`/`DropdownMenuLabel`/`DropdownMenuSub` → `DropdownMenuGroup`;
93
+ `ContextMenuItem` → `ContextMenuGroup`. A Label outside its Group **crashes the component at
94
+ runtime** (Base UI requires the group context); keep items grouped too.
95
+ - **`Dialog` and `AlertDialog` always need a Title** (`DialogTitle` — use
96
+ `className="sr-only"` to hide it visually).
97
+ - **`TabsTrigger` must be inside `TabsList`**, never directly in `Tabs`.
98
+ - **`Avatar` always needs `AvatarFallback`** for when the image fails.
99
+ - **Button has no `isLoading`** — compose: `<Button disabled><Spinner data-icon="inline-start" />Saving…</Button>`.
100
+ - **Use components, not custom markup**: callout → `Alert` (+`AlertTitle`/`AlertDescription`),
101
+ loading placeholder → `Skeleton` (no custom `animate-pulse` divs), status chip → `Badge` (no
102
+ styled spans), divider → `Separator` (no `<hr>`/border divs), inline loading → `Spinner`.
103
+
104
+ ## Base UI API gotchas
105
+
106
+ The biggest source of bugs when you know Radix-era shadcn. When unsure, `moi ui-components docs
107
+ <name>` has the real API.
108
+
109
+ - **Select needs an `items` prop on the root**; the placeholder is a `{ value: null }` item, not
110
+ a `placeholder` prop:
111
+
112
+ ```tsx
113
+ const items = [
114
+ { label: 'Pick a fruit', value: null },
115
+ { label: 'Apple', value: 'apple' },
116
+ ]
117
+ <Select items={items}>
118
+ <SelectTrigger><SelectValue /></SelectTrigger>
119
+ <SelectContent>
120
+ <SelectGroup>
121
+ {items.map(item => (
122
+ <SelectItem key={item.value} value={item.value}>{item.label}</SelectItem>
123
+ ))}
124
+ </SelectGroup>
125
+ </SelectContent>
126
+ </Select>
127
+ ```
128
+
129
+ Extras: `multiple` + render-function `SelectValue` for multi-select; `itemToStringValue` for
130
+ object values; `alignItemWithTrigger={false}` to position like a plain dropdown.
131
+ - **ToggleGroup**: no `type` prop — single-select by default, `multiple` for multi; `value`/
132
+ `defaultValue` is **always an array** (`defaultValue={["daily"]}`; controlled single value:
133
+ `value={[value]} onValueChange={v => setValue(v[0])}`).
134
+ - **Slider**: plain number for one thumb (`defaultValue={50}`), array only for ranges.
135
+ - **Accordion**: no `type`/`collapsible` props — `defaultValue` is **always an array**
136
+ (`defaultValue={["item-1"]}`), `multiple` to allow several open.
137
+
138
+ ## Forms
139
+
140
+ - Lay out forms with `FieldGroup` + `Field` — never raw `div`s with spacing utilities:
141
+
142
+ ```tsx
143
+ <FieldGroup>
144
+ <Field>
145
+ <FieldLabel htmlFor="email">Email</FieldLabel>
146
+ <Input id="email" type="email" />
147
+ <FieldDescription>Work email preferred.</FieldDescription>
148
+ </Field>
149
+ </FieldGroup>
150
+ ```
151
+
152
+ `Field orientation="horizontal"` for settings rows; `FieldSet` + `FieldLegend` for groups of
153
+ related checkboxes/radios/switches.
154
+ - **Validation and disabled need both attributes**: `data-invalid` on `Field` + `aria-invalid`
155
+ on the control; `data-disabled` on `Field` + `disabled` on the control.
156
+ - **Inside `InputGroup`, use `InputGroupInput`/`InputGroupTextarea`** — never raw
157
+ `Input`/`Textarea`. A button attached to an input is `InputGroup` + `InputGroupAddon`, never
158
+ absolute positioning over an `Input`.
159
+ - **2–7 exclusive options → `ToggleGroup`**, not a loop of `Button`s with manual active state.
160
+ - Control chooser: free text → `input`/`textarea` · predefined options → `select` · searchable →
161
+ `combobox` · boolean setting → `switch` · boolean consent → `checkbox` · one-of-few →
162
+ `radio-group` · numeric range → `slider`.
163
+
164
+ ## Styling
165
+
166
+ - **Semantic tokens only, never raw colors**: `bg-primary`, `text-muted-foreground`,
167
+ `text-destructive`, `bg-popover` — not `bg-blue-500` or `text-emerald-600`. Every token pairs
168
+ `name`/`name-foreground` (background / text-on-it): `background`, `card`, `popover`,
169
+ `primary`, `secondary`, `muted`, `accent`, `destructive`, plus `border`, `input`, `ring`,
170
+ `chart-1…5`, and `--radius`. Status colors come from `Badge` variants or `text-destructive`.
171
+ - **Built-in variants before custom classes**: `variant="outline"`, `size="sm"` — not
172
+ hand-rolled border/bg utilities on `Button`.
173
+ - **Prefer each component's default size.** Use smaller variants such as `sm` or `xs` only when a
174
+ real density constraint calls for them and the reduced control remains comfortable to use. When
175
+ using a non-default size, compare it with neighboring controls. Controls in the same group must
176
+ have matching heights and compatible visual weight.
177
+ - **`className` is for layout** (`max-w-md`, `mt-4`, `w-full`) — never for overriding a
178
+ component's colors or typography.
179
+ - **`gap-*`, not `space-x-*`/`space-y-*`** (`flex flex-col gap-4`). **`size-10`, not
180
+ `w-10 h-10`.** **`truncate`**, not the three-class spell.
181
+ - **`cn()` from `../ui/utils` for conditional classes** — no template-literal ternaries.
182
+ - **No manual `z-index` on overlays** — dialog/popover/menu/tooltip handle their own stacking.
183
+
184
+ ## Icons
185
+
186
+ - Tabler only: `import { IconSearch } from '@tabler/icons-react'` — every name is
187
+ `Icon`-prefixed. Installed components already come converted.
188
+ - In a `Button`, mark position with `data-icon="inline-start"` / `"inline-end"`; **no sizing
189
+ classes on icons inside components** (Button, DropdownMenuItem, Alert size them via CSS).
190
+ - Pass icons as component objects (`icon={IconCheck}`), never as string keys into a lookup map.
191
+
192
+ ## Customization
193
+
194
+ Cheapest first — stop at the first level that works:
195
+
196
+ 1. **Workspace theme** (`moi theme`) — fonts, colors, radius flow into every component through
197
+ tokens.
198
+ 2. **Built-in variants + `className` layout** at the callsite (merges correctly via `cn`).
199
+ 3. **Edit the file in `.moi/ui/`** — e.g. add a `cva` variant to `button.tsx`; propagates to
200
+ every applet using it, and `add` won't overwrite it without `--force`.
201
+ 4. **Wrapper components** — compose primitives into app-level pieces (a `ConfirmDialog` wrapping
202
+ `AlertDialog` parts) in `.moi/widgets/_shared.tsx`-style files.
203
+
204
+ ## Fit within applets
205
+
206
+ - **Widgets** are small: keep the composition compact, the number of controls low, and enough room
207
+ around each action. Keep interactions inline and self-contained; avoid layered UI such as
208
+ popovers and tooltips. Page-scale chrome (sidebars, nav menus, sheets, toasts) is deliberately not
209
+ in the set — widgets don't need it, and a view's chrome should be custom (see
210
+ `references/DESIGN.md`).
211
+ - **Views** can use the full set, including `resizable` layouts and `data-table`.
@@ -1,127 +0,0 @@
1
- import type { Ref } from 'react'
2
-
3
- import { motion, useReducedMotion } from 'motion/react'
4
-
5
- import type { IconProps } from '@tabler/icons-react'
6
-
7
- import { cn } from '@/client/lib/cn'
8
-
9
- type IconGhostProps = IconProps & {
10
- animated?: boolean
11
- ref?: Ref<SVGSVGElement>
12
- }
13
-
14
- type Point = {
15
- x: number
16
- y: number
17
- }
18
-
19
- const bodyPath =
20
- 'M5 11a7 7 0 0 1 14 0v7a1.78 1.78 0 0 1 -3.1 1.4a1.65 1.65 0 0 0 -2.6 0a1.65 1.65 0 0 1 -2.6 0a1.65 1.65 0 0 0 -2.6 0a1.78 1.78 0 0 1 -3.1 -1.4v-7'
21
-
22
- const animatedEdgeY = 18.85
23
-
24
- function formatPoint(value: number): string {
25
- return value.toFixed(3)
26
- }
27
-
28
- function smoothPath(points: Point[]): string {
29
- let path = ''
30
-
31
- for (let index = 0; index < points.length - 1; index += 1) {
32
- const previous = points[index - 1] ?? points[index]
33
- const current = points[index]
34
- const next = points[index + 1]
35
- const afterNext = points[index + 2] ?? next
36
- const firstControl =
37
- index === 0
38
- ? { x: current.x, y: current.y + 0.4 }
39
- : {
40
- x: current.x + (next.x - previous.x) / 6,
41
- y: current.y + (next.y - previous.y) / 6
42
- }
43
- const secondControl =
44
- index === points.length - 2
45
- ? { x: next.x, y: next.y + 0.4 }
46
- : {
47
- x: next.x - (afterNext.x - current.x) / 6,
48
- y: next.y - (afterNext.y - current.y) / 6
49
- }
50
-
51
- path += `C${formatPoint(firstControl.x)} ${formatPoint(firstControl.y)} ${formatPoint(secondControl.x)} ${formatPoint(secondControl.y)} ${formatPoint(next.x)} ${formatPoint(next.y)}`
52
- }
53
-
54
- return path
55
- }
56
-
57
- function bodyPathAt(progress: number): string {
58
- const phase = progress * Math.PI * 2
59
- const verticalProgress = 1 - Math.abs(progress * 2 - 1)
60
- const verticalOffset = verticalProgress * 1.55
61
- const edgeY = animatedEdgeY + verticalOffset
62
- const points = Array.from({ length: 13 }, (_, index): Point => {
63
- const horizontalProgress = index / 12
64
- const envelope = Math.sin(Math.PI * horizontalProgress) ** 0.35
65
- const baseline = edgeY + 0.3 * envelope
66
- const wave = 0.55 * envelope * Math.sin(5 * Math.PI * horizontalProgress - phase)
67
-
68
- return {
69
- x: 5 + 14 * horizontalProgress,
70
- y: baseline + wave
71
- }
72
- })
73
- const sideLength = edgeY - 11
74
-
75
- return `M5 11a7 7 0 0 1 14 0v${formatPoint(sideLength)}${smoothPath(points.reverse())}v-${formatPoint(sideLength)}`
76
- }
77
-
78
- const animatedBodyPaths = Array.from({ length: 17 }, (_, index) => bodyPathAt(index / 16))
79
-
80
- function IconGhost({
81
- animated = false,
82
- color = 'currentColor',
83
- size = 24,
84
- stroke = 2,
85
- title,
86
- className,
87
- children,
88
- ref,
89
- ...props
90
- }: IconGhostProps) {
91
- const prefersReducedMotion = useReducedMotion()
92
- const shouldAnimate = animated && !prefersReducedMotion
93
-
94
- return (
95
- <svg
96
- ref={ref}
97
- xmlns="http://www.w3.org/2000/svg"
98
- width={size}
99
- height={size}
100
- viewBox="0 0 24 24"
101
- fill="none"
102
- stroke={color}
103
- strokeWidth={stroke}
104
- strokeLinecap="round"
105
- strokeLinejoin="round"
106
- className={cn('tabler-icon tabler-icon-ghost', className)}
107
- {...props}
108
- >
109
- {title && <title>{title}</title>}
110
- {shouldAnimate ? (
111
- <motion.path
112
- d={animatedBodyPaths[0]}
113
- animate={{ d: animatedBodyPaths }}
114
- transition={{ duration: 2, ease: 'linear', repeat: Infinity }}
115
- />
116
- ) : (
117
- <path d={bodyPath} />
118
- )}
119
- <path d="M10 10l.01 0" />
120
- <path d="M14 10l.01 0" />
121
- <path d="M10 14a3.5 3.5 0 0 0 4 0" />
122
- {children}
123
- </svg>
124
- )
125
- }
126
-
127
- export { IconGhost }