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
package/README.md
CHANGED
|
@@ -6,14 +6,50 @@
|
|
|
6
6
|
THE UI FOR YOUR AI
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
An extendable visual workspace where your AI agents build their own UI.
|
|
10
10
|
See [moi.computer](https://moi.computer) for what it is and how it works.
|
|
11
11
|
|
|
12
|
+
Moi gives your agent of choice a UI it can reshape on the fly and grow into your
|
|
13
|
+
personal software. Under the hood, the agent writes and embeds live components
|
|
14
|
+
wired to real data: APIs, local files and commands, MCP servers.
|
|
15
|
+
|
|
12
16
|
Works with the harness you already use:
|
|
13
17
|
|
|
14
|
-
| [Claude Code](https://github.com/anthropics/claude-code) | [Codex](https://github.com/openai/codex) |
|
|
15
|
-
|
|
|
16
|
-
| [OpenClaw](https://github.com/openclaw/openclaw)
|
|
18
|
+
| <img src="assets/harnesses/claude.svg" width="16" /> [Claude Code](https://github.com/anthropics/claude-code) | <img src="assets/harnesses/codex.png" width="16" /> [Codex](https://github.com/openai/codex) |
|
|
19
|
+
| :------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------- |
|
|
20
|
+
| <img src="assets/harnesses/openclaw.svg" width="16" /> [OpenClaw](https://github.com/openclaw/openclaw) | <img src="assets/harnesses/hermes.png" width="16" /> Hermes _(coming soon)_ |
|
|
21
|
+
|
|
22
|
+
# Features
|
|
23
|
+
|
|
24
|
+
- **Workspace**. The folder where your agent (e.g. Claude Code) runs and keeps
|
|
25
|
+
its data. It gets a special skill that teaches it how to communicate with moi.
|
|
26
|
+
- **Theme**. The agent can modify the appearance of the workspace for you:
|
|
27
|
+
fonts, color scheme and more.
|
|
28
|
+
- **Scratchpad**. A shared canvas where you ideate together with the agent: ask
|
|
29
|
+
it to draw diagrams, add feedback or comments, visualize knowledge and plans.
|
|
30
|
+
- **Widgets**. A dynamic dashboard made of small apps wired to the data from
|
|
31
|
+
your workspace. They can be rearranged, modified, and completely customized.
|
|
32
|
+
- **Views**. An app embedded in the workspace that lives in its own tab. Build
|
|
33
|
+
complex interfaces: CRMs, task trackers, second brain storage, customer
|
|
34
|
+
support views, etc.
|
|
35
|
+
|
|
36
|
+
<table>
|
|
37
|
+
<tr>
|
|
38
|
+
<td align="center"><img src="assets/screenshots/moi-moi-dash-2.webp" alt="Widgets dashboard" /><br /><sub>Widgets wired to live project stats</sub></td>
|
|
39
|
+
<td align="center"><img src="assets/screenshots/moi-magazin-scratch-2.webp" alt="Scratchpad" /><br /><sub>Order funnel on the scratchpad, live from Postgres</sub></td>
|
|
40
|
+
<td align="center"><img src="assets/screenshots/moi-magazin-products-2.webp" alt="Products view" /><br /><sub>Use the agent as a copilot when working with products</sub></td>
|
|
41
|
+
</tr>
|
|
42
|
+
<tr>
|
|
43
|
+
<td align="center"><img src="assets/screenshots/moi-magazin-dash-2.webp" alt="Store dashboard" /><br /><sub>E-commerce store dashboard connected to Postgres and Resend</sub></td>
|
|
44
|
+
<td align="center"><img src="assets/screenshots/moi-view-screen.webp" alt="Roadmap view" /><br /><sub>Build a Roadmap view with epics and pull requests</sub></td>
|
|
45
|
+
<td align="center"><img src="assets/screenshots/moi-scratch.webp" alt="Scratchpad canvas" /><br /><sub>Sketching architecture together with the agent</sub></td>
|
|
46
|
+
</tr>
|
|
47
|
+
<tr>
|
|
48
|
+
<td align="center"><img src="assets/screenshots/moi-color-grading.webp" alt="Color grading review" /><br /><sub>Custom view for color grading</sub></td>
|
|
49
|
+
<td align="center"><img src="assets/screenshots/moi-home.webp" alt="Home screen" /><br /><sub>Home screen with your workspaces</sub></td>
|
|
50
|
+
<td align="center"><img src="assets/screenshots/moi-linear.webp" alt="Issues view" /><br /><sub>Issues view, a lightweight Linear-like tracker</sub></td>
|
|
51
|
+
</tr>
|
|
52
|
+
</table>
|
|
17
53
|
|
|
18
54
|
# Quick start
|
|
19
55
|
|
|
@@ -28,7 +64,7 @@ For OpenClaw or a manual setup, read on.
|
|
|
28
64
|
|
|
29
65
|
## Manual install
|
|
30
66
|
|
|
31
|
-
Make sure [Bun](https://bun.sh) is installed. moi uses it to run the web server and bundle the dynamic UI.
|
|
67
|
+
Make sure [Bun](https://bun.sh) 1.3 or newer is installed. moi uses it to run the web server and bundle the dynamic UI.
|
|
32
68
|
|
|
33
69
|
Install the `moi-computer` package from npm and start the web UI:
|
|
34
70
|
|
package/bin/moi.mjs
CHANGED
|
@@ -11,6 +11,17 @@ if (!process.versions.bun) {
|
|
|
11
11
|
process.exit(1)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
// The widget bundler needs Bun 1.3: it hands `Bun.build` a virtual entrypoint
|
|
15
|
+
// that only 1.3+ lets a plugin resolve. Older Bun starts fine and then fails on
|
|
16
|
+
// the first widget build, so reject it here where the cause is still legible.
|
|
17
|
+
// `?.` because a Bun without `Bun.semver` is old enough to reject anyway.
|
|
18
|
+
const MIN_BUN = '1.3.0'
|
|
19
|
+
if (!Bun.semver?.satisfies(Bun.version, `>=${MIN_BUN}`)) {
|
|
20
|
+
console.error(`moi requires Bun ${MIN_BUN} or newer (this is Bun ${Bun.version}).`)
|
|
21
|
+
console.error('Upgrade Bun: bun upgrade')
|
|
22
|
+
process.exit(1)
|
|
23
|
+
}
|
|
24
|
+
|
|
14
25
|
// The `moi` command is meant to live on your PATH permanently: the agent
|
|
15
26
|
// shells out to `moi bundle`/`moi refresh` from your workspaces, which only
|
|
16
27
|
// works if it's installed. If `moi` doesn't resolve as a command, nudge toward
|
|
@@ -14,5 +14,6 @@ export const workspaceKeys = {
|
|
|
14
14
|
mcp: (id: string) => ['workspaces', 'mcp', id] as const,
|
|
15
15
|
models: (id: string) => ['workspaces', 'models', id] as const,
|
|
16
16
|
availability: (id: string) => ['workspaces', 'availability', id] as const,
|
|
17
|
+
skills: (id: string) => ['workspaces', 'skills', id] as const,
|
|
17
18
|
env: (id: string) => ['workspaces', 'env', id] as const
|
|
18
19
|
}
|
package/client/app/AppRouter.tsx
CHANGED
|
@@ -34,7 +34,11 @@ export function AppRouter() {
|
|
|
34
34
|
<Switch>
|
|
35
35
|
<Route path="/" component={HomeRoute} />
|
|
36
36
|
<Route path="/dev/*?" component={DevLazy} />
|
|
37
|
-
|
|
37
|
+
{/* The wildcard is the workspace tab id (`view:orders`, `widgets`, …) —
|
|
38
|
+
the URL is the tab address, read downstream with `useParams`. This
|
|
39
|
+
pattern is its only definition. Keyed by workspace id only, so tab
|
|
40
|
+
switches never remount the workspace tree. */}
|
|
41
|
+
<Route path="/workspace/:id/*?">
|
|
38
42
|
{(params: { id: string }) => <WorkspaceRoute key={params.id} id={params.id} />}
|
|
39
43
|
</Route>
|
|
40
44
|
</Switch>
|
|
@@ -24,6 +24,8 @@ type WorkspaceRouteProps = {
|
|
|
24
24
|
id: string
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// The URL's tab segment is not threaded down — useWorkspaceNavigation reads it
|
|
28
|
+
// off the matched route with wouter's `useParams`.
|
|
27
29
|
export function WorkspaceRoute({ id }: WorkspaceRouteProps) {
|
|
28
30
|
return (
|
|
29
31
|
<Workspace id={id}>
|
|
@@ -87,11 +89,13 @@ type SeedActiveSessionProps = {
|
|
|
87
89
|
function SeedActiveSession({ workspaceId, sessions }: SeedActiveSessionProps) {
|
|
88
90
|
useEffect(() => {
|
|
89
91
|
if (!sessions) return
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
const activeByWorkspace = liveStore.getState().activeByWorkspace
|
|
93
|
+
const hasActiveSelection = Object.prototype.hasOwnProperty.call(activeByWorkspace, workspaceId)
|
|
94
|
+
const activeSessionId = activeByWorkspace[workspaceId]
|
|
95
|
+
const activeStillValid =
|
|
96
|
+
activeSessionId === null || sessions.some(session => session.sessionId === activeSessionId)
|
|
97
|
+
if (hasActiveSelection && activeStillValid) return
|
|
98
|
+
liveStore.getState().setActive(workspaceId, sessions[0]?.sessionId ?? null)
|
|
95
99
|
}, [workspaceId, sessions])
|
|
96
100
|
return null
|
|
97
101
|
}
|
|
@@ -55,13 +55,12 @@ export function SidebarLayout({
|
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
return (
|
|
58
|
-
<div className=
|
|
58
|
+
<div className={cn('flex h-dvh bg-muted')}>
|
|
59
59
|
<Sidebar workspaces={showWorkspaces ? (workspaces ?? []) : []} />
|
|
60
60
|
<main
|
|
61
61
|
className={cn(
|
|
62
62
|
'flex min-w-0 flex-1 flex-col overflow-hidden',
|
|
63
|
-
panel === 'default' &&
|
|
64
|
-
'rounded-l-md border-l border-border bg-background shadow-[1px_0_3px_0_var(--border)]'
|
|
63
|
+
panel === 'default' && 'bg-background shadow-xs'
|
|
65
64
|
)}
|
|
66
65
|
>
|
|
67
66
|
{children}
|
|
@@ -93,7 +92,7 @@ function Sidebar({ workspaces }: SidebarProps) {
|
|
|
93
92
|
className="flex flex-col gap-4"
|
|
94
93
|
onReorder={ids => reorder.mutate(ids)}
|
|
95
94
|
renderPlaceholder={() => (
|
|
96
|
-
<div className="pointer-events-none absolute top-0 left-1 size-10 rounded-
|
|
95
|
+
<div className="pointer-events-none absolute top-0 left-1 size-10 rounded-xl bg-accent" />
|
|
97
96
|
)}
|
|
98
97
|
renderOverlay={ws => <WorkspaceButton workspace={ws} dragOverlay />}
|
|
99
98
|
renderItem={(ws, state) => <WorkspaceButton workspace={ws} dragState={state} />}
|
|
@@ -134,7 +133,10 @@ function WorkspaceButton({ workspace, dragOverlay = false, dragState }: Workspac
|
|
|
134
133
|
const [location] = useLocation()
|
|
135
134
|
const href = `/workspace/${workspace.id}`
|
|
136
135
|
const label = workspaceDisplayName(workspace)
|
|
137
|
-
|
|
136
|
+
// A workspace URL carries a tab suffix (`/workspace/:id/view:orders`), so the
|
|
137
|
+
// rail matches the workspace segment, not the whole path. The trailing slash
|
|
138
|
+
// keeps `/workspace/ws1` from lighting up a sibling `/workspace/ws1-other`.
|
|
139
|
+
const active = location === href || location.startsWith(`${href}/`)
|
|
138
140
|
const content = (
|
|
139
141
|
<>
|
|
140
142
|
<div
|
|
@@ -150,7 +152,7 @@ function WorkspaceButton({ workspace, dragOverlay = false, dragState }: Workspac
|
|
|
150
152
|
<img
|
|
151
153
|
src={workspace.icon ?? workspaceProviderIcon[workspace.type ?? 'claude-code']}
|
|
152
154
|
alt=""
|
|
153
|
-
className="size-7 shrink-0 rounded-
|
|
155
|
+
className="size-7 shrink-0 rounded-xs"
|
|
154
156
|
/>
|
|
155
157
|
</div>
|
|
156
158
|
<span className="mt-0.5 line-clamp-2 w-full text-center text-[11px] leading-snug font-medium text-ellipsis text-foreground">
|
|
@@ -172,7 +174,7 @@ function WorkspaceButton({ workspace, dragOverlay = false, dragState }: Workspac
|
|
|
172
174
|
if (dragState?.isDragging) event.preventDefault()
|
|
173
175
|
}}
|
|
174
176
|
className={cn(
|
|
175
|
-
'group flex w-14 flex-col items-center rounded-
|
|
177
|
+
'group flex w-14 flex-col items-center rounded-lg outline-none',
|
|
176
178
|
dragState?.isDragging && 'invisible'
|
|
177
179
|
)}
|
|
178
180
|
{...dragState?.dragHandleProps}
|
|
@@ -2,19 +2,29 @@ import type { ReactNode, Ref } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { motion } from 'motion/react'
|
|
4
4
|
|
|
5
|
+
import { IconX } from '@tabler/icons-react'
|
|
6
|
+
|
|
7
|
+
import { Button } from '@/client/components/ui/button'
|
|
8
|
+
import { cn } from '@/client/lib/cn'
|
|
9
|
+
|
|
5
10
|
type BottomPanelProps = {
|
|
11
|
+
className?: string
|
|
6
12
|
title: string
|
|
7
13
|
children: ReactNode
|
|
14
|
+
onClose: () => void
|
|
8
15
|
// Forwarded to the panel element so the working area can measure its height
|
|
9
16
|
// and reserve matching space below the grid.
|
|
10
17
|
ref?: Ref<HTMLDivElement>
|
|
11
18
|
}
|
|
12
19
|
|
|
13
|
-
export function BottomPanel({ title, children, ref }: BottomPanelProps) {
|
|
20
|
+
export function BottomPanel({ className, title, children, onClose, ref }: BottomPanelProps) {
|
|
14
21
|
return (
|
|
15
22
|
<motion.div
|
|
16
23
|
ref={ref}
|
|
17
|
-
className=
|
|
24
|
+
className={cn(
|
|
25
|
+
'absolute inset-x-4 bottom-4 no-scrollbar flex max-h-full flex-col gap-4 overflow-y-auto rounded-2xl bg-card p-(--page-pad) pb-0 text-card-foreground shadow-md',
|
|
26
|
+
className
|
|
27
|
+
)}
|
|
18
28
|
variants={{
|
|
19
29
|
hidden: { opacity: 0, y: 40, filter: 'blur(4px)' },
|
|
20
30
|
visible: { opacity: 1, y: 0, filter: 'blur(0px)' }
|
|
@@ -24,10 +34,19 @@ export function BottomPanel({ title, children, ref }: BottomPanelProps) {
|
|
|
24
34
|
exit="hidden"
|
|
25
35
|
transition={{ type: 'spring', duration: 0.25, bounce: 0 }}
|
|
26
36
|
>
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
<div className="flex shrink-0 items-center justify-between gap-4">
|
|
38
|
+
<p className="text-sm font-medium">{title}</p>
|
|
39
|
+
<Button
|
|
40
|
+
type="button"
|
|
41
|
+
variant="ghost"
|
|
42
|
+
size="icon-sm"
|
|
43
|
+
onClick={onClose}
|
|
44
|
+
aria-label="Close panel"
|
|
45
|
+
>
|
|
46
|
+
<IconX stroke={1.75} />
|
|
47
|
+
</Button>
|
|
30
48
|
</div>
|
|
49
|
+
<div className="flex-1 pb-(--page-pad)">{children}</div>
|
|
31
50
|
</motion.div>
|
|
32
51
|
)
|
|
33
52
|
}
|
|
@@ -31,7 +31,7 @@ export function Composer({
|
|
|
31
31
|
composerRef.current?.focus()
|
|
32
32
|
}}
|
|
33
33
|
className={cn(
|
|
34
|
-
'flex w-full
|
|
34
|
+
'flex w-full cursor-text flex-col gap-1 rounded-xl bg-card p-2 text-card-foreground shadow-xs transition-[color,box-shadow] outline-none focus-within:shadow-sm',
|
|
35
35
|
className
|
|
36
36
|
)}
|
|
37
37
|
>
|
|
@@ -2,7 +2,7 @@ import type { ReactNode } from 'react'
|
|
|
2
2
|
|
|
3
3
|
export function PanelHeader({ children }: { children?: ReactNode }) {
|
|
4
4
|
return (
|
|
5
|
-
<header className="@container flex h-11 shrink-0 items-center gap-2.5 border-b border-border/75
|
|
5
|
+
<header className="@container flex h-11 shrink-0 items-center gap-2.5 border-b border-border/75 pr-3 pl-4">
|
|
6
6
|
{children}
|
|
7
7
|
</header>
|
|
8
8
|
)
|
|
@@ -4,7 +4,7 @@ import { type VariantProps, cva } from 'class-variance-authority'
|
|
|
4
4
|
import { cn } from '@/client/lib/cn'
|
|
5
5
|
|
|
6
6
|
const buttonVariants = cva(
|
|
7
|
-
'inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-
|
|
7
|
+
'inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
|
|
8
8
|
{
|
|
9
9
|
variants: {
|
|
10
10
|
variant: {
|
|
@@ -18,13 +18,13 @@ const buttonVariants = cva(
|
|
|
18
18
|
'bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20'
|
|
19
19
|
},
|
|
20
20
|
size: {
|
|
21
|
-
sm: 'h-7 gap-1.5 rounded-
|
|
21
|
+
sm: 'h-7 gap-1.5 rounded-md px-2.5 text-sm has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg]:size-4',
|
|
22
22
|
default:
|
|
23
23
|
'h-8 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5 [&_svg]:size-5',
|
|
24
|
-
lg: 'h-10 rounded-
|
|
25
|
-
'icon-sm': 'size-7 rounded-
|
|
24
|
+
lg: 'h-10 rounded-xl px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3 [&_svg]:size-5',
|
|
25
|
+
'icon-sm': 'size-7 rounded-md [&_svg]:size-4',
|
|
26
26
|
icon: 'size-8 [&_svg]:size-5',
|
|
27
|
-
'icon-lg': 'size-10 rounded-
|
|
27
|
+
'icon-lg': 'size-10 rounded-xl [&_svg]:size-5'
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
defaultVariants: {
|
|
@@ -38,7 +38,7 @@ function DropdownMenuContent({
|
|
|
38
38
|
<MenuPrimitive.Popup
|
|
39
39
|
data-slot="dropdown-menu-content"
|
|
40
40
|
className={cn(
|
|
41
|
-
'z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-
|
|
41
|
+
'z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-border duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95',
|
|
42
42
|
className
|
|
43
43
|
)}
|
|
44
44
|
{...props}
|
|
@@ -87,7 +87,7 @@ function DropdownMenuItem({
|
|
|
87
87
|
data-inset={inset}
|
|
88
88
|
data-variant={variant}
|
|
89
89
|
className={cn(
|
|
90
|
-
"group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-
|
|
90
|
+
"group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-md px-2 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
|
|
91
91
|
className
|
|
92
92
|
)}
|
|
93
93
|
{...props}
|
|
@@ -112,7 +112,7 @@ function DropdownMenuSubTrigger({
|
|
|
112
112
|
data-slot="dropdown-menu-sub-trigger"
|
|
113
113
|
data-inset={inset}
|
|
114
114
|
className={cn(
|
|
115
|
-
"flex cursor-default items-center gap-2 rounded-
|
|
115
|
+
"flex cursor-default items-center gap-2 rounded-md px-2 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
116
116
|
className
|
|
117
117
|
)}
|
|
118
118
|
{...props}
|
|
@@ -135,7 +135,7 @@ function DropdownMenuSubContent({
|
|
|
135
135
|
<DropdownMenuContent
|
|
136
136
|
data-slot="dropdown-menu-sub-content"
|
|
137
137
|
className={cn(
|
|
138
|
-
'w-auto min-w-[96px] rounded-
|
|
138
|
+
'w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-border duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
|
|
139
139
|
className
|
|
140
140
|
)}
|
|
141
141
|
align={align}
|
|
@@ -161,7 +161,7 @@ function DropdownMenuCheckboxItem({
|
|
|
161
161
|
data-slot="dropdown-menu-checkbox-item"
|
|
162
162
|
data-inset={inset}
|
|
163
163
|
className={cn(
|
|
164
|
-
"relative flex cursor-default items-center gap-2 rounded-
|
|
164
|
+
"relative flex cursor-default items-center gap-2 rounded-md py-1 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
165
165
|
className
|
|
166
166
|
)}
|
|
167
167
|
checked={checked}
|
|
@@ -197,7 +197,7 @@ function DropdownMenuRadioItem({
|
|
|
197
197
|
data-slot="dropdown-menu-radio-item"
|
|
198
198
|
data-inset={inset}
|
|
199
199
|
className={cn(
|
|
200
|
-
"relative flex cursor-default items-center gap-2 rounded-
|
|
200
|
+
"relative flex cursor-default items-center gap-2 rounded-md py-1 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
201
201
|
className
|
|
202
202
|
)}
|
|
203
203
|
{...props}
|
|
@@ -31,7 +31,7 @@ function HoverCardContent({
|
|
|
31
31
|
<PreviewCardPrimitive.Popup
|
|
32
32
|
data-slot="hover-card-content"
|
|
33
33
|
className={cn(
|
|
34
|
-
'z-50 w-64 origin-(--transform-origin) rounded-
|
|
34
|
+
'z-50 w-64 origin-(--transform-origin) rounded-xl bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-border outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
|
|
35
35
|
className
|
|
36
36
|
)}
|
|
37
37
|
{...props}
|
|
@@ -10,7 +10,7 @@ function Input({ className, type, ...props }: ComponentProps<'input'>) {
|
|
|
10
10
|
type={type}
|
|
11
11
|
data-slot="input"
|
|
12
12
|
className={cn(
|
|
13
|
-
'h-8 w-full min-w-0 rounded-
|
|
13
|
+
'h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40',
|
|
14
14
|
className
|
|
15
15
|
)}
|
|
16
16
|
{...props}
|
|
@@ -36,7 +36,7 @@ function PopoverContent({
|
|
|
36
36
|
<PopoverPrimitive.Popup
|
|
37
37
|
data-slot="popover-content"
|
|
38
38
|
className={cn(
|
|
39
|
-
'z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-
|
|
39
|
+
'z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-border outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
|
|
40
40
|
className
|
|
41
41
|
)}
|
|
42
42
|
{...props}
|
|
@@ -4,7 +4,7 @@ function Skeleton({ className, ...props }: React.ComponentProps<'div'>) {
|
|
|
4
4
|
return (
|
|
5
5
|
<div
|
|
6
6
|
data-slot="skeleton"
|
|
7
|
-
className={cn('animate-pulse rounded-
|
|
7
|
+
className={cn('animate-pulse rounded-lg bg-muted', className)}
|
|
8
8
|
{...props}
|
|
9
9
|
/>
|
|
10
10
|
)
|
|
@@ -7,7 +7,7 @@ function Textarea({ className, ...props }: ComponentProps<'textarea'>) {
|
|
|
7
7
|
<textarea
|
|
8
8
|
data-slot="textarea"
|
|
9
9
|
className={cn(
|
|
10
|
-
'flex field-sizing-content min-h-16 w-full rounded-
|
|
10
|
+
'flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-sm transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40',
|
|
11
11
|
className
|
|
12
12
|
)}
|
|
13
13
|
{...props}
|
|
@@ -36,7 +36,7 @@ function TooltipContent({
|
|
|
36
36
|
<TooltipPrimitive.Popup
|
|
37
37
|
data-slot="tooltip-content"
|
|
38
38
|
className={cn(
|
|
39
|
-
'z-50 w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-
|
|
39
|
+
'z-50 w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-lg bg-popover px-2.5 py-1.5 text-xs font-medium text-popover-foreground shadow-md has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-lg data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
|
|
40
40
|
className
|
|
41
41
|
)}
|
|
42
42
|
{...props}
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
// `useAppletCacheInvalidation`), and the per-applet hook invalidates the mounted
|
|
14
14
|
// one too. Either path bumps the version + drops the cached module, so the next
|
|
15
15
|
// load() fetches the rebuilt bundle.
|
|
16
|
+
import { disposeAppletBridge } from '@/client/features/applets/applet-runtime'
|
|
17
|
+
|
|
16
18
|
export type AppletSegment = 'widgets' | 'views'
|
|
17
19
|
|
|
18
20
|
// `${segment}/${workspaceId}/${name}` — namespaced so a widget and a view (or
|
|
@@ -54,9 +56,26 @@ export function setCachedApplet(key: string, mod: Promise<unknown>): void {
|
|
|
54
56
|
// Drop the cached module and bump the load version for one applet, so the next
|
|
55
57
|
// load() — including a fresh mount of a previously-backgrounded tab — fetches the
|
|
56
58
|
// rebuilt bundle instead of the memoized old one. Safe (and intended) to call
|
|
57
|
-
// when nothing for this applet is mounted.
|
|
59
|
+
// when nothing for this applet is mounted. The old module instance stays in
|
|
60
|
+
// browser memory forever; disposing its bridge is what makes it inert.
|
|
58
61
|
export function invalidateApplet(segment: AppletSegment, workspaceId: string, name: string): void {
|
|
59
62
|
const key = appletKey(segment, workspaceId, name)
|
|
60
63
|
moduleCache.delete(key)
|
|
61
64
|
versions.set(key, (versions.get(key) ?? 0) + 1)
|
|
65
|
+
disposeAppletBridge(key)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Invalidate every applet of one kind across all workspaces — the
|
|
69
|
+
// `applets:refresh` path, which names no specific applet. Only keys that have
|
|
70
|
+
// ever been loaded (or bumped) exist in the maps; anything else already loads
|
|
71
|
+
// fresh on first mount.
|
|
72
|
+
export function invalidateAppletSegment(segment: AppletSegment): void {
|
|
73
|
+
const prefix = `${segment}/`
|
|
74
|
+
for (const key of new Set([...moduleCache.keys(), ...versions.keys()])) {
|
|
75
|
+
if (key.startsWith(prefix)) {
|
|
76
|
+
moduleCache.delete(key)
|
|
77
|
+
versions.set(key, (versions.get(key) ?? 0) + 1)
|
|
78
|
+
disposeAppletBridge(key)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
62
81
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRateLimiter } from '@/client/lib/rate-limit'
|
|
1
2
|
import type { AppletClientError, AppletKind } from '@/lib/types'
|
|
2
3
|
|
|
3
4
|
// Fire-and-forget reporter for browser-side applet errors — the client half of
|
|
@@ -7,40 +8,19 @@ import type { AppletClientError, AppletKind } from '@/lib/types'
|
|
|
7
8
|
// them to the agent. Always on: when the user says "it's broken", the crash
|
|
8
9
|
// their tab saw five minutes ago is already on record.
|
|
9
10
|
//
|
|
10
|
-
// Reporting must never hurt the app: fetch errors are swallowed, and
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
const
|
|
18
|
-
const lastSent = new Map<string, number>()
|
|
19
|
-
|
|
20
|
-
const RATE_WINDOW_MS = 60_000
|
|
21
|
-
const RATE_MAX_PER_WINDOW = 30
|
|
22
|
-
let rateWindowStart = 0
|
|
23
|
-
let rateCount = 0
|
|
11
|
+
// Reporting must never hurt the app: fetch errors are swallowed, and the
|
|
12
|
+
// limiter bounds the network chatter. Its per-error cooldown collapses a crash
|
|
13
|
+
// loop of the SAME error into one POST per window; its window cap bounds the
|
|
14
|
+
// total regardless of message — an error whose text varies every occurrence
|
|
15
|
+
// (timestamps, ids) would defeat key-based cooldown and server dedup alike, and
|
|
16
|
+
// a tight throw loop must not become a POST-per-frame storm. Drops are silent
|
|
17
|
+
// here: the journal is best-effort diagnostics, not telemetry.
|
|
18
|
+
const limiter = createRateLimiter({ cooldownMs: 5_000, windowMs: 60_000, maxPerWindow: 30 })
|
|
24
19
|
|
|
25
20
|
export function reportAppletError(workspaceId: string, event: AppletClientError): void {
|
|
26
|
-
const now = Date.now()
|
|
27
|
-
|
|
28
21
|
const key = [workspaceId, event.source, event.kind, event.name, event.message].join('\0')
|
|
29
|
-
|
|
30
|
-
if (last !== undefined && now - last < COOLDOWN_MS) return
|
|
22
|
+
if (limiter.admit(key) !== 'ok') return
|
|
31
23
|
|
|
32
|
-
if (now - rateWindowStart >= RATE_WINDOW_MS) {
|
|
33
|
-
rateWindowStart = now
|
|
34
|
-
rateCount = 0
|
|
35
|
-
}
|
|
36
|
-
if (rateCount >= RATE_MAX_PER_WINDOW) return
|
|
37
|
-
rateCount++
|
|
38
|
-
|
|
39
|
-
lastSent.set(key, now)
|
|
40
|
-
// Bound the cooldown map: drop the oldest half if it ever balloons.
|
|
41
|
-
if (lastSent.size > 256) {
|
|
42
|
-
for (const k of [...lastSent.keys()].slice(0, 128)) lastSent.delete(k)
|
|
43
|
-
}
|
|
44
24
|
void fetch(`/api/workspaces/${workspaceId}/applet-log`, {
|
|
45
25
|
method: 'POST',
|
|
46
26
|
headers: { 'Content-Type': 'application/json' },
|