moi-computer 0.12.1-next.3 → 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.
- package/bunfig.toml +1 -5
- package/client/api/app-config.ts +1 -2
- package/client/api/app-ui-keys.ts +3 -1
- package/client/api/http.ts +4 -1
- package/client/api/workspace-keys.ts +3 -3
- package/client/app/app-provider.tsx +22 -2
- package/client/app/app-router.tsx +4 -0
- package/client/app/routes/home-route.tsx +14 -0
- package/client/app/routes/onboarding-route.tsx +11 -0
- package/client/app/routes/settings-route.tsx +1 -1
- package/client/app/routes/workspace-route.tsx +21 -19
- package/client/components/shared/screen-shell.tsx +23 -0
- package/client/components/shared/ultrafast-icon.tsx +61 -0
- package/client/components/shared/workspace-icon.tsx +2 -2
- package/client/features/account/account-test-utils.tsx +4 -3
- package/client/features/app-settings/api.ts +33 -0
- package/client/features/app-settings/general-settings.tsx +39 -0
- package/client/features/{settings → app-settings}/settings-page.tsx +5 -1
- package/client/features/chat/applet-chat-intents.ts +4 -20
- package/client/features/chat/chat-send.ts +17 -13
- package/client/features/chat/composer/model-order.ts +8 -4
- package/client/features/chat/composer/model-picker.tsx +88 -34
- package/client/features/chat/composer/use-workspace-composer-state.tsx +11 -3
- package/client/features/chat/composer/use-workspace-skill-updates.ts +1 -1
- package/client/features/chat/connection/chat-frames.ts +3 -15
- package/client/features/chat/messages/chat-empty-state.tsx +1 -4
- package/client/features/chat/messages/fork-history.ts +5 -5
- package/client/features/chat/messages/turn-view.tsx +3 -12
- package/client/features/chat/messages/user-message-bubble.tsx +63 -0
- package/client/features/chat/sessions/api.ts +121 -80
- package/client/features/chat/sessions/browser-tab-state.ts +14 -12
- package/client/features/chat/sessions/chat-selector.tsx +5 -6
- package/client/features/chat/sessions/use-selected-session.ts +172 -257
- package/client/features/chat/use-chat.ts +14 -19
- package/client/features/collab/workspace-users-menu.tsx +1 -1
- package/client/features/demo/demo-dialog.tsx +11 -3
- package/client/features/dev/dev-index-page.tsx +5 -0
- package/client/features/dev/dev-routes.tsx +2 -0
- package/client/features/dev/harness-debug-page.tsx +3 -3
- package/client/features/dev/onboarding-preview-page.tsx +76 -0
- package/client/features/dev/workspace-setup-mocks.ts +16 -14
- package/client/features/dev/workspace-setup-preview.tsx +11 -17
- package/client/features/harness/api.ts +45 -15
- package/client/features/harness/device-login-steps.tsx +9 -3
- package/client/features/harness/harness-login-panel.tsx +228 -0
- package/client/features/harness/harness-presentation.ts +15 -0
- package/client/features/harness/harness-selector.tsx +119 -0
- package/client/features/harness/use-harness-login.ts +77 -0
- package/client/features/home/home-page.tsx +7 -7
- package/client/features/onboarding/agent-setup-step.tsx +57 -0
- package/client/features/onboarding/api.ts +42 -0
- package/client/features/onboarding/onboarding-idea-disk.tsx +129 -0
- package/client/features/onboarding/onboarding-page.tsx +32 -0
- package/client/features/onboarding/onboarding-screen.tsx +20 -0
- package/client/features/onboarding/onboarding-status.tsx +24 -0
- package/client/features/onboarding/workspace-setup-step.tsx +239 -0
- package/client/features/overview/default/registry.tsx +2 -2
- package/client/features/overview/default/views-widget.tsx +6 -5
- package/client/features/overview/overview.tsx +9 -11
- package/client/features/overview/widget-canvas.tsx +1 -1
- package/client/features/overview/workspace-name.tsx +2 -2
- package/client/features/views/api.ts +69 -16
- package/client/features/views/pending-view-screen.tsx +30 -9
- package/client/features/views/use-view-actions.ts +19 -20
- package/client/features/views/view-presentation.ts +2 -2
- package/client/features/views/view-submission.ts +28 -41
- package/client/features/workspace/add/api.ts +3 -23
- package/client/features/workspace/add/create-workspace-dialog.tsx +6 -5
- package/client/features/workspace/add/import-workspace-dialog.tsx +3 -3
- package/client/features/workspace/add/workspace-agent-options.ts +11 -12
- package/client/features/workspace/add/workspace-agent-selector.tsx +3 -132
- package/client/features/workspace/api.ts +32 -36
- package/client/features/workspace/harness-transition.ts +88 -0
- package/client/features/{settings → workspace/settings}/api.ts +1 -34
- package/client/features/{settings → workspace/settings}/general-settings.tsx +76 -2
- package/client/features/{settings → workspace/settings}/use-env-vars.ts +1 -1
- package/client/features/{settings → workspace/settings}/workspace-icon-picker.tsx +3 -3
- package/client/features/workspace/setup/workspace-login-state.tsx +37 -156
- package/client/features/workspace/setup/workspace-recovery-states.tsx +0 -12
- package/client/features/workspace/setup/workspace-setup.tsx +34 -14
- package/client/features/workspace/setup/workspace-welcome-state.tsx +2 -2
- package/client/features/workspace/use-workspace-navigation.ts +25 -9
- package/client/features/workspace/workspace-content.tsx +11 -8
- package/client/features/workspace/workspace-frame.tsx +2 -1
- package/client/features/workspace/workspace-layout-context.tsx +5 -2
- package/client/features/workspace/workspace-menu.tsx +12 -8
- package/client/features/workspace/workspace-pending-screen.tsx +10 -10
- package/client/features/workspace/workspace-presentation.tsx +5 -13
- package/client/features/workspace/workspace-state.ts +169 -0
- package/client/features/workspace/workspace-tabs.tsx +22 -2
- package/client/index.css +2 -0
- package/client/index.tsx +3 -3
- package/client/lib/flags.ts +1 -1
- package/client/lib/{app-icon-registry.ts → identity-icon-registry.ts} +10 -14
- package/client/runtime/workspace-events.ts +21 -4
- package/client/runtime/workspace-theme.ts +9 -0
- package/client/tailwind-config.ts +43 -0
- package/dist/chunk-0mjzg20x.js +2 -0
- package/dist/chunk-2y59vrxg.js +5 -0
- package/dist/chunk-58dyt9bk.js +2 -0
- package/dist/chunk-5aj040e5.css +1 -0
- package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
- package/dist/chunk-71fn6rmj.js +546 -0
- package/dist/chunk-7yg1m8hx.js +2 -0
- package/dist/chunk-825hys3h.js +1 -0
- package/dist/chunk-9bb8m9rx.js +2 -0
- package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
- package/dist/chunk-g0tcwqxc.js +1 -0
- package/dist/chunk-n0nab26d.js +1 -0
- package/dist/chunk-nf2wkvf9.js +14 -0
- package/dist/chunk-v88n1bay.js +74 -0
- package/dist/index.html +1 -1
- package/lib/harness-instructions.ts +1 -1
- package/lib/{app-icons.ts → identity-icons.ts} +6 -7
- package/lib/onboarding.ts +41 -0
- package/lib/speed-mode.ts +5 -0
- package/lib/types.ts +71 -62
- package/lib/view-build-directives.ts +1 -2
- package/lib/workspace-icon.ts +2 -2
- package/lib/workspace-layout.ts +1 -1
- package/lib/workspace-name.ts +15 -12
- package/package.json +9 -8
- package/server/README.md +27 -25
- package/server/api/harnesses.ts +31 -8
- package/server/api/index.ts +163 -126
- package/server/api/onboarding.ts +46 -0
- package/server/app-config.ts +16 -24
- package/server/app-settings.ts +6 -2
- package/server/applets/config.ts +5 -5
- package/server/applets/views.ts +19 -17
- package/server/cli/commands/init.ts +3 -3
- package/server/cli/commands/skill.ts +16 -17
- package/server/cli/commands/start.ts +8 -34
- package/server/cli/server.ts +18 -6
- package/server/collab/config.ts +1 -2
- package/server/collab/manager.ts +4 -1
- package/server/collab/skill/index.ts +1 -1
- package/server/control.ts +3 -3
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +24 -8
- package/server/harness/acp/session.ts +8 -4
- package/server/harness/auth.ts +14 -17
- package/server/harness/claude-code/NOTES.md +4 -3
- package/server/harness/claude-code/index.ts +2 -0
- package/server/harness/claude-code/models.ts +2 -20
- package/server/harness/claude-code/run-action.ts +123 -0
- package/server/harness/claude-code/session-title.ts +5 -7
- package/server/harness/claude-code/session.ts +24 -16
- package/server/harness/codex/NOTES.md +14 -9
- package/server/harness/codex/adapter.ts +14 -17
- package/server/harness/codex/index.ts +2 -0
- package/server/harness/codex/run-action.ts +93 -0
- package/server/harness/codex/session-title.ts +6 -8
- package/server/harness/codex/session.ts +11 -11
- package/server/harness/command.ts +45 -0
- package/server/harness/executable.ts +5 -0
- package/server/harness/fork.ts +6 -4
- package/server/harness/install.ts +49 -0
- package/server/harness/openclaw/session.ts +1 -2
- package/server/harness/run-action.ts +85 -0
- package/server/harness/session-title.ts +0 -46
- package/server/harness/types.ts +26 -2
- package/server/onboarding/brief.ts +29 -0
- package/server/onboarding/ideas.ts +48 -0
- package/server/onboarding/jobs.ts +291 -0
- package/server/onboarding/prompt.md +49 -0
- package/server/sessions/archive.ts +5 -14
- package/server/sessions/config.ts +17 -16
- package/server/sessions/lifecycle.ts +15 -13
- package/server/sessions/pending-views.ts +79 -108
- package/server/sessions/selected.ts +75 -161
- package/server/sessions/store.ts +40 -113
- package/server/sessions/view-sessions.ts +128 -111
- package/server/skills/locations.ts +82 -0
- package/server/skills/lock.ts +29 -0
- package/server/skills/template.ts +36 -25
- package/server/skills/update.ts +52 -5
- package/server/skills/version.ts +17 -22
- package/server/skills/workspace.ts +121 -0
- package/server/web.ts +22 -8
- package/server/workspace-state/file.ts +177 -0
- package/server/workspace-state/index.ts +162 -0
- package/server/workspace-state/legacy-migration.ts +79 -0
- package/server/workspace-state/lock.ts +42 -0
- package/server/workspace-state/types.ts +16 -0
- package/server/workspaces/change-harness.ts +88 -0
- package/server/workspaces/harness-transition.ts +29 -0
- package/server/workspaces/init.ts +29 -6
- package/server/workspaces/layout.ts +3 -0
- package/server/workspaces/registry.ts +27 -1
- package/{workspace/.claude/skills/moi-workspace → skill}/SKILL.md +7 -5
- package/{workspace/.claude/skills/moi-workspace → skill}/references/COLLAB.md +4 -8
- package/skill/references/DESIGN.md +148 -0
- package/{workspace/.claude/skills/moi-workspace → skill}/references/SCRATCHPAD.md +2 -2
- package/{workspace/.claude/skills/moi-workspace → skill}/references/UI-COMPONENTS.md +3 -0
- package/ui-components/badge.tsx +1 -1
- package/client/accept-hmr-dependencies.ts +0 -22
- package/client/features/workspace/setup/workspace-setup-panel.tsx +0 -18
- package/dist/chunk-20ynagd4.js +0 -2
- package/dist/chunk-42tde9a6.js +0 -1
- package/dist/chunk-9w543s0r.js +0 -2
- package/dist/chunk-a5372n61.js +0 -546
- package/dist/chunk-aja9y1vn.js +0 -68
- package/dist/chunk-fvcvrh3d.css +0 -1
- package/dist/chunk-gtfjw3nx.js +0 -1
- package/dist/chunk-j39y2aky.js +0 -14
- package/dist/chunk-pcnahct1.js +0 -5
- package/dist/chunk-pja30km3.js +0 -1
- package/dist/chunk-rm894bc2.js +0 -2
- package/dist/chunk-tevvtfbk.js +0 -10
- package/dist/chunk-tgt9zd0r.js +0 -2
- package/dist/chunk-tv5k5z00.js +0 -1
- package/dist/chunk-zq2ae5dx.js +0 -2
- package/lib/experimental.ts +0 -14
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +0 -157
- /package/client/features/{settings → app-settings}/profile-settings.tsx +0 -0
- /package/client/features/{settings → app-settings}/settings-section.tsx +0 -0
- /package/client/features/{settings → app-settings}/users-settings.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/connectors-settings.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/environment-settings.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/icon-picker-options.ts +0 -0
- /package/client/features/{settings → workspace/settings}/settings-layout.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/workspace-settings-dialog.tsx +0 -0
- /package/{workspace/.claude/skills/moi-workspace → skill}/references/INTENTS.md +0 -0
|
@@ -7,6 +7,11 @@ type DevRouteEntry = {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const DEV_ROUTES: DevRouteEntry[] = [
|
|
10
|
+
{
|
|
11
|
+
path: '/dev/onboarding',
|
|
12
|
+
title: 'Onboarding ideas',
|
|
13
|
+
description: 'Polish the real idea cards with fixed mock data and inactive build actions.'
|
|
14
|
+
},
|
|
10
15
|
{
|
|
11
16
|
path: '/dev/workspace-setup',
|
|
12
17
|
title: 'Workspace setup',
|
|
@@ -9,6 +9,7 @@ import { HarnessDebugPage } from './harness-debug-page'
|
|
|
9
9
|
import { TextureLabPage } from './texture-lab-page'
|
|
10
10
|
import { ToolCallsPage } from './tool-calls-page'
|
|
11
11
|
import { UiComponentsPage } from './ui-components/ui-components-page'
|
|
12
|
+
import { OnboardingPreviewPage } from './onboarding-preview-page'
|
|
12
13
|
|
|
13
14
|
// All /dev/* routes live with their pages here and load only in development;
|
|
14
15
|
// see the dynamic import in AppRouter. /dev itself is the index; list new
|
|
@@ -20,6 +21,7 @@ const CollabPage = lazy(() =>
|
|
|
20
21
|
export default function DevRoutes() {
|
|
21
22
|
return (
|
|
22
23
|
<Switch>
|
|
24
|
+
<Route path="/dev/onboarding" component={OnboardingPreviewPage} />
|
|
23
25
|
<Route path="/dev/collab-kit">
|
|
24
26
|
<Redirect to="/dev/collab" />
|
|
25
27
|
</Route>
|
|
@@ -7,7 +7,7 @@ import { Button } from '@/client/components/ui/button'
|
|
|
7
7
|
import { cn } from '@/client/lib/cn'
|
|
8
8
|
import { useLatestRef } from '@/client/lib/use-latest-ref'
|
|
9
9
|
import { wsUrl } from '@/client/lib/ws-url'
|
|
10
|
-
import type { Model,
|
|
10
|
+
import type { Model, WorkspaceHarness, WorkspaceEntry } from '@/lib/types'
|
|
11
11
|
|
|
12
12
|
// Scratch route for driving any harness end to end: pick a workspace, fire
|
|
13
13
|
// canned scenarios (or your own prompt), and watch three synchronized logs —
|
|
@@ -236,9 +236,9 @@ export function HarnessDebugPage() {
|
|
|
236
236
|
// Model list for the selected workspace.
|
|
237
237
|
useEffect(() => {
|
|
238
238
|
if (!workspaceId) return
|
|
239
|
-
fetch(`/api/workspaces/${workspaceId}/
|
|
239
|
+
fetch(`/api/workspaces/${workspaceId}/harness`)
|
|
240
240
|
.then(r => r.json())
|
|
241
|
-
.then((m:
|
|
241
|
+
.then((m: WorkspaceHarness) => setModels(m.models))
|
|
242
242
|
.catch(() => setModels([]))
|
|
243
243
|
}, [workspaceId])
|
|
244
244
|
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { ScreenShell } from '@/client/components/shared/screen-shell'
|
|
3
|
+
import { Button } from '@/client/components/ui/button'
|
|
4
|
+
import { IdeaOptions } from '@/client/features/onboarding/workspace-setup-step'
|
|
5
|
+
import type { OnboardingIdea, OnboardingViewPlan } from '@/lib/onboarding'
|
|
6
|
+
|
|
7
|
+
// Fixed preview data. These actions never call discovery or create a workspace.
|
|
8
|
+
function view(name: string, icon: OnboardingViewPlan['icon']): OnboardingViewPlan {
|
|
9
|
+
return { name, icon, description: name, features: [name] }
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ideas: OnboardingIdea[] = [
|
|
13
|
+
{
|
|
14
|
+
id: 'review-desk',
|
|
15
|
+
name: 'Moi review desk',
|
|
16
|
+
icon: 'palette',
|
|
17
|
+
theme: { font: 'geometric', color: 'mint' },
|
|
18
|
+
description:
|
|
19
|
+
'Keep Moi’s product reviews, visual checks, and design decisions together. A focused place to turn ongoing development into clear next steps.',
|
|
20
|
+
views: [
|
|
21
|
+
view('Review queue', 'code'),
|
|
22
|
+
view('Visual checks', 'photo'),
|
|
23
|
+
view('Design decisions', 'bulb')
|
|
24
|
+
],
|
|
25
|
+
widgets: []
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'tool-notebook',
|
|
29
|
+
name: 'Agent tool notebook',
|
|
30
|
+
icon: 'flask',
|
|
31
|
+
theme: { font: 'mono', color: 'lavender' },
|
|
32
|
+
description:
|
|
33
|
+
'Keep tool invites, hands-on trials, and useful product ideas in one place. Fits your ongoing exploration of agent software and personal computing.',
|
|
34
|
+
views: [
|
|
35
|
+
view('Access tracker', 'key'),
|
|
36
|
+
view('Trial bench', 'flask'),
|
|
37
|
+
view('Useful patterns', 'brain')
|
|
38
|
+
],
|
|
39
|
+
widgets: []
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'berlin-plans',
|
|
43
|
+
name: 'Berlin plans',
|
|
44
|
+
icon: 'compass',
|
|
45
|
+
theme: { font: 'rounded', color: 'sand' },
|
|
46
|
+
description:
|
|
47
|
+
'Turn Berlin guides and cinema emails into a short list of places and plans. Keep booked outings handy and save interesting finds for later.',
|
|
48
|
+
views: [
|
|
49
|
+
view('Saved places', 'map'),
|
|
50
|
+
view('Outing planner', 'calendar'),
|
|
51
|
+
view('Tickets', 'file')
|
|
52
|
+
],
|
|
53
|
+
widgets: []
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
export function OnboardingPreviewPage() {
|
|
58
|
+
const [selectedIdeaId, setSelectedIdeaId] = useState<string>()
|
|
59
|
+
return (
|
|
60
|
+
<main className="flex h-dvh flex-col overflow-hidden">
|
|
61
|
+
<ScreenShell>
|
|
62
|
+
<IdeaOptions
|
|
63
|
+
ideas={ideas}
|
|
64
|
+
selectedIdeaId={selectedIdeaId}
|
|
65
|
+
onSelect={setSelectedIdeaId}
|
|
66
|
+
feedback={null}
|
|
67
|
+
footer={
|
|
68
|
+
<Button size="lg" variant="ghost" onClick={() => setSelectedIdeaId(undefined)}>
|
|
69
|
+
{selectedIdeaId ? 'Reset preview' : 'Skip onboarding'}
|
|
70
|
+
</Button>
|
|
71
|
+
}
|
|
72
|
+
/>
|
|
73
|
+
</ScreenShell>
|
|
74
|
+
</main>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
@@ -2,20 +2,14 @@ import type {
|
|
|
2
2
|
AppEnvironment,
|
|
3
3
|
HarnessAvailability,
|
|
4
4
|
HarnessLoginState,
|
|
5
|
-
|
|
5
|
+
WorkspaceHarness
|
|
6
6
|
} from '@/lib/types'
|
|
7
7
|
import type { LoginHarness } from '@/client/features/harness/api'
|
|
8
8
|
|
|
9
9
|
export const PREVIEW_WORKSPACE_ID = 'setup-preview'
|
|
10
10
|
export const MOCK_CODE_SIGN_IN_URL = 'https://example.invalid/moi-code-sign-in'
|
|
11
11
|
export const MOCK_SIGN_IN_URL = 'https://example.invalid/moi-sign-in'
|
|
12
|
-
export const SETUP_SCENARIOS = [
|
|
13
|
-
'welcome',
|
|
14
|
-
'login',
|
|
15
|
-
'missing-agent',
|
|
16
|
-
'missing-folder',
|
|
17
|
-
'loading'
|
|
18
|
-
] as const
|
|
12
|
+
export const SETUP_SCENARIOS = ['welcome', 'install', 'login', 'missing-folder', 'loading'] as const
|
|
19
13
|
export type SetupScenario = (typeof SETUP_SCENARIOS)[number]
|
|
20
14
|
|
|
21
15
|
export function createSetupMocks(
|
|
@@ -24,7 +18,7 @@ export function createSetupMocks(
|
|
|
24
18
|
scenario: SetupScenario
|
|
25
19
|
) {
|
|
26
20
|
let availability: HarnessAvailability =
|
|
27
|
-
scenario === '
|
|
21
|
+
scenario === 'install'
|
|
28
22
|
? {
|
|
29
23
|
status: 'unavailable',
|
|
30
24
|
code: 'not-installed',
|
|
@@ -52,24 +46,32 @@ export function createSetupMocks(
|
|
|
52
46
|
return Response.json({
|
|
53
47
|
environment,
|
|
54
48
|
demo: false,
|
|
55
|
-
|
|
49
|
+
collab: false,
|
|
56
50
|
demoInstallUrl: ''
|
|
57
51
|
})
|
|
58
52
|
}
|
|
59
53
|
if (path === `/api/workspaces/${PREVIEW_WORKSPACE_ID}` && method === 'DELETE')
|
|
60
54
|
return new Response(null, { status: 204 })
|
|
61
|
-
if (path === `/api/workspaces/${PREVIEW_WORKSPACE_ID}/
|
|
55
|
+
if (path === `/api/workspaces/${PREVIEW_WORKSPACE_ID}/harness` && method === 'GET') {
|
|
62
56
|
return Response.json({
|
|
63
57
|
provider: harness,
|
|
64
58
|
availability,
|
|
65
59
|
models: [],
|
|
66
60
|
supportsStreaming: true,
|
|
67
61
|
supportsArchiving: true,
|
|
68
|
-
|
|
69
|
-
} satisfies
|
|
62
|
+
isFolderMissing: missingFolder
|
|
63
|
+
} satisfies WorkspaceHarness)
|
|
70
64
|
}
|
|
71
65
|
const authPath = `/api/harnesses/${harness}/auth`
|
|
72
|
-
if (path ===
|
|
66
|
+
if (path === '/api/harnesses/status' && method === 'GET')
|
|
67
|
+
return Response.json({ [harness]: { availability, login } })
|
|
68
|
+
if (path === `${authPath}/install` && method === 'POST') {
|
|
69
|
+
if (environment !== 'local')
|
|
70
|
+
return new Response('Installation is local only', { status: 400 })
|
|
71
|
+
await new Promise(resolve => setTimeout(resolve, 2000))
|
|
72
|
+
availability = { status: 'login-required', reason: 'Log in to continue' }
|
|
73
|
+
return Response.json({ ok: true })
|
|
74
|
+
}
|
|
73
75
|
if (path === `${authPath}/login` && method === 'POST') {
|
|
74
76
|
login = { state: 'starting' }
|
|
75
77
|
await new Promise(resolve => setTimeout(resolve, 500))
|
|
@@ -23,7 +23,7 @@ import { WorkspaceWelcomeState } from '@/client/features/workspace/setup/workspa
|
|
|
23
23
|
import { WorkspaceLoadingState } from '@/client/features/workspace/setup/workspace-recovery-states'
|
|
24
24
|
import type { AppEnvironment } from '@/lib/types'
|
|
25
25
|
import { workspaceTypeLabel } from '@/client/features/workspace/workspace-presentation'
|
|
26
|
-
import {
|
|
26
|
+
import { useHarnessStatus, type LoginHarness } from '@/client/features/harness/api'
|
|
27
27
|
import {
|
|
28
28
|
createSetupMocks,
|
|
29
29
|
MOCK_SIGN_IN_URL,
|
|
@@ -35,8 +35,8 @@ import type { SetupScenario } from './workspace-setup-mocks'
|
|
|
35
35
|
|
|
36
36
|
const scenarioLabels: Record<SetupScenario, string> = {
|
|
37
37
|
welcome: 'Welcome',
|
|
38
|
-
login: '
|
|
39
|
-
|
|
38
|
+
login: 'Log in',
|
|
39
|
+
install: 'Install',
|
|
40
40
|
'missing-folder': 'Folder missing',
|
|
41
41
|
loading: 'Loading'
|
|
42
42
|
}
|
|
@@ -53,7 +53,7 @@ function SetupPreview({ mocks, client, environment, harness, scenario }: SetupPr
|
|
|
53
53
|
const [provider, setProvider] = useState<'browser' | 'code' | 'closed'>()
|
|
54
54
|
const [deviceCode, setDeviceCode] = useState('')
|
|
55
55
|
const [layout, setLayout] = useState(createDefaultWorkspaceLayout)
|
|
56
|
-
const auth =
|
|
56
|
+
const auth = useHarnessStatus(harness)
|
|
57
57
|
const pendingId = auth.data?.login?.state === 'pending' ? auth.data.login.id : undefined
|
|
58
58
|
// Both local harnesses open the browser automatically.
|
|
59
59
|
const providerPage = provider ?? (environment === 'local' && pendingId ? 'browser' : 'closed')
|
|
@@ -85,7 +85,12 @@ function SetupPreview({ mocks, client, environment, harness, scenario }: SetupPr
|
|
|
85
85
|
key={value}
|
|
86
86
|
size="sm"
|
|
87
87
|
variant={environment === value ? 'default' : 'secondary'}
|
|
88
|
-
onClick={() =>
|
|
88
|
+
onClick={() =>
|
|
89
|
+
restart({
|
|
90
|
+
environment: value,
|
|
91
|
+
scenario: value === 'cloud' && scenario === 'install' ? 'login' : scenario
|
|
92
|
+
})
|
|
93
|
+
}
|
|
89
94
|
>
|
|
90
95
|
{value === 'local' ? 'Local' : 'Cloud'}
|
|
91
96
|
</Button>
|
|
@@ -109,24 +114,13 @@ function SetupPreview({ mocks, client, environment, harness, scenario }: SetupPr
|
|
|
109
114
|
key={value}
|
|
110
115
|
size="sm"
|
|
111
116
|
variant={scenario === value ? 'default' : 'secondary'}
|
|
117
|
+
disabled={value === 'install' && environment === 'cloud'}
|
|
112
118
|
onClick={() => restart({ scenario: value })}
|
|
113
119
|
>
|
|
114
120
|
{scenarioLabels[value]}
|
|
115
121
|
</Button>
|
|
116
122
|
))}
|
|
117
123
|
</div>
|
|
118
|
-
<div className="flex flex-wrap gap-2" role="group" aria-label="Layout">
|
|
119
|
-
{(['split', 'fullscreen'] as const).map(layoutMode => (
|
|
120
|
-
<Button
|
|
121
|
-
key={layoutMode}
|
|
122
|
-
size="sm"
|
|
123
|
-
variant={layout.layoutMode === layoutMode ? 'default' : 'secondary'}
|
|
124
|
-
onClick={() => setLayout(current => ({ ...current, layoutMode }))}
|
|
125
|
-
>
|
|
126
|
-
{layoutMode === 'split' ? 'Split' : 'Fullscreen'}
|
|
127
|
-
</Button>
|
|
128
|
-
))}
|
|
129
|
-
</div>
|
|
130
124
|
</header>
|
|
131
125
|
<WorkspaceLayoutContext
|
|
132
126
|
value={{
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { useQuery } from '@tanstack/react-query'
|
|
1
|
+
import { queryOptions, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
2
2
|
import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
3
|
-
import type {
|
|
4
|
-
HarnessAvailability,
|
|
5
|
-
HarnessLogin,
|
|
6
|
-
HarnessLoginState,
|
|
7
|
-
WorkspaceType
|
|
8
|
-
} from '@/lib/types'
|
|
3
|
+
import type { HarnessStatuses, HarnessLogin, WorkspaceType } from '@/lib/types'
|
|
9
4
|
|
|
10
5
|
export function startHarnessLogin(type: WorkspaceType): Promise<HarnessLogin> {
|
|
11
6
|
return requestJson(
|
|
@@ -17,20 +12,55 @@ export function startHarnessLogin(type: WorkspaceType): Promise<HarnessLogin> {
|
|
|
17
12
|
|
|
18
13
|
export type LoginHarness = 'claude-code' | 'codex'
|
|
19
14
|
|
|
20
|
-
export type
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
export type { HarnessStatus } from '@/lib/types'
|
|
16
|
+
|
|
17
|
+
const harnessStatusOptions = queryOptions({
|
|
18
|
+
queryKey: ['harness-status'],
|
|
19
|
+
queryFn: ({ signal }) => requestJson<HarnessStatuses>('/api/harnesses/status', { signal }),
|
|
20
|
+
staleTime: Infinity,
|
|
21
|
+
gcTime: Infinity,
|
|
22
|
+
refetchOnWindowFocus: 'always',
|
|
23
|
+
refetchInterval: query =>
|
|
24
|
+
Object.values(query.state.data ?? {}).some(
|
|
25
|
+
status => status.login?.state === 'starting' || status.login?.state === 'pending'
|
|
26
|
+
)
|
|
27
|
+
? 2_000
|
|
28
|
+
: false
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// Only user-requested retries bypass the server's availability cache.
|
|
32
|
+
export function useRetryHarnessStatus() {
|
|
33
|
+
const client = useQueryClient()
|
|
34
|
+
return useMutation({
|
|
35
|
+
mutationFn: () => requestJson<HarnessStatuses>('/api/harnesses/status?refresh=true'),
|
|
36
|
+
onMutate: async () => {
|
|
37
|
+
await client.cancelQueries({ queryKey: harnessStatusOptions.queryKey })
|
|
38
|
+
return client.getQueryData(harnessStatusOptions.queryKey)
|
|
39
|
+
},
|
|
40
|
+
onSuccess: (statuses, _variables, previous) => {
|
|
41
|
+
// An auth event received during the retry is newer than this response.
|
|
42
|
+
if (client.getQueryData(harnessStatusOptions.queryKey) === previous)
|
|
43
|
+
client.setQueryData(harnessStatusOptions.queryKey, statuses)
|
|
44
|
+
}
|
|
45
|
+
})
|
|
23
46
|
}
|
|
24
47
|
|
|
25
|
-
export function
|
|
48
|
+
export function useHarnessStatuses() {
|
|
49
|
+
return useQuery(harnessStatusOptions)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function useHarnessStatus(type: WorkspaceType | undefined) {
|
|
26
53
|
return useQuery({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
refetchInterval: 2_000
|
|
54
|
+
...harnessStatusOptions,
|
|
55
|
+
enabled: type === 'claude-code' || type === 'codex',
|
|
56
|
+
select: statuses => (type ? statuses[type] : undefined)
|
|
31
57
|
})
|
|
32
58
|
}
|
|
33
59
|
|
|
34
60
|
export function submitHarnessLoginCode(type: WorkspaceType, id: string, code: string) {
|
|
35
61
|
return requestVoid(`/api/harnesses/${type}/auth/login/${id}/code`, jsonRequest('POST', { code }))
|
|
36
62
|
}
|
|
63
|
+
|
|
64
|
+
export function installHarness(type: LoginHarness) {
|
|
65
|
+
return requestVoid(`/api/harnesses/${type}/auth/install`, { method: 'POST' })
|
|
66
|
+
}
|
|
@@ -15,9 +15,10 @@ import { cn } from '@/client/lib/cn'
|
|
|
15
15
|
type DeviceLoginStepsProps = {
|
|
16
16
|
code: string
|
|
17
17
|
url: string
|
|
18
|
+
className?: string
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
export function DeviceLoginSteps({ code, url }: DeviceLoginStepsProps) {
|
|
21
|
+
export function DeviceLoginSteps({ code, url, className }: DeviceLoginStepsProps) {
|
|
21
22
|
const [copied, setCopied] = useState(false)
|
|
22
23
|
|
|
23
24
|
useEffect(() => {
|
|
@@ -34,7 +35,12 @@ export function DeviceLoginSteps({ code, url }: DeviceLoginStepsProps) {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
return (
|
|
37
|
-
<ol
|
|
38
|
+
<ol
|
|
39
|
+
className={cn(
|
|
40
|
+
'mx-auto grid w-full max-w-64 gap-6 text-left text-sm lg:max-w-3xl lg:grid-cols-3 lg:text-center',
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
43
|
+
>
|
|
38
44
|
<li className="flex flex-col items-start gap-3 lg:items-center">
|
|
39
45
|
<IconCircleNumber1 size={24} stroke={1.5} className="shrink-0" />
|
|
40
46
|
<div className="flex min-w-0 flex-col items-start gap-3 lg:items-center">
|
|
@@ -86,7 +92,7 @@ export function DeviceLoginSteps({ code, url }: DeviceLoginStepsProps) {
|
|
|
86
92
|
<li className="flex flex-col items-start gap-3 lg:items-center">
|
|
87
93
|
<IconCircleNumber3 size={24} stroke={1.5} className="shrink-0" />
|
|
88
94
|
<div className="flex min-w-0 flex-col items-start gap-3 lg:items-center">
|
|
89
|
-
<p>
|
|
95
|
+
<p>Log in to ChatGPT, paste the code, then come back to Moi</p>
|
|
90
96
|
<a href={url} target="_blank" rel="noopener noreferrer" className={buttonVariants()}>
|
|
91
97
|
Open ChatGPT
|
|
92
98
|
</a>
|
|
@@ -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
|
+
}
|