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.
- package/README.md +41 -5
- package/bin/moi.mjs +11 -0
- package/client/api/workspace-keys.ts +1 -0
- package/client/app/AppRouter.tsx +5 -1
- package/client/app/routes/WorkspaceRoute.tsx +9 -5
- package/client/app/shell/SidebarLayout.tsx +9 -7
- package/client/components/shared/BottomPanel.tsx +24 -5
- package/client/components/shared/Composer.tsx +1 -1
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/components/ui/button.tsx +5 -5
- package/client/components/ui/dropdown-menu.tsx +6 -6
- package/client/components/ui/hover-card.tsx +1 -1
- package/client/components/ui/input.tsx +1 -1
- package/client/components/ui/popover.tsx +1 -1
- package/client/components/ui/skeleton.tsx +1 -1
- package/client/components/ui/textarea.tsx +1 -1
- package/client/components/ui/tooltip.tsx +1 -1
- package/client/features/applets/applet-cache.ts +20 -1
- package/client/features/applets/applet-log.ts +10 -30
- package/client/features/applets/applet-runtime.ts +272 -0
- package/client/features/applets/useApplet.ts +36 -10
- package/client/features/chat/ChatComposer.tsx +1 -1
- package/client/features/chat/ChatEmptyState.tsx +186 -0
- package/client/features/chat/ChatPanel.tsx +95 -54
- package/client/features/chat/ChatPopup.tsx +3 -13
- package/client/features/chat/ChatPromptBubbles.tsx +74 -0
- package/client/features/chat/MarkdownContent.tsx +15 -3
- package/client/features/chat/ModelPicker.tsx +1 -1
- package/client/features/chat/TurnView.tsx +6 -17
- package/client/features/chat/chat-send.ts +26 -1
- package/client/features/chat/tool-group/CodeBlock.tsx +1 -1
- package/client/features/chat/tool-group/ReadImagePreview.tsx +1 -1
- package/client/features/chat/tool-group/SubagentCard.tsx +1 -1
- package/client/features/chat/tool-group/TimelineRow.tsx +4 -4
- package/client/features/chat/tool-group/ToolCallGroup.tsx +12 -5
- package/client/features/chat/tool-group/ToolOutput.tsx +2 -2
- package/client/features/chat/tool-group/format.ts +3 -3
- package/client/features/chat/useAppletChatMessage.ts +69 -0
- package/client/features/chat/useChat.ts +49 -14
- package/client/features/chat/useStickToBottom.ts +11 -1
- package/client/features/connectors/McpServerCards.tsx +3 -3
- package/client/features/dev/HarnessDebugPage.tsx +4 -4
- package/client/features/dev/PixelPainter.tsx +1 -1
- package/client/features/dev/PlaygroundPage.tsx +1 -1
- package/client/features/dev/ToolCallsPage.tsx +2 -2
- package/client/features/home/HomePage.tsx +17 -14
- package/client/features/home/WorkspacePreview.tsx +12 -13
- package/client/features/home/api.ts +8 -5
- package/client/features/home/workspace-presentation.tsx +1 -1
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +1 -1
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +21 -8
- package/client/features/scratchpad/Scratchpad.tsx +41 -2
- package/client/features/scratchpad/ScratchpadControls.tsx +13 -13
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +1 -1
- package/client/features/settings/EnvironmentSettings.tsx +1 -1
- package/client/features/settings/IconPicker.tsx +11 -11
- package/client/features/settings/SettingsLayout.tsx +1 -1
- package/client/features/settings/WorkspaceSettings.tsx +2 -2
- package/client/features/settings/api.ts +33 -1
- package/client/features/widgets/HiddenPanel.tsx +4 -3
- package/client/features/widgets/Widgets.tsx +1 -0
- package/client/features/workspace/CustomizePanel.tsx +96 -82
- package/client/features/workspace/WorkspaceScreen.tsx +129 -107
- package/client/features/workspace/WorkspaceSkillUpdateBanner.tsx +91 -0
- package/client/features/workspace/WorkspaceTabs.tsx +1 -1
- package/client/features/workspace/api.ts +52 -0
- package/client/features/workspace/moi-context.ts +63 -17
- package/client/features/workspace/tab-resolution.ts +75 -0
- package/client/features/workspace/useWorkspaceNavigation.ts +128 -0
- package/client/features/workspace/useWorkspaceSkillUpdates.ts +160 -0
- package/client/index.css +10 -15
- package/client/lib/app-icon-registry.ts +77 -70
- package/client/lib/rate-limit.ts +77 -0
- package/client/runtime/useWorkspaceEvents.ts +15 -2
- package/client/runtime/workspace-theme.ts +115 -0
- package/client/store/ui.ts +42 -17
- package/client/theme.css +20 -15
- package/dist/{chunk-fh2mf6v9.js → chunk-3m1xe1j3.js} +94 -94
- package/dist/chunk-5vaevt8z.js +2 -0
- package/dist/{chunk-69nhbjhy.js → chunk-7bzpmtxp.js} +4 -4
- package/dist/chunk-h0hk61pm.js +9 -0
- package/dist/{chunk-35fq49qa.js → chunk-h3evrtyp.js} +1 -1
- package/dist/chunk-k5sjx9s5.js +1 -0
- package/dist/{chunk-2vaafjp4.js → chunk-m9qja0nx.js} +1 -1
- package/dist/chunk-s7za1qsv.css +1 -0
- package/dist/{chunk-72atbmh3.js → chunk-tcfa3vt3.js} +1 -1
- package/dist/chunk-v797g6ap.js +51 -0
- package/dist/chunk-xyrw8318.js +27 -0
- package/dist/index.html +1 -1
- package/lib/app-icons.ts +73 -0
- package/lib/moi-context.ts +104 -3
- package/lib/themes.ts +83 -45
- package/lib/types.ts +44 -9
- package/lib/workspace-tabs.ts +48 -0
- package/package.json +4 -1
- package/server/api.ts +57 -5
- package/server/app-settings.ts +65 -0
- package/server/applets.ts +132 -22
- package/server/bundler/build-applet.ts +74 -16
- package/server/cli.ts +144 -17
- package/server/control.ts +53 -7
- package/server/data-dir.ts +1 -1
- package/server/events.ts +1 -1
- package/server/functions-worker.ts +15 -1
- package/server/functions.ts +51 -6
- package/server/layout.ts +9 -14
- package/server/moi-scaffold.ts +37 -3
- package/server/registry.ts +1 -1
- package/server/skill-update.ts +47 -0
- package/server/skill-version.ts +2 -11
- package/server/tabs.ts +59 -0
- package/server/theme.ts +8 -14
- package/server/view-builders.ts +6 -2
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +265 -107
- package/workspace/.claude/skills/moi-workspace/SKILL.md +85 -11
- package/client/features/workspace/useWorkspaceTheme.ts +0 -82
- package/dist/chunk-19g80zc9.css +0 -1
- package/dist/chunk-7mkv2gr0.js +0 -2
- package/dist/chunk-gt7n06ef.js +0 -1
- package/dist/chunk-jwmc32rp.js +0 -63
- package/dist/chunk-kh24bstm.js +0 -10
- package/dist/chunk-sfa4mbmx.js +0 -15
- package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +0 -22
|
@@ -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
|
|
114
|
-
|
|
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`
|
|
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
|
|
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
|
|
258
|
-
|
|
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
|
|
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 `
|
|
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
|
|
327
|
-
|
|
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.
|
|
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
|
-
}
|