moi-computer 0.3.0-next.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/README.md +1 -1
  2. package/client/AGENTS.md +2 -2
  3. package/client/api/http.ts +1 -1
  4. package/client/api/workspace-keys.ts +1 -0
  5. package/client/app/AppRouter.tsx +14 -5
  6. package/client/app/routes/HomeRoute.tsx +1 -1
  7. package/client/app/routes/WorkspaceRoute.tsx +8 -2
  8. package/client/app/shell/SidebarLayout.tsx +10 -5
  9. package/client/assets/openai.svg +3 -0
  10. package/client/components/shared/BottomPanel.tsx +2 -2
  11. package/client/components/ui/button.tsx +3 -2
  12. package/client/components/ui/input.tsx +1 -1
  13. package/client/features/applets/AppletMount.tsx +44 -0
  14. package/client/features/applets/WidgetShell.tsx +4 -1
  15. package/client/features/applets/applet-cache.ts +8 -0
  16. package/client/features/applets/applet-styles.ts +61 -0
  17. package/client/features/chat/ChatComposer.tsx +2 -2
  18. package/client/features/chat/ChatPanel.tsx +8 -25
  19. package/client/features/chat/ChatPopup.tsx +3 -3
  20. package/client/features/chat/{ThreadSelector.tsx → ChatSelector.tsx} +4 -4
  21. package/client/features/chat/TurnView.tsx +8 -9
  22. package/client/features/chat/api.ts +1 -1
  23. package/client/features/chat/chat-send.ts +57 -0
  24. package/client/features/chat/tool-group/ToolCallGroup.tsx +2 -1
  25. package/client/features/chat/tool-group/format.ts +117 -0
  26. package/client/features/chat/useChat.ts +10 -34
  27. package/client/features/connectors/McpMenu.tsx +4 -21
  28. package/client/features/dev/DevRoutes.tsx +18 -0
  29. package/client/features/dev/HarnessDebugPage.tsx +468 -0
  30. package/client/{components/playground → features/dev}/PlaygroundPage.tsx +1 -1
  31. package/client/features/home/CreateWorkspaceDialog.tsx +64 -158
  32. package/client/features/home/CreateWorkspaceDialogSteps.tsx +234 -0
  33. package/client/features/home/HomeLogo.tsx +344 -0
  34. package/client/features/home/HomePage.tsx +15 -21
  35. package/client/features/home/WorkspacePreview.tsx +12 -5
  36. package/client/features/home/api.ts +11 -3
  37. package/client/features/home/workspace-presentation.tsx +4 -4
  38. package/client/features/settings/GeneralSettings.tsx +3 -3
  39. package/client/features/settings/IconPicker.tsx +4 -3
  40. package/client/features/settings/icon-picker-options.ts +0 -131
  41. package/client/features/views/ViewBuilderTab.tsx +153 -0
  42. package/client/features/views/api.ts +124 -0
  43. package/client/features/views/useViewBuilderActions.ts +72 -0
  44. package/client/features/widgets/WidgetGrid.tsx +36 -20
  45. package/client/features/widgets/Widgets.tsx +140 -90
  46. package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -9
  47. package/client/features/workspace/WorkspaceScreen.tsx +179 -40
  48. package/client/features/workspace/WorkspaceTabs.tsx +4 -4
  49. package/client/index.css +0 -35
  50. package/client/index.html +1 -1
  51. package/client/lib/app-icon-registry.ts +145 -0
  52. package/client/runtime/useWorkspaceEvents.ts +3 -1
  53. package/client/theme.css +1 -1
  54. package/dist/chunk-4vf1t6v1.js +10 -0
  55. package/dist/chunk-4z52b2av.css +1 -0
  56. package/dist/chunk-6c8cwpzc.js +1 -0
  57. package/dist/chunk-b4b276wx.js +15 -0
  58. package/dist/{chunk-c4j722at.js → chunk-cs8vbert.js} +2 -2
  59. package/dist/chunk-fjksw6xf.js +1 -0
  60. package/dist/chunk-kxmvv1ax.js +48 -0
  61. package/dist/{chunk-p68fnz3q.js → chunk-vkvb3hjm.js} +1 -1
  62. package/dist/chunk-y82s1jxm.js +61 -0
  63. package/dist/chunk-zpxrb1ce.js +2 -0
  64. package/dist/index.html +2 -2
  65. package/dist/openai-h13pza4b.svg +3 -0
  66. package/lib/format.ts +2 -2
  67. package/lib/types.ts +38 -2
  68. package/lib/view-builder-meta.ts +35 -0
  69. package/lib/workspace-layout.ts +14 -0
  70. package/package.json +2 -1
  71. package/server/AGENTS.md +3 -3
  72. package/server/api.ts +165 -51
  73. package/server/applets.ts +1 -1
  74. package/server/bundle-queue.ts +19 -0
  75. package/server/bundler/applet-css.ts +50 -0
  76. package/server/{build-applet.ts → bundler/build-applet.ts} +36 -26
  77. package/server/cli.ts +79 -2
  78. package/server/control.ts +106 -8
  79. package/server/env-apply.ts +2 -2
  80. package/server/harness/README.md +228 -0
  81. package/server/harness/claude-code/NOTES.md +578 -0
  82. package/{lib/claude-adapter.ts → server/harness/claude-code/adapter.ts} +67 -5
  83. package/server/harness/claude-code/index.ts +124 -0
  84. package/server/{mcp.ts → harness/claude-code/mcp.ts} +1 -1
  85. package/server/{cc-session.ts → harness/claude-code/session.ts} +42 -14
  86. package/server/harness/claude-code/sessions.ts +42 -0
  87. package/server/harness/codex/NOTES.md +326 -0
  88. package/server/harness/codex/adapter.ts +414 -0
  89. package/server/harness/codex/client.ts +343 -0
  90. package/server/harness/codex/index.ts +68 -0
  91. package/server/harness/codex/probe.ts +186 -0
  92. package/server/harness/codex/session.ts +617 -0
  93. package/server/harness/debug.ts +57 -0
  94. package/server/harness/openclaw/NOTES.md +316 -0
  95. package/server/{openclaw-adapter.ts → harness/openclaw/adapter.ts} +2 -2
  96. package/server/harness/openclaw/index.ts +93 -0
  97. package/server/{openclaw-session.ts → harness/openclaw/session.ts} +44 -9
  98. package/server/{openclaw-strip.ts → harness/openclaw/strip.ts} +3 -1
  99. package/server/harness/registry.ts +36 -0
  100. package/server/harness/types.ts +87 -0
  101. package/server/layout.ts +6 -12
  102. package/server/moi-scaffold.ts +1 -1
  103. package/server/registry.ts +14 -52
  104. package/server/state.ts +5 -38
  105. package/server/status.ts +7 -46
  106. package/server/vendor.ts +1 -1
  107. package/server/view-builders.ts +428 -0
  108. package/server/views.ts +0 -0
  109. package/server/web.ts +18 -40
  110. package/server/workspace-init.ts +6 -6
  111. package/workspace/.claude/skills/moi-workspace/DESIGN.md +1 -0
  112. package/workspace/.claude/skills/moi-workspace/SKILL.md +28 -7
  113. package/client/assets/hermes-nous.png +0 -0
  114. package/client/hooks/useScrollFade.ts +0 -38
  115. package/dist/chunk-23cgr1tz.css +0 -1
  116. package/dist/chunk-3hy3qy6d.js +0 -10
  117. package/dist/chunk-dyfaffyz.js +0 -119
  118. package/dist/chunk-kpe40hm8.js +0 -1
  119. package/dist/chunk-ty6dvda0.js +0 -1
  120. package/dist/hermes-nous-pznd63x9.png +0 -0
  121. /package/client/{components/playground → features/dev}/PixelPainter.tsx +0 -0
  122. /package/client/{components/playground → features/dev}/ToolCallsPage.tsx +0 -0
  123. /package/server/{agent.ts → harness/claude-code/models.ts} +0 -0
  124. /package/server/{openclaw.ts → harness/openclaw/discovery.ts} +0 -0
  125. /package/server/{openclaw-gateway.ts → harness/openclaw/gateway.ts} +0 -0
@@ -4,53 +4,20 @@ import { IconX } from '@tabler/icons-react'
4
4
  import { useLocation } from 'wouter'
5
5
 
6
6
  import { useAddWorkspace, useChooseFolder, useCreateWorkspace, useCreateWorkspaceInfo } from './api'
7
+ import { WorkspaceAgentStep, WorkspaceNameStep } from './CreateWorkspaceDialogSteps'
7
8
  import { Button } from '@/client/components/ui/button'
8
- import {
9
- Dialog,
10
- DialogClose,
11
- DialogContent,
12
- DialogDescription,
13
- DialogTitle,
14
- DialogTrigger
15
- } from '@/client/components/ui/dialog'
16
- import { Input } from '@/client/components/ui/input'
17
- import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
18
- import { cn } from '@/client/lib/cn'
19
- import {
20
- WorkspaceTypeIcon,
21
- workspaceTypeLabel
22
- } from '@/client/features/home/workspace-presentation'
9
+ import { Dialog, DialogClose, DialogContent, DialogTrigger } from '@/client/components/ui/dialog'
23
10
  import { validateWorkspaceFolderName } from '@/lib/workspace-name'
24
11
  import type { WorkspaceType } from '@/lib/types'
25
12
 
26
- type AgentOption = {
27
- type: WorkspaceType
28
- hint: string
29
- disabled?: boolean
30
- }
31
-
32
- // Only Claude Code workspaces can be created from scratch for now. OpenClaw
33
- // workspaces belong to their agents — they arrive via discovery on the home
34
- // page — and Hermes has no init path yet.
35
- const AGENT_OPTIONS: AgentOption[] = [
36
- { type: 'claude-code', hint: 'Powered by the Claude Agent SDK' },
37
- {
38
- type: 'openclaw',
39
- hint: 'Initialize OpenClaw in the folder manually, then import it from Home',
40
- disabled: true
41
- },
42
- { type: 'hermes', hint: 'Coming soon', disabled: true }
43
- ]
44
-
45
13
  type CreateWorkspaceDialogProps = {
46
14
  trigger: ReactElement
47
15
  }
48
16
 
49
- type Step = 'type' | 'name'
17
+ type CreateWorkspaceStep = 'agent' | 'name'
18
+
19
+ const DEFAULT_WORKSPACE_TYPE: WorkspaceType = 'claude-code'
50
20
 
51
- // A two-step dialog for adding a workspace. Step one picks the agent type and
52
- // offers "Use existing folder" (opens the OS folder picker via the server) or
53
- // "Next"; step two names a brand-new folder created under the workspaces root.
54
21
  export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
55
22
  const [, navigate] = useLocation()
56
23
  const info = useCreateWorkspaceInfo()
@@ -59,54 +26,71 @@ export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
59
26
  const chooseFolder = useChooseFolder()
60
27
 
61
28
  const [open, setOpen] = useState(false)
62
- const [step, setStep] = useState<Step>('type')
63
- const [type, setType] = useState<WorkspaceType>('claude-code')
29
+ const [step, setStep] = useState<CreateWorkspaceStep>('agent')
30
+ const [type, setType] = useState<WorkspaceType>(DEFAULT_WORKSPACE_TYPE)
64
31
  const [name, setName] = useState('')
65
32
 
66
- const trimmed = name.trim()
67
- const nameError = trimmed ? validateWorkspaceFolderName(trimmed) : null
68
- // The native folder picker is macOS-only (osascript). Elsewhere the button is
69
- // disabled with a tooltip pointing to the manual `moi init` path. Default to
70
- // enabled while the flag loads so mac users don't see a flicker.
33
+ const trimmedName = name.trim()
34
+ const nameError = trimmedName ? validateWorkspaceFolderName(trimmedName) : null
71
35
  const canChooseFolder = info.data?.canChooseFolder ?? true
72
- const busy = createMutation.isPending || addMutation.isPending || chooseFolder.isPending
73
- const error = createMutation.error ?? addMutation.error ?? chooseFolder.error
74
-
75
- function handleOpenChange(next: boolean) {
76
- setOpen(next)
77
- if (!next) {
78
- // Reset so the dialog always reopens at step one with a clean slate.
79
- setStep('type')
80
- setName('')
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
81
53
  }
54
+ resetDialog()
82
55
  }
83
56
 
84
- function finish(id: string) {
85
- setOpen(false)
86
- navigate(`/workspace/${id}`)
57
+ function finish(workspaceId: string) {
58
+ resetDialog()
59
+ navigate(`/workspace/${workspaceId}`)
87
60
  }
88
61
 
89
62
  async function handleUseExisting() {
90
- if (busy) return
63
+ if (isImporting) return
64
+
65
+ chooseFolder.reset()
66
+ addMutation.reset()
67
+
91
68
  try {
92
69
  const result = await chooseFolder.mutateAsync()
93
70
  if ('canceled' in result) return
94
71
  const entry = await addMutation.mutateAsync({ path: result.path, type })
95
72
  finish(entry.id)
96
73
  } catch {
97
- // Surfaced via the mutation error state below.
74
+ // The active step renders the mutation error.
98
75
  }
99
76
  }
100
77
 
78
+ function handleContinue() {
79
+ createMutation.reset()
80
+ setStep('name')
81
+ }
82
+
101
83
  function handleCreate() {
102
- if (!trimmed || nameError || busy) return
103
- createMutation.mutate({ name: trimmed, type }, { onSuccess: entry => finish(entry.id) })
84
+ if (!trimmedName || nameError || isCreating) return
85
+
86
+ createMutation.reset()
87
+ createMutation.mutate({ name: trimmedName, type }, { onSuccess: entry => finish(entry.id) })
104
88
  }
105
89
 
106
90
  return (
107
91
  <Dialog open={open} onOpenChange={handleOpenChange}>
108
92
  <DialogTrigger render={trigger} />
109
- <DialogContent className="w-[520px] max-w-[92vw] p-6">
93
+ <DialogContent className="w-[calc(100%-2rem)] max-w-lg p-6">
110
94
  <DialogClose
111
95
  render={
112
96
  <Button
@@ -120,103 +104,25 @@ export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
120
104
  }
121
105
  />
122
106
 
123
- {step === 'type' ? (
124
- <>
125
- <DialogTitle>Create new space</DialogTitle>
126
- <p className="mt-4 mb-2 text-sm font-medium text-foreground">Space type</p>
127
- <div className="flex flex-col gap-2">
128
- {AGENT_OPTIONS.map(option => {
129
- const selected = type === option.type
130
- return (
131
- <button
132
- key={option.type}
133
- type="button"
134
- disabled={option.disabled}
135
- onClick={() => setType(option.type)}
136
- aria-pressed={selected}
137
- className={cn(
138
- 'flex items-center gap-3 rounded-lg border p-3 text-left transition-colors',
139
- selected
140
- ? 'border-ring bg-muted/50 shadow-[inset_0_0_0_1px_var(--ring)]'
141
- : 'border-border hover:bg-accent',
142
- option.disabled && 'cursor-not-allowed opacity-50 hover:bg-transparent'
143
- )}
144
- >
145
- <WorkspaceTypeIcon type={option.type} className="size-5" />
146
- <span className="flex min-w-0 flex-col">
147
- <span className="text-sm font-medium text-foreground">
148
- {workspaceTypeLabel[option.type]}
149
- </span>
150
- <span className="text-xs text-muted-foreground">{option.hint}</span>
151
- </span>
152
- </button>
153
- )
154
- })}
155
- </div>
156
-
157
- {error && <p className="mt-4 text-xs text-destructive">{error.message}</p>}
158
-
159
- <div className="mt-6 flex items-center justify-end gap-2">
160
- {canChooseFolder ? (
161
- <Button variant="secondary" onClick={handleUseExisting} disabled={busy}>
162
- Use existing folder
163
- </Button>
164
- ) : (
165
- <Tooltip delay={50}>
166
- <TooltipTrigger
167
- render={
168
- // aria-disabled (not the native `disabled` attr) keeps the
169
- // button hoverable so the tooltip still shows.
170
- <Button
171
- variant="secondary"
172
- aria-disabled
173
- onClick={e => e.preventDefault()}
174
- className="cursor-not-allowed opacity-50"
175
- >
176
- Use existing folder
177
- </Button>
178
- }
179
- />
180
- <TooltipContent className="max-w-64 text-center">
181
- Run <code className="font-mono">moi init</code> in the folder to add it
182
- manually.
183
- </TooltipContent>
184
- </Tooltip>
185
- )}
186
- <Button onClick={() => setStep('name')} disabled={busy}>
187
- Next
188
- </Button>
189
- </div>
190
- </>
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
+ />
191
117
  ) : (
192
- <>
193
- <DialogTitle>Name the space</DialogTitle>
194
- <DialogDescription className="mt-1">Keep it short and recognizable.</DialogDescription>
195
-
196
- <div className="mt-5">
197
- <Input
198
- value={name}
199
- onChange={e => setName(e.target.value)}
200
- onKeyDown={e => {
201
- if (e.key === 'Enter') handleCreate()
202
- }}
203
- placeholder="my-space"
204
- autoFocus
205
- aria-invalid={!!nameError}
206
- autoComplete="off"
207
- spellCheck={false}
208
- />
209
- {nameError && <p className="mt-2 text-xs text-destructive">{nameError}</p>}
210
- </div>
211
-
212
- {error && <p className="mt-4 text-xs text-destructive">{error.message}</p>}
213
-
214
- <div className="mt-6 flex items-center justify-end gap-2">
215
- <Button onClick={handleCreate} disabled={!trimmed || !!nameError || busy}>
216
- {createMutation.isPending ? 'Creating…' : 'Create new space'}
217
- </Button>
218
- </div>
219
- </>
118
+ <WorkspaceNameStep
119
+ name={name}
120
+ validationError={nameError}
121
+ requestError={createMutation.error?.message}
122
+ isPending={isCreating}
123
+ onNameChange={setName}
124
+ onSubmit={handleCreate}
125
+ />
220
126
  )}
221
127
  </DialogContent>
222
128
  </Dialog>
@@ -0,0 +1,234 @@
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
+ }