moi-computer 0.13.1-next.1 → 0.13.1-next.2
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/client/api/app-config.ts +12 -1
- package/client/api/http.ts +11 -1
- package/client/app/app-router.tsx +3 -2
- package/client/app/routes/home-route.tsx +1 -1
- package/client/app/routes/workspace-registration.tsx +68 -0
- package/client/app/routes/workspace-route.tsx +33 -6
- package/client/app/shell/sidebar-layout.tsx +10 -5
- package/client/components/shared/workspace-icon.tsx +8 -17
- package/client/features/account/account-test-utils.tsx +15 -9
- package/client/features/account/api.ts +6 -6
- package/client/features/account/profile-actions.ts +5 -7
- package/client/features/app-settings/settings-page.tsx +2 -1
- package/client/features/applets/api.ts +6 -6
- package/client/features/applets/applet-cache.ts +6 -5
- package/client/features/applets/applet-log.ts +2 -1
- package/client/features/applets/applet-runtime.ts +2 -1
- package/client/features/applets/use-applet.ts +73 -18
- package/client/features/applets/widget-shell.tsx +4 -2
- package/client/features/chat/applet-chat-intents.ts +5 -13
- package/client/features/chat/chat-popup.tsx +8 -4
- package/client/features/chat/chat-send.ts +2 -2
- package/client/features/chat/composer/model-order.ts +4 -4
- package/client/features/chat/composer/model-picker.tsx +12 -10
- package/client/features/chat/composer/use-workspace-composer-state.tsx +1 -1
- package/client/features/chat/sessions/api.ts +11 -28
- package/client/features/chat/sessions/use-selected-session.ts +18 -100
- package/client/features/chat/use-chat.ts +8 -12
- package/client/features/collab/members/api.ts +4 -10
- package/client/features/collab/members/hooks.ts +32 -38
- package/client/features/collab/members/store.ts +96 -71
- package/client/features/collab/members/types.ts +5 -3
- package/client/features/collab/presence/client.ts +2 -3
- package/client/features/collab/presence/hooks.tsx +1 -1
- package/client/features/collab/proxy-user.ts +1 -3
- package/client/features/collab/sharing/workspace-members.tsx +0 -8
- package/client/features/dev/chat-states-page.tsx +3 -1
- package/client/features/dev/harness-debug-page.tsx +7 -7
- package/client/features/dev/workspace-setup-mocks.ts +1 -1
- package/client/features/dev/workspace-setup-preview.tsx +6 -4
- package/client/features/harness/api.ts +13 -10
- package/client/features/harness/harness-login-panel.tsx +9 -5
- package/client/features/harness/harness-presentation.ts +4 -4
- package/client/features/harness/harness-selector.tsx +13 -13
- package/client/features/harness/use-harness-login.ts +5 -5
- package/client/features/home/api.ts +38 -2
- package/client/features/home/home-page.tsx +43 -13
- package/client/features/home/shared-workspaces.tsx +70 -0
- package/client/features/home/workspace-invitations.tsx +101 -0
- package/client/features/identity/host-api.ts +3 -2
- package/client/features/identity/store.ts +1 -7
- package/client/features/onboarding/agent-setup-step.tsx +8 -8
- package/client/features/onboarding/onboarding-page.tsx +3 -2
- package/client/features/onboarding/workspace-setup-step.tsx +1 -1
- package/client/features/overview/api.ts +3 -5
- package/client/features/overview/default/registry.tsx +1 -1
- package/client/features/overview/default/views-widget.tsx +2 -2
- package/client/features/overview/hidden-panel.tsx +7 -5
- package/client/features/overview/overview.tsx +18 -16
- package/client/features/overview/workspace-name.tsx +2 -2
- package/client/features/scratchpad/scratchpad.tsx +9 -7
- package/client/features/scratchpad/use-scratchpad-snapshot.tsx +13 -5
- package/client/features/views/api.ts +34 -16
- package/client/features/views/use-view-actions.ts +10 -20
- package/client/features/views/view-manager.tsx +1 -1
- package/client/features/views/view-submission.ts +2 -21
- package/client/features/workspace/add/api.ts +5 -4
- package/client/features/workspace/add/create-workspace-dialog.tsx +12 -9
- package/client/features/workspace/add/import-workspace-dialog.tsx +7 -7
- package/client/features/workspace/add/use-workspace-import.ts +10 -10
- package/client/features/workspace/add/workspace-agent-options.ts +21 -20
- package/client/features/workspace/add/workspace-agent-selector.tsx +11 -11
- package/client/features/workspace/api.ts +60 -13
- package/client/features/workspace/harness-transition.ts +7 -13
- package/client/features/workspace/remote.ts +25 -0
- package/client/features/workspace/settings/api.ts +7 -12
- package/client/features/workspace/settings/connectors-settings.tsx +3 -3
- package/client/features/workspace/settings/general-settings.tsx +8 -8
- package/client/features/workspace/setup/workspace-login-state.tsx +4 -4
- package/client/features/workspace/setup/workspace-recovery-states.tsx +43 -14
- package/client/features/workspace/setup/workspace-setup.tsx +6 -6
- package/client/features/workspace/tab-resolution.ts +2 -2
- package/client/features/workspace/use-workspace-navigation.ts +7 -4
- package/client/features/workspace/workspace-content.tsx +22 -20
- package/client/features/workspace/workspace-frame.tsx +13 -26
- package/client/features/workspace/workspace-layout-context.tsx +45 -12
- package/client/features/workspace/workspace-menu.tsx +2 -2
- package/client/features/workspace/workspace-pane.tsx +22 -0
- package/client/features/workspace/workspace-pending-screen.tsx +1 -1
- package/client/features/workspace/workspace-preferences.ts +34 -0
- package/client/features/workspace/workspace-presentation.tsx +12 -16
- package/client/features/workspace/workspace-screen.tsx +2 -2
- package/client/features/workspace/workspace-state.ts +2 -1
- package/client/features/workspace/workspace-tabs.tsx +1 -1
- package/client/features/workspace/workspace-test-utils.ts +23 -0
- package/client/runtime/use-workspace-events.ts +14 -0
- package/client/runtime/workspace-events.ts +9 -9
- package/client/store/ui.ts +29 -9
- package/dist/chunk-44khk4sp.js +2 -0
- package/dist/chunk-ba6mz56s.js +72 -0
- package/dist/chunk-ec5ennpv.js +1 -0
- package/dist/chunk-ectsnw81.js +2 -0
- package/dist/chunk-en7w5ypg.js +1 -0
- package/dist/chunk-f695wcx5.js +5 -0
- package/dist/chunk-kffcah9w.css +1 -0
- package/dist/{chunk-th91xfnp.js → chunk-n0fawy9x.js} +1 -1
- package/dist/chunk-pdt9hxfw.js +2 -0
- package/dist/chunk-rmd0ctfx.js +546 -0
- package/dist/chunk-zv22wv0g.js +1 -0
- package/dist/index.html +1 -1
- package/lib/harness-instructions.ts +4 -4
- package/lib/harness-types.ts +13 -0
- package/lib/types.ts +34 -49
- package/lib/workspace-config.ts +48 -0
- package/lib/workspace-layout.ts +2 -4
- package/package.json +4 -2
- package/server/README.md +29 -27
- package/server/api/harnesses.ts +5 -5
- package/server/api/index.ts +170 -68
- package/server/applets/index.ts +15 -9
- package/server/applets/views.ts +2 -17
- package/server/applets/widgets.ts +3 -2
- package/server/cli/commands/config.ts +8 -20
- package/server/cli/commands/hermes.ts +2 -2
- package/server/cli/commands/init.ts +96 -53
- package/server/cli/commands/openclaw.ts +2 -2
- package/server/cli/commands/refresh.ts +10 -1
- package/server/cli/commands/remote.ts +228 -0
- package/server/cli/commands/skill.ts +4 -4
- package/server/cli/commands/tabs.ts +5 -12
- package/server/cli/control.ts +35 -4
- package/server/cli/index.ts +10 -6
- package/server/cli/remote-command.ts +77 -0
- package/server/cli/remote-control.ts +70 -0
- package/server/cli/remote-operations.ts +244 -0
- package/server/collab/config.ts +3 -3
- package/server/collab/skill/index.ts +3 -3
- package/server/control.ts +38 -11
- package/server/harness/acp/session.ts +4 -4
- package/server/harness/auth.ts +26 -31
- package/server/harness/claude-code/index.ts +1 -1
- package/server/harness/codex/discovery.ts +1 -1
- package/server/harness/codex/session.ts +1 -1
- package/server/harness/detect.ts +14 -19
- package/server/harness/executable.ts +10 -10
- package/server/harness/hermes/NOTES.md +2 -2
- package/server/harness/hermes/index.ts +1 -1
- package/server/harness/install.ts +11 -11
- package/server/harness/openclaw/index.ts +1 -1
- package/server/harness/registry.ts +7 -6
- package/server/harness/types.ts +4 -4
- package/server/onboarding/jobs.ts +1 -1
- package/server/operations/commands.ts +46 -0
- package/server/operations/files.ts +148 -0
- package/server/operations/server.ts +206 -0
- package/server/remote/agent.ts +103 -0
- package/server/remote/client.ts +665 -0
- package/server/remote/workspace.ts +34 -0
- package/server/scratchpad/document.ts +32 -12
- package/server/scratchpad/executor.ts +16 -7
- package/server/sessions/config.ts +8 -5
- package/server/sessions/pending-views.ts +16 -0
- package/server/sessions/view-sessions.ts +10 -12
- package/server/skills/locations.ts +4 -4
- package/server/skills/update.ts +11 -11
- package/server/skills/version.ts +7 -7
- package/server/skills/workspace.ts +13 -11
- package/server/web.ts +11 -8
- package/server/workspace-state/file.ts +2 -0
- package/server/workspace-state/index.ts +0 -4
- package/server/workspaces/api.ts +28 -0
- package/server/workspaces/change-harness.ts +15 -26
- package/server/workspaces/import.ts +4 -4
- package/server/workspaces/init.ts +15 -13
- package/server/workspaces/layout.ts +60 -66
- package/server/workspaces/registry.ts +43 -18
- package/server/workspaces/shared.ts +74 -0
- package/server/workspaces/tabs.ts +6 -12
- package/skill/SKILL.md +24 -4
- package/client/api/app-ui-keys.ts +0 -6
- package/client/features/chat/sessions/browser-tab-state.ts +0 -43
- package/client/features/collab/members/keys.ts +0 -6
- package/client/features/workspace/browser-tab-state.ts +0 -51
- package/client/features/workspace/layout-save.ts +0 -13
- package/dist/chunk-3smkkcfw.js +0 -546
- package/dist/chunk-47h9c2qy.js +0 -2
- package/dist/chunk-8qed2gqp.js +0 -75
- package/dist/chunk-8zy3vesm.js +0 -1
- package/dist/chunk-a47zy276.js +0 -2
- package/dist/chunk-g4c1nte9.css +0 -1
- package/dist/chunk-kcactdr4.js +0 -2
- package/dist/chunk-m8bhx6tw.js +0 -1
- package/dist/chunk-pf19zcrn.js +0 -2
- package/dist/chunk-ygzxah0e.js +0 -1
- package/lib/workspace-types.ts +0 -13
- package/server/workspace-state/legacy-migration.ts +0 -79
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { useEffect } from 'react'
|
|
2
2
|
import { matchQuery, useQueryClient, type QueryClient, type Query } from '@tanstack/react-query'
|
|
3
3
|
import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
|
|
4
|
-
import type { WorkspaceLayoutResponse,
|
|
4
|
+
import type { WorkspaceLayoutResponse, HarnessType } from '@/lib/types'
|
|
5
5
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
6
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
7
|
import { changeWorkspaceStateCache } from './workspace-state'
|
|
10
8
|
|
|
11
9
|
export async function receiveWorkspaceHarness(
|
|
12
10
|
queryClient: QueryClient,
|
|
13
11
|
id: string,
|
|
14
|
-
harness:
|
|
12
|
+
harness: HarnessType
|
|
15
13
|
) {
|
|
16
14
|
const cached = queryClient.getQueryData<WorkspaceLayoutResponse>(workspaceKeys.layout(id))
|
|
17
|
-
let previous = cached ? (cached.
|
|
15
|
+
let previous = cached ? (cached.harness ?? 'claude-code') : undefined
|
|
18
16
|
try {
|
|
19
17
|
const key = `moi:workspace-harness:${id}`
|
|
20
|
-
previous = (sessionStorage.getItem(key) as
|
|
18
|
+
previous = (sessionStorage.getItem(key) as HarnessType | null) ?? previous
|
|
21
19
|
sessionStorage.setItem(key, harness)
|
|
22
20
|
} catch {
|
|
23
21
|
/* Cached layout still detects live changes when storage is unavailable. */
|
|
@@ -44,16 +42,12 @@ export async function receiveWorkspaceHarness(
|
|
|
44
42
|
previous
|
|
45
43
|
? {
|
|
46
44
|
...previous,
|
|
47
|
-
|
|
48
|
-
selectedModel: undefined,
|
|
49
|
-
selectedEffort: undefined,
|
|
50
|
-
selectedSpeedMode: undefined
|
|
45
|
+
harness
|
|
51
46
|
}
|
|
52
47
|
: previous
|
|
53
48
|
)
|
|
54
|
-
writeSelectedSession(id, { selected: {} })
|
|
55
|
-
queryClient.setQueryData(browserTabSelectionKey(id), { selected: {} })
|
|
56
49
|
changeWorkspaceStateCache(queryClient, id, state => {
|
|
50
|
+
state.chatDefaults = {}
|
|
57
51
|
state.selected = {}
|
|
58
52
|
delete state.pinnedSessionId
|
|
59
53
|
})
|
|
@@ -74,7 +68,7 @@ export async function receiveWorkspaceHarness(
|
|
|
74
68
|
])
|
|
75
69
|
}
|
|
76
70
|
|
|
77
|
-
export function useWorkspaceHarnessChanges(id: string, harness:
|
|
71
|
+
export function useWorkspaceHarnessChanges(id: string, harness: HarnessType | null) {
|
|
78
72
|
const queryClient = useQueryClient()
|
|
79
73
|
useEffect(() => {
|
|
80
74
|
if (harness) void receiveWorkspaceHarness(queryClient, id, harness)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { queryClient as appQueryClient } from '@/client/api/query-client'
|
|
2
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
3
|
+
import type { QueryClient } from '@tanstack/react-query'
|
|
4
|
+
import type { WorkspaceLayoutResponse } from '@/lib/types'
|
|
5
|
+
|
|
6
|
+
// Non-React consumers read the same workspace info that the loader gives to context.
|
|
7
|
+
const workspaceInfo = (localId: string, client: QueryClient) =>
|
|
8
|
+
client.getQueryData<WorkspaceLayoutResponse>(workspaceKeys.layout(localId))
|
|
9
|
+
|
|
10
|
+
export function isRemoteWorkspace(localId: string, client: QueryClient = appQueryClient) {
|
|
11
|
+
return workspaceInfo(localId, client)?.isRemote ?? false
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function getWorkspaceApiBase(localId: string, client: QueryClient = appQueryClient): string {
|
|
15
|
+
const apiBase = workspaceInfo(localId, client)?.apiBase
|
|
16
|
+
if (!apiBase) throw new Error('Workspace identity is not loaded')
|
|
17
|
+
return apiBase
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// `workspaceId`, or `ownerId:workspaceId` for a workspace on someone else's machine.
|
|
21
|
+
// Until the info loads, a workspace is taken to be the account's own.
|
|
22
|
+
export function getWorkspaceAddress(localId: string, client: QueryClient = appQueryClient) {
|
|
23
|
+
const apiBase = workspaceInfo(localId, client)?.apiBase
|
|
24
|
+
return apiBase ? decodeURIComponent(apiBase.slice('/api/workspaces/'.length)) : localId
|
|
25
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-layout-context'
|
|
1
2
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
2
3
|
import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
3
4
|
import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
|
|
@@ -32,14 +33,11 @@ export function useUpdateEnv(workspaceId: string) {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export function useSaveWorkspaceName(workspaceId: string) {
|
|
36
|
+
const { apiBase } = useWorkspaceLayoutCtx()
|
|
35
37
|
const queryClient = useQueryClient()
|
|
36
38
|
return useMutation<void, Error, string | null>({
|
|
37
39
|
mutationFn: name =>
|
|
38
|
-
requestVoid(
|
|
39
|
-
`/api/workspaces/${workspaceId}/config`,
|
|
40
|
-
jsonRequest('PUT', { name }),
|
|
41
|
-
'Failed to save name'
|
|
42
|
-
),
|
|
40
|
+
requestVoid(`${apiBase}/config`, jsonRequest('PUT', { name }), 'Failed to save name'),
|
|
43
41
|
onSuccess: () => {
|
|
44
42
|
queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(workspaceId) })
|
|
45
43
|
queryClient.invalidateQueries({ queryKey: workspaceKeys.all })
|
|
@@ -53,6 +51,7 @@ type WorkspaceIconMutation =
|
|
|
53
51
|
| { kind: 'reset' }
|
|
54
52
|
|
|
55
53
|
export function useUpdateWorkspaceIcon(workspaceId: string) {
|
|
54
|
+
const { apiBase } = useWorkspaceLayoutCtx()
|
|
56
55
|
const queryClient = useQueryClient()
|
|
57
56
|
const mutationKey = ['workspace-icon', workspaceId]
|
|
58
57
|
return useMutation<void, Error, WorkspaceIconMutation>({
|
|
@@ -61,21 +60,17 @@ export function useUpdateWorkspaceIcon(workspaceId: string) {
|
|
|
61
60
|
mutationFn: async update => {
|
|
62
61
|
if (update.kind === 'set') {
|
|
63
62
|
await requestVoid(
|
|
64
|
-
|
|
63
|
+
`${apiBase}/config`,
|
|
65
64
|
jsonRequest('PUT', { icon: update.icon, origin: BROWSER_TAB_ID }),
|
|
66
65
|
'Failed to save icon'
|
|
67
66
|
)
|
|
68
67
|
return
|
|
69
68
|
}
|
|
70
69
|
if (update.kind === 'reset') {
|
|
71
|
-
await requestVoid(
|
|
72
|
-
`/api/workspaces/${workspaceId}/icon`,
|
|
73
|
-
{ method: 'DELETE' },
|
|
74
|
-
'Failed to reset icon'
|
|
75
|
-
)
|
|
70
|
+
await requestVoid(`${apiBase}/icon`, { method: 'DELETE' }, 'Failed to reset icon')
|
|
76
71
|
return
|
|
77
72
|
}
|
|
78
|
-
await requestJson(
|
|
73
|
+
await requestJson(`${apiBase}/icon`, {
|
|
79
74
|
method: 'PUT',
|
|
80
75
|
headers: { 'Content-Type': update.file.type || 'application/octet-stream' },
|
|
81
76
|
body: update.file
|
|
@@ -90,16 +90,16 @@ function ConnectorsState({ children }: ConnectorsStateProps) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
export function ConnectorsSettings() {
|
|
93
|
-
const { workspaceId,
|
|
93
|
+
const { workspaceId, harness } = useWorkspaceLayoutCtx()
|
|
94
94
|
const connectors = useWorkspaceMcp(workspaceId, true)
|
|
95
95
|
|
|
96
96
|
return (
|
|
97
97
|
<SettingsPage
|
|
98
98
|
title="Connectors"
|
|
99
99
|
description={
|
|
100
|
-
|
|
100
|
+
harness === 'codex'
|
|
101
101
|
? 'Manage your connectors in the ChatGPT app'
|
|
102
|
-
:
|
|
102
|
+
: harness === 'claude-code'
|
|
103
103
|
? 'Manage your connectors in the Claude app'
|
|
104
104
|
: 'Manage your connectors in your agent’s settings'
|
|
105
105
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IconChevronDown, IconLoader2 } from '@tabler/icons-react'
|
|
2
2
|
import { useLocation } from 'wouter'
|
|
3
3
|
|
|
4
|
-
import { useAppConfig } from '@/client/api/app-config'
|
|
4
|
+
import { homePath, useAppConfig } from '@/client/api/app-config'
|
|
5
5
|
import {
|
|
6
6
|
AlertDialog,
|
|
7
7
|
AlertDialogAction,
|
|
@@ -39,7 +39,7 @@ export function GeneralSettings() {
|
|
|
39
39
|
const label = name ?? cwd ?? 'this space'
|
|
40
40
|
|
|
41
41
|
const remove = () => {
|
|
42
|
-
removeWorkspace.mutate(workspaceId, { onSuccess: () => navigate(
|
|
42
|
+
removeWorkspace.mutate(workspaceId, { onSuccess: () => navigate(homePath()) })
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
return (
|
|
@@ -118,8 +118,8 @@ export function GeneralSettings() {
|
|
|
118
118
|
|
|
119
119
|
function WorkspaceHarnessSetting() {
|
|
120
120
|
const { demo } = useAppConfig()
|
|
121
|
-
const { workspaceId,
|
|
122
|
-
const
|
|
121
|
+
const { workspaceId, harness } = useWorkspaceLayoutCtx()
|
|
122
|
+
const current = harness ?? 'claude-code'
|
|
123
123
|
const change = useChangeWorkspaceHarness(workspaceId)
|
|
124
124
|
const active = useLive(state =>
|
|
125
125
|
Object.entries(state.activity).some(
|
|
@@ -128,7 +128,7 @@ function WorkspaceHarnessSetting() {
|
|
|
128
128
|
)
|
|
129
129
|
const reason = demo
|
|
130
130
|
? 'Changing agents is unavailable in the demo'
|
|
131
|
-
:
|
|
131
|
+
: current === 'hermes' || current === 'openclaw'
|
|
132
132
|
? 'This workspace belongs to its agent and cannot use another agent'
|
|
133
133
|
: active
|
|
134
134
|
? 'Wait for the agent to finish before changing it'
|
|
@@ -147,13 +147,13 @@ function WorkspaceHarnessSetting() {
|
|
|
147
147
|
disabled={Boolean(reason) || change.isPending}
|
|
148
148
|
aria-label="Agent"
|
|
149
149
|
>
|
|
150
|
-
<img src={harnessIcon[
|
|
151
|
-
{harnessLabel[
|
|
150
|
+
<img src={harnessIcon[current]} alt="" className="size-4 shrink-0" />
|
|
151
|
+
{harnessLabel[current]}
|
|
152
152
|
<IconChevronDown stroke={1.5} />
|
|
153
153
|
</DropdownMenuTrigger>
|
|
154
154
|
<DropdownMenuContent align="end" className="min-w-44">
|
|
155
155
|
<DropdownMenuRadioGroup
|
|
156
|
-
value={
|
|
156
|
+
value={current}
|
|
157
157
|
onValueChange={value => change.mutate(value)}
|
|
158
158
|
>
|
|
159
159
|
{(['claude-code', 'codex'] as const).map(option => (
|
|
@@ -4,7 +4,7 @@ import { harnessLabel } from '@/client/features/harness/harness-presentation'
|
|
|
4
4
|
import type { LoginHarness } from '@/client/features/harness/api'
|
|
5
5
|
|
|
6
6
|
type WorkspaceLoginStateProps = {
|
|
7
|
-
|
|
7
|
+
harness: LoginHarness
|
|
8
8
|
reason: string
|
|
9
9
|
checking: boolean
|
|
10
10
|
onRecheck: () => void
|
|
@@ -12,7 +12,7 @@ type WorkspaceLoginStateProps = {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function WorkspaceLoginState({
|
|
15
|
-
|
|
15
|
+
harness,
|
|
16
16
|
reason,
|
|
17
17
|
checking,
|
|
18
18
|
onRecheck,
|
|
@@ -20,11 +20,11 @@ export function WorkspaceLoginState({
|
|
|
20
20
|
}: WorkspaceLoginStateProps) {
|
|
21
21
|
return (
|
|
22
22
|
<HarnessLoginPanel
|
|
23
|
-
|
|
23
|
+
harness={harness}
|
|
24
24
|
onConnected={onConnected}
|
|
25
25
|
connectedContent={
|
|
26
26
|
<WorkspaceAccessState
|
|
27
|
-
name={harnessLabel[
|
|
27
|
+
name={harnessLabel[harness]}
|
|
28
28
|
reason={reason}
|
|
29
29
|
checking={checking}
|
|
30
30
|
onRecheck={onRecheck}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
|
+
import { homePath } from '@/client/api/app-config'
|
|
3
|
+
import { HttpError } from '@/client/api/http'
|
|
2
4
|
import { useLocation } from 'wouter'
|
|
3
5
|
import { IconFolderOff } from '@tabler/icons-react'
|
|
4
6
|
|
|
5
|
-
import {
|
|
7
|
+
import { harnessIcon } from '@/client/components/shared/workspace-icon'
|
|
6
8
|
import { Button } from '@/client/components/ui/button'
|
|
7
9
|
import { Spinner } from '@/client/components/ui/spinner'
|
|
8
10
|
import { useRemoveWorkspace } from '@/client/features/home/api'
|
|
9
|
-
import type { HarnessAvailability,
|
|
11
|
+
import type { HarnessAvailability, HarnessType } from '@/lib/types'
|
|
10
12
|
|
|
11
13
|
type RecoveryRetryProps = {
|
|
12
14
|
retrying: boolean
|
|
@@ -37,7 +39,7 @@ export function WorkspaceMissingState({ workspaceId }: WorkspaceMissingStateProp
|
|
|
37
39
|
<Button
|
|
38
40
|
variant="secondary"
|
|
39
41
|
disabled={remove.isPending}
|
|
40
|
-
onClick={() => remove.mutate(workspaceId, { onSuccess: () => navigate(
|
|
42
|
+
onClick={() => remove.mutate(workspaceId, { onSuccess: () => navigate(homePath()) })}
|
|
41
43
|
>
|
|
42
44
|
{remove.isPending ? 'Deleting workspace…' : 'Delete workspace'}
|
|
43
45
|
</Button>
|
|
@@ -51,12 +53,12 @@ export function WorkspaceMissingState({ workspaceId }: WorkspaceMissingStateProp
|
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
type HarnessUnavailableStateProps = RecoveryRetryProps & {
|
|
54
|
-
|
|
56
|
+
harness: HarnessType
|
|
55
57
|
availability: Exclude<HarnessAvailability, { status: 'available' }>
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
export function HarnessUnavailableState({
|
|
59
|
-
|
|
61
|
+
harness,
|
|
60
62
|
availability,
|
|
61
63
|
...retry
|
|
62
64
|
}: HarnessUnavailableStateProps) {
|
|
@@ -64,7 +66,7 @@ export function HarnessUnavailableState({
|
|
|
64
66
|
return (
|
|
65
67
|
<RecoveryMessage
|
|
66
68
|
title={needsTerminalLogin ? 'Connect your agent' : 'Your agent is unavailable'}
|
|
67
|
-
|
|
69
|
+
harness={harness}
|
|
68
70
|
{...retry}
|
|
69
71
|
>
|
|
70
72
|
{availability.reason}
|
|
@@ -87,24 +89,51 @@ export function WorkspaceLoadingState() {
|
|
|
87
89
|
)
|
|
88
90
|
}
|
|
89
91
|
|
|
92
|
+
type WorkspaceOpenErrorProps = RecoveryRetryProps & { error: Error }
|
|
93
|
+
|
|
94
|
+
export function WorkspaceOpenError({ error, retrying, onRetry }: WorkspaceOpenErrorProps) {
|
|
95
|
+
const [, navigate] = useLocation()
|
|
96
|
+
const missing = error instanceof HttpError && error.status === 404
|
|
97
|
+
return (
|
|
98
|
+
<RecoveryMessage
|
|
99
|
+
title={missing ? 'Workspace not found or you don’t have access' : 'Couldn’t open workspace'}
|
|
100
|
+
retrying={!missing && retrying}
|
|
101
|
+
onRetry={missing ? () => navigate(homePath()) : onRetry}
|
|
102
|
+
actionLabel={missing ? 'Back to home' : 'Try again'}
|
|
103
|
+
>
|
|
104
|
+
{missing ? undefined : error.message}
|
|
105
|
+
</RecoveryMessage>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
90
109
|
type RecoveryMessageProps = RecoveryRetryProps & {
|
|
91
110
|
title: string
|
|
92
|
-
|
|
93
|
-
children
|
|
111
|
+
harness?: HarnessType
|
|
112
|
+
children?: ReactNode
|
|
113
|
+
actionLabel?: string
|
|
94
114
|
}
|
|
95
115
|
|
|
96
|
-
function RecoveryMessage({
|
|
116
|
+
export function RecoveryMessage({
|
|
117
|
+
title,
|
|
118
|
+
harness,
|
|
119
|
+
children,
|
|
120
|
+
retrying,
|
|
121
|
+
onRetry,
|
|
122
|
+
actionLabel = 'Try again'
|
|
123
|
+
}: RecoveryMessageProps) {
|
|
97
124
|
return (
|
|
98
125
|
<div className="flex flex-1 items-center justify-center p-6">
|
|
99
126
|
<div className="flex w-full max-w-md flex-col gap-6">
|
|
100
|
-
{
|
|
127
|
+
{harness && <img src={harnessIcon[harness]} alt="" className="size-10 self-center" />}
|
|
101
128
|
<h1 className="text-center text-xl font-medium">{title}</h1>
|
|
102
129
|
<div role="alert" className="flex flex-col items-center gap-4">
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
130
|
+
{children && (
|
|
131
|
+
<p className="text-sm wrap-anywhere whitespace-pre-wrap text-muted-foreground">
|
|
132
|
+
{children}
|
|
133
|
+
</p>
|
|
134
|
+
)}
|
|
106
135
|
<Button variant="secondary" disabled={retrying} onClick={onRetry}>
|
|
107
|
-
|
|
136
|
+
{actionLabel}
|
|
108
137
|
</Button>
|
|
109
138
|
</div>
|
|
110
139
|
</div>
|
|
@@ -25,7 +25,7 @@ export function useWorkspaceSetup(
|
|
|
25
25
|
const workspace = useWorkspaceHarness(workspaceId)
|
|
26
26
|
const { data } = workspace
|
|
27
27
|
const status = useHarnessStatus(
|
|
28
|
-
data?.hasAuthOverrides || data?.isFolderMissing ? undefined : data?.
|
|
28
|
+
data?.hasAuthOverrides || data?.isFolderMissing ? undefined : data?.harness
|
|
29
29
|
)
|
|
30
30
|
const retry = useRetryHarnessStatus()
|
|
31
31
|
const readiness = status.isEnabled ? status : workspace
|
|
@@ -53,7 +53,7 @@ export function useWorkspaceSetup(
|
|
|
53
53
|
if (data.isFolderMissing) {
|
|
54
54
|
return <WorkspaceMissingState workspaceId={workspaceId} />
|
|
55
55
|
}
|
|
56
|
-
const {
|
|
56
|
+
const { harness } = data
|
|
57
57
|
if (availability.status === 'available') return undefined
|
|
58
58
|
if (
|
|
59
59
|
(availability.status === 'login-required' ||
|
|
@@ -61,11 +61,11 @@ export function useWorkspaceSetup(
|
|
|
61
61
|
!demo &&
|
|
62
62
|
availability.status === 'unavailable' &&
|
|
63
63
|
availability.code === 'not-installed')) &&
|
|
64
|
-
(
|
|
64
|
+
(harness === 'claude-code' || harness === 'codex')
|
|
65
65
|
) {
|
|
66
66
|
return (
|
|
67
67
|
<WorkspaceLoginState
|
|
68
|
-
|
|
68
|
+
harness={harness}
|
|
69
69
|
reason={availability.reason}
|
|
70
70
|
checking={isFetching}
|
|
71
71
|
onConnected={recheck}
|
|
@@ -75,7 +75,7 @@ export function useWorkspaceSetup(
|
|
|
75
75
|
}
|
|
76
76
|
return (
|
|
77
77
|
<HarnessUnavailableState
|
|
78
|
-
|
|
78
|
+
harness={harness}
|
|
79
79
|
availability={availability}
|
|
80
80
|
retrying={isFetching}
|
|
81
81
|
onRetry={retryStatus}
|
|
@@ -83,9 +83,9 @@ export function useWorkspaceSetup(
|
|
|
83
83
|
)
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
const welcoming = useWorkspaceWelcome(workspaceId)
|
|
86
87
|
const recovery = renderRecovery()
|
|
87
88
|
const ready = !recovery && !contentPending && !checking
|
|
88
|
-
const welcoming = useWorkspaceWelcome(workspaceId)
|
|
89
89
|
return {
|
|
90
90
|
content: welcoming ? (
|
|
91
91
|
<WorkspaceWelcomeState {...welcome} />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Pure tab-state derivation for the workspace screen. The URL is the live
|
|
2
|
-
//
|
|
3
|
-
// keeps the open set and
|
|
2
|
+
// address for the active tab (`/workspace/:id/views/<id>`, etc.); personal state
|
|
3
|
+
// keeps the open set and active tab in sync across windows. These helpers
|
|
4
4
|
// turn (URL segment + layout + what actually exists) into the rendered state.
|
|
5
5
|
import type { ViewInfo, WorkspaceTabId, WorkspaceTabsState } from '@/lib/types'
|
|
6
6
|
import { viewIdFromTab } from '@/lib/workspace-tabs'
|
|
@@ -8,7 +8,7 @@ import { toast } from '@/client/components/ui/toast'
|
|
|
8
8
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
9
9
|
import { reportAppletError } from '@/client/features/applets/applet-log'
|
|
10
10
|
import { useAppletEvent } from '@/client/features/applets/applet-runtime'
|
|
11
|
-
import { useWorkspaceTabs } from '@/client/features/workspace/
|
|
11
|
+
import { useWorkspaceTabs } from '@/client/features/workspace/workspace-preferences'
|
|
12
12
|
import { resolveActiveTab, tabAvailable } from './tab-resolution'
|
|
13
13
|
import { useWorkspaceLayoutCtx } from './workspace-layout-context'
|
|
14
14
|
import { useNavigationClient } from '@/client/runtime/use-workspace-events'
|
|
@@ -45,7 +45,7 @@ type UseWorkspaceNavigationOptions = {
|
|
|
45
45
|
|
|
46
46
|
export function useWorkspaceNavigation({ views, onOpenChat }: UseWorkspaceNavigationOptions) {
|
|
47
47
|
const queryClient = useQueryClient()
|
|
48
|
-
const { workspaceId } = useWorkspaceLayoutCtx()
|
|
48
|
+
const { workspaceId, apiBase } = useWorkspaceLayoutCtx()
|
|
49
49
|
const [tabsState, saveTabs] = useWorkspaceTabs()
|
|
50
50
|
const latest = useRef({ views, tabsState, onOpenChat })
|
|
51
51
|
useLayoutEffect(() => {
|
|
@@ -99,7 +99,7 @@ export function useWorkspaceNavigation({ views, onOpenChat }: UseWorkspaceNaviga
|
|
|
99
99
|
{ replace = false }: NavigationOptions = {},
|
|
100
100
|
controller = new AbortController()
|
|
101
101
|
) => {
|
|
102
|
-
const target = resolveUrl(href, { workspaceId, base })
|
|
102
|
+
const target = resolveUrl(href, { workspaceId, base, apiBase })
|
|
103
103
|
navigationRequest.current?.controller.abort()
|
|
104
104
|
if (!target.startsWith(prefix)) {
|
|
105
105
|
navigationRequest.current = null
|
|
@@ -130,7 +130,7 @@ export function useWorkspaceNavigation({ views, onOpenChat }: UseWorkspaceNaviga
|
|
|
130
130
|
)
|
|
131
131
|
const destinationHref =
|
|
132
132
|
destination && destination !== tab ? tabUrl(remembered, destination) : href
|
|
133
|
-
commit(resolveUrl(destinationHref, { workspaceId, base }))
|
|
133
|
+
commit(resolveUrl(destinationHref, { workspaceId, base, apiBase }))
|
|
134
134
|
if (destination) latest.current.onOpenChat()
|
|
135
135
|
return
|
|
136
136
|
}
|
|
@@ -160,6 +160,7 @@ export function useWorkspaceNavigation({ views, onOpenChat }: UseWorkspaceNaviga
|
|
|
160
160
|
prefix,
|
|
161
161
|
queryClient,
|
|
162
162
|
remembered,
|
|
163
|
+
apiBase,
|
|
163
164
|
selectLinkedChat,
|
|
164
165
|
setLocation,
|
|
165
166
|
workspaceId
|
|
@@ -211,6 +212,8 @@ export function useWorkspaceNavigation({ views, onOpenChat }: UseWorkspaceNaviga
|
|
|
211
212
|
return () => controller.abort()
|
|
212
213
|
}, [activeTab, isChatLink, navigate, path, remembered, reportError, search])
|
|
213
214
|
|
|
215
|
+
// This window follows its own URL. Saving the tab only records where a bare
|
|
216
|
+
// `/workspace/:id` lands next; other windows never move because of it.
|
|
214
217
|
useEffect(() => {
|
|
215
218
|
if (!isAvailableTab) return
|
|
216
219
|
remembered.set(activeTab, `moi:/${activeTab}${search}`)
|
|
@@ -60,7 +60,8 @@ import { composerDraftKey, draftSessionId } from '@/lib/session-drafts'
|
|
|
60
60
|
import type { CompiledView, PendingView, ViewInfo, WidgetInfo, WorkspaceTabId } from '@/lib/types'
|
|
61
61
|
import { viewIdFromTab, viewTabId } from '@/lib/workspace-tabs'
|
|
62
62
|
|
|
63
|
-
import { WorkspaceFrame,
|
|
63
|
+
import { WorkspaceFrame, useWorkspaceFrame } from './workspace-frame'
|
|
64
|
+
import { WorkspacePane } from './workspace-pane'
|
|
64
65
|
import { UnavailablePage } from './unavailable-page'
|
|
65
66
|
|
|
66
67
|
const Scratchpad = lazy(() =>
|
|
@@ -144,7 +145,7 @@ export function WorkspaceContent({ widgets, views: allViews }: WorkspaceContentP
|
|
|
144
145
|
const revealChat = useCallback(() => {
|
|
145
146
|
setFloatingChatOpen(true)
|
|
146
147
|
setChatFocusRequest(request => request + 1)
|
|
147
|
-
}, [])
|
|
148
|
+
}, [setFloatingChatOpen])
|
|
148
149
|
|
|
149
150
|
// The tab address: URL in, active tab + applet params out, plus the persisted
|
|
150
151
|
// tab state it keeps in sync. See useWorkspaceNavigation for the invariants.
|
|
@@ -247,17 +248,11 @@ export function WorkspaceContent({ widgets, views: allViews }: WorkspaceContentP
|
|
|
247
248
|
})
|
|
248
249
|
}, [allViews, setTabs, tabsState])
|
|
249
250
|
|
|
250
|
-
useEffect(() => {
|
|
251
|
-
if (mode !== 'fullscreen') {
|
|
252
|
-
setFloatingChatOpen(false)
|
|
253
|
-
}
|
|
254
|
-
}, [mode])
|
|
255
|
-
|
|
256
251
|
useEffect(() => {
|
|
257
252
|
if (!activeDraftViewId) return
|
|
258
253
|
if (mode === 'fullscreen') setFloatingChatOpen(true)
|
|
259
254
|
setChatFocusRequest(request => request + 1)
|
|
260
|
-
}, [activeDraftViewId, mode])
|
|
255
|
+
}, [activeDraftViewId, mode, setFloatingChatOpen])
|
|
261
256
|
|
|
262
257
|
const openTab = navigateToTab
|
|
263
258
|
|
|
@@ -365,6 +360,12 @@ export function WorkspaceContent({ widgets, views: allViews }: WorkspaceContentP
|
|
|
365
360
|
useAppletChatMessage({ sessionId, send, revealChat: openChat, agentAvailability })
|
|
366
361
|
useAppletChatAttachment(composerSessionId, openChat)
|
|
367
362
|
|
|
363
|
+
const onCreateView = createView
|
|
364
|
+
const onCreateWidget = () => {
|
|
365
|
+
selectSession(null)
|
|
366
|
+
openChat('Create widget')
|
|
367
|
+
}
|
|
368
|
+
|
|
368
369
|
const createItems: CreateWorkspaceTabItem[] = [
|
|
369
370
|
...(!openSet.has('scratchpad')
|
|
370
371
|
? ([
|
|
@@ -387,12 +388,16 @@ export function WorkspaceContent({ widgets, views: allViews }: WorkspaceContentP
|
|
|
387
388
|
onClick: () => openTab(tab)
|
|
388
389
|
})
|
|
389
390
|
),
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
391
|
+
...(onCreateView
|
|
392
|
+
? [
|
|
393
|
+
{
|
|
394
|
+
key: 'create-view',
|
|
395
|
+
Icon: IconBrowserPlus,
|
|
396
|
+
label: 'New view',
|
|
397
|
+
onClick: onCreateView
|
|
398
|
+
}
|
|
399
|
+
]
|
|
400
|
+
: [])
|
|
396
401
|
]
|
|
397
402
|
|
|
398
403
|
const removeViewDrawing = useCallback(() => {
|
|
@@ -466,11 +471,8 @@ export function WorkspaceContent({ widgets, views: allViews }: WorkspaceContentP
|
|
|
466
471
|
widgets={widgets}
|
|
467
472
|
views={allViews}
|
|
468
473
|
onOpenView={viewId => openTab(viewTabId(viewId))}
|
|
469
|
-
onCreateView={
|
|
470
|
-
onCreateWidget={
|
|
471
|
-
selectSession(null)
|
|
472
|
-
openChat('Create widget')
|
|
473
|
-
}}
|
|
474
|
+
onCreateView={onCreateView}
|
|
475
|
+
onCreateWidget={onCreateWidget}
|
|
474
476
|
/>
|
|
475
477
|
) : activeTab === 'scratchpad' ? (
|
|
476
478
|
<Suspense fallback={null}>
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import type { MouseEventHandler, ReactNode } from 'react'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { useUiStore } from '@/client/store/ui'
|
|
3
|
+
import { useWorkspaceUi } from './workspace-preferences'
|
|
5
4
|
import type { LayoutMode } from '@/lib/types'
|
|
6
5
|
|
|
7
6
|
import { useFitsSplitLayout } from './use-fits-split-layout'
|
|
8
|
-
import { useWorkspaceLayoutCtx } from './workspace-layout-context'
|
|
9
7
|
import { WorkspaceSplitLayout } from './workspace-split-layout'
|
|
10
8
|
|
|
11
9
|
export function useWorkspaceFrame(expanded = false) {
|
|
12
|
-
const { layout, setLayout } = useWorkspaceLayoutCtx()
|
|
13
10
|
const { ref, fits, constraints } = useFitsSplitLayout<HTMLDivElement>()
|
|
14
|
-
const
|
|
15
|
-
const
|
|
11
|
+
const [layout, setLayout] = useWorkspaceUi()
|
|
12
|
+
const chatWidth = layout.dockedChatWidth
|
|
13
|
+
const setChatWidth = (dockedChatWidth: number) => setLayout({ dockedChatWidth })
|
|
16
14
|
const mode: LayoutMode =
|
|
17
15
|
!expanded && fits && layout.layoutMode === 'split' ? 'split' : 'fullscreen'
|
|
18
16
|
const setMode = (layoutMode: LayoutMode) => setLayout({ layoutMode })
|
|
19
17
|
|
|
20
|
-
return {
|
|
18
|
+
return {
|
|
19
|
+
ref,
|
|
20
|
+
canUseSplit: fits,
|
|
21
|
+
constraints,
|
|
22
|
+
mode,
|
|
23
|
+
setMode,
|
|
24
|
+
chatWidth,
|
|
25
|
+
setChatWidth
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
type WorkspaceFrameProps = {
|
|
@@ -56,22 +62,3 @@ export function WorkspaceFrame({ frame, workspace, chat, children, onClick }: Wo
|
|
|
56
62
|
</div>
|
|
57
63
|
)
|
|
58
64
|
}
|
|
59
|
-
|
|
60
|
-
type WorkspacePaneProps = {
|
|
61
|
-
mode: LayoutMode
|
|
62
|
-
children: ReactNode
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function WorkspacePane({ mode, children }: WorkspacePaneProps) {
|
|
66
|
-
return (
|
|
67
|
-
<div
|
|
68
|
-
data-slot="workspace-pane"
|
|
69
|
-
className={cn(
|
|
70
|
-
'@container/workspace relative flex h-full min-h-0 min-w-0 flex-1 flex-col-reverse overflow-hidden bg-background shadow-md transition-[border-radius,background-color] duration-100 ease-out motion-reduce:transition-none',
|
|
71
|
-
mode === 'split' && 'rounded-xl'
|
|
72
|
-
)}
|
|
73
|
-
>
|
|
74
|
-
{children}
|
|
75
|
-
</div>
|
|
76
|
-
)
|
|
77
|
-
}
|