moi-computer 0.3.0-next.1 → 0.3.0-next.3

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 (206) hide show
  1. package/README.md +1 -1
  2. package/bunfig.toml +5 -1
  3. package/client/AGENTS.md +17 -2
  4. package/client/accept-hmr-dependencies.ts +22 -0
  5. package/client/api/http.ts +31 -0
  6. package/client/api/query-options.ts +6 -0
  7. package/client/api/workspace-keys.ts +18 -0
  8. package/client/app/AppRouter.tsx +44 -0
  9. package/client/app/routes/HomeRoute.tsx +13 -0
  10. package/client/app/routes/WorkspaceRoute.tsx +95 -0
  11. package/client/app/shell/SidebarLayout.tsx +196 -0
  12. package/client/assets/openai.svg +3 -0
  13. package/client/assets.d.ts +9 -0
  14. package/client/components/{BottomPanel.tsx → shared/BottomPanel.tsx} +2 -2
  15. package/client/components/shared/PanelHeader.tsx +9 -0
  16. package/client/components/shared/ReorderableList.tsx +199 -0
  17. package/client/components/ui/button.tsx +11 -7
  18. package/client/components/ui/collapsible.tsx +15 -0
  19. package/client/components/ui/dialog.tsx +2 -2
  20. package/client/components/ui/dropdown-menu.tsx +5 -5
  21. package/client/components/ui/hover-card.tsx +1 -1
  22. package/client/components/ui/input.tsx +1 -1
  23. package/client/components/ui/popover.tsx +1 -1
  24. package/client/components/ui/skeleton.tsx +13 -0
  25. package/client/components/ui/tooltip.tsx +1 -1
  26. package/client/externalize-react.ts +7 -1
  27. package/client/features/applets/AppletMount.tsx +44 -0
  28. package/client/{components → features/applets}/WidgetErrorBoundary.tsx +1 -1
  29. package/client/{components → features/applets}/WidgetShell.tsx +5 -2
  30. package/client/{lib → features/applets}/applet-cache.ts +8 -0
  31. package/client/features/applets/applet-styles.ts +61 -0
  32. package/client/{hooks → features/applets}/useApplet.ts +6 -7
  33. package/client/{components/ChatInput.tsx → features/chat/ChatComposer.tsx} +30 -24
  34. package/client/features/chat/ChatPanel.tsx +171 -0
  35. package/client/{components → features/chat}/ChatPopup.tsx +24 -13
  36. package/client/{components/ThreadSelector.tsx → features/chat/ChatSelector.tsx} +15 -13
  37. package/client/{components → features/chat}/MarkdownContent.tsx +1 -1
  38. package/client/{components → features/chat}/ModelPicker.tsx +68 -17
  39. package/client/{components → features/chat}/TurnView.tsx +17 -11
  40. package/client/features/chat/api.ts +78 -0
  41. package/client/features/chat/chat-connection.ts +107 -0
  42. package/client/features/chat/chat-frames.ts +131 -0
  43. package/client/features/chat/chat-send.ts +57 -0
  44. package/client/{lib → features/chat}/preview-turn.ts +1 -1
  45. package/client/{components → features/chat}/tool-group/ReadImagePreview.tsx +1 -1
  46. package/client/{components → features/chat}/tool-group/SubagentCard.tsx +12 -10
  47. package/client/{components → features/chat}/tool-group/TimelineRow.tsx +5 -5
  48. package/client/{components → features/chat}/tool-group/ToolCallGroup.tsx +14 -5
  49. package/client/{components → features/chat}/tool-group/ToolOutput.tsx +12 -18
  50. package/client/{components → features/chat}/tool-group/format.ts +117 -0
  51. package/client/{hooks → features/chat}/useChat.ts +16 -44
  52. package/client/features/connectors/ConnectorsPage.tsx +92 -0
  53. package/client/features/connectors/McpMenu.tsx +145 -0
  54. package/client/features/connectors/api.ts +28 -0
  55. package/client/features/dev/DevRoutes.tsx +18 -0
  56. package/client/features/dev/HarnessDebugPage.tsx +468 -0
  57. package/client/{components/playground → features/dev}/PixelPainter.tsx +10 -21
  58. package/client/{components/playground → features/dev}/PlaygroundPage.tsx +10 -12
  59. package/client/{components/playground → features/dev}/ToolCallsPage.tsx +9 -11
  60. package/client/features/home/CreateWorkspaceDialog.tsx +130 -0
  61. package/client/features/home/CreateWorkspaceDialogSteps.tsx +234 -0
  62. package/client/features/home/HomeLogo.tsx +344 -0
  63. package/client/features/home/HomePage.tsx +214 -0
  64. package/client/{components → features/home}/WorkspacePreview.tsx +4 -4
  65. package/client/features/home/api.ts +156 -0
  66. package/client/features/home/workspace-presentation.tsx +44 -0
  67. package/client/features/scratchpad/Scratchpad.tsx +312 -0
  68. package/client/features/scratchpad/ScratchpadControls.tsx +503 -0
  69. package/client/features/scratchpad/useScratchpadSnapshot.tsx +115 -0
  70. package/client/features/settings/EnvironmentSettings.tsx +149 -0
  71. package/client/features/settings/GeneralSettings.tsx +90 -0
  72. package/client/{components → features}/settings/IconPicker.tsx +76 -224
  73. package/client/features/settings/SettingsLayout.tsx +53 -0
  74. package/client/{components → features}/settings/WorkspaceSettings.tsx +12 -16
  75. package/client/features/settings/api.ts +88 -0
  76. package/client/features/settings/icon-picker-options.ts +30 -0
  77. package/client/{hooks → features/settings}/useEnvVars.ts +4 -4
  78. package/client/features/views/ViewBuilderTab.tsx +153 -0
  79. package/client/features/views/api.ts +124 -0
  80. package/client/features/views/useViewBuilderActions.ts +72 -0
  81. package/client/{components → features/widgets}/HiddenPanel.tsx +3 -3
  82. package/client/{components → features/widgets}/WidgetFrame.tsx +3 -8
  83. package/client/{components → features/widgets}/WidgetGrid.tsx +38 -29
  84. package/client/features/widgets/Widgets.tsx +265 -0
  85. package/client/{lib/grid-pack.ts → features/widgets/grid.ts} +7 -1
  86. package/client/{hooks → features/widgets}/useGridReconcile.ts +1 -1
  87. package/client/{components → features/workspace}/CustomizePanel.tsx +5 -6
  88. package/client/{lib → features/workspace}/WorkspaceLayoutContext.tsx +16 -15
  89. package/client/features/workspace/WorkspaceScreen.tsx +675 -0
  90. package/client/features/workspace/WorkspaceTabs.tsx +205 -0
  91. package/client/features/workspace/api.ts +56 -0
  92. package/client/features/workspace/useFitsSplitLayout.ts +37 -0
  93. package/client/global.d.ts +5 -0
  94. package/client/index.css +6 -45
  95. package/client/index.html +2 -2
  96. package/client/index.tsx +14 -31
  97. package/client/lib/app-icon-registry.ts +145 -0
  98. package/client/main.tsx +2 -2
  99. package/client/runtime/hmr-watchdog.ts +39 -0
  100. package/client/{hooks/useMeiEvents.ts → runtime/useWorkspaceEvents.ts} +12 -7
  101. package/client/store/ui.ts +5 -1
  102. package/client/theme.css +1 -3
  103. package/dist/chunk-11cab5dq.css +1 -0
  104. package/dist/chunk-4vf1t6v1.js +10 -0
  105. package/dist/chunk-6c24yndg.js +61 -0
  106. package/dist/chunk-6c8cwpzc.js +1 -0
  107. package/dist/chunk-b4b276wx.js +15 -0
  108. package/dist/chunk-cs8vbert.js +546 -0
  109. package/dist/chunk-cwqmay73.css +1 -0
  110. package/dist/chunk-kxmvv1ax.js +48 -0
  111. package/dist/chunk-pcnahct1.js +5 -0
  112. package/dist/chunk-rq0ar7vp.js +1 -0
  113. package/dist/chunk-tqd3pkg8.css +1 -0
  114. package/dist/chunk-vkvb3hjm.js +2 -0
  115. package/dist/chunk-zpxrb1ce.js +2 -0
  116. package/dist/index.html +3 -3
  117. package/dist/openai-h13pza4b.svg +3 -0
  118. package/lib/format.ts +2 -2
  119. package/lib/types.ts +56 -9
  120. package/lib/view-builder-meta.ts +35 -0
  121. package/lib/workspace-layout.ts +14 -0
  122. package/lib/workspace-name.ts +14 -0
  123. package/package.json +4 -2
  124. package/server/AGENTS.md +3 -3
  125. package/server/api.ts +279 -60
  126. package/server/applets.ts +1 -1
  127. package/server/bundle-queue.ts +19 -0
  128. package/server/bundler/applet-css.ts +50 -0
  129. package/server/{build-applet.ts → bundler/build-applet.ts} +36 -26
  130. package/server/cli.ts +90 -7
  131. package/server/control.ts +106 -8
  132. package/server/env-apply.ts +2 -2
  133. package/server/harness/README.md +228 -0
  134. package/server/harness/claude-code/NOTES.md +578 -0
  135. package/{lib/claude-adapter.ts → server/harness/claude-code/adapter.ts} +67 -5
  136. package/server/harness/claude-code/index.ts +124 -0
  137. package/server/{mcp.ts → harness/claude-code/mcp.ts} +73 -16
  138. package/server/{cc-session.ts → harness/claude-code/session.ts} +42 -14
  139. package/server/harness/claude-code/sessions.ts +42 -0
  140. package/server/harness/codex/NOTES.md +239 -0
  141. package/server/harness/codex/adapter.ts +414 -0
  142. package/server/harness/codex/client.ts +343 -0
  143. package/server/harness/codex/index.ts +68 -0
  144. package/server/harness/codex/probe.ts +186 -0
  145. package/server/harness/codex/session.ts +617 -0
  146. package/server/harness/debug.ts +57 -0
  147. package/server/harness/openclaw/NOTES.md +316 -0
  148. package/server/{openclaw-adapter.ts → harness/openclaw/adapter.ts} +2 -2
  149. package/server/harness/openclaw/index.ts +93 -0
  150. package/server/{openclaw-session.ts → harness/openclaw/session.ts} +44 -9
  151. package/server/{openclaw-strip.ts → harness/openclaw/strip.ts} +3 -1
  152. package/server/harness/registry.ts +36 -0
  153. package/server/harness/types.ts +87 -0
  154. package/server/layout.ts +36 -11
  155. package/server/moi-scaffold.ts +56 -11
  156. package/server/registry.ts +30 -52
  157. package/server/state.ts +5 -38
  158. package/server/status.ts +7 -46
  159. package/server/vendor.ts +1 -1
  160. package/server/view-builders.ts +428 -0
  161. package/server/views.ts +0 -0
  162. package/server/web.ts +19 -40
  163. package/server/workspace-init.ts +11 -25
  164. package/tsconfig.json +1 -1
  165. package/workspace/.claude/skills/moi-workspace/DESIGN.md +2 -1
  166. package/workspace/.claude/skills/moi-workspace/SKILL.md +28 -7
  167. package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +1 -1
  168. package/client/api/workspaces.ts +0 -427
  169. package/client/assets/hermes-nous.png +0 -0
  170. package/client/components/App.tsx +0 -41
  171. package/client/components/ChatPanel.tsx +0 -275
  172. package/client/components/HomePage.tsx +0 -17
  173. package/client/components/McpMenu.tsx +0 -125
  174. package/client/components/Scratchpad.tsx +0 -935
  175. package/client/components/Widgets.tsx +0 -132
  176. package/client/components/WorkspacesPage.tsx +0 -245
  177. package/client/components/layout/SidebarLayout.tsx +0 -258
  178. package/client/components/routes/workspace/[id].tsx +0 -675
  179. package/client/components/routes/workspace/create.tsx +0 -155
  180. package/client/components/settings/SettingsPages.tsx +0 -255
  181. package/client/hooks/useFitsSidebar.ts +0 -34
  182. package/client/hooks/useScrollFade.ts +0 -38
  183. package/client/lib/connection.ts +0 -238
  184. package/dist/chunk-07qf2tv1.css +0 -1
  185. package/dist/chunk-w18801vn.js +0 -672
  186. package/dist/hermes-nous-pznd63x9.png +0 -0
  187. /package/client/components/{playground → shared}/LedLogo.tsx +0 -0
  188. /package/client/{components → features/chat}/ShimmerText.tsx +0 -0
  189. /package/client/{store/live.ts → features/chat/chat-store.ts} +0 -0
  190. /package/client/{lib → features/chat}/group-turns.ts +0 -0
  191. /package/client/{components → features/chat}/tool-group/CodeBlock.tsx +0 -0
  192. /package/client/{components → features/chat}/tool-group/Collapse.tsx +0 -0
  193. /package/client/{components → features/chat}/tool-group/detect.ts +0 -0
  194. /package/client/{components → features/chat}/tool-group/fixtures.ts +0 -0
  195. /package/client/{components → features/chat}/tool-group/index.ts +0 -0
  196. /package/client/{lib → features/chat}/uploads.ts +0 -0
  197. /package/client/{hooks → features/chat}/useStickToBottom.ts +0 -0
  198. /package/client/{components → features/connectors}/IconMcp.tsx +0 -0
  199. /package/client/{lib → features/connectors}/mcp-icons.ts +0 -0
  200. /package/client/{lib → features/scratchpad}/scratch-executor.ts +0 -0
  201. /package/client/{lib → features/settings}/render-icon.ts +0 -0
  202. /package/client/{lib → features/workspace}/WorkspaceContext.tsx +0 -0
  203. /package/client/{hooks → features/workspace}/useWorkspaceTheme.ts +0 -0
  204. /package/server/{agent.ts → harness/claude-code/models.ts} +0 -0
  205. /package/server/{openclaw.ts → harness/openclaw/discovery.ts} +0 -0
  206. /package/server/{openclaw-gateway.ts → harness/openclaw/gateway.ts} +0 -0
@@ -0,0 +1,130 @@
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
+ }
@@ -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
+ }
@@ -0,0 +1,344 @@
1
+ import { useEffect, useRef } from 'react'
2
+
3
+ import { cn } from '@/client/lib/cn'
4
+
5
+ const GLYPH_ROWS = [
6
+ ['OOOOO', 'O.O.O', 'O.O.O'],
7
+ ['OOO', 'O.O', 'OOO'],
8
+ ['O', 'O', 'O']
9
+ ] as const
10
+
11
+ const CELL_SIZE = 10
12
+ const CELL_GAP = 3
13
+ const CELL_RADIUS = 2.5
14
+ const CELL_OPACITY: Record<string, number> = { O: 1, o: 0.5, '.': 0 }
15
+
16
+ const INTRO_DURATION = 3000
17
+ const INTRO_SEED = 2
18
+ const INTRO_SPREAD = 3
19
+ const FIELD_SPACING = 3
20
+ const REST_THRESHOLD = 1e-3
21
+
22
+ const WAVE_PARAMS = {
23
+ courantSquared: 0.14,
24
+ damping: 0.976,
25
+ driveAmplitude: 1.4,
26
+ driveFrequency: 0.027,
27
+ gain: 0.65,
28
+ fadeIn: 0.36,
29
+ fadeOut: 0.1
30
+ } as const
31
+
32
+ type Pixel = {
33
+ x: number
34
+ y: number
35
+ centerX: number
36
+ centerY: number
37
+ targetOpacity: number
38
+ }
39
+
40
+ type GlyphGeometry = {
41
+ width: number
42
+ height: number
43
+ fieldColumns: number
44
+ fieldRows: number
45
+ pixels: Pixel[]
46
+ }
47
+
48
+ function buildGlyph(rows: readonly string[]): GlyphGeometry {
49
+ const columns = Math.max(...rows.map(row => row.length))
50
+ const width = columns * CELL_SIZE + (columns - 1) * CELL_GAP
51
+ const height = rows.length * CELL_SIZE + (rows.length - 1) * CELL_GAP
52
+ const pixels: Pixel[] = []
53
+
54
+ rows.forEach((row, rowIndex) => {
55
+ Array.from(row).forEach((cell, columnIndex) => {
56
+ const targetOpacity = CELL_OPACITY[cell]
57
+ if (targetOpacity === undefined) return
58
+
59
+ const x = columnIndex * (CELL_SIZE + CELL_GAP)
60
+ const y = rowIndex * (CELL_SIZE + CELL_GAP)
61
+ pixels.push({
62
+ x,
63
+ y,
64
+ centerX: x + CELL_SIZE / 2,
65
+ centerY: y + CELL_SIZE / 2,
66
+ targetOpacity
67
+ })
68
+ })
69
+ })
70
+
71
+ return {
72
+ width,
73
+ height,
74
+ fieldColumns: Math.round(width / FIELD_SPACING) + 1,
75
+ fieldRows: Math.round(height / FIELD_SPACING) + 1,
76
+ pixels
77
+ }
78
+ }
79
+
80
+ const GLYPHS = GLYPH_ROWS.map(buildGlyph)
81
+
82
+ function clamp(value: number, min: number, max: number): number {
83
+ return value < min ? min : value > max ? max : value
84
+ }
85
+
86
+ function easeInOut(value: number): number {
87
+ return value < 0.5 ? 2 * value * value : 1 - (-2 * value + 2) ** 2 / 2
88
+ }
89
+
90
+ class GlyphWaveEngine {
91
+ private readonly rects: (SVGRectElement | null)[]
92
+ private readonly svg: SVGSVGElement
93
+ private readonly geometry: GlyphGeometry
94
+ private animationFrame = 0
95
+ private running = false
96
+ private intro = true
97
+ private introStartedAt = -1
98
+ private field: Float32Array
99
+ private previousField: Float32Array
100
+ private nextField: Float32Array
101
+ private pointerActive = false
102
+ private pointerX = 0
103
+ private pointerY = 0
104
+ private activation = 0
105
+
106
+ constructor(rects: (SVGRectElement | null)[], svg: SVGSVGElement, geometry: GlyphGeometry) {
107
+ this.rects = rects
108
+ this.svg = svg
109
+ this.geometry = geometry
110
+ const fieldSize = geometry.fieldColumns * geometry.fieldRows
111
+ this.field = new Float32Array(fieldSize)
112
+ this.previousField = new Float32Array(fieldSize)
113
+ this.nextField = new Float32Array(fieldSize)
114
+ }
115
+
116
+ start(): void {
117
+ this.seedImpulse()
118
+ this.activation = 1
119
+ this.resume()
120
+ }
121
+
122
+ stop(): void {
123
+ cancelAnimationFrame(this.animationFrame)
124
+ this.running = false
125
+ }
126
+
127
+ handlePointerMove = (event: PointerEvent): void => {
128
+ const bounds = this.svg.getBoundingClientRect()
129
+ if (!bounds.width || !bounds.height) return
130
+
131
+ this.pointerActive =
132
+ event.clientX >= bounds.left &&
133
+ event.clientX <= bounds.right &&
134
+ event.clientY >= bounds.top &&
135
+ event.clientY <= bounds.bottom
136
+
137
+ if (this.pointerActive) {
138
+ this.pointerX = ((event.clientX - bounds.left) / bounds.width) * this.geometry.width
139
+ this.pointerY = ((event.clientY - bounds.top) / bounds.height) * this.geometry.height
140
+ this.resume()
141
+ }
142
+ }
143
+
144
+ private seedImpulse(): void {
145
+ const centerColumn = Math.round(this.geometry.width / 2 / FIELD_SPACING)
146
+ const centerRow = Math.round(this.geometry.height / 2 / FIELD_SPACING)
147
+ const spread = 2 * INTRO_SPREAD * INTRO_SPREAD
148
+
149
+ for (let row = 0; row < this.geometry.fieldRows; row++) {
150
+ for (let column = 0; column < this.geometry.fieldColumns; column++) {
151
+ const distance = (column - centerColumn) ** 2 + (row - centerRow) ** 2
152
+ const value = INTRO_SEED * Math.exp(-distance / spread)
153
+ const index = row * this.geometry.fieldColumns + column
154
+ this.field[index] = value
155
+ this.previousField[index] = value
156
+ }
157
+ }
158
+ }
159
+
160
+ private resume(): void {
161
+ if (this.running) return
162
+ this.running = true
163
+ this.animationFrame = requestAnimationFrame(this.animate)
164
+ }
165
+
166
+ private animate = (timestamp: number): void => {
167
+ this.stepWave()
168
+ if (this.pointerActive) this.driveWave(timestamp)
169
+
170
+ if (this.intro && !this.pointerActive) {
171
+ if (this.introStartedAt < 0) this.introStartedAt = timestamp
172
+ const progress = (timestamp - this.introStartedAt) / INTRO_DURATION
173
+ this.activation = 1 - easeInOut(Math.min(1, progress))
174
+ if (progress >= 1) this.intro = false
175
+ } else {
176
+ this.intro = false
177
+ const target = this.pointerActive ? 1 : 0
178
+ const fade = this.pointerActive ? WAVE_PARAMS.fadeIn : WAVE_PARAMS.fadeOut
179
+ this.activation += (target - this.activation) * fade
180
+ }
181
+
182
+ const peak = this.renderWave()
183
+ if (
184
+ this.intro ||
185
+ this.pointerActive ||
186
+ this.activation > REST_THRESHOLD ||
187
+ peak > REST_THRESHOLD
188
+ ) {
189
+ this.animationFrame = requestAnimationFrame(this.animate)
190
+ return
191
+ }
192
+
193
+ this.running = false
194
+ this.activation = 0
195
+ this.renderTargets()
196
+ }
197
+
198
+ private stepWave(): void {
199
+ const { fieldColumns, fieldRows } = this.geometry
200
+
201
+ for (let row = 1; row < fieldRows - 1; row++) {
202
+ for (let column = 1; column < fieldColumns - 1; column++) {
203
+ const index = row * fieldColumns + column
204
+ const laplacian =
205
+ this.field[index - 1] +
206
+ this.field[index + 1] +
207
+ this.field[index - fieldColumns] +
208
+ this.field[index + fieldColumns] -
209
+ 4 * this.field[index]
210
+ this.nextField[index] =
211
+ (2 * this.field[index] -
212
+ this.previousField[index] +
213
+ WAVE_PARAMS.courantSquared * laplacian) *
214
+ WAVE_PARAMS.damping
215
+ }
216
+ }
217
+
218
+ const previousField = this.previousField
219
+ this.previousField = this.field
220
+ this.field = this.nextField
221
+ this.nextField = previousField
222
+ }
223
+
224
+ private driveWave(timestamp: number): void {
225
+ const column = clamp(
226
+ Math.round(this.pointerX / FIELD_SPACING),
227
+ 1,
228
+ this.geometry.fieldColumns - 2
229
+ )
230
+ const row = clamp(Math.round(this.pointerY / FIELD_SPACING), 1, this.geometry.fieldRows - 2)
231
+ this.field[row * this.geometry.fieldColumns + column] =
232
+ WAVE_PARAMS.driveAmplitude * Math.sin(timestamp * WAVE_PARAMS.driveFrequency)
233
+ }
234
+
235
+ private sampleField(x: number, y: number): number {
236
+ const fieldX = clamp(x / FIELD_SPACING, 0, this.geometry.fieldColumns - 1)
237
+ const fieldY = clamp(y / FIELD_SPACING, 0, this.geometry.fieldRows - 1)
238
+ const left = Math.floor(fieldX)
239
+ const top = Math.floor(fieldY)
240
+ const right = Math.min(left + 1, this.geometry.fieldColumns - 1)
241
+ const bottom = Math.min(top + 1, this.geometry.fieldRows - 1)
242
+ const offsetX = fieldX - left
243
+ const offsetY = fieldY - top
244
+ const { fieldColumns } = this.geometry
245
+ const topLeft = this.field[top * fieldColumns + left]
246
+ const topRight = this.field[top * fieldColumns + right]
247
+ const bottomLeft = this.field[bottom * fieldColumns + left]
248
+ const bottomRight = this.field[bottom * fieldColumns + right]
249
+
250
+ return (
251
+ (topLeft * (1 - offsetX) + topRight * offsetX) * (1 - offsetY) +
252
+ (bottomLeft * (1 - offsetX) + bottomRight * offsetX) * offsetY
253
+ )
254
+ }
255
+
256
+ private renderWave(): number {
257
+ let peak = 0
258
+
259
+ this.geometry.pixels.forEach((pixel, index) => {
260
+ const element = this.rects[index]
261
+ if (!element) return
262
+
263
+ const sample = this.sampleField(pixel.centerX, pixel.centerY)
264
+ peak = Math.max(peak, Math.abs(sample))
265
+ const waveOpacity = clamp(0.5 + sample * WAVE_PARAMS.gain, 0, 1)
266
+ const opacity = pixel.targetOpacity * (1 - this.activation) + waveOpacity * this.activation
267
+ element.setAttribute('opacity', opacity.toFixed(3))
268
+ })
269
+
270
+ return peak
271
+ }
272
+
273
+ private renderTargets(): void {
274
+ this.geometry.pixels.forEach((pixel, index) => {
275
+ this.rects[index]?.setAttribute('opacity', String(pixel.targetOpacity))
276
+ })
277
+ }
278
+ }
279
+
280
+ type HomeLogoGlyphProps = {
281
+ geometry: GlyphGeometry
282
+ }
283
+
284
+ function HomeLogoGlyph({ geometry }: HomeLogoGlyphProps) {
285
+ const rects = useRef<(SVGRectElement | null)[]>([])
286
+ const svgRef = useRef<SVGSVGElement | null>(null)
287
+
288
+ useEffect(() => {
289
+ const svg = svgRef.current
290
+ if (!svg || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return
291
+
292
+ const engine = new GlyphWaveEngine(rects.current, svg, geometry)
293
+ engine.start()
294
+ window.addEventListener('pointermove', engine.handlePointerMove)
295
+
296
+ return () => {
297
+ engine.stop()
298
+ window.removeEventListener('pointermove', engine.handlePointerMove)
299
+ }
300
+ }, [geometry])
301
+
302
+ return (
303
+ <svg
304
+ ref={svgRef}
305
+ className="h-8 w-auto"
306
+ viewBox={`0 0 ${geometry.width} ${geometry.height}`}
307
+ fill="currentColor"
308
+ aria-hidden="true"
309
+ >
310
+ {geometry.pixels.map((pixel, index) => (
311
+ <rect
312
+ key={`${pixel.x}-${pixel.y}`}
313
+ ref={element => {
314
+ rects.current[index] = element
315
+ }}
316
+ x={pixel.x}
317
+ y={pixel.y}
318
+ width={CELL_SIZE}
319
+ height={CELL_SIZE}
320
+ rx={CELL_RADIUS}
321
+ opacity={pixel.targetOpacity}
322
+ />
323
+ ))}
324
+ </svg>
325
+ )
326
+ }
327
+
328
+ type HomeLogoProps = {
329
+ className?: string
330
+ }
331
+
332
+ export function HomeLogo({ className }: HomeLogoProps) {
333
+ return (
334
+ <div
335
+ role="img"
336
+ aria-label="moi"
337
+ className={cn('flex items-center gap-2 text-accent', className)}
338
+ >
339
+ {GLYPHS.map((geometry, index) => (
340
+ <HomeLogoGlyph key={index} geometry={geometry} />
341
+ ))}
342
+ </div>
343
+ )
344
+ }