moi-computer 0.3.1-next.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/shell/SidebarLayout.tsx +3 -16
- package/client/assets/openai.svg +1 -3
- package/client/components/shared/Composer.tsx +53 -2
- package/client/components/ui/button.tsx +1 -1
- package/client/components/ui/tooltip.tsx +12 -15
- package/client/features/chat/ChatComposer.tsx +25 -15
- package/client/features/chat/ChatPanel.tsx +5 -2
- package/client/features/chat/MarkdownContent.tsx +20 -2
- package/client/features/chat/ModelPicker.tsx +5 -3
- package/client/features/chat/TurnView.tsx +2 -2
- package/client/features/chat/chat-frames.ts +13 -6
- package/client/features/chat/chat-send.ts +1 -1
- package/client/features/chat/chat-store.ts +22 -17
- 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 +11 -2
- package/client/features/connectors/McpServerCards.tsx +95 -0
- package/client/features/connectors/api.ts +0 -11
- package/client/features/home/HomePage.tsx +33 -28
- 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/SettingsLayout.tsx +2 -2
- package/client/features/settings/WorkspaceSettings.tsx +8 -4
- package/client/features/views/ViewBuilderTab.tsx +19 -15
- package/client/features/views/useViewBuilderActions.ts +1 -1
- package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -4
- package/client/features/workspace/WorkspaceScreen.tsx +11 -3
- package/client/features/workspace/api.ts +19 -1
- package/client/features/workspace/moi-context.ts +85 -0
- package/client/main.tsx +7 -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-kxmvv1ax.js → chunk-qwm5f6qk.js} +1 -1
- package/dist/{chunk-axszxe4c.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 +29 -11
- package/lib/view-builder-directives.ts +16 -0
- package/lib/workspace-types.ts +12 -0
- package/package.json +2 -1
- package/server/api.ts +92 -30
- package/server/harness/README.md +25 -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 +32 -12
- 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/codex/NOTES.md +41 -11
- package/server/harness/codex/adapter.ts +21 -7
- package/server/harness/codex/client.ts +33 -17
- package/server/harness/codex/discovery.ts +114 -0
- package/server/harness/codex/index.ts +9 -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/index.ts +8 -14
- 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 +22 -5
- package/server/registry.ts +57 -12
- package/server/view-builders.ts +3 -2
- package/server/web.ts +24 -8
- package/server/workspace-import.ts +45 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +3 -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-b3ynfk4g.js +0 -62
- package/dist/chunk-b4b276wx.js +0 -15
- package/dist/chunk-npwq6jmr.css +0 -1
- package/dist/openai-h13pza4b.svg +0 -3
- package/lib/view-builder-meta.ts +0 -35
|
@@ -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
|
-
}
|