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
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { matchQuery, useQueryClient, type QueryClient, type Query } from '@tanstack/react-query'
|
|
3
|
+
import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
|
|
4
|
+
import type { WorkspaceLayoutResponse, WorkspaceType } from '@/lib/types'
|
|
5
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
6
|
+
import { liveStore } from '@/client/features/chat/chat-store'
|
|
7
|
+
import { writeSelectedSession } from '@/client/features/chat/sessions/browser-tab-state'
|
|
8
|
+
import { browserTabSelectionKey } from '@/client/features/chat/sessions/use-selected-session'
|
|
9
|
+
import { changeWorkspaceStateCache } from './workspace-state'
|
|
10
|
+
|
|
11
|
+
export async function receiveWorkspaceHarness(
|
|
12
|
+
queryClient: QueryClient,
|
|
13
|
+
id: string,
|
|
14
|
+
harness: WorkspaceType
|
|
15
|
+
) {
|
|
16
|
+
const cached = queryClient.getQueryData<WorkspaceLayoutResponse>(workspaceKeys.layout(id))
|
|
17
|
+
let previous = cached ? (cached.provider ?? 'claude-code') : undefined
|
|
18
|
+
try {
|
|
19
|
+
const key = `moi:workspace-harness:${id}`
|
|
20
|
+
previous = (sessionStorage.getItem(key) as WorkspaceType | null) ?? previous
|
|
21
|
+
sessionStorage.setItem(key, harness)
|
|
22
|
+
} catch {
|
|
23
|
+
/* Cached layout still detects live changes when storage is unavailable. */
|
|
24
|
+
}
|
|
25
|
+
if (!previous || previous === harness) return
|
|
26
|
+
|
|
27
|
+
const keys = [
|
|
28
|
+
workspaceKeys.layout(id),
|
|
29
|
+
workspaceKeys.state(id),
|
|
30
|
+
workspaceKeys.sessions(id),
|
|
31
|
+
workspaceKeys.mcp(id),
|
|
32
|
+
workspaceKeys.skills(id),
|
|
33
|
+
workspaceKeys.views(id),
|
|
34
|
+
['workspaces', 'events', id]
|
|
35
|
+
]
|
|
36
|
+
const affected = {
|
|
37
|
+
predicate: (query: Query) => keys.some(queryKey => matchQuery({ queryKey }, query))
|
|
38
|
+
}
|
|
39
|
+
await queryClient.cancelQueries(affected)
|
|
40
|
+
// Discard the old provider snapshot before rendering the new harness status.
|
|
41
|
+
void queryClient.resetQueries({ queryKey: workspaceKeys.harness(id), exact: true })
|
|
42
|
+
queryClient.setQueryData<WorkspaceLayoutResponse>(workspaceKeys.layout(id), previous =>
|
|
43
|
+
previous
|
|
44
|
+
? {
|
|
45
|
+
...previous,
|
|
46
|
+
provider: harness,
|
|
47
|
+
selectedModel: undefined,
|
|
48
|
+
selectedEffort: undefined,
|
|
49
|
+
selectedSpeedMode: undefined
|
|
50
|
+
}
|
|
51
|
+
: previous
|
|
52
|
+
)
|
|
53
|
+
writeSelectedSession(id, { selected: {} })
|
|
54
|
+
queryClient.setQueryData(browserTabSelectionKey(id), { selected: {} })
|
|
55
|
+
changeWorkspaceStateCache(queryClient, id, state => {
|
|
56
|
+
state.selected = {}
|
|
57
|
+
delete state.pinnedSessionId
|
|
58
|
+
})
|
|
59
|
+
const clean = <T>(entries: Record<string, T>) =>
|
|
60
|
+
Object.fromEntries(Object.entries(entries).filter(([key]) => !key.startsWith(`${id}:`)))
|
|
61
|
+
liveStore.setState(state => ({
|
|
62
|
+
activity: clean(state.activity),
|
|
63
|
+
errors: clean(state.errors),
|
|
64
|
+
previews: Object.fromEntries(
|
|
65
|
+
Object.entries(state.previews).filter(([, preview]) => preview.workspaceId !== id)
|
|
66
|
+
)
|
|
67
|
+
}))
|
|
68
|
+
queryClient.removeQueries({ queryKey: ['workspaces', 'events', id] })
|
|
69
|
+
await Promise.all([
|
|
70
|
+
queryClient.invalidateQueries(affected),
|
|
71
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.all, exact: true }),
|
|
72
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.previews })
|
|
73
|
+
])
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function useWorkspaceHarnessChanges(id: string, harness: WorkspaceType | null) {
|
|
77
|
+
const queryClient = useQueryClient()
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (harness) void receiveWorkspaceHarness(queryClient, id, harness)
|
|
80
|
+
}, [harness, id, queryClient])
|
|
81
|
+
useWorkspaceEvent(event => {
|
|
82
|
+
if (event.type === 'connection:opened') {
|
|
83
|
+
void queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(id) })
|
|
84
|
+
} else if (event.type === 'workspace-harness:switched' && event.workspaceId === id) {
|
|
85
|
+
void receiveWorkspaceHarness(queryClient, id, event.harness)
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
}
|
|
@@ -1,43 +1,10 @@
|
|
|
1
1
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
2
|
-
|
|
3
2
|
import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
4
3
|
import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
|
|
5
4
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
6
5
|
import type { WorkspaceLayoutResponse } from '@/client/features/workspace/api'
|
|
7
6
|
import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
|
|
8
|
-
import {
|
|
9
|
-
import type { AppSettings, WorkspaceEntry, WorkspaceEnvView, WorkspaceIcon } from '@/lib/types'
|
|
10
|
-
|
|
11
|
-
// App-wide settings (server-side settings.json, GET/PATCH /api/settings) —
|
|
12
|
-
// shared by every workspace, unlike the per-workspace queries below.
|
|
13
|
-
export const appSettingsKey = ['app-settings'] as const
|
|
14
|
-
|
|
15
|
-
export function useAppSettings() {
|
|
16
|
-
const queryClient = useQueryClient()
|
|
17
|
-
// Another client can change settings; the server broadcasts the new value
|
|
18
|
-
// over the live-events socket so every open client stays in sync.
|
|
19
|
-
useWorkspaceEvent(event => {
|
|
20
|
-
if (event.type === 'settings:updated') {
|
|
21
|
-
queryClient.setQueryData<AppSettings>(appSettingsKey, event.settings)
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
return useQuery<AppSettings>({
|
|
25
|
-
queryKey: appSettingsKey,
|
|
26
|
-
queryFn: () => requestJson('/api/settings'),
|
|
27
|
-
staleTime: 30_000
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function useSaveAppSettings() {
|
|
32
|
-
const queryClient = useQueryClient()
|
|
33
|
-
return useMutation<AppSettings, Error, Partial<AppSettings>>({
|
|
34
|
-
mutationFn: patch =>
|
|
35
|
-
requestJson('/api/settings', jsonRequest('PATCH', patch), 'Failed to save settings'),
|
|
36
|
-
onSuccess: next => {
|
|
37
|
-
queryClient.setQueryData<AppSettings>(appSettingsKey, next)
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
}
|
|
7
|
+
import type { WorkspaceEntry, WorkspaceEnvView, WorkspaceIcon } from '@/lib/types'
|
|
41
8
|
|
|
42
9
|
export function useWorkspaceEnv(workspaceId: string) {
|
|
43
10
|
return useQuery<WorkspaceEnvView>({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IconLoader2 } from '@tabler/icons-react'
|
|
1
|
+
import { IconChevronDown, IconLoader2 } from '@tabler/icons-react'
|
|
2
2
|
import { useLocation } from 'wouter'
|
|
3
3
|
|
|
4
4
|
import { useAppConfig } from '@/client/api/app-config'
|
|
@@ -17,7 +17,18 @@ import { Button } from '@/client/components/ui/button'
|
|
|
17
17
|
import { Input } from '@/client/components/ui/input'
|
|
18
18
|
import { useRemoveWorkspace } from '@/client/features/home/api'
|
|
19
19
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-layout-context'
|
|
20
|
+
import { harnessIcon, harnessLabel } from '@/client/features/harness/harness-presentation'
|
|
21
|
+
import {
|
|
22
|
+
DropdownMenu,
|
|
23
|
+
DropdownMenuTrigger,
|
|
24
|
+
DropdownMenuContent,
|
|
25
|
+
DropdownMenuRadioGroup,
|
|
26
|
+
DropdownMenuRadioItem
|
|
27
|
+
} from '@/client/components/ui/dropdown-menu'
|
|
28
|
+
import { Tooltip, TooltipTrigger, TooltipContent } from '@/client/components/ui/tooltip'
|
|
29
|
+
import { useLive } from '@/client/features/chat/chat-store'
|
|
20
30
|
|
|
31
|
+
import { useChangeWorkspaceHarness } from '@/client/features/workspace/api'
|
|
21
32
|
import { SettingsPage, SettingsRow, SettingsSection } from './settings-layout'
|
|
22
33
|
|
|
23
34
|
export function GeneralSettings() {
|
|
@@ -46,6 +57,7 @@ export function GeneralSettings() {
|
|
|
46
57
|
/>
|
|
47
58
|
}
|
|
48
59
|
/>
|
|
60
|
+
<WorkspaceHarnessSetting />
|
|
49
61
|
</SettingsSection>
|
|
50
62
|
|
|
51
63
|
{!demo && (
|
|
@@ -56,7 +68,7 @@ export function GeneralSettings() {
|
|
|
56
68
|
control={
|
|
57
69
|
<AlertDialog>
|
|
58
70
|
<AlertDialogTrigger
|
|
59
|
-
render={<Button type="button" variant="destructive"
|
|
71
|
+
render={<Button type="button" variant="destructive" />}
|
|
60
72
|
disabled={removeWorkspace.isPending}
|
|
61
73
|
>
|
|
62
74
|
Remove
|
|
@@ -101,3 +113,65 @@ export function GeneralSettings() {
|
|
|
101
113
|
</SettingsPage>
|
|
102
114
|
)
|
|
103
115
|
}
|
|
116
|
+
|
|
117
|
+
function WorkspaceHarnessSetting() {
|
|
118
|
+
const { demo } = useAppConfig()
|
|
119
|
+
const { workspaceId, provider } = useWorkspaceLayoutCtx()
|
|
120
|
+
const type = provider ?? 'claude-code'
|
|
121
|
+
const change = useChangeWorkspaceHarness(workspaceId)
|
|
122
|
+
const active = useLive(state =>
|
|
123
|
+
Object.entries(state.activity).some(
|
|
124
|
+
([key, activity]) => key.startsWith(`${workspaceId}:`) && activity !== 'idle'
|
|
125
|
+
)
|
|
126
|
+
)
|
|
127
|
+
const reason = demo
|
|
128
|
+
? 'Changing agents is unavailable in the demo'
|
|
129
|
+
: type === 'hermes' || type === 'openclaw'
|
|
130
|
+
? 'This workspace belongs to its agent and cannot use another agent'
|
|
131
|
+
: active
|
|
132
|
+
? 'Wait for the agent to finish before changing it'
|
|
133
|
+
: undefined
|
|
134
|
+
return (
|
|
135
|
+
<>
|
|
136
|
+
<SettingsRow
|
|
137
|
+
title="Agent"
|
|
138
|
+
control={
|
|
139
|
+
<Tooltip disabled={!reason}>
|
|
140
|
+
<TooltipTrigger render={<span tabIndex={reason ? 0 : undefined} aria-label={reason} />}>
|
|
141
|
+
<DropdownMenu>
|
|
142
|
+
<DropdownMenuTrigger
|
|
143
|
+
render={<Button variant="outline" />}
|
|
144
|
+
disabled={Boolean(reason) || change.isPending}
|
|
145
|
+
aria-label="Agent"
|
|
146
|
+
>
|
|
147
|
+
<img src={harnessIcon[type]} alt="" className="size-4 shrink-0" />
|
|
148
|
+
{harnessLabel[type]}
|
|
149
|
+
<IconChevronDown stroke={1.5} />
|
|
150
|
+
</DropdownMenuTrigger>
|
|
151
|
+
<DropdownMenuContent align="end" className="min-w-44">
|
|
152
|
+
<DropdownMenuRadioGroup
|
|
153
|
+
value={type}
|
|
154
|
+
onValueChange={value => change.mutate(value)}
|
|
155
|
+
>
|
|
156
|
+
{(['claude-code', 'codex'] as const).map(option => (
|
|
157
|
+
<DropdownMenuRadioItem key={option} value={option}>
|
|
158
|
+
<img src={harnessIcon[option]} alt="" className="size-4 shrink-0" />
|
|
159
|
+
{harnessLabel[option]}
|
|
160
|
+
</DropdownMenuRadioItem>
|
|
161
|
+
))}
|
|
162
|
+
</DropdownMenuRadioGroup>
|
|
163
|
+
</DropdownMenuContent>
|
|
164
|
+
</DropdownMenu>
|
|
165
|
+
</TooltipTrigger>
|
|
166
|
+
<TooltipContent>{reason}</TooltipContent>
|
|
167
|
+
</Tooltip>
|
|
168
|
+
}
|
|
169
|
+
/>
|
|
170
|
+
{change.error && (
|
|
171
|
+
<p role="alert" className="text-sm text-destructive">
|
|
172
|
+
{change.error.message}
|
|
173
|
+
</p>
|
|
174
|
+
)}
|
|
175
|
+
</>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useQueryClient } from '@tanstack/react-query'
|
|
2
2
|
|
|
3
3
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
4
|
-
import { useUpdateEnv, useWorkspaceEnv } from '@/client/features/settings/api'
|
|
4
|
+
import { useUpdateEnv, useWorkspaceEnv } from '@/client/features/workspace/settings/api'
|
|
5
5
|
import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
|
|
6
6
|
|
|
7
7
|
// Workspace env state in one hook: the masked env view (query), the patch
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
import { Button } from '@/client/components/ui/button'
|
|
12
12
|
import { Checkbox } from '@/client/components/ui/checkbox'
|
|
13
13
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/client/components/ui/tabs'
|
|
14
|
-
import { useUpdateWorkspaceIcon } from '@/client/features/settings/api'
|
|
14
|
+
import { useUpdateWorkspaceIcon } from '@/client/features/workspace/settings/api'
|
|
15
15
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-layout-context'
|
|
16
|
-
import {
|
|
16
|
+
import { IDENTITY_ICON_CHOICES } from '@/client/lib/identity-icon-registry'
|
|
17
17
|
import { cn } from '@/client/lib/cn'
|
|
18
18
|
import type { WorkspaceIcon } from '@/lib/types'
|
|
19
19
|
import { EMOJI_FONT, FAVORITE_EMOJI } from './icon-picker-options'
|
|
@@ -241,7 +241,7 @@ export function WorkspaceIconPicker() {
|
|
|
241
241
|
className="scrollbar-thin h-72 overflow-y-auto rounded-xl border border-border bg-background p-1.5"
|
|
242
242
|
>
|
|
243
243
|
<PickerItems>
|
|
244
|
-
{
|
|
244
|
+
{IDENTITY_ICON_CHOICES.map(({ id, Icon }) => (
|
|
245
245
|
<PickerItem
|
|
246
246
|
key={id}
|
|
247
247
|
aria-label={id}
|
|
@@ -1,175 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import { useAppConfig } from '@/client/api/app-config'
|
|
6
|
-
import { Button, buttonVariants } from '@/client/components/ui/button'
|
|
7
|
-
import { Textarea } from '@/client/components/ui/textarea'
|
|
8
|
-
import { workspaceTypeLabel } from '@/client/features/workspace/workspace-presentation'
|
|
9
|
-
import { Spinner } from '@/client/components/ui/spinner'
|
|
10
|
-
import {
|
|
11
|
-
startHarnessLogin,
|
|
12
|
-
submitHarnessLoginCode,
|
|
13
|
-
useHarnessAuth,
|
|
14
|
-
type LoginHarness
|
|
15
|
-
} from '@/client/features/harness/api'
|
|
16
|
-
import { workspaceProviderIcon } from '@/client/components/shared/workspace-icon'
|
|
17
|
-
|
|
18
|
-
import { DeviceLoginSteps } from '@/client/features/harness/device-login-steps'
|
|
19
|
-
import { IconArrowRight } from '@tabler/icons-react'
|
|
1
|
+
import { Button } from '@/client/components/ui/button'
|
|
2
|
+
import { HarnessLoginPanel } from '@/client/features/harness/harness-login-panel'
|
|
3
|
+
import { harnessLabel } from '@/client/features/harness/harness-presentation'
|
|
4
|
+
import type { LoginHarness } from '@/client/features/harness/api'
|
|
20
5
|
|
|
21
6
|
type WorkspaceLoginStateProps = {
|
|
22
7
|
type: LoginHarness
|
|
23
8
|
reason: string
|
|
24
9
|
checking: boolean
|
|
25
10
|
onRecheck: () => void
|
|
11
|
+
onConnected?: () => void
|
|
26
12
|
}
|
|
27
13
|
|
|
28
14
|
export function WorkspaceLoginState({
|
|
29
15
|
type,
|
|
30
16
|
reason,
|
|
31
17
|
checking,
|
|
32
|
-
onRecheck
|
|
18
|
+
onRecheck,
|
|
19
|
+
onConnected = onRecheck
|
|
33
20
|
}: WorkspaceLoginStateProps) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const connected = !starting && !pending && auth.data?.availability.status === 'available'
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (connected) onRecheck()
|
|
48
|
-
}, [connected, onRecheck])
|
|
49
|
-
const action = useMutation({
|
|
50
|
-
mutationFn: async (kind: 'start' | 'submit') => {
|
|
51
|
-
if (kind === 'start') {
|
|
52
|
-
setManualLogin(false)
|
|
53
|
-
setCode('')
|
|
54
|
-
await startHarnessLogin(type)
|
|
55
|
-
}
|
|
56
|
-
if (kind === 'submit' && pending) {
|
|
57
|
-
await submitHarnessLoginCode(type, pending.id, code)
|
|
58
|
-
setCode('')
|
|
21
|
+
return (
|
|
22
|
+
<HarnessLoginPanel
|
|
23
|
+
type={type}
|
|
24
|
+
onConnected={onConnected}
|
|
25
|
+
connectedContent={
|
|
26
|
+
<WorkspaceAccessState
|
|
27
|
+
name={harnessLabel[type]}
|
|
28
|
+
reason={reason}
|
|
29
|
+
checking={checking}
|
|
30
|
+
onRecheck={onRecheck}
|
|
31
|
+
/>
|
|
59
32
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
33
|
+
/>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type WorkspaceAccessStateProps = {
|
|
38
|
+
name: string
|
|
39
|
+
reason: string
|
|
40
|
+
checking: boolean
|
|
41
|
+
onRecheck: () => void
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function WorkspaceAccessState({ name, reason, checking, onRecheck }: WorkspaceAccessStateProps) {
|
|
45
|
+
let message = `Logged in to ${name}, but this workspace still needs attention. ${reason}`
|
|
46
|
+
if (checking) message = 'Checking workspace access…'
|
|
65
47
|
|
|
66
48
|
return (
|
|
67
|
-
<div className="flex flex-
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
className={cn('flex w-full flex-col gap-3 self-center', !pending?.userCode && 'max-w-xs')}
|
|
73
|
-
aria-label={name}
|
|
74
|
-
>
|
|
75
|
-
{auth.isPending ? (
|
|
76
|
-
<Spinner className="size-6 self-center text-muted-foreground" stroke={1.5} />
|
|
77
|
-
) : checkError ? (
|
|
78
|
-
<div role="alert" className="flex flex-col items-start gap-2">
|
|
79
|
-
<p>Could not check agent sign-in status.</p>
|
|
80
|
-
<Button
|
|
81
|
-
variant="secondary"
|
|
82
|
-
disabled={auth.isFetching}
|
|
83
|
-
onClick={() => void auth.refetch()}
|
|
84
|
-
>
|
|
85
|
-
Try again
|
|
86
|
-
</Button>
|
|
87
|
-
</div>
|
|
88
|
-
) : connected ? (
|
|
89
|
-
<div role="status" className="flex flex-col items-center gap-4">
|
|
90
|
-
<p className="text-sm text-muted-foreground">
|
|
91
|
-
{checking
|
|
92
|
-
? 'Checking workspace access…'
|
|
93
|
-
: `Signed in to ${name}, but this workspace still needs attention. ${reason}`}
|
|
94
|
-
</p>
|
|
95
|
-
<Button variant="secondary" disabled={checking} onClick={onRecheck}>
|
|
96
|
-
Try again
|
|
97
|
-
</Button>
|
|
98
|
-
</div>
|
|
99
|
-
) : (
|
|
100
|
-
<>
|
|
101
|
-
{pending?.userCode ? (
|
|
102
|
-
<DeviceLoginSteps code={pending.userCode} url={pending.url} />
|
|
103
|
-
) : pending ? (
|
|
104
|
-
<>
|
|
105
|
-
<p role="status" className="text-sm text-muted-foreground">
|
|
106
|
-
{pending.codeUrl && !waitingForBrowser
|
|
107
|
-
? `Sign in to ${name} to get the authorization code.`
|
|
108
|
-
: `Sign in to ${name}, then come back to Moi. Your workspace will open once you’re connected.`}
|
|
109
|
-
</p>
|
|
110
|
-
<a
|
|
111
|
-
className={buttonVariants({ variant: 'secondary' })}
|
|
112
|
-
href={manualLogin ? (pending.codeUrl ?? pending.url) : pending.url}
|
|
113
|
-
target="_blank"
|
|
114
|
-
rel="noopener noreferrer"
|
|
115
|
-
>
|
|
116
|
-
Open {name}
|
|
117
|
-
</a>
|
|
118
|
-
{waitingForBrowser && pending.codeUrl && (
|
|
119
|
-
<Button variant="ghost" onClick={() => setManualLogin(true)}>
|
|
120
|
-
Having trouble signing in?
|
|
121
|
-
</Button>
|
|
122
|
-
)}
|
|
123
|
-
{!waitingForBrowser && pending.codeUrl && (
|
|
124
|
-
<form
|
|
125
|
-
className="mt-3 flex flex-col gap-3"
|
|
126
|
-
onSubmit={event => {
|
|
127
|
-
event.preventDefault()
|
|
128
|
-
action.mutate('submit')
|
|
129
|
-
}}
|
|
130
|
-
>
|
|
131
|
-
<label htmlFor={inputId} className="text-sm text-muted-foreground">
|
|
132
|
-
Paste the code here:
|
|
133
|
-
</label>
|
|
134
|
-
<Textarea
|
|
135
|
-
id={inputId}
|
|
136
|
-
aria-label="Authorization code"
|
|
137
|
-
rows={3}
|
|
138
|
-
className="field-sizing-fixed resize-none"
|
|
139
|
-
value={code}
|
|
140
|
-
onChange={event => setCode(event.target.value)}
|
|
141
|
-
autoComplete="off"
|
|
142
|
-
spellCheck={false}
|
|
143
|
-
/>
|
|
144
|
-
<Button
|
|
145
|
-
type="submit"
|
|
146
|
-
className="mt-3"
|
|
147
|
-
disabled={!code.trim() || action.isPending}
|
|
148
|
-
>
|
|
149
|
-
{action.isPending ? 'Connecting…' : 'Continue'}
|
|
150
|
-
</Button>
|
|
151
|
-
</form>
|
|
152
|
-
)}
|
|
153
|
-
</>
|
|
154
|
-
) : (
|
|
155
|
-
<Button
|
|
156
|
-
className="self-center"
|
|
157
|
-
disabled={action.isPending || starting}
|
|
158
|
-
onClick={() => action.mutate('start')}
|
|
159
|
-
>
|
|
160
|
-
Continue
|
|
161
|
-
<IconArrowRight stroke={1.75} data-icon="inline-end" />
|
|
162
|
-
</Button>
|
|
163
|
-
)}
|
|
164
|
-
</>
|
|
165
|
-
)}
|
|
166
|
-
{failure && (
|
|
167
|
-
<p role="alert" className="text-sm text-destructive">
|
|
168
|
-
{failure}
|
|
169
|
-
</p>
|
|
170
|
-
)}
|
|
171
|
-
</section>
|
|
172
|
-
</div>
|
|
49
|
+
<div role="status" className="mt-6 flex flex-col items-center gap-4">
|
|
50
|
+
<p className="text-sm text-muted-foreground">{message}</p>
|
|
51
|
+
<Button variant="secondary" disabled={checking} onClick={onRecheck}>
|
|
52
|
+
Try again
|
|
53
|
+
</Button>
|
|
173
54
|
</div>
|
|
174
55
|
)
|
|
175
56
|
}
|
|
@@ -5,7 +5,6 @@ import { IconFolderOff } from '@tabler/icons-react'
|
|
|
5
5
|
import { workspaceProviderIcon } from '@/client/components/shared/workspace-icon'
|
|
6
6
|
import { Button } from '@/client/components/ui/button'
|
|
7
7
|
import { Spinner } from '@/client/components/ui/spinner'
|
|
8
|
-
import { workspaceTypeLabel } from '../workspace-presentation'
|
|
9
8
|
import { useRemoveWorkspace } from '@/client/features/home/api'
|
|
10
9
|
import type { HarnessAvailability, WorkspaceType } from '@/lib/types'
|
|
11
10
|
|
|
@@ -61,17 +60,6 @@ export function HarnessUnavailableState({
|
|
|
61
60
|
availability,
|
|
62
61
|
...retry
|
|
63
62
|
}: HarnessUnavailableStateProps) {
|
|
64
|
-
if (availability.status === 'unavailable' && availability.code === 'not-installed') {
|
|
65
|
-
return (
|
|
66
|
-
<div className="flex flex-1 flex-col items-center justify-center gap-4 p-6 text-center">
|
|
67
|
-
<img src={workspaceProviderIcon[type]} alt="" className="size-10" />
|
|
68
|
-
<h1 className="font-medium">{workspaceTypeLabel[type]} is uninstalled from the device</h1>
|
|
69
|
-
<Button variant="secondary" disabled={retry.retrying} onClick={retry.onRetry}>
|
|
70
|
-
Check again
|
|
71
|
-
</Button>
|
|
72
|
-
</div>
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
63
|
const needsTerminalLogin = availability.status === 'login-required'
|
|
76
64
|
return (
|
|
77
65
|
<RecoveryMessage
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { useHarnessStatus, useRetryHarnessStatus } from '@/client/features/harness/api'
|
|
1
2
|
import { useCallback } from 'react'
|
|
3
|
+
import { useAppConfig } from '@/client/api/app-config'
|
|
2
4
|
|
|
3
|
-
import {
|
|
5
|
+
import { useWorkspaceHarness } from '../api'
|
|
4
6
|
import {
|
|
5
7
|
useWorkspaceWelcome,
|
|
6
8
|
WorkspaceWelcomeState,
|
|
@@ -19,29 +21,46 @@ export function useWorkspaceSetup(
|
|
|
19
21
|
contentPending = false,
|
|
20
22
|
welcome: WorkspaceWelcomeStateProps = {}
|
|
21
23
|
) {
|
|
22
|
-
const {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
24
|
+
const { environment, demo } = useAppConfig()
|
|
25
|
+
const workspace = useWorkspaceHarness(workspaceId)
|
|
26
|
+
const { data } = workspace
|
|
27
|
+
const status = useHarnessStatus(
|
|
28
|
+
data?.hasAuthOverrides || data?.isFolderMissing ? undefined : data?.provider
|
|
29
|
+
)
|
|
30
|
+
const retry = useRetryHarnessStatus()
|
|
31
|
+
const readiness = status.isEnabled ? status : workspace
|
|
32
|
+
const isFetching = readiness.isFetching || workspace.isFetching || retry.isPending
|
|
33
|
+
const refetch = workspace.isError ? workspace.refetch : readiness.refetch
|
|
34
|
+
const availability = readiness.data?.availability
|
|
35
|
+
const isError = readiness.isError || workspace.isError || retry.isError
|
|
36
|
+
const checking = workspace.isPending || readiness.isPending
|
|
27
37
|
const recheck = useCallback(() => {
|
|
28
38
|
void refetch()
|
|
29
39
|
}, [refetch])
|
|
30
40
|
|
|
41
|
+
const retryStatus = () => {
|
|
42
|
+
if (status.isEnabled && !workspace.isError) retry.mutate()
|
|
43
|
+
else recheck()
|
|
44
|
+
}
|
|
45
|
+
|
|
31
46
|
function renderRecovery() {
|
|
32
47
|
if (checking) return undefined
|
|
33
48
|
// Background network failures do not invalidate a known working workspace.
|
|
34
|
-
if (isError &&
|
|
35
|
-
if (isError || !data) {
|
|
36
|
-
return <WorkspaceCheckFailedState retrying={isFetching} onRetry={
|
|
49
|
+
if (isError && availability?.status === 'available') return undefined
|
|
50
|
+
if (isError || !data || !availability) {
|
|
51
|
+
return <WorkspaceCheckFailedState retrying={isFetching} onRetry={retryStatus} />
|
|
37
52
|
}
|
|
38
|
-
if (data.
|
|
53
|
+
if (data.isFolderMissing) {
|
|
39
54
|
return <WorkspaceMissingState workspaceId={workspaceId} />
|
|
40
55
|
}
|
|
41
|
-
const { provider
|
|
56
|
+
const { provider } = data
|
|
42
57
|
if (availability.status === 'available') return undefined
|
|
43
58
|
if (
|
|
44
|
-
availability.status === 'login-required'
|
|
59
|
+
(availability.status === 'login-required' ||
|
|
60
|
+
(environment === 'local' &&
|
|
61
|
+
!demo &&
|
|
62
|
+
availability.status === 'unavailable' &&
|
|
63
|
+
availability.code === 'not-installed')) &&
|
|
45
64
|
(provider === 'claude-code' || provider === 'codex')
|
|
46
65
|
) {
|
|
47
66
|
return (
|
|
@@ -49,7 +68,8 @@ export function useWorkspaceSetup(
|
|
|
49
68
|
type={provider}
|
|
50
69
|
reason={availability.reason}
|
|
51
70
|
checking={isFetching}
|
|
52
|
-
|
|
71
|
+
onConnected={recheck}
|
|
72
|
+
onRecheck={retryStatus}
|
|
53
73
|
/>
|
|
54
74
|
)
|
|
55
75
|
}
|
|
@@ -58,7 +78,7 @@ export function useWorkspaceSetup(
|
|
|
58
78
|
type={provider}
|
|
59
79
|
availability={availability}
|
|
60
80
|
retrying={isFetching}
|
|
61
|
-
onRetry={
|
|
81
|
+
onRetry={retryStatus}
|
|
62
82
|
/>
|
|
63
83
|
)
|
|
64
84
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
import { WorkspaceIdentity, type WorkspaceIdentityProps } from '../workspace-identity'
|
|
4
|
-
import {
|
|
4
|
+
import { IDENTITY_ICON_IDS } from '@/client/lib/identity-icon-registry'
|
|
5
5
|
|
|
6
6
|
const greetings = [
|
|
7
7
|
'Welcome to',
|
|
@@ -43,7 +43,7 @@ export function WorkspaceWelcomeState({
|
|
|
43
43
|
}: WorkspaceWelcomeStateProps) {
|
|
44
44
|
const [greeting] = useState(() => greetings[Math.floor(Math.random() * greetings.length)])
|
|
45
45
|
const [icons] = useState(() => {
|
|
46
|
-
const choices = [...
|
|
46
|
+
const choices = [...IDENTITY_ICON_IDS]
|
|
47
47
|
return Array.from(
|
|
48
48
|
{ length: 4 },
|
|
49
49
|
() => choices.splice(Math.floor(Math.random() * choices.length), 1)[0]!
|