moi-computer 0.12.1-next.2 → 0.12.1-next.4

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 (243) hide show
  1. package/bunfig.toml +1 -5
  2. package/client/api/app-config.ts +1 -2
  3. package/client/api/app-ui-keys.ts +3 -1
  4. package/client/api/http.ts +4 -1
  5. package/client/api/workspace-keys.ts +3 -3
  6. package/client/app/app-provider.tsx +22 -2
  7. package/client/app/app-router.tsx +6 -0
  8. package/client/app/routes/home-route.tsx +14 -0
  9. package/client/app/routes/onboarding-route.tsx +11 -0
  10. package/client/app/routes/settings-route.tsx +10 -0
  11. package/client/app/routes/workspace-route.tsx +21 -19
  12. package/client/app/shell/sidebar-layout.tsx +34 -53
  13. package/client/components/shared/screen-shell.tsx +23 -0
  14. package/client/components/shared/ultrafast-icon.tsx +61 -0
  15. package/client/components/shared/workspace-icon.tsx +2 -2
  16. package/client/features/account/account-menu.tsx +96 -0
  17. package/client/features/account/account-provider.tsx +142 -0
  18. package/client/features/account/account-test-utils.tsx +294 -0
  19. package/client/features/account/api.ts +142 -0
  20. package/client/features/account/identity.ts +23 -0
  21. package/client/features/app-settings/api.ts +33 -0
  22. package/client/features/app-settings/general-settings.tsx +39 -0
  23. package/client/features/app-settings/profile-settings.tsx +95 -0
  24. package/client/features/app-settings/settings-page.tsx +48 -0
  25. package/client/features/app-settings/settings-section.tsx +26 -0
  26. package/client/features/app-settings/users-settings.tsx +195 -0
  27. package/client/features/chat/applet-chat-intents.ts +4 -20
  28. package/client/features/chat/chat-send.ts +17 -13
  29. package/client/features/chat/composer/model-order.ts +8 -4
  30. package/client/features/chat/composer/model-picker.tsx +88 -34
  31. package/client/features/chat/composer/use-workspace-composer-state.tsx +11 -3
  32. package/client/features/chat/composer/use-workspace-skill-updates.ts +1 -1
  33. package/client/features/chat/connection/chat-frames.ts +3 -15
  34. package/client/features/chat/messages/chat-empty-state.tsx +1 -4
  35. package/client/features/chat/messages/fork-history.ts +5 -5
  36. package/client/features/chat/messages/turn-view.tsx +3 -12
  37. package/client/features/chat/messages/user-message-bubble.tsx +63 -0
  38. package/client/features/chat/sessions/api.ts +121 -80
  39. package/client/features/chat/sessions/browser-tab-state.ts +14 -12
  40. package/client/features/chat/sessions/chat-selector.tsx +5 -6
  41. package/client/features/chat/sessions/use-selected-session.ts +172 -257
  42. package/client/features/chat/use-chat.ts +14 -19
  43. package/client/features/collab/applet-api.ts +15 -14
  44. package/client/features/collab/components/cursors.tsx +61 -24
  45. package/client/features/collab/components/presence-avatars.tsx +25 -12
  46. package/client/features/collab/components/presence-frame.tsx +20 -24
  47. package/client/features/collab/components/presence-group.tsx +15 -7
  48. package/client/features/collab/components/user-avatar-group.tsx +21 -8
  49. package/client/features/collab/components/user-avatar.tsx +38 -7
  50. package/client/features/collab/components/user.tsx +31 -12
  51. package/client/features/collab/users.ts +0 -5
  52. package/client/features/collab/workspace-users-menu.tsx +4 -4
  53. package/client/features/demo/demo-dialog.tsx +11 -3
  54. package/client/features/dev/collab/collab-playground.tsx +7 -7
  55. package/client/features/dev/collab/local-user-settings.tsx +7 -53
  56. package/client/features/dev/dev-index-page.tsx +5 -0
  57. package/client/features/dev/dev-routes.tsx +2 -0
  58. package/client/features/dev/harness-debug-page.tsx +3 -3
  59. package/client/features/dev/onboarding-preview-page.tsx +76 -0
  60. package/client/features/dev/workspace-setup-mocks.ts +16 -14
  61. package/client/features/dev/workspace-setup-preview.tsx +11 -17
  62. package/client/features/harness/api.ts +45 -15
  63. package/client/features/harness/device-login-steps.tsx +9 -3
  64. package/client/features/harness/harness-login-panel.tsx +228 -0
  65. package/client/features/harness/harness-presentation.ts +15 -0
  66. package/client/features/harness/harness-selector.tsx +119 -0
  67. package/client/features/harness/use-harness-login.ts +77 -0
  68. package/client/features/home/home-page.tsx +7 -7
  69. package/client/features/onboarding/agent-setup-step.tsx +57 -0
  70. package/client/features/onboarding/api.ts +42 -0
  71. package/client/features/onboarding/onboarding-idea-disk.tsx +129 -0
  72. package/client/features/onboarding/onboarding-page.tsx +32 -0
  73. package/client/features/onboarding/onboarding-screen.tsx +20 -0
  74. package/client/features/onboarding/onboarding-status.tsx +24 -0
  75. package/client/features/onboarding/workspace-setup-step.tsx +239 -0
  76. package/client/features/overview/default/registry.tsx +2 -2
  77. package/client/features/overview/default/views-widget.tsx +6 -5
  78. package/client/features/overview/overview.tsx +9 -11
  79. package/client/features/overview/widget-canvas.tsx +1 -1
  80. package/client/features/overview/workspace-name.tsx +2 -2
  81. package/client/features/update/update-control.tsx +1 -1
  82. package/client/features/views/api.ts +69 -16
  83. package/client/features/views/pending-view-screen.tsx +30 -9
  84. package/client/features/views/use-view-actions.ts +19 -20
  85. package/client/features/views/view-presentation.ts +2 -2
  86. package/client/features/views/view-submission.ts +28 -41
  87. package/client/features/workspace/add/api.ts +3 -23
  88. package/client/features/workspace/add/create-workspace-dialog.tsx +11 -7
  89. package/client/features/workspace/add/import-workspace-dialog.tsx +3 -3
  90. package/client/features/workspace/add/workspace-agent-options.ts +11 -12
  91. package/client/features/workspace/add/workspace-agent-selector.tsx +3 -132
  92. package/client/features/workspace/api.ts +32 -36
  93. package/client/features/workspace/harness-transition.ts +88 -0
  94. package/client/features/{settings → workspace/settings}/api.ts +1 -34
  95. package/client/features/{settings → workspace/settings}/connectors-settings.tsx +3 -3
  96. package/client/features/{settings → workspace/settings}/environment-settings.tsx +3 -3
  97. package/client/features/{settings → workspace/settings}/general-settings.tsx +77 -3
  98. package/client/features/{settings → workspace/settings}/use-env-vars.ts +1 -1
  99. package/client/features/{settings → workspace/settings}/workspace-icon-picker.tsx +3 -3
  100. package/client/features/workspace/setup/workspace-login-state.tsx +37 -156
  101. package/client/features/workspace/setup/workspace-recovery-states.tsx +0 -12
  102. package/client/features/workspace/setup/workspace-setup.tsx +34 -14
  103. package/client/features/workspace/setup/workspace-welcome-state.tsx +2 -2
  104. package/client/features/workspace/use-workspace-navigation.ts +25 -9
  105. package/client/features/workspace/workspace-content.tsx +11 -8
  106. package/client/features/workspace/workspace-frame.tsx +2 -1
  107. package/client/features/workspace/workspace-layout-context.tsx +5 -2
  108. package/client/features/workspace/workspace-menu.tsx +12 -8
  109. package/client/features/workspace/workspace-pending-screen.tsx +10 -10
  110. package/client/features/workspace/workspace-presentation.tsx +5 -13
  111. package/client/features/workspace/workspace-state.ts +169 -0
  112. package/client/features/workspace/workspace-tabs.tsx +22 -2
  113. package/client/index.css +2 -0
  114. package/client/index.tsx +3 -3
  115. package/client/lib/flags.ts +1 -1
  116. package/client/lib/{app-icon-registry.ts → identity-icon-registry.ts} +10 -14
  117. package/client/lib/user-display-name.ts +6 -0
  118. package/client/main.tsx +4 -1
  119. package/client/runtime/workspace-events.ts +21 -4
  120. package/client/runtime/workspace-theme.ts +9 -0
  121. package/client/tailwind-config.ts +43 -0
  122. package/dist/chunk-0mjzg20x.js +2 -0
  123. package/dist/chunk-2y59vrxg.js +5 -0
  124. package/dist/chunk-58dyt9bk.js +2 -0
  125. package/dist/chunk-5aj040e5.css +1 -0
  126. package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
  127. package/dist/chunk-71fn6rmj.js +546 -0
  128. package/dist/chunk-7yg1m8hx.js +2 -0
  129. package/dist/chunk-825hys3h.js +1 -0
  130. package/dist/chunk-9bb8m9rx.js +2 -0
  131. package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
  132. package/dist/chunk-g0tcwqxc.js +1 -0
  133. package/dist/chunk-n0nab26d.js +1 -0
  134. package/dist/chunk-nf2wkvf9.js +14 -0
  135. package/dist/chunk-v88n1bay.js +74 -0
  136. package/dist/index.html +1 -1
  137. package/lib/harness-instructions.ts +1 -1
  138. package/lib/{app-icons.ts → identity-icons.ts} +6 -7
  139. package/lib/onboarding.ts +41 -0
  140. package/lib/speed-mode.ts +5 -0
  141. package/lib/types.ts +72 -63
  142. package/lib/view-build-directives.ts +1 -2
  143. package/lib/workspace-icon.ts +2 -2
  144. package/lib/workspace-layout.ts +1 -1
  145. package/lib/workspace-name.ts +15 -12
  146. package/package.json +9 -8
  147. package/server/README.md +27 -25
  148. package/server/api/harnesses.ts +31 -8
  149. package/server/api/index.ts +164 -131
  150. package/server/api/onboarding.ts +46 -0
  151. package/server/app-config.ts +23 -24
  152. package/server/app-settings.ts +6 -2
  153. package/server/applets/config.ts +5 -5
  154. package/server/applets/views.ts +19 -17
  155. package/server/cli/commands/init.ts +3 -3
  156. package/server/cli/commands/skill.ts +16 -17
  157. package/server/cli/commands/start.ts +8 -34
  158. package/server/cli/server.ts +18 -6
  159. package/server/collab/config.ts +1 -2
  160. package/server/collab/manager.ts +4 -1
  161. package/server/collab/skill/index.ts +1 -1
  162. package/server/control.ts +3 -3
  163. package/server/data-dir.ts +1 -1
  164. package/server/harness/README.md +24 -8
  165. package/server/harness/acp/session.ts +8 -4
  166. package/server/harness/auth.ts +14 -17
  167. package/server/harness/claude-code/NOTES.md +4 -3
  168. package/server/harness/claude-code/index.ts +2 -0
  169. package/server/harness/claude-code/models.ts +2 -20
  170. package/server/harness/claude-code/run-action.ts +123 -0
  171. package/server/harness/claude-code/session-title.ts +5 -7
  172. package/server/harness/claude-code/session.ts +24 -16
  173. package/server/harness/codex/NOTES.md +14 -9
  174. package/server/harness/codex/adapter.ts +14 -17
  175. package/server/harness/codex/index.ts +2 -0
  176. package/server/harness/codex/run-action.ts +93 -0
  177. package/server/harness/codex/session-title.ts +6 -8
  178. package/server/harness/codex/session.ts +11 -11
  179. package/server/harness/command.ts +45 -0
  180. package/server/harness/executable.ts +5 -0
  181. package/server/harness/fork.ts +6 -4
  182. package/server/harness/install.ts +49 -0
  183. package/server/harness/openclaw/session.ts +1 -2
  184. package/server/harness/run-action.ts +85 -0
  185. package/server/harness/session-title.ts +0 -46
  186. package/server/harness/types.ts +26 -2
  187. package/server/onboarding/brief.ts +29 -0
  188. package/server/onboarding/ideas.ts +48 -0
  189. package/server/onboarding/jobs.ts +291 -0
  190. package/server/onboarding/prompt.md +49 -0
  191. package/server/sessions/archive.ts +5 -14
  192. package/server/sessions/config.ts +17 -16
  193. package/server/sessions/lifecycle.ts +15 -13
  194. package/server/sessions/pending-views.ts +79 -108
  195. package/server/sessions/selected.ts +75 -161
  196. package/server/sessions/store.ts +40 -113
  197. package/server/sessions/view-sessions.ts +128 -111
  198. package/server/skills/locations.ts +82 -0
  199. package/server/skills/lock.ts +29 -0
  200. package/server/skills/template.ts +36 -25
  201. package/server/skills/update.ts +52 -5
  202. package/server/skills/version.ts +17 -22
  203. package/server/skills/workspace.ts +121 -0
  204. package/server/web.ts +23 -8
  205. package/server/workspace-state/file.ts +177 -0
  206. package/server/workspace-state/index.ts +162 -0
  207. package/server/workspace-state/legacy-migration.ts +79 -0
  208. package/server/workspace-state/lock.ts +42 -0
  209. package/server/workspace-state/types.ts +16 -0
  210. package/server/workspaces/change-harness.ts +88 -0
  211. package/server/workspaces/harness-transition.ts +29 -0
  212. package/server/workspaces/init.ts +29 -16
  213. package/server/workspaces/layout.ts +3 -0
  214. package/server/workspaces/registry.ts +58 -10
  215. package/{workspace/.claude/skills/moi-workspace → skill}/SKILL.md +7 -5
  216. package/{workspace/.claude/skills/moi-workspace → skill}/references/COLLAB.md +4 -8
  217. package/skill/references/DESIGN.md +148 -0
  218. package/{workspace/.claude/skills/moi-workspace → skill}/references/SCRATCHPAD.md +2 -2
  219. package/{workspace/.claude/skills/moi-workspace → skill}/references/UI-COMPONENTS.md +3 -0
  220. package/ui-components/badge.tsx +1 -1
  221. package/client/accept-hmr-dependencies.ts +0 -22
  222. package/client/features/workspace/setup/workspace-setup-panel.tsx +0 -18
  223. package/dist/chunk-00rh9df4.js +0 -2
  224. package/dist/chunk-4nh7y1hq.css +0 -1
  225. package/dist/chunk-am4agx6v.js +0 -2
  226. package/dist/chunk-d7cbm65e.js +0 -2
  227. package/dist/chunk-hbpdv7vd.js +0 -1
  228. package/dist/chunk-hmka9rt5.js +0 -2
  229. package/dist/chunk-hvh9f5h0.js +0 -14
  230. package/dist/chunk-mjjregkn.js +0 -10
  231. package/dist/chunk-pcnahct1.js +0 -5
  232. package/dist/chunk-rt30jbcm.js +0 -1
  233. package/dist/chunk-vt6zybej.js +0 -2
  234. package/dist/chunk-wbkwf6cc.js +0 -68
  235. package/dist/chunk-xjyfyz64.js +0 -1
  236. package/dist/chunk-y8nbwp21.js +0 -546
  237. package/dist/chunk-ysfdcew7.js +0 -1
  238. package/lib/experimental.ts +0 -14
  239. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +0 -157
  240. /package/client/features/{settings → workspace/settings}/icon-picker-options.ts +0 -0
  241. /package/client/features/{settings → workspace/settings}/settings-layout.tsx +0 -0
  242. /package/client/features/{settings → workspace/settings}/workspace-settings-dialog.tsx +0 -0
  243. /package/{workspace/.claude/skills/moi-workspace → skill}/references/INTENTS.md +0 -0
@@ -0,0 +1,228 @@
1
+ import { useEffect, useId, type ReactNode } from 'react'
2
+ import { IconArrowRight } from '@tabler/icons-react'
3
+ import type { HarnessLogin } from '@/lib/types'
4
+ import { cn } from '@/client/lib/cn'
5
+ import { Button, buttonVariants } from '@/client/components/ui/button'
6
+ import { Textarea } from '@/client/components/ui/textarea'
7
+ import { Spinner } from '@/client/components/ui/spinner'
8
+ import { harnessLabel, harnessIcon } from './harness-presentation'
9
+ import { DeviceLoginSteps } from './device-login-steps'
10
+ import { useHarnessLogin } from './use-harness-login'
11
+ import { useRetryHarnessStatus, type LoginHarness } from './api'
12
+
13
+ type HarnessLoginPanelProps = {
14
+ type: LoginHarness
15
+ onConnected: () => void
16
+ connectedContent?: ReactNode
17
+ }
18
+
19
+ export function HarnessLoginPanel({ type, onConnected, connectedContent }: HarnessLoginPanelProps) {
20
+ const {
21
+ auth,
22
+ needsInstall,
23
+ installing,
24
+ code,
25
+ setCode,
26
+ manualLogin,
27
+ setManualLogin,
28
+ pending,
29
+ starting,
30
+ waitingForBrowser,
31
+ connected,
32
+ action,
33
+ checkError,
34
+ failure
35
+ } = useHarnessLogin(type)
36
+ const retry = useRetryHarnessStatus()
37
+ const name = harnessLabel[type]
38
+ useEffect(() => {
39
+ if (connected) onConnected()
40
+ }, [connected, onConnected])
41
+ if (auth.isPending || (connected && !connectedContent)) {
42
+ return (
43
+ <div className="flex flex-1 items-center justify-center p-6">
44
+ <Spinner className="size-6 text-muted-foreground" stroke={1.5} />
45
+ </div>
46
+ )
47
+ }
48
+
49
+ function renderContent() {
50
+ if (checkError && !needsInstall && !installing) {
51
+ return (
52
+ <LoginCheckError
53
+ retrying={auth.isFetching || retry.isPending}
54
+ onRetry={() => retry.mutate()}
55
+ />
56
+ )
57
+ }
58
+ if (connected) return connectedContent
59
+ if (pending && !installing) {
60
+ return (
61
+ <PendingLoginState
62
+ name={name}
63
+ pending={pending}
64
+ manualLogin={manualLogin}
65
+ waitingForBrowser={waitingForBrowser}
66
+ onManualLogin={() => setManualLogin(true)}
67
+ code={code}
68
+ onCodeChange={setCode}
69
+ submitting={action.isPending}
70
+ onSubmit={() => action.mutate('submit')}
71
+ />
72
+ )
73
+ }
74
+ return (
75
+ <>
76
+ <p className="mt-2 text-center text-sm text-muted-foreground">
77
+ {needsInstall || installing
78
+ ? `${name} isn’t installed on your computer yet. Install it, then log in to get started.`
79
+ : 'Let’s log in and get your agent ready'}
80
+ </p>
81
+ <Button
82
+ className="mt-6 self-center"
83
+ disabled={installing || action.isPending || starting}
84
+ onClick={() => action.mutate(needsInstall ? 'install' : 'start')}
85
+ >
86
+ {installing ? 'Installing…' : needsInstall ? `Install ${name}` : 'Log in'}
87
+ {!needsInstall && !installing && <IconArrowRight stroke={1.75} data-icon="inline-end" />}
88
+ </Button>
89
+ </>
90
+ )
91
+ }
92
+
93
+ return (
94
+ <div className="mx-auto flex w-full max-w-5xl flex-1 flex-col items-center justify-center p-6 text-center">
95
+ <img src={harnessIcon[type]} alt="" className="mb-4 size-10" />
96
+ <h1 className="text-center text-xl font-medium">Set up {name}</h1>
97
+ <section
98
+ className={cn('flex w-full flex-col items-center', !pending?.userCode && 'max-w-xs')}
99
+ aria-label={name}
100
+ >
101
+ {renderContent()}
102
+ {failure && (
103
+ <p role="alert" className="mt-6 text-sm text-destructive">
104
+ {failure}
105
+ </p>
106
+ )}
107
+ </section>
108
+ </div>
109
+ )
110
+ }
111
+
112
+ type LoginCheckErrorProps = {
113
+ retrying: boolean
114
+ onRetry: () => void
115
+ }
116
+
117
+ function LoginCheckError({ retrying, onRetry }: LoginCheckErrorProps) {
118
+ return (
119
+ <div role="alert" className="mt-6 flex flex-col items-start gap-2">
120
+ <p>Couldn’t check whether you’re logged in</p>
121
+ <Button variant="secondary" disabled={retrying} onClick={onRetry}>
122
+ Try again
123
+ </Button>
124
+ </div>
125
+ )
126
+ }
127
+
128
+ type PendingLoginStateProps = {
129
+ name: string
130
+ pending: HarnessLogin
131
+ manualLogin: boolean
132
+ waitingForBrowser: boolean
133
+ onManualLogin: () => void
134
+ code: string
135
+ onCodeChange: (code: string) => void
136
+ submitting: boolean
137
+ onSubmit: () => void
138
+ }
139
+
140
+ function PendingLoginState({
141
+ name,
142
+ pending,
143
+ manualLogin,
144
+ waitingForBrowser,
145
+ onManualLogin,
146
+ code,
147
+ onCodeChange,
148
+ submitting,
149
+ onSubmit
150
+ }: PendingLoginStateProps) {
151
+ if (pending.userCode) {
152
+ return <DeviceLoginSteps code={pending.userCode} url={pending.url} className="mt-6" />
153
+ }
154
+
155
+ const showCodeForm = Boolean(pending.codeUrl && !waitingForBrowser)
156
+ let message = 'Log in in your browser, then come back to Moi'
157
+ if (showCodeForm) message = `Log in to ${name} to get your authorization code.`
158
+
159
+ let url = pending.url
160
+ if (manualLogin) url = pending.codeUrl ?? pending.url
161
+
162
+ return (
163
+ <>
164
+ <p role="status" className="mt-6 text-sm text-muted-foreground">
165
+ {message}
166
+ </p>
167
+ <a
168
+ className={cn(buttonVariants({ variant: 'secondary' }), 'mt-4')}
169
+ href={url}
170
+ target="_blank"
171
+ rel="noopener noreferrer"
172
+ >
173
+ Open {name}
174
+ </a>
175
+ {waitingForBrowser && pending.codeUrl && (
176
+ <Button variant="ghost" onClick={onManualLogin} className="mt-4">
177
+ Having trouble logging in?
178
+ </Button>
179
+ )}
180
+ {showCodeForm && (
181
+ <LoginCodeForm
182
+ code={code}
183
+ onCodeChange={onCodeChange}
184
+ submitting={submitting}
185
+ onSubmit={onSubmit}
186
+ />
187
+ )}
188
+ </>
189
+ )
190
+ }
191
+
192
+ type LoginCodeFormProps = {
193
+ code: string
194
+ onCodeChange: (code: string) => void
195
+ submitting: boolean
196
+ onSubmit: () => void
197
+ }
198
+
199
+ function LoginCodeForm({ code, onCodeChange, submitting, onSubmit }: LoginCodeFormProps) {
200
+ const inputId = useId()
201
+
202
+ return (
203
+ <form
204
+ className="mt-6 flex w-full flex-col gap-3"
205
+ onSubmit={event => {
206
+ event.preventDefault()
207
+ onSubmit()
208
+ }}
209
+ >
210
+ <label htmlFor={inputId} className="text-sm text-muted-foreground">
211
+ Paste the code here:
212
+ </label>
213
+ <Textarea
214
+ id={inputId}
215
+ aria-label="Authorization code"
216
+ rows={3}
217
+ className="field-sizing-fixed resize-none"
218
+ value={code}
219
+ onChange={event => onCodeChange(event.target.value)}
220
+ autoComplete="off"
221
+ spellCheck={false}
222
+ />
223
+ <Button type="submit" className="mt-3" disabled={!code.trim() || submitting}>
224
+ {submitting ? 'Connecting…' : 'Continue'}
225
+ </Button>
226
+ </form>
227
+ )
228
+ }
@@ -0,0 +1,15 @@
1
+ import type { WorkspaceType } from '@/lib/types'
2
+ export { workspaceProviderIcon as harnessIcon } from '@/client/components/shared/workspace-icon'
3
+ export const harnessLabel: Record<WorkspaceType, string> = {
4
+ 'claude-code': 'Claude',
5
+ openclaw: 'OpenClaw',
6
+ codex: 'ChatGPT',
7
+ hermes: 'Hermes'
8
+ }
9
+
10
+ export const harnessDescription: Record<WorkspaceType, string> = {
11
+ 'claude-code': 'Anthropic',
12
+ codex: 'OpenAI',
13
+ openclaw: 'Open-source',
14
+ hermes: 'Nous Research'
15
+ }
@@ -0,0 +1,119 @@
1
+ import { IconCircleCheckFilled } from '@tabler/icons-react'
2
+ import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
3
+ import { cn } from '@/client/lib/cn'
4
+ import type { WorkspaceType } from '@/lib/types'
5
+ import { harnessLabel, harnessIcon } from './harness-presentation'
6
+
7
+ export type HarnessOption = {
8
+ type: WorkspaceType
9
+ description: string
10
+ disabled: boolean
11
+ disabledReason?: string
12
+ disabledCommand?: string
13
+ }
14
+
15
+ type HarnessSelectorProps = {
16
+ mode?: 'select' | 'action'
17
+ cardClassName?: string
18
+ disabled: boolean
19
+ options: HarnessOption[]
20
+ selectedType?: WorkspaceType
21
+ onTypeChange: (type: WorkspaceType) => void
22
+ }
23
+
24
+ export function HarnessSelector({
25
+ mode = 'select',
26
+ cardClassName,
27
+ disabled,
28
+ options,
29
+ selectedType,
30
+ onTypeChange
31
+ }: HarnessSelectorProps) {
32
+ return (
33
+ <fieldset
34
+ disabled={disabled}
35
+ aria-label="Agent"
36
+ className="flex min-w-0 flex-wrap justify-center gap-2"
37
+ >
38
+ {options.map(option => (
39
+ <HarnessOptionButton
40
+ key={option.type}
41
+ option={option}
42
+ className={cardClassName}
43
+ selected={mode === 'select' ? selectedType === option.type : undefined}
44
+ onSelect={onTypeChange}
45
+ />
46
+ ))}
47
+ </fieldset>
48
+ )
49
+ }
50
+
51
+ type HarnessOptionButtonProps = {
52
+ className?: string
53
+ option: HarnessOption
54
+ selected?: boolean
55
+ onSelect: (type: WorkspaceType) => void
56
+ }
57
+
58
+ function HarnessOptionButton({ option, selected, onSelect, className }: HarnessOptionButtonProps) {
59
+ const showDisabledTooltip = Boolean(option.disabledReason)
60
+ const button = (
61
+ <button
62
+ type="button"
63
+ disabled={option.disabled && !showDisabledTooltip}
64
+ aria-disabled={option.disabled || undefined}
65
+ aria-pressed={selected}
66
+ onClick={event => {
67
+ if (option.disabled) {
68
+ event.preventDefault()
69
+ return
70
+ }
71
+ onSelect(option.type)
72
+ }}
73
+ className={cn(
74
+ 'relative flex h-32 min-w-32 flex-1 flex-col items-start justify-between gap-6 rounded-xl bg-card p-4 text-left ring-1 ring-border transition-opacity outline-none focus-visible:ring-3 focus-visible:ring-ring/50',
75
+ (selected === false || option.disabled) && 'opacity-70',
76
+ !selected && !option.disabled && 'cursor-pointer hover:opacity-100',
77
+ option.disabled && 'cursor-not-allowed',
78
+ className
79
+ )}
80
+ >
81
+ <span className="relative inline-flex">
82
+ <img src={harnessIcon[option.type]} alt="" className="size-8 shrink-0" />
83
+ {selected && (
84
+ <IconCircleCheckFilled
85
+ size={16}
86
+ stroke={1.75}
87
+ aria-hidden="true"
88
+ className="absolute -top-1.5 -right-1.5"
89
+ />
90
+ )}
91
+ </span>
92
+ <span className="flex min-w-0 flex-col gap-0.5">
93
+ <span className="text-sm font-medium text-foreground">{harnessLabel[option.type]}</span>
94
+ <span className="text-xs leading-4 text-muted-foreground">{option.description}</span>
95
+ </span>
96
+ </button>
97
+ )
98
+
99
+ if (!showDisabledTooltip) return button
100
+
101
+ return (
102
+ <Tooltip>
103
+ <TooltipTrigger render={button} />
104
+ <TooltipContent className="max-w-[calc(100vw-2rem)] leading-5 sm:max-w-96">
105
+ <span className="text-center">
106
+ {option.disabledReason}
107
+ {option.disabledCommand && (
108
+ <>
109
+ <br />
110
+ <code className="rounded-xs bg-accent px-1 py-0.5 font-mono wrap-anywhere">
111
+ {option.disabledCommand}
112
+ </code>
113
+ </>
114
+ )}
115
+ </span>
116
+ </TooltipContent>
117
+ </Tooltip>
118
+ )
119
+ }
@@ -0,0 +1,77 @@
1
+ import { useState } from 'react'
2
+ import { useMutation, useQueryClient } from '@tanstack/react-query'
3
+ import { useAppConfig } from '@/client/api/app-config'
4
+ import {
5
+ installHarness,
6
+ startHarnessLogin,
7
+ submitHarnessLoginCode,
8
+ useHarnessStatus,
9
+ type LoginHarness
10
+ } from './api'
11
+
12
+ export function useHarnessLogin(type: LoginHarness) {
13
+ const { environment, demo } = useAppConfig()
14
+ const auth = useHarnessStatus(type)
15
+ const queryClient = useQueryClient()
16
+ const [code, setCode] = useState('')
17
+ const [manualLogin, setManualLogin] = useState(false)
18
+ const login = auth.data?.login
19
+ const pending = login?.state === 'pending' ? login : undefined
20
+ const starting = login?.state === 'starting'
21
+ const waitingForBrowser = environment === 'local' && !manualLogin
22
+ const availability = auth.data?.availability
23
+ const action = useMutation({
24
+ mutationFn: async (kind: 'install' | 'start' | 'submit') => {
25
+ if (kind === 'install') {
26
+ await installHarness(type)
27
+ const refreshed = await auth.refetch({ throwOnError: true })
28
+ if (refreshed.data?.availability.status === 'available') return
29
+ }
30
+ if (kind === 'start' || kind === 'install') {
31
+ setManualLogin(false)
32
+ setCode('')
33
+ await startHarnessLogin(type)
34
+ }
35
+ if (kind === 'submit' && pending) {
36
+ await submitHarnessLoginCode(type, pending.id, code)
37
+ setCode('')
38
+ }
39
+ },
40
+ onSettled: () => queryClient.invalidateQueries({ queryKey: ['harness-status'] })
41
+ })
42
+ const needsInstall =
43
+ environment === 'local' &&
44
+ !demo &&
45
+ availability?.status === 'unavailable' &&
46
+ availability.code === 'not-installed'
47
+ const checkError = auth.isError || availability?.status === 'unavailable'
48
+ const failure = action.error?.message ?? (login?.state === 'failed' ? login.reason : undefined)
49
+ // Keep the install button busy until the next screen's status has arrived.
50
+ const installing =
51
+ action.variables === 'install' &&
52
+ (action.isPending ||
53
+ (action.isSuccess &&
54
+ !pending &&
55
+ availability?.status !== 'available' &&
56
+ !checkError &&
57
+ !failure))
58
+ const connected =
59
+ !needsInstall && !installing && !starting && !pending && availability?.status === 'available'
60
+
61
+ return {
62
+ auth,
63
+ needsInstall,
64
+ installing,
65
+ code,
66
+ setCode,
67
+ manualLogin,
68
+ setManualLogin,
69
+ pending,
70
+ starting,
71
+ waitingForBrowser,
72
+ connected,
73
+ action,
74
+ checkError,
75
+ failure
76
+ }
77
+ }
@@ -88,7 +88,7 @@ export function HomePage() {
88
88
  {count > 0 ? (
89
89
  <section className="mb-12">
90
90
  <div className="mb-4 flex items-center justify-between gap-2">
91
- <h1 className="text-sm font-medium text-foreground">My workspaces</h1>
91
+ <h1 className="text-sm font-medium text-foreground">Workspaces</h1>
92
92
  <CreateWorkspaceDialog
93
93
  trigger={
94
94
  <Button variant="outline" size="sm">
@@ -107,15 +107,15 @@ export function HomePage() {
107
107
  </section>
108
108
  ) : (
109
109
  <div className="mb-10 flex flex-col items-center gap-4 px-8 pt-8 pb-16 text-center">
110
- <IconEggCracked size={32} stroke={1.5} className="text-muted-foreground" />
110
+ <IconEggCracked size={56} stroke={0.75} className="text-muted-foreground" />
111
111
  <div className="flex flex-col gap-1.5">
112
- <h2 className="font-medium">Let’s start with creating your first workspace</h2>
112
+ <h2 className="font-medium">Create your first workspace</h2>
113
113
  <p className="mx-auto max-w-sm text-sm text-muted-foreground">
114
- Workspace is a place for all the chats, widgets, and views that share the same
115
- context. Create a new one or import an existing folder you&rsquo;ve worked in before.
114
+ Workspace is a place for all views and widgets that share the same context. Create a
115
+ new one or import an existing folder you&rsquo;ve worked in before.
116
116
  </p>
117
117
  </div>
118
- <CreateWorkspaceDialog trigger={<Button>Create workspace</Button>} />
118
+ <CreateWorkspaceDialog trigger={<Button>New workspace</Button>} />
119
119
  </div>
120
120
  )}
121
121
 
@@ -133,7 +133,7 @@ export function HomePage() {
133
133
  'text-muted-foreground group-data-open:text-foreground hover:text-foreground'
134
134
  )}
135
135
  >
136
- <span className="text-sm font-medium">Import from this computer</span>
136
+ <span className="text-sm font-medium">Import other workspaces</span>
137
137
  <IconChevronRight
138
138
  size={16}
139
139
  stroke={2}
@@ -0,0 +1,57 @@
1
+ import { useAppConfig } from '@/client/api/app-config'
2
+ import { useCallback, useState } from 'react'
3
+ import { HarnessSelector } from '@/client/features/harness/harness-selector'
4
+ import { HarnessLoginPanel } from '@/client/features/harness/harness-login-panel'
5
+ import { harnessDescription } from '@/client/features/harness/harness-presentation'
6
+ import { useHarnessStatuses, useRetryHarnessStatus } from '@/client/features/harness/api'
7
+ import type { OnboardingHarness } from '@/lib/onboarding'
8
+ import { OnboardingStatus } from './onboarding-status'
9
+ import { OnboardingScreen } from './onboarding-screen'
10
+
11
+ type AgentSetupStepProps = { onComplete: (harness: OnboardingHarness) => void }
12
+ export function AgentSetupStep({ onComplete }: AgentSetupStepProps) {
13
+ const [harness, setHarness] = useState<OnboardingHarness>()
14
+ const onConnected = useCallback(() => {
15
+ if (harness) onComplete(harness)
16
+ }, [harness, onComplete])
17
+ if (!harness) return <ChooseAgent onSelect={setHarness} />
18
+ return <HarnessLoginPanel type={harness} onConnected={onConnected} />
19
+ }
20
+
21
+ type ChooseAgentProps = { onSelect: (harness: OnboardingHarness) => void }
22
+ function ChooseAgent({ onSelect }: ChooseAgentProps) {
23
+ const { environment, demo } = useAppConfig()
24
+ const canInstall = environment === 'local' && !demo
25
+ const installed = useHarnessStatuses()
26
+ const retry = useRetryHarnessStatus()
27
+ if (installed.isPending || installed.error)
28
+ return <OnboardingStatus error={installed.error ?? undefined} onRetry={() => retry.mutate()} />
29
+ const options = (['claude-code', 'codex'] as const).map(type => ({
30
+ type,
31
+ description: harnessDescription[type],
32
+ disabled: !canInstall && installed.data[type].availability.status === 'unavailable',
33
+ disabledReason:
34
+ canInstall || installed.data[type].availability.status !== 'unavailable'
35
+ ? undefined
36
+ : 'This agent is not installed on your computer'
37
+ }))
38
+ return (
39
+ <OnboardingScreen className="max-w-sm">
40
+ <div className="flex flex-col items-center gap-2 text-center">
41
+ <h1 className="text-xl font-medium">Choose your agent</h1>
42
+ <p className="max-w-60 text-sm text-muted-foreground">
43
+ Connect an existing subscription to build and personalize Moi
44
+ </p>
45
+ </div>
46
+ <HarnessSelector
47
+ options={options}
48
+ mode="action"
49
+ cardClassName="h-36"
50
+ disabled={false}
51
+ onTypeChange={type => {
52
+ if (type === 'claude-code' || type === 'codex') onSelect(type)
53
+ }}
54
+ />
55
+ </OnboardingScreen>
56
+ )
57
+ }
@@ -0,0 +1,42 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+ import { useAppConfig } from '@/client/api/app-config'
3
+ import { jsonRequest, requestJson } from '@/client/api/http'
4
+ import { useAppSettings } from '@/client/features/app-settings/api'
5
+ import type { IdeaDiscovery, OnboardingJobResult } from '@/lib/onboarding'
6
+
7
+ export function useOnboardingSettings() {
8
+ const config = useAppConfig()
9
+ const enabled = !config.demo
10
+ const settings = useAppSettings()
11
+ return {
12
+ ...settings,
13
+ enabled,
14
+ loading: enabled && settings.isPending,
15
+ error: enabled ? settings.error : undefined,
16
+ retry: () => void settings.refetch()
17
+ }
18
+ }
19
+
20
+ export function cancelDiscovery(runId: string) {
21
+ return requestJson('/api/onboarding/cancel', jsonRequest('POST', { runId }))
22
+ }
23
+
24
+ type BuildRequest = IdeaDiscovery & { ideaId: string; operationId: string }
25
+ export function useOnboardingJob(
26
+ action: 'discover' | 'create',
27
+ request?: IdeaDiscovery | BuildRequest,
28
+ retry = false
29
+ ) {
30
+ return useQuery({
31
+ queryKey: ['onboarding-job', action, request, retry],
32
+ queryFn: ({ signal }) =>
33
+ requestJson<OnboardingJobResult>(`/api/onboarding/${action}`, {
34
+ ...jsonRequest('POST', { ...request, retry }),
35
+ signal
36
+ }),
37
+ enabled: !!request,
38
+ retry: false,
39
+ refetchOnWindowFocus: false,
40
+ refetchInterval: query => (query.state.data?.status === 'running' ? 1500 : false)
41
+ })
42
+ }