moi-computer 0.7.0 → 0.8.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 (48) hide show
  1. package/README.md +2 -2
  2. package/client/components/shared/BottomPanel.tsx +2 -1
  3. package/client/components/shared/PanelHeader.tsx +1 -1
  4. package/client/features/applets/AppletMount.tsx +9 -22
  5. package/client/features/applets/applet-cache.ts +7 -0
  6. package/client/features/applets/applet-styles.ts +21 -1
  7. package/client/features/applets/useApplet.ts +1 -1
  8. package/client/features/chat/ChatComposer.tsx +18 -4
  9. package/client/features/chat/ChatSelector.tsx +1 -1
  10. package/client/features/chat/TurnView.tsx +1 -1
  11. package/client/features/home/api.ts +0 -10
  12. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +21 -64
  13. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +1 -1
  14. package/client/features/scratchpad/Scratchpad.tsx +1 -3
  15. package/client/features/views/ViewManager.tsx +258 -0
  16. package/client/features/views/view-residency.ts +77 -0
  17. package/client/features/widgets/WidgetFrame.tsx +6 -2
  18. package/client/features/workspace/CustomizePanel.tsx +40 -24
  19. package/client/features/workspace/WorkspaceLayoutContext.tsx +8 -0
  20. package/client/features/workspace/WorkspaceScreen.tsx +51 -103
  21. package/client/features/workspace/WorkspaceTabs.tsx +1 -1
  22. package/client/index.css +4 -1
  23. package/client/runtime/workspace-theme.ts +29 -10
  24. package/client/theme.css +96 -6
  25. package/dist/chunk-0k7brsms.js +9 -0
  26. package/dist/{chunk-m11ckkxd.js → chunk-dtwxpxbg.js} +1 -1
  27. package/dist/{chunk-55sh4dty.js → chunk-ga7t9qsk.js} +1 -1
  28. package/dist/{chunk-w3tnv51j.js → chunk-h9h8f176.js} +1 -1
  29. package/dist/{chunk-rxvx4ta9.js → chunk-r5ce5cdg.js} +2 -2
  30. package/dist/chunk-tey2nq7c.js +31 -0
  31. package/dist/{chunk-afgbg75t.js → chunk-z73xpsa0.js} +1 -1
  32. package/dist/chunk-zzgredta.css +1 -0
  33. package/dist/index.html +1 -1
  34. package/lib/themes.ts +123 -51
  35. package/lib/types.ts +2 -5
  36. package/package.json +5 -4
  37. package/server/api.ts +2 -73
  38. package/server/bundler/build-applet.ts +7 -4
  39. package/server/cli.ts +46 -15
  40. package/server/control.ts +13 -6
  41. package/server/moi-scaffold.ts +1 -1
  42. package/server/registry.ts +0 -20
  43. package/server/theme.ts +24 -27
  44. package/workspace/.claude/skills/moi-workspace/DESIGN.md +94 -57
  45. package/workspace/.claude/skills/moi-workspace/SKILL.md +10 -12
  46. package/dist/chunk-175bm057.js +0 -27
  47. package/dist/chunk-agtetn7n.css +0 -1
  48. package/dist/chunk-exj6hr30.js +0 -9
package/server/theme.ts CHANGED
@@ -1,17 +1,17 @@
1
- import { COLOR_THEMES, FONT_THEMES } from '@/lib/themes'
2
- import type { ColorTheme, FontTheme, WorkspaceLayout } from '@/lib/types'
1
+ import { COLOR_THEMES, FONT_THEMES, RADIUS_THEMES, resolveWorkspaceTheme } from '@/lib/themes'
2
+ import type { ColorTheme, FontTheme, RadiusTheme, WorkspaceTheme } from '@/lib/types'
3
3
 
4
- type ThemeShape = NonNullable<WorkspaceLayout['theme']>
5
-
6
- export type ThemeUpdate = { font?: string; color?: string }
4
+ export type ThemeUpdate = { font?: string; color?: string; radius?: string }
7
5
  export type ThemeUpdateResult =
8
- | { ok: true; theme: ThemeShape; applied: { font?: FontTheme; color?: ColorTheme } }
6
+ | {
7
+ ok: true
8
+ theme: WorkspaceTheme
9
+ applied: Partial<WorkspaceTheme>
10
+ }
9
11
  | { ok: false; error: string }
10
12
 
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.
13
13
  export function applyThemeUpdate(
14
- current: WorkspaceLayout['theme'],
14
+ current: WorkspaceTheme | undefined,
15
15
  update: ThemeUpdate
16
16
  ): ThemeUpdateResult {
17
17
  if (update.font && !(update.font in FONT_THEMES)) {
@@ -20,30 +20,27 @@ export function applyThemeUpdate(
20
20
  if (update.color && !(update.color in COLOR_THEMES)) {
21
21
  return { ok: false, error: `Unknown color theme: ${update.color}` }
22
22
  }
23
-
24
- const primary = update.color ? COLOR_THEMES[update.color as ColorTheme].primary : current?.primary
25
- const theme: ThemeShape = {
26
- font: (update.font as FontTheme) ?? current?.font ?? 'default',
27
- ...(primary ? { primary } : {})
23
+ if (update.radius && !(update.radius in RADIUS_THEMES)) {
24
+ return { ok: false, error: `Unknown radius theme: ${update.radius}` }
28
25
  }
29
26
 
27
+ const font = update.font as FontTheme | undefined
28
+ const color = update.color as ColorTheme | undefined
29
+ const radius = update.radius as RadiusTheme | undefined
30
+ const theme = resolveWorkspaceTheme({
31
+ ...current,
32
+ ...(font ? { font } : {}),
33
+ ...(color ? { color } : {}),
34
+ ...(radius ? { radius } : {})
35
+ })
36
+
30
37
  return {
31
38
  ok: true,
32
39
  theme,
33
40
  applied: {
34
- ...(update.font ? { font: update.font as FontTheme } : {}),
35
- ...(update.color ? { color: update.color as ColorTheme } : {})
41
+ ...(font ? { font } : {}),
42
+ ...(color ? { color } : {}),
43
+ ...(radius ? { radius } : {})
36
44
  }
37
45
  }
38
46
  }
39
-
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 {
42
- for (const [key, preset] of Object.entries(COLOR_THEMES) as [
43
- ColorTheme,
44
- (typeof COLOR_THEMES)[ColorTheme]
45
- ][]) {
46
- if (preset.primary === primary) return key
47
- }
48
- return null
49
- }
@@ -29,57 +29,97 @@ spacing, or interaction patterns. They do not need to look identical.
29
29
 
30
30
  ## Color
31
31
 
32
- ### Widget surfaces
32
+ Widgets and views use the same semantic token vocabulary. Use
33
+ `h-full w-full bg-background text-foreground` for most applet roots. Each token keeps the same
34
+ purpose in both applet types; the host changes its value to suit the surrounding surface.
33
35
 
34
- The host applies the `.dark` class around every widget. Semantic tokens inside a widget therefore
35
- use dark-mode values regardless of the workspace color preset. The host frame stays transparent, so
36
- every widget root must cover the full frame with an opaque background.
36
+ ### How tokens resolve
37
37
 
38
- Choose each widget's background deliberately. Prefer an intentional solid color for most widgets,
39
- using your design judgment to fit the content, purpose, mood, data, status, and surrounding widgets.
40
- Pair it with a readable foreground and keep the surface consistent through every state. An image or
41
- visualization may own the surface when it has an opaque fallback.
38
+ - **Widgets:** The host applies a widget-local semantic theme derived from the selected workspace
39
+ color. `background` is the workspace `primary`, `foreground` is its paired readable color, and
40
+ the local `primary` pair becomes the light action surface derived from that color. The host frame
41
+ stays transparent, so every widget root must cover the full frame with an opaque background. An
42
+ image or visualization may own the surface when it has an opaque fallback.
43
+ - **Views:** Semantic tokens inherit the workspace page theme. The default root uses the normal
44
+ workspace page surface and text.
45
+ - **Portalled UI:** Menus, tooltips, and popovers render in workspace scope and keep
46
+ `bg-popover text-popover-foreground`.
42
47
 
43
- `h-full w-full bg-background text-foreground` is a sensible fallback when no more specific surface
44
- fits. In the widget scope, it resolves to a dark background with light text.
45
-
46
- ### View surfaces
47
-
48
- Views are separate pages. Their semantic tokens inherit the workspace theme, so
49
- `h-full w-full bg-background text-foreground` is a sensible default root.
48
+ ### Semantic token reference
50
49
 
51
50
  | Context or intent | Tailwind classes | Use |
52
51
  | --- | --- | --- |
53
- | Widget fallback | `bg-background text-foreground` | Dark semantic surface when no content-led color fits |
54
- | Default view root | `bg-background text-foreground` | The workspace page surface and text |
55
- | Primary content | `text-foreground` | Content on the default dark widget surface or normal view surface |
56
- | Secondary content | `text-muted-foreground` | Supporting content on the default dark widget surface or normal view surface |
57
- | Inset surface | `bg-card text-card-foreground` | A real contained object or raised region inside the applet |
52
+ | Applet root | `bg-background text-foreground` | The full widget surface or view page |
53
+ | Main content | `text-foreground` | Titles, labels, values, and important icons |
54
+ | Supporting content | `text-muted-foreground` | Descriptions and secondary information |
55
+ | Inset surface | `bg-card text-card-foreground` | A functionally distinct contained region, used sparingly |
58
56
  | Floating surface | `bg-popover text-popover-foreground` | Menus, tooltips, and other floating content |
59
- | Primary action | `bg-primary text-primary-foreground` | The most important action in a local region |
60
- | Subdued surface | `bg-muted` | Skeletons, quiet fills, and disabled structure |
61
- | Control state | `bg-accent text-accent-foreground` | Hover, active, and selected states on interactive controls |
62
- | Error or danger | `text-destructive` / `bg-destructive` | Errors, destructive actions, and invalid states |
63
- | Structure | `ring-border`, `border-input`, `ring-ring` | Container edges, controls, and visible focus on semantic surfaces |
57
+ | Quiet fill | `bg-muted` | Inset regions, skeletons, and disabled structure |
58
+ | Control state | `bg-accent text-accent-foreground` | Hover, active, and selected controls |
59
+ | Main action | `bg-primary text-primary-foreground hover:bg-primary/90` | The most important action in a local region |
60
+ | Positive or active state | `text-success` / `bg-success/10` | Positive outcomes, healthy states, presence, and progress indicators |
61
+ | Error or danger | `text-destructive` / `bg-destructive/10` | Errors, destructive actions, and invalid states |
62
+ | Object edge | `ring-1 ring-border` | Complete outlines around containers and controls |
63
+ | Focus | `focus-visible:ring-2 focus-visible:ring-ring` | Visible keyboard focus on interactive elements |
64
+ | Separator | `border-b border-border` | A one-sided division between adjacent regions |
64
65
 
65
66
  Use lower opacity from the surface's foreground only for tertiary metadata that remains readable.
66
- Avoid weak alpha text for important labels or values. Keep inset surfaces rare so a widget does not
67
- become a stack of cards.
68
-
69
- Keep container edges subtle. Use `ring-1 ring-border` on semantic surfaces and an equally restrained
70
- outline suited to a custom light or colored surface. Avoid a bare `border` or raw high-contrast
71
- colors as custom container chrome.
72
-
73
- Custom color is welcome when it carries identity, data, status, or useful emphasis. On a saturated
74
- surface, choose an explicit light or dark foreground with strong contrast. Keep state colors
75
- consistent and pair them with text, shape, or an icon when they convey meaning.
76
-
77
- Use solid filled surfaces by default. A restrained shadow, glow, texture, image, or visualization
78
- may add depth when it supports the subject. Do not use gradients as generic visual polish. Use a
79
- gradient only when it encodes information or is essential to the specific content.
80
-
81
- Use purple, violet, and fuchsia only when the content, brand, or user preference calls for them.
82
- Never use a purple gradient as a default creativity or technology cue.
67
+ Avoid weak alpha text for important labels or values.
68
+
69
+ Prefer a subtle ring for the complete outline of a container or control. Use `ring-1 ring-border` on
70
+ semantic surfaces. Reserve one-sided borders such as `border-b` for separators between adjacent
71
+ regions. Never use a border and a ring on the same element. Avoid raw high-contrast colors for
72
+ either treatment.
73
+
74
+ Derive extra neutral or tonal colors and custom gradients from the local semantic tokens with
75
+ `color-mix()`. Use Tailwind palette colors only when they have clear content meaning, distinguish
76
+ infographic data, or follow an explicit user request. Keep each mapping consistent and explain it
77
+ with labels, legends, shapes, or direct values. Do not use palette colors for generic decoration or
78
+ unrelated widget backgrounds. Purple, violet, and fuchsia need a content, brand, or user reason;
79
+ never use a purple gradient as a default creativity or technology cue. On a saturated surface,
80
+ choose an explicit light or dark foreground with strong contrast.
81
+
82
+ ### Surfaces and grouping
83
+
84
+ Use an open layout by default. Group content with spacing, alignment, type hierarchy, and, when
85
+ needed, a one-sided separator. Add one surface around content that shares a functional boundary: an
86
+ interactive object, an independently scrolling region, a distinct state, or a self-contained work
87
+ region. Page headers, tab rows, summaries, metrics, and ordinary sections stay unboxed by default.
88
+ Standard controls keep their normal component surfaces.
89
+
90
+ Never use a large rounded surface as a second page frame around the header, navigation, summary,
91
+ primary content, and supporting sections. Avoid adjacent or nested cards and wrappers that only
92
+ repeat the page structure.
93
+
94
+ Align page-level content to shared edges or grid columns. Apply outer padding once on the root or
95
+ layout grid, then use gaps to group unboxed content. When removing a surface, remove its card-like
96
+ padding and radius and realign its children; do not leave spacing that implies an invisible card.
97
+
98
+ ### Textures
99
+
100
+ Use one texture on every widget or view root and no more than one per applet. Pair it with an opaque
101
+ semantic base, such as `h-full w-full bg-background text-foreground texture-checker`. The same
102
+ classes resolve through the widget-local theme or view page theme. Skip it only when an opaque
103
+ full-bleed image, map, canvas, or visualization owns the background, the user explicitly asks for a
104
+ plain surface, or preserving readability would require several extra solid wrappers.
105
+
106
+ | Texture | Tailwind class | Character |
107
+ | --- | --- | --- |
108
+ | Checker | `texture-checker` | Two softly tinted semantic squares with no empty cells |
109
+ | Grid | `texture-grid` | Fine semantic graph-paper lines over the base color |
110
+ | Noise | `texture-noise` | Foreground-tinted fractal grain that lets the base tint show through |
111
+ | Linear gradient | `texture-gradient-linear` | A restrained top-to-bottom wash derived from `primary` |
112
+ | Inset shadow | `texture-inset-shadow` | A soft edge glow derived from `primary` |
113
+
114
+ Textures add an effect without setting `background-color`; the base color remains visible through
115
+ them. Open content may sit directly on the textured root when contrast stays clear. Add an opaque
116
+ semantic surface above it only when that surface has a functional reason described under Surfaces
117
+ and grouping. Do not apply a texture to a card, panel, control, or text region, and do not stack
118
+ textures or add tuning variables.
119
+
120
+ Check nearby widgets and views before choosing one. Give unrelated applets different textures so
121
+ they remain distinct at a glance. A widget that opens, summarizes, or represents a view shares that
122
+ view's texture as part of the same visual language.
83
123
 
84
124
  ## Typography and hierarchy
85
125
 
@@ -154,6 +194,8 @@ Data-driven applets need the following when applicable:
154
194
 
155
195
  Keep state layouts stable so loading, success, empty, and error do not cause avoidable jumps. Errors
156
196
  and empty states should still fit the configured widget height or the view's normal content frame.
197
+ When a primary region uses a surface, loading, populated, empty, success, and error states keep that
198
+ surface in the same position and size.
157
199
 
158
200
  ## Widgets
159
201
 
@@ -234,21 +276,16 @@ stretching a widget-like card to fill the page.
234
276
 
235
277
  ## Final review
236
278
 
237
- After implementation, do a removal pass from top to bottom. For every label, badge, icon, helper
238
- sentence, container, divider, and decoration, ask which user decision, action, or understanding it
239
- improves. Remove it when the screen stays equally clear and usable without it.
279
+ After implementation, do a removal pass from top to bottom. For every visible element and wrapper,
280
+ ask what it helps the user understand, do, or recognize as a state. Remove it when the screen stays
281
+ clear without it, then realign the remaining content.
240
282
 
241
283
  Before finishing an applet, confirm:
242
284
 
243
- - Every visible element has a clear purpose.
244
- - Its purpose and first reading are clear at the intended size.
245
- - Semantic colors handle structure and custom color has a reason.
246
- - Surfaces use solid fills by default; gradients have a content-specific reason.
247
- - Purple appears only for a content, brand, or user reason and never as a default gradient.
248
- - Type, spacing, density, and expression support the content.
249
- - Numeric UI values use the default font, with `tabular-nums` when alignment helps.
250
- - Custom container outlines suit their surface and stay subtle.
251
- - The layout handles realistic content and deliberate overflow.
252
- - Every control is necessary, complete, and accessible.
253
- - The widget or view follows its frame, sizing, and scrolling rules.
254
- - It feels related to the workspace without copying the quieter host shell.
285
+ - The first reading and every visible element have a clear purpose.
286
+ - Color, texture, type, spacing, and expression support the content and remain readable.
287
+ - Surfaces mark real boundaries, and unboxed page content shares clear alignment axes.
288
+ - States remain stable, and the layout handles realistic content and deliberate overflow.
289
+ - Controls are necessary, complete, and accessible.
290
+ - The widget or view follows its frame, sizing, and scrolling rules and feels related to the
291
+ workspace.
@@ -1,12 +1,6 @@
1
1
  ---
2
2
  name: moi-workspace
3
- description: >-
4
- The moi workspace — the web UI the user chats from, extended with agent-authored applets
5
- (widgets, views) plus theme & config. Read this FIRST in two cases. (a) A message carries a hidden
6
- moi-context envelope: it was fired from a moi workspace, so you are running inside one even if
7
- nothing else says so. (b) The user uses moi vocab — workspace, applet, widget, view, scratchpad,
8
- dashboard, or a `moi` command — or asks to build, edit, customize, or theme the workspace UI or
9
- its layout.
3
+ description: The moi workspace — the web UI the user chats from, extended with agent-authored applets (widgets, views) plus theme & config. Read this FIRST when a message carries a hidden moi-context envelope or the user uses moi vocab such as workspace, applet, widget, view, scratchpad, dashboard, or a `moi` command, or asks to build, edit, customize, or theme the workspace UI or its layout.
10
4
  ---
11
5
 
12
6
  # Workspace
@@ -127,6 +121,7 @@ never from inside `.moi/` itself. You don't pass paths; moi resolves the workspa
127
121
  - `moi debug logs` — applet runtime errors on record (experimental)
128
122
  - `moi theme --font=<key>` — change font theme (omit `--font` to list options)
129
123
  - `moi theme --color=<key>` — change color preset (omit `--color` to list options)
124
+ - `moi theme --radius=<key>` — change corner-radius preset (omit `--radius` to list options)
130
125
  - `moi config` — set the workspace name & icon (`moi config --help` for usage)
131
126
  - `moi env` — list available env keys and where they come from (never values);
132
127
  `moi env exec -- <cmd>` runs a command with the workspace env (see Environment & secrets)
@@ -336,9 +331,12 @@ Render **content only**: a plain `h-full w-full` region with no card chrome (`ro
336
331
  own the fill, so the widget must set its own opaque background.
337
332
  Changing `colSpan`/`rowSpan` needs `moi bundle --force`. See `DESIGN.md`.
338
333
 
339
- Typical loop: check/`bun install` deps → write `.moi/widgets/<name>.tsx` → `moi bundle` → it appears
340
- on the dashboard → change it and re-`bundle`, or `moi refresh` after mutating data, or any other `moi`
341
- command as needed. Views work the same way (`.moi/views/<name>.tsx`, appears as a nav tab).
334
+ Typical loop: check/`bun install` deps → write the applet → `moi bundle` → run any checks.
335
+ After the final successful bundle and any checks, always make tab focus the final workspace action:
336
+
337
+ - After building or editing a widget, run `moi tab focus widgets`.
338
+ - After building or editing a view, run `moi tab focus view:<view-id>`, using its file name or claimed
339
+ builder id.
342
340
 
343
341
  # Debugging applets
344
342
 
@@ -381,7 +379,7 @@ moi builder set <view-id> --builder <builder-id> --kind view --title "<title>" -
381
379
  Choose the icon id from the available view icons in the hidden context. The id must use lowercase
382
380
  letters, numbers, `_`, or `-`. The first call locks the id; running the same command again may update
383
381
  its title and icon. After claiming, write `.moi/views/<view-id>.tsx`, use the same icon id in its
384
- config, and finish with `moi bundle --only views`. The tab uses the claimed title and icon while you
382
+ config, and build it with `moi bundle --only views`. The tab uses the claimed title and icon while you
385
383
  work and changes into the built view after a successful bundle. (Bundling marks the view ready; the
386
384
  build state is otherwise server-managed, so you never set it to done by hand.)
387
385
 
@@ -408,4 +406,4 @@ This skill is installed with moi (via the CLI or the UI) and can fall behind whe
408
406
  - **Then** — if you updated, mention it.
409
407
 
410
408
  <!-- moi skill version marker — read by `moi skill` to detect drift; do not edit by hand -->
411
- <moi-skill version="0.10.0" />
409
+ <moi-skill version="0.11.0" />