moi-computer 0.3.0 → 0.3.1-next.1
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/client/api/workspace-keys.ts +2 -2
- package/client/app/AppRouter.tsx +0 -2
- package/client/app/routes/WorkspaceRoute.tsx +3 -1
- package/client/app/shell/SidebarLayout.tsx +3 -16
- package/client/assets/openai.svg +1 -3
- package/client/components/shared/Composer.tsx +112 -0
- package/client/components/ui/button.tsx +1 -1
- package/client/components/ui/dropdown-menu.tsx +3 -3
- package/client/components/ui/tooltip.tsx +12 -15
- package/client/features/applets/WidgetErrorBoundary.tsx +19 -3
- package/client/features/applets/WidgetShell.tsx +8 -1
- package/client/features/applets/applet-log.ts +100 -0
- package/client/features/applets/useApplet.ts +21 -7
- package/client/features/chat/ChatComposer.tsx +33 -30
- package/client/features/chat/ChatPanel.tsx +5 -2
- package/client/features/chat/MarkdownContent.tsx +20 -2
- package/client/features/chat/ModelPicker.tsx +29 -41
- package/client/features/chat/TurnView.tsx +2 -2
- package/client/features/chat/chat-frames.ts +14 -6
- package/client/features/chat/chat-send.ts +1 -1
- package/client/features/chat/chat-store.ts +22 -17
- package/client/features/chat/model-order.ts +47 -0
- package/client/features/chat/tool-group/ToolOutput.tsx +4 -12
- package/client/features/chat/tool-group/format.ts +0 -6
- package/client/features/chat/useChat.ts +15 -2
- package/client/features/connectors/McpServerCards.tsx +95 -0
- package/client/features/connectors/api.ts +0 -11
- package/client/features/home/HomePage.tsx +45 -42
- package/client/features/home/WorkspacePreview.tsx +179 -38
- package/client/features/home/api.ts +24 -12
- package/client/features/home/workspace-presentation.tsx +17 -15
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +243 -0
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +95 -0
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +230 -0
- package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +35 -0
- package/client/features/home/workspace-setup/useWorkspaceImport.ts +61 -0
- package/client/features/settings/ConnectorsSettings.tsx +89 -0
- package/client/features/settings/GeneralSettings.tsx +12 -0
- package/client/features/settings/SettingsLayout.tsx +2 -2
- package/client/features/settings/WorkspaceSettings.tsx +8 -4
- package/client/features/views/ViewBuilderTab.tsx +28 -29
- package/client/features/views/useViewBuilderActions.ts +1 -1
- package/client/features/widgets/WidgetFrame.tsx +3 -0
- package/client/features/widgets/WidgetGrid.tsx +1 -0
- package/client/features/widgets/Widgets.tsx +12 -3
- package/client/features/widgets/api.ts +47 -0
- package/client/features/widgets/useWidgetThumbnails.ts +107 -0
- package/client/features/widgets/widget-snapshot.ts +71 -0
- package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -4
- package/client/features/workspace/WorkspaceScreen.tsx +19 -4
- package/client/features/workspace/api.ts +25 -3
- package/client/features/workspace/moi-context.ts +85 -0
- package/client/index.css +0 -5
- package/client/main.tsx +13 -4
- package/dist/{chunk-cs8vbert.js → chunk-1dfbr7n2.js} +2 -2
- package/dist/chunk-339jds4x.js +15 -0
- package/dist/chunk-3xsvsnhr.css +1 -0
- package/dist/{chunk-zpxrb1ce.js → chunk-anqmsbjt.js} +2 -2
- package/dist/chunk-hbvfb6sk.js +63 -0
- package/dist/chunk-jen6xcm1.js +14 -0
- package/dist/{chunk-kxmvv1ax.js → chunk-qwm5f6qk.js} +1 -1
- package/dist/{chunk-fjksw6xf.js → chunk-sxbfh73c.js} +1 -1
- package/dist/chunk-yp4srgqt.js +10 -0
- package/dist/index.html +1 -1
- package/dist/openai-ep9ht2pq.svg +1 -0
- package/lib/ids.ts +15 -0
- package/lib/moi-context.ts +170 -0
- package/lib/types.ts +95 -13
- package/lib/view-builder-directives.ts +16 -0
- package/lib/workspace-types.ts +12 -0
- package/package.json +4 -2
- package/server/api.ts +180 -34
- package/server/applet-log.ts +149 -0
- package/server/cli.ts +161 -7
- package/server/control.ts +81 -1
- package/server/functions.ts +44 -14
- package/server/harness/README.md +26 -9
- package/server/harness/claude-code/NOTES.md +20 -6
- package/server/harness/claude-code/adapter.ts +2 -2
- package/server/harness/claude-code/git-worktree.ts +32 -0
- package/server/harness/claude-code/index.ts +35 -13
- package/server/harness/claude-code/mcp.ts +16 -65
- package/server/harness/claude-code/models.ts +3 -0
- package/server/harness/claude-code/session.ts +196 -61
- package/server/harness/claude-code/sessions.ts +51 -0
- package/server/harness/codex/NOTES.md +41 -11
- package/server/harness/codex/adapter.ts +52 -6
- package/server/harness/codex/client.ts +69 -18
- package/server/harness/codex/discovery.ts +114 -0
- package/server/harness/codex/index.ts +12 -5
- package/server/harness/codex/probe.ts +4 -2
- package/server/harness/codex/session.ts +57 -5
- package/server/harness/executable.ts +82 -0
- package/server/harness/openclaw/adapter.ts +8 -1
- package/server/harness/openclaw/discovery.ts +139 -6
- package/server/harness/openclaw/gateway.ts +40 -18
- package/server/harness/openclaw/index.ts +12 -15
- package/server/harness/openclaw/session.ts +50 -10
- package/server/harness/openclaw/strip.ts +2 -2
- package/server/harness/shell-path.ts +79 -0
- package/server/harness/types.ts +37 -5
- package/server/layout.ts +81 -51
- package/server/registry.ts +57 -12
- package/server/scratchpad-assets.ts +41 -6
- package/server/scratchpad.ts +30 -0
- package/server/view-builders.ts +3 -2
- package/server/views.ts +5 -0
- package/server/web.ts +30 -8
- package/server/widgets.ts +23 -2
- package/server/workspace-import.ts +45 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +27 -3
- package/client/features/connectors/ConnectorsPage.tsx +0 -92
- package/client/features/connectors/McpMenu.tsx +0 -145
- package/client/features/home/CreateWorkspaceDialog.tsx +0 -130
- package/client/features/home/CreateWorkspaceDialogSteps.tsx +0 -234
- package/dist/chunk-4vf1t6v1.js +0 -10
- package/dist/chunk-4z52b2av.css +0 -1
- package/dist/chunk-b4b276wx.js +0 -15
- package/dist/chunk-y82s1jxm.js +0 -61
- package/dist/openai-h13pza4b.svg +0 -3
- package/lib/view-builder-meta.ts +0 -35
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: moi-workspace
|
|
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 in two cases. (a) A message carries hidden <moi>…</moi>
|
|
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 in two cases. (a) A message carries a hidden <moi-context>…</moi-context> envelope: it was fired from a moi workspace, so you are running inside one even if nothing else says so. (b) The user uses moi vocab — workspace, applet, widget, view, scratchpad, dashboard, or a `moi` command — or asks to build, edit, customize, or theme the workspace UI or its layout.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Workspace
|
|
@@ -112,6 +112,8 @@ never from inside `.moi/` itself. You don't pass paths; moi resolves the workspa
|
|
|
112
112
|
- `moi bundle --force` — rebuild all applets (use after changing `config`)
|
|
113
113
|
- `moi refresh` — re-fetch widget/view data without rebuilding (use after you mutated data the
|
|
114
114
|
widgets read — DB rows, files, external API records — so the displayed values catch up)
|
|
115
|
+
- `moi call-server-fn <module>/<fn> '[args]'` — invoke a `.server.ts` function directly (smoke test)
|
|
116
|
+
- `moi debug logs` — applet runtime errors on record (experimental)
|
|
115
117
|
- `moi theme --font=<key>` — change font theme (omit `--font` to list options)
|
|
116
118
|
- `moi theme --color=<key>` — change color preset (omit `--color` to list options)
|
|
117
119
|
- `moi config` — set the workspace name & icon (`moi config --help` for usage)
|
|
@@ -259,13 +261,35 @@ Typical loop: check/`bun install` deps → write `.moi/widgets/<name>.tsx` → `
|
|
|
259
261
|
on the dashboard → change it and re-`bundle`, or `moi refresh` after mutating data, or any other `moi`
|
|
260
262
|
command as needed. Views work the same way (`.moi/views/<name>.tsx`, appears as a nav tab).
|
|
261
263
|
|
|
264
|
+
# Debugging applets
|
|
265
|
+
|
|
266
|
+
`moi bundle` only proves an applet compiles — it can still fail to load in the browser, crash on
|
|
267
|
+
render, or throw in its server functions. Two feedback channels exist for what happens after the
|
|
268
|
+
build; reach for them when they'd help (smoke-testing something new, or investigating a problem):
|
|
269
|
+
|
|
270
|
+
- `moi call-server-fn widgets/hello/getGreeting` /
|
|
271
|
+
`moi call-server-fn views/crm/searchUsers '["ann", 10]'` — run one `.server.ts` function
|
|
272
|
+
directly (args are one JSON array). Each invocation runs in a fresh, isolated one-shot process
|
|
273
|
+
with the same env, module loading, and timeout as the browser's calls, so a pass means the real
|
|
274
|
+
path works — handy for trying a function without touching the UI. Server functions only; for
|
|
275
|
+
arbitrary scripts use `moi env exec`.
|
|
276
|
+
- `moi debug logs` — the applet errors the workspace has seen since each applet's last good
|
|
277
|
+
build: browser-side load failures and render crashes, plus server-function (rpc) errors. The
|
|
278
|
+
user's tab reports these automatically, so when the user says something is broken, what
|
|
279
|
+
happened is usually already on record — a good first place to look. Entries clear when their
|
|
280
|
+
applet next builds successfully. (`moi debug` is an experimental command group — expect its
|
|
281
|
+
output and flags to evolve; use `--json` when you need to parse it.)
|
|
282
|
+
|
|
283
|
+
`moi bundle`'s footer also mentions when runtime errors are on record, so standing breakage
|
|
284
|
+
surfaces on its own.
|
|
285
|
+
|
|
262
286
|
# Views
|
|
263
287
|
|
|
264
288
|
Full-screen apps, one per nav tab — the user switches tabs; there is no routing inside a view.
|
|
265
289
|
|
|
266
290
|
## View builder requests
|
|
267
291
|
|
|
268
|
-
When the
|
|
292
|
+
When the message's hidden `<moi-context>` envelope is marked `View builder request`, this chat is
|
|
269
293
|
linked to a pending view tab. Before reading files, planning, or writing code, infer a short stable
|
|
270
294
|
id, a clear sentence-case title, and a relevant icon from the requirements. Capitalize only the
|
|
271
295
|
first word of the title. Your first action must claim them:
|
|
@@ -304,4 +328,4 @@ This skill is installed with moi (via the CLI or the UI) and can fall behind whe
|
|
|
304
328
|
- **Then** — if you updated, mention it.
|
|
305
329
|
|
|
306
330
|
<!-- moi skill version marker — read by `moi skill` to detect drift; do not edit by hand -->
|
|
307
|
-
<moi-skill version="0.
|
|
331
|
+
<moi-skill version="0.7.0" />
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { IconPlugConnected } from '@tabler/icons-react'
|
|
2
|
-
|
|
3
|
-
import { useUserMcp } from './api'
|
|
4
|
-
import { McpServerCard, sortMcpServers } from '@/client/features/connectors/McpMenu'
|
|
5
|
-
import { SidebarLayout } from '@/client/app/shell/SidebarLayout'
|
|
6
|
-
import { Button } from '@/client/components/ui/button'
|
|
7
|
-
import { Skeleton } from '@/client/components/ui/skeleton'
|
|
8
|
-
|
|
9
|
-
const CONNECTOR_SKELETONS = Array.from({ length: 6 }, (_, index) => index)
|
|
10
|
-
|
|
11
|
-
export function ConnectorsPage() {
|
|
12
|
-
return (
|
|
13
|
-
<SidebarLayout panel="flat">
|
|
14
|
-
<div className="min-h-0 flex-1 overflow-y-auto">
|
|
15
|
-
<UserConnectorsPage />
|
|
16
|
-
</div>
|
|
17
|
-
</SidebarLayout>
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function UserConnectorsPage() {
|
|
22
|
-
const connectorsQuery = useUserMcp()
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<div className="mx-auto w-full max-w-3xl px-8 pt-14 pb-16">
|
|
26
|
-
<div className="mb-4 flex items-center justify-between gap-2">
|
|
27
|
-
<h1 className="text-sm font-medium text-foreground">Connectors</h1>
|
|
28
|
-
</div>
|
|
29
|
-
|
|
30
|
-
<ConnectorsContent connectorsQuery={connectorsQuery} />
|
|
31
|
-
</div>
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type ConnectorsContentProps = {
|
|
36
|
-
connectorsQuery: ReturnType<typeof useUserMcp>
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function ConnectorsContent({ connectorsQuery }: ConnectorsContentProps) {
|
|
40
|
-
if (connectorsQuery.isPending) {
|
|
41
|
-
return (
|
|
42
|
-
<div
|
|
43
|
-
role="status"
|
|
44
|
-
aria-label="Loading connectors"
|
|
45
|
-
className="grid grid-cols-1 gap-3 sm:grid-cols-2"
|
|
46
|
-
>
|
|
47
|
-
{CONNECTOR_SKELETONS.map(index => (
|
|
48
|
-
<div
|
|
49
|
-
key={index}
|
|
50
|
-
className="flex min-h-20 items-center gap-3 rounded-xl border border-border bg-card px-4 py-3"
|
|
51
|
-
>
|
|
52
|
-
<Skeleton className="size-10 shrink-0 rounded-sm" />
|
|
53
|
-
<div className="flex min-w-0 flex-1 flex-col gap-2">
|
|
54
|
-
<Skeleton className="h-4 w-36" />
|
|
55
|
-
<Skeleton className="h-3 w-20" />
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
))}
|
|
59
|
-
</div>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (connectorsQuery.isError) {
|
|
64
|
-
return (
|
|
65
|
-
<div className="flex min-h-48 flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-border px-8 py-12 text-center">
|
|
66
|
-
<p className="text-sm text-muted-foreground">Could not load connectors.</p>
|
|
67
|
-
<Button variant="outline" size="sm" onClick={() => connectorsQuery.refetch()}>
|
|
68
|
-
Retry
|
|
69
|
-
</Button>
|
|
70
|
-
</div>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const connectors = sortMcpServers(connectorsQuery.data)
|
|
75
|
-
|
|
76
|
-
if (connectors.length === 0) {
|
|
77
|
-
return (
|
|
78
|
-
<div className="flex min-h-48 flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-border px-8 py-12 text-center">
|
|
79
|
-
<IconPlugConnected size={24} stroke={1.5} className="text-muted-foreground" />
|
|
80
|
-
<p className="mx-auto max-w-md text-sm text-foreground">No user connectors configured.</p>
|
|
81
|
-
</div>
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
|
87
|
-
{connectors.map(connector => (
|
|
88
|
-
<McpServerCard key={connector.name} server={connector} />
|
|
89
|
-
))}
|
|
90
|
-
</div>
|
|
91
|
-
)
|
|
92
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { useWorkspaceMcp } from './api'
|
|
2
|
-
import { IconAlertCircleFilled, IconPlugConnected } from '@tabler/icons-react'
|
|
3
|
-
import { IconMcp } from '@/client/features/connectors/IconMcp'
|
|
4
|
-
import { Button } from '@/client/components/ui/button'
|
|
5
|
-
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/client/components/ui/hover-card'
|
|
6
|
-
import { formatMcpServerName, getMcpIcon } from '@/client/features/connectors/mcp-icons'
|
|
7
|
-
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
8
|
-
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
9
|
-
import { cn } from '@/client/lib/cn'
|
|
10
|
-
import type { McpServer } from '@/lib/types'
|
|
11
|
-
|
|
12
|
-
function statusLabel(status: McpServer['status']): string {
|
|
13
|
-
if (status === 'needs-auth') return 'Needs auth'
|
|
14
|
-
return status[0].toUpperCase() + status.slice(1)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function McpStatusDot({ status }: { status: McpServer['status'] }) {
|
|
18
|
-
const connected = status === 'connected'
|
|
19
|
-
return (
|
|
20
|
-
<span
|
|
21
|
-
className={cn(
|
|
22
|
-
'size-[5px] shrink-0 rounded-full',
|
|
23
|
-
connected ? 'bg-emerald-500' : 'bg-yellow-500'
|
|
24
|
-
)}
|
|
25
|
-
/>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type McpServerIconProps = {
|
|
30
|
-
name: string
|
|
31
|
-
status: McpServer['status']
|
|
32
|
-
size?: 'sm' | 'lg'
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function McpServerIcon({ name, status, size = 'sm' }: McpServerIconProps) {
|
|
36
|
-
const icon = getMcpIcon(name)
|
|
37
|
-
const large = size === 'lg'
|
|
38
|
-
const className = 'size-full rounded-sm ring-2 ring-background'
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<span className={cn('relative shrink-0', large ? 'size-10' : 'size-5')}>
|
|
42
|
-
{icon ? (
|
|
43
|
-
<img src={icon} alt="" className={className} />
|
|
44
|
-
) : (
|
|
45
|
-
<span
|
|
46
|
-
className={cn(
|
|
47
|
-
'flex size-full items-center justify-center bg-muted text-muted-foreground ring-2 ring-background',
|
|
48
|
-
large ? 'rounded-sm' : 'rounded'
|
|
49
|
-
)}
|
|
50
|
-
>
|
|
51
|
-
<IconMcp className={large ? 'size-5' : 'size-4'} />
|
|
52
|
-
</span>
|
|
53
|
-
)}
|
|
54
|
-
{large && status !== 'connected' && (
|
|
55
|
-
<IconAlertCircleFilled
|
|
56
|
-
aria-hidden="true"
|
|
57
|
-
size={16}
|
|
58
|
-
stroke={1.75}
|
|
59
|
-
className="absolute -top-1 -right-1 rounded-full bg-card text-amber-400"
|
|
60
|
-
/>
|
|
61
|
-
)}
|
|
62
|
-
</span>
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function sortMcpServers(servers: McpServer[]): McpServer[] {
|
|
67
|
-
// Active (connected) servers first, then disabled/errored/auth-pending. The
|
|
68
|
-
// sort is stable, so each group keeps the server list's original order.
|
|
69
|
-
return [...servers].sort(
|
|
70
|
-
(a, b) => Number(b.status === 'connected') - Number(a.status === 'connected')
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function McpServerRow({ server }: { server: McpServer }) {
|
|
75
|
-
return (
|
|
76
|
-
<div className="flex items-center gap-2.5 rounded-xs px-2 py-1 text-foreground hover:bg-accent hover:text-accent-foreground">
|
|
77
|
-
<McpServerIcon name={server.name} status={server.status} />
|
|
78
|
-
<span className="flex-1 truncate text-sm">{formatMcpServerName(server.name)}</span>
|
|
79
|
-
<McpStatusDot status={server.status} />
|
|
80
|
-
</div>
|
|
81
|
-
)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function McpServerCard({ server }: { server: McpServer }) {
|
|
85
|
-
return (
|
|
86
|
-
<div className="flex min-h-20 items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 text-card-foreground">
|
|
87
|
-
<McpServerIcon name={server.name} status={server.status} size="lg" />
|
|
88
|
-
<div className="flex min-w-0 flex-1 flex-col justify-center gap-0.5">
|
|
89
|
-
<div className="truncate text-sm font-medium text-foreground">
|
|
90
|
-
{formatMcpServerName(server.name)}
|
|
91
|
-
</div>
|
|
92
|
-
<span className="text-sm text-muted-foreground">{statusLabel(server.status)}</span>
|
|
93
|
-
</div>
|
|
94
|
-
</div>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// The scrollable server list. Overflow is signalled with scroll-aware fades;
|
|
99
|
-
// the scrollbar is hidden.
|
|
100
|
-
function McpList({ servers }: { servers: McpServer[] }) {
|
|
101
|
-
return (
|
|
102
|
-
<div className="no-scrollbar flex max-h-72 scroll-fade flex-col overflow-y-auto overscroll-contain [--scroll-fade-reveal:16px]">
|
|
103
|
-
{servers.map(server => (
|
|
104
|
-
<McpServerRow key={server.name} server={server} />
|
|
105
|
-
))}
|
|
106
|
-
</div>
|
|
107
|
-
)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Project-scoped connector status hover card — Claude workspaces only
|
|
111
|
-
// (OpenClaw/Hermes use other backends). User-scoped connectors live on the
|
|
112
|
-
// standalone Connectors page.
|
|
113
|
-
export function McpMenu() {
|
|
114
|
-
const workspaceId = useWorkspaceId()
|
|
115
|
-
// Read provider from the shared layout context, not a second `useWorkspaceLayout`
|
|
116
|
-
// observer — a duplicate observer that remounts (e.g. when this menu moves
|
|
117
|
-
// between the fullscreen and two-pane headers) fires `refetchOnMount`, which
|
|
118
|
-
// overwrites an in-flight optimistic chat-mode change before it's persisted.
|
|
119
|
-
const { provider, isLoading } = useWorkspaceLayoutCtx()
|
|
120
|
-
const isClaude = !isLoading && provider !== 'openclaw'
|
|
121
|
-
const { data: servers } = useWorkspaceMcp(workspaceId, isClaude)
|
|
122
|
-
|
|
123
|
-
if (!isClaude) return null
|
|
124
|
-
if (!servers || servers.length === 0) return null
|
|
125
|
-
|
|
126
|
-
const trigger = (
|
|
127
|
-
<Button variant="ghost" size="icon-sm" aria-label="Connectors" title="Connectors">
|
|
128
|
-
<IconPlugConnected stroke={1.75} />
|
|
129
|
-
</Button>
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
const sorted = sortMcpServers(servers)
|
|
133
|
-
|
|
134
|
-
return (
|
|
135
|
-
<HoverCard>
|
|
136
|
-
<HoverCardTrigger render={trigger} delay={0} closeDelay={100} />
|
|
137
|
-
<HoverCardContent align="end" sideOffset={6} className="w-56 p-1">
|
|
138
|
-
<div className="px-2 pt-1 pb-1.5 text-xs font-medium text-muted-foreground">
|
|
139
|
-
Project connectors
|
|
140
|
-
</div>
|
|
141
|
-
<McpList servers={sorted} />
|
|
142
|
-
</HoverCardContent>
|
|
143
|
-
</HoverCard>
|
|
144
|
-
)
|
|
145
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { type ReactElement, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
import { IconX } from '@tabler/icons-react'
|
|
4
|
-
import { useLocation } from 'wouter'
|
|
5
|
-
|
|
6
|
-
import { useAddWorkspace, useChooseFolder, useCreateWorkspace, useCreateWorkspaceInfo } from './api'
|
|
7
|
-
import { WorkspaceAgentStep, WorkspaceNameStep } from './CreateWorkspaceDialogSteps'
|
|
8
|
-
import { Button } from '@/client/components/ui/button'
|
|
9
|
-
import { Dialog, DialogClose, DialogContent, DialogTrigger } from '@/client/components/ui/dialog'
|
|
10
|
-
import { validateWorkspaceFolderName } from '@/lib/workspace-name'
|
|
11
|
-
import type { WorkspaceType } from '@/lib/types'
|
|
12
|
-
|
|
13
|
-
type CreateWorkspaceDialogProps = {
|
|
14
|
-
trigger: ReactElement
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type CreateWorkspaceStep = 'agent' | 'name'
|
|
18
|
-
|
|
19
|
-
const DEFAULT_WORKSPACE_TYPE: WorkspaceType = 'claude-code'
|
|
20
|
-
|
|
21
|
-
export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
|
|
22
|
-
const [, navigate] = useLocation()
|
|
23
|
-
const info = useCreateWorkspaceInfo()
|
|
24
|
-
const createMutation = useCreateWorkspace()
|
|
25
|
-
const addMutation = useAddWorkspace()
|
|
26
|
-
const chooseFolder = useChooseFolder()
|
|
27
|
-
|
|
28
|
-
const [open, setOpen] = useState(false)
|
|
29
|
-
const [step, setStep] = useState<CreateWorkspaceStep>('agent')
|
|
30
|
-
const [type, setType] = useState<WorkspaceType>(DEFAULT_WORKSPACE_TYPE)
|
|
31
|
-
const [name, setName] = useState('')
|
|
32
|
-
|
|
33
|
-
const trimmedName = name.trim()
|
|
34
|
-
const nameError = trimmedName ? validateWorkspaceFolderName(trimmedName) : null
|
|
35
|
-
const canChooseFolder = info.data?.canChooseFolder ?? true
|
|
36
|
-
const isImporting = chooseFolder.isPending || addMutation.isPending
|
|
37
|
-
const isCreating = createMutation.isPending
|
|
38
|
-
|
|
39
|
-
function resetDialog() {
|
|
40
|
-
setOpen(false)
|
|
41
|
-
setStep('agent')
|
|
42
|
-
setType(DEFAULT_WORKSPACE_TYPE)
|
|
43
|
-
setName('')
|
|
44
|
-
chooseFolder.reset()
|
|
45
|
-
addMutation.reset()
|
|
46
|
-
createMutation.reset()
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function handleOpenChange(nextOpen: boolean) {
|
|
50
|
-
if (nextOpen) {
|
|
51
|
-
setOpen(true)
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
resetDialog()
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function finish(workspaceId: string) {
|
|
58
|
-
resetDialog()
|
|
59
|
-
navigate(`/workspace/${workspaceId}`)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function handleUseExisting() {
|
|
63
|
-
if (isImporting) return
|
|
64
|
-
|
|
65
|
-
chooseFolder.reset()
|
|
66
|
-
addMutation.reset()
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
const result = await chooseFolder.mutateAsync()
|
|
70
|
-
if ('canceled' in result) return
|
|
71
|
-
const entry = await addMutation.mutateAsync({ path: result.path, type })
|
|
72
|
-
finish(entry.id)
|
|
73
|
-
} catch {
|
|
74
|
-
// The active step renders the mutation error.
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function handleContinue() {
|
|
79
|
-
createMutation.reset()
|
|
80
|
-
setStep('name')
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function handleCreate() {
|
|
84
|
-
if (!trimmedName || nameError || isCreating) return
|
|
85
|
-
|
|
86
|
-
createMutation.reset()
|
|
87
|
-
createMutation.mutate({ name: trimmedName, type }, { onSuccess: entry => finish(entry.id) })
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<Dialog open={open} onOpenChange={handleOpenChange}>
|
|
92
|
-
<DialogTrigger render={trigger} />
|
|
93
|
-
<DialogContent className="w-[calc(100%-2rem)] max-w-lg p-6">
|
|
94
|
-
<DialogClose
|
|
95
|
-
render={
|
|
96
|
-
<Button
|
|
97
|
-
variant="ghost"
|
|
98
|
-
size="icon-sm"
|
|
99
|
-
aria-label="Close"
|
|
100
|
-
className="absolute top-4 right-4"
|
|
101
|
-
>
|
|
102
|
-
<IconX stroke={1.75} />
|
|
103
|
-
</Button>
|
|
104
|
-
}
|
|
105
|
-
/>
|
|
106
|
-
|
|
107
|
-
{step === 'agent' ? (
|
|
108
|
-
<WorkspaceAgentStep
|
|
109
|
-
type={type}
|
|
110
|
-
canChooseFolder={canChooseFolder}
|
|
111
|
-
isPending={isImporting}
|
|
112
|
-
errorMessage={(chooseFolder.error ?? addMutation.error)?.message}
|
|
113
|
-
onTypeChange={setType}
|
|
114
|
-
onUseExisting={handleUseExisting}
|
|
115
|
-
onContinue={handleContinue}
|
|
116
|
-
/>
|
|
117
|
-
) : (
|
|
118
|
-
<WorkspaceNameStep
|
|
119
|
-
name={name}
|
|
120
|
-
validationError={nameError}
|
|
121
|
-
requestError={createMutation.error?.message}
|
|
122
|
-
isPending={isCreating}
|
|
123
|
-
onNameChange={setName}
|
|
124
|
-
onSubmit={handleCreate}
|
|
125
|
-
/>
|
|
126
|
-
)}
|
|
127
|
-
</DialogContent>
|
|
128
|
-
</Dialog>
|
|
129
|
-
)
|
|
130
|
-
}
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import type { FormEvent } from 'react'
|
|
2
|
-
|
|
3
|
-
import { IconCircleCheckFilled } from '@tabler/icons-react'
|
|
4
|
-
|
|
5
|
-
import { Button } from '@/client/components/ui/button'
|
|
6
|
-
import { DialogDescription, DialogTitle } from '@/client/components/ui/dialog'
|
|
7
|
-
import { Input } from '@/client/components/ui/input'
|
|
8
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
9
|
-
import { cn } from '@/client/lib/cn'
|
|
10
|
-
import {
|
|
11
|
-
WorkspaceTypeIcon,
|
|
12
|
-
workspaceTypeLabel
|
|
13
|
-
} from '@/client/features/home/workspace-presentation'
|
|
14
|
-
import type { WorkspaceType } from '@/lib/types'
|
|
15
|
-
|
|
16
|
-
type WorkspaceAgentOption = {
|
|
17
|
-
type: WorkspaceType
|
|
18
|
-
hint: string
|
|
19
|
-
disabled?: boolean
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Only Claude Code workspaces can be created from scratch for now. OpenClaw
|
|
23
|
-
// workspaces arrive through discovery, and Hermes has no initialization path.
|
|
24
|
-
const WORKSPACE_AGENT_OPTIONS: WorkspaceAgentOption[] = [
|
|
25
|
-
{ type: 'claude-code', hint: 'Great all-rounder for complex tasks built by Anthropic' },
|
|
26
|
-
{
|
|
27
|
-
type: 'openclaw',
|
|
28
|
-
hint: 'Initialize OpenClaw in the folder manually, then import it to moi',
|
|
29
|
-
disabled: true
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
|
|
33
|
-
type WorkspaceAgentStepProps = {
|
|
34
|
-
type: WorkspaceType
|
|
35
|
-
canChooseFolder: boolean
|
|
36
|
-
isPending: boolean
|
|
37
|
-
errorMessage?: string
|
|
38
|
-
onTypeChange: (type: WorkspaceType) => void
|
|
39
|
-
onUseExisting: () => void
|
|
40
|
-
onContinue: () => void
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function WorkspaceAgentStep({
|
|
44
|
-
type,
|
|
45
|
-
canChooseFolder,
|
|
46
|
-
isPending,
|
|
47
|
-
errorMessage,
|
|
48
|
-
onTypeChange,
|
|
49
|
-
onUseExisting,
|
|
50
|
-
onContinue
|
|
51
|
-
}: WorkspaceAgentStepProps) {
|
|
52
|
-
return (
|
|
53
|
-
<div className="flex flex-col gap-5">
|
|
54
|
-
<div className="flex flex-col gap-0.5 pr-8">
|
|
55
|
-
<DialogTitle>Choose agent</DialogTitle>
|
|
56
|
-
<DialogDescription>It will be used to build your workspace</DialogDescription>
|
|
57
|
-
</div>
|
|
58
|
-
|
|
59
|
-
<div role="group" aria-label="Agent" className="grid grid-cols-2 gap-2">
|
|
60
|
-
{WORKSPACE_AGENT_OPTIONS.map(option => (
|
|
61
|
-
<WorkspaceAgentOptionButton
|
|
62
|
-
key={option.type}
|
|
63
|
-
option={option}
|
|
64
|
-
selected={type === option.type}
|
|
65
|
-
onSelect={onTypeChange}
|
|
66
|
-
/>
|
|
67
|
-
))}
|
|
68
|
-
</div>
|
|
69
|
-
|
|
70
|
-
{errorMessage && (
|
|
71
|
-
<p role="alert" className="text-xs text-destructive">
|
|
72
|
-
{errorMessage}
|
|
73
|
-
</p>
|
|
74
|
-
)}
|
|
75
|
-
|
|
76
|
-
<div className="flex items-center justify-end gap-2">
|
|
77
|
-
<ExistingFolderButton
|
|
78
|
-
available={canChooseFolder}
|
|
79
|
-
disabled={isPending}
|
|
80
|
-
onClick={onUseExisting}
|
|
81
|
-
/>
|
|
82
|
-
<Button onClick={onContinue} disabled={isPending}>
|
|
83
|
-
Next
|
|
84
|
-
</Button>
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
type WorkspaceNameStepProps = {
|
|
91
|
-
name: string
|
|
92
|
-
validationError: string | null
|
|
93
|
-
requestError?: string
|
|
94
|
-
isPending: boolean
|
|
95
|
-
onNameChange: (name: string) => void
|
|
96
|
-
onSubmit: () => void
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function WorkspaceNameStep({
|
|
100
|
-
name,
|
|
101
|
-
validationError,
|
|
102
|
-
requestError,
|
|
103
|
-
isPending,
|
|
104
|
-
onNameChange,
|
|
105
|
-
onSubmit
|
|
106
|
-
}: WorkspaceNameStepProps) {
|
|
107
|
-
function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
|
108
|
-
event.preventDefault()
|
|
109
|
-
onSubmit()
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<form className="flex flex-col gap-5" onSubmit={handleSubmit}>
|
|
114
|
-
<div className="flex flex-col gap-0.5 pr-8">
|
|
115
|
-
<DialogTitle>Name workspace</DialogTitle>
|
|
116
|
-
<DialogDescription>Keep it short and recognizable</DialogDescription>
|
|
117
|
-
</div>
|
|
118
|
-
|
|
119
|
-
<div className="flex flex-col gap-2">
|
|
120
|
-
<label htmlFor="workspace-name" className="sr-only">
|
|
121
|
-
Workspace name
|
|
122
|
-
</label>
|
|
123
|
-
<Input
|
|
124
|
-
id="workspace-name"
|
|
125
|
-
value={name}
|
|
126
|
-
onChange={event => onNameChange(event.target.value)}
|
|
127
|
-
placeholder="my-workspace"
|
|
128
|
-
autoFocus
|
|
129
|
-
aria-invalid={Boolean(validationError)}
|
|
130
|
-
aria-describedby={validationError ? 'workspace-name-error' : undefined}
|
|
131
|
-
autoComplete="off"
|
|
132
|
-
spellCheck={false}
|
|
133
|
-
/>
|
|
134
|
-
{validationError && (
|
|
135
|
-
<p id="workspace-name-error" role="alert" className="text-xs text-destructive">
|
|
136
|
-
{validationError}
|
|
137
|
-
</p>
|
|
138
|
-
)}
|
|
139
|
-
</div>
|
|
140
|
-
|
|
141
|
-
{requestError && (
|
|
142
|
-
<p role="alert" className="text-xs text-destructive">
|
|
143
|
-
{requestError}
|
|
144
|
-
</p>
|
|
145
|
-
)}
|
|
146
|
-
|
|
147
|
-
<div className="flex items-center justify-end gap-2">
|
|
148
|
-
<Button type="submit" disabled={!name.trim() || Boolean(validationError) || isPending}>
|
|
149
|
-
{isPending ? 'Creating…' : `Create workspace`}
|
|
150
|
-
</Button>
|
|
151
|
-
</div>
|
|
152
|
-
</form>
|
|
153
|
-
)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
type WorkspaceAgentOptionButtonProps = {
|
|
157
|
-
option: WorkspaceAgentOption
|
|
158
|
-
selected: boolean
|
|
159
|
-
onSelect: (type: WorkspaceType) => void
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function WorkspaceAgentOptionButton({
|
|
163
|
-
option,
|
|
164
|
-
selected,
|
|
165
|
-
onSelect
|
|
166
|
-
}: WorkspaceAgentOptionButtonProps) {
|
|
167
|
-
return (
|
|
168
|
-
<button
|
|
169
|
-
type="button"
|
|
170
|
-
disabled={option.disabled}
|
|
171
|
-
onClick={() => onSelect(option.type)}
|
|
172
|
-
aria-pressed={selected}
|
|
173
|
-
className={cn(
|
|
174
|
-
'relative flex w-full flex-col items-start justify-between gap-6 rounded-lg bg-card p-4 text-left ring-1 ring-border transition-shadow outline-none focus-visible:ring-3 focus-visible:ring-ring/50',
|
|
175
|
-
!selected && !option.disabled && 'cursor-pointer',
|
|
176
|
-
option.disabled && 'cursor-not-allowed opacity-50'
|
|
177
|
-
)}
|
|
178
|
-
>
|
|
179
|
-
<span className="relative inline-flex">
|
|
180
|
-
<WorkspaceTypeIcon type={option.type} className="size-10" />
|
|
181
|
-
{selected && (
|
|
182
|
-
<IconCircleCheckFilled
|
|
183
|
-
size={20}
|
|
184
|
-
stroke={1.5}
|
|
185
|
-
aria-hidden="true"
|
|
186
|
-
className="absolute -top-1.5 -right-1.5"
|
|
187
|
-
/>
|
|
188
|
-
)}
|
|
189
|
-
</span>
|
|
190
|
-
<span className="flex min-w-0 flex-col gap-0.5">
|
|
191
|
-
<span className="text-sm font-medium text-foreground">
|
|
192
|
-
{workspaceTypeLabel[option.type]}
|
|
193
|
-
</span>
|
|
194
|
-
<span className="text-xs leading-4 text-muted-foreground">{option.hint}</span>
|
|
195
|
-
</span>
|
|
196
|
-
</button>
|
|
197
|
-
)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
type ExistingFolderButtonProps = {
|
|
201
|
-
available: boolean
|
|
202
|
-
disabled: boolean
|
|
203
|
-
onClick: () => void
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function ExistingFolderButton({ available, disabled, onClick }: ExistingFolderButtonProps) {
|
|
207
|
-
if (available) {
|
|
208
|
-
return (
|
|
209
|
-
<Button variant="secondary" onClick={onClick} disabled={disabled}>
|
|
210
|
-
Use existing folder
|
|
211
|
-
</Button>
|
|
212
|
-
)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return (
|
|
216
|
-
<Tooltip delay={50}>
|
|
217
|
-
<TooltipTrigger
|
|
218
|
-
render={
|
|
219
|
-
<Button
|
|
220
|
-
variant="secondary"
|
|
221
|
-
aria-disabled
|
|
222
|
-
onClick={event => event.preventDefault()}
|
|
223
|
-
className="cursor-not-allowed opacity-50"
|
|
224
|
-
>
|
|
225
|
-
Use existing folder
|
|
226
|
-
</Button>
|
|
227
|
-
}
|
|
228
|
-
/>
|
|
229
|
-
<TooltipContent className="max-w-64 text-center">
|
|
230
|
-
Run <code className="font-mono">moi init</code> in the folder to add it manually.
|
|
231
|
-
</TooltipContent>
|
|
232
|
-
</Tooltip>
|
|
233
|
-
)
|
|
234
|
-
}
|