moi-computer 0.12.1-next.1 → 0.12.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/AGENTS.md +3 -2
- package/client/api/app-config.ts +3 -9
- package/client/api/workspace-keys.ts +2 -1
- package/client/app/app-provider.tsx +25 -0
- package/client/app/routes/workspace-route.tsx +4 -0
- package/client/app/shell/sidebar-layout.tsx +19 -13
- package/client/dev/index.html +5 -5
- package/client/features/applets/api.ts +1 -1
- package/client/features/chat/connection/chat-frames.ts +2 -2
- package/client/features/chat/sessions/api.ts +1 -1
- package/client/features/chat/use-chat.ts +1 -1
- package/client/features/collab/host-state.ts +24 -7
- package/client/features/collab/local-user.ts +1 -1
- package/client/features/collab/proxy-user.ts +4 -9
- package/client/features/demo/demo-dialog.tsx +25 -79
- package/client/features/dev/workspace-setup-preview.tsx +43 -16
- package/client/features/harness/device-login-steps.tsx +2 -2
- package/client/features/home/api.ts +29 -9
- package/client/features/home/home-page.tsx +7 -4
- package/client/features/scratchpad/scratchpad.tsx +3 -6
- package/client/features/settings/api.ts +14 -8
- package/client/features/workspace/api.ts +12 -16
- package/client/features/workspace/setup/workspace-login-state.tsx +4 -4
- package/client/features/workspace/setup/workspace-setup.tsx +2 -1
- package/client/features/workspace/workspace-content.tsx +12 -52
- package/client/features/workspace/workspace-frame.tsx +76 -0
- package/client/features/workspace/workspace-layout-context.tsx +2 -0
- package/client/features/workspace/workspace-pending-screen.tsx +26 -0
- package/client/features/workspace/workspace-screen.tsx +3 -3
- package/client/index.html +28 -9
- package/client/index.tsx +7 -2
- package/client/lib/browser-tab-id.ts +4 -0
- package/client/main.tsx +9 -6
- package/client/runtime/app-context.ts +20 -0
- package/client/runtime/use-workspace-events.ts +29 -153
- package/client/runtime/workspace-events.ts +151 -0
- package/dist/chunk-00rh9df4.js +2 -0
- package/dist/chunk-4nh7y1hq.css +1 -0
- package/dist/{chunk-jvyvwwv3.js → chunk-am4agx6v.js} +1 -1
- package/dist/chunk-hbpdv7vd.js +1 -0
- package/dist/chunk-hmka9rt5.js +2 -0
- package/dist/chunk-mjjregkn.js +10 -0
- package/dist/chunk-vt6zybej.js +2 -0
- package/dist/chunk-wbkwf6cc.js +68 -0
- package/dist/chunk-xjyfyz64.js +1 -0
- package/dist/{chunk-q0gbdts4.js → chunk-y8nbwp21.js} +71 -71
- package/dist/chunk-ysfdcew7.js +1 -0
- package/dist/index.html +29 -10
- package/lib/ids.ts +2 -2
- package/package.json +1 -1
- package/server/api/index.ts +41 -22
- package/server/applets/thumbnails.ts +8 -5
- package/server/harness/codex/thread-list.ts +4 -0
- package/server/static.ts +4 -2
- package/server/vendor.ts +23 -30
- package/server/web.ts +3 -2
- package/server/workspaces/layout.ts +11 -6
- package/dist/chunk-08ndj2rg.js +0 -2
- package/dist/chunk-2x040tmg.js +0 -68
- package/dist/chunk-3smxq0ts.js +0 -1
- package/dist/chunk-68ch5hs8.js +0 -2
- package/dist/chunk-9vg3xa81.js +0 -2
- package/dist/chunk-c2p00p9j.css +0 -1
- package/dist/chunk-cs833y9j.js +0 -1
- package/dist/chunk-nwevqe86.js +0 -10
- package/dist/chunk-y5y3kj67.js +0 -1
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-dom-client.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-dom.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-dom-client.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-dom.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom-client.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-dom-client.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-dom.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react.js +0 -0
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
1
|
+
import { queryOptions, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
2
2
|
|
|
3
3
|
import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
4
4
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
5
|
+
import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
|
|
5
6
|
import type { DiscoveredWorkspace, WorkspaceEntry, WorkspacePreview } from '@/lib/types'
|
|
6
7
|
|
|
7
8
|
export function useWorkspaces() {
|
|
8
9
|
return useQuery<WorkspaceEntry[]>({
|
|
9
10
|
queryKey: workspaceKeys.all,
|
|
10
11
|
queryFn: () => requestJson('/api/workspaces'),
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
// Live events invalidate the list on every change. This only bounds how
|
|
13
|
+
// long a missed event (socket down) can leave it wrong; route switches
|
|
14
|
+
// within the window reuse the cache.
|
|
15
|
+
staleTime: 5 * 60_000
|
|
13
16
|
})
|
|
14
17
|
}
|
|
15
18
|
|
|
19
|
+
const workspacePreviewsOptions = queryOptions({
|
|
20
|
+
queryKey: workspaceKeys.previews,
|
|
21
|
+
queryFn: () => requestJson<Record<string, WorkspacePreview>>('/api/workspaces/previews'),
|
|
22
|
+
staleTime: 60_000
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
// Every card's preview in one request. The home page starts it beside the
|
|
26
|
+
// workspace list so it doesn't wait for the cards to mount.
|
|
27
|
+
export function useWorkspacePreviews() {
|
|
28
|
+
return useQuery(workspacePreviewsOptions)
|
|
29
|
+
}
|
|
30
|
+
|
|
16
31
|
export function useWorkspacePreview(workspaceId: string) {
|
|
17
|
-
return useQuery
|
|
18
|
-
queryKey: workspaceKeys.preview(workspaceId),
|
|
19
|
-
queryFn: () => requestJson(`/api/workspaces/${workspaceId}/preview`),
|
|
20
|
-
staleTime: 60_000
|
|
21
|
-
})
|
|
32
|
+
return useQuery({ ...workspacePreviewsOptions, select: previews => previews[workspaceId] })
|
|
22
33
|
}
|
|
23
34
|
|
|
24
35
|
export function useDiscoveredWorkspaces() {
|
|
@@ -28,11 +39,18 @@ export function useDiscoveredWorkspaces() {
|
|
|
28
39
|
})
|
|
29
40
|
}
|
|
30
41
|
|
|
42
|
+
const REORDER_KEY = ['workspaces-reorder']
|
|
43
|
+
|
|
31
44
|
export function useReorderWorkspaces() {
|
|
32
45
|
const queryClient = useQueryClient()
|
|
33
46
|
return useMutation<WorkspaceEntry[], Error, string[], { previous?: WorkspaceEntry[] }>({
|
|
47
|
+
mutationKey: REORDER_KEY,
|
|
34
48
|
mutationFn: ids =>
|
|
35
|
-
requestJson(
|
|
49
|
+
requestJson(
|
|
50
|
+
'/api/workspaces/order',
|
|
51
|
+
jsonRequest('PUT', { ids, origin: BROWSER_TAB_ID }),
|
|
52
|
+
'Failed to reorder spaces'
|
|
53
|
+
),
|
|
36
54
|
onMutate: async ids => {
|
|
37
55
|
// Exact: only pause the workspace list itself — a prefix cancel would
|
|
38
56
|
// abort unrelated in-flight fetches (transcripts, widgets) that never
|
|
@@ -55,6 +73,8 @@ export function useReorderWorkspaces() {
|
|
|
55
73
|
queryClient.invalidateQueries({ queryKey: workspaceKeys.all, exact: true })
|
|
56
74
|
},
|
|
57
75
|
onSuccess: entries => {
|
|
76
|
+
// An earlier drag's response must not land over a newer optimistic order.
|
|
77
|
+
if (queryClient.isMutating({ mutationKey: REORDER_KEY }) > 1) return
|
|
58
78
|
queryClient.setQueryData(workspaceKeys.all, entries)
|
|
59
79
|
}
|
|
60
80
|
})
|
|
@@ -3,8 +3,12 @@ import { useState } from 'react'
|
|
|
3
3
|
import { IconChevronRight, IconEggCracked, IconLoader2, IconPlus } from '@tabler/icons-react'
|
|
4
4
|
import { Link, useLocation } from 'wouter'
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
useDiscoveredWorkspaces,
|
|
8
|
+
useWorkspacePreview,
|
|
9
|
+
useWorkspacePreviews,
|
|
10
|
+
useWorkspaces
|
|
11
|
+
} from './api'
|
|
8
12
|
import { CreateWorkspaceDialog } from '@/client/features/workspace/add/create-workspace-dialog'
|
|
9
13
|
import { ImportWorkspaceDialog } from '@/client/features/workspace/add/import-workspace-dialog'
|
|
10
14
|
import { DemoDialog } from '@/client/features/demo/demo-dialog'
|
|
@@ -38,6 +42,7 @@ export function HomePage() {
|
|
|
38
42
|
usePreloadWorkspaceFonts()
|
|
39
43
|
const [, navigate] = useLocation()
|
|
40
44
|
const workspacesQuery = useWorkspaces()
|
|
45
|
+
useWorkspacePreviews()
|
|
41
46
|
const discoveredQuery = useDiscoveredWorkspaces()
|
|
42
47
|
const importFlow = useWorkspaceImport({
|
|
43
48
|
onSuccess: entry => navigate(`/workspace/${entry.id}`)
|
|
@@ -170,8 +175,6 @@ type WorkspaceCardProps = {
|
|
|
170
175
|
}
|
|
171
176
|
|
|
172
177
|
function WorkspaceCard({ workspace }: WorkspaceCardProps) {
|
|
173
|
-
// Warm the shared readiness cache before the user enters this workspace.
|
|
174
|
-
useWorkspaceAgent(workspace.id)
|
|
175
178
|
const name = workspaceDisplayName(workspace)
|
|
176
179
|
const previewQuery = useWorkspacePreview(workspace.id)
|
|
177
180
|
const theme = workspace.theme ?? previewQuery.data?.theme
|
|
@@ -22,6 +22,7 @@ import 'tldraw/tldraw.css'
|
|
|
22
22
|
import { useWorkspaceId } from '@/client/features/workspace/workspace-context'
|
|
23
23
|
import { setScratchExecutor } from '@/client/features/scratchpad/scratch-executor'
|
|
24
24
|
import { persistScratchSession } from '@/client/features/scratchpad/scratch-session'
|
|
25
|
+
import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
|
|
25
26
|
import { type WorkspaceEvent, useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
|
|
26
27
|
import type { ScratchOp, ScratchOpResult } from '@/lib/types'
|
|
27
28
|
import {
|
|
@@ -32,10 +33,6 @@ import {
|
|
|
32
33
|
} from './use-scratchpad-snapshot'
|
|
33
34
|
import { ScratchStyleBar, ScratchToolbar } from './scratchpad-controls'
|
|
34
35
|
|
|
35
|
-
// Identifies this tab's writes so it can ignore the `scratchpad:updated` echo of
|
|
36
|
-
// its own save (see the MEI reload below). Per page load.
|
|
37
|
-
const ORIGIN_ID = Math.random().toString(36).slice(2)
|
|
38
|
-
|
|
39
36
|
const AUTOSAVE_MS = 500
|
|
40
37
|
|
|
41
38
|
// tldraw license key, inlined at build time from the PUBLIC_TLDRAW_LICENSE_KEY
|
|
@@ -221,7 +218,7 @@ function WorkspaceScratchpad({ workspaceId }: { workspaceId: string }) {
|
|
|
221
218
|
void fetch(`/api/workspaces/${workspaceId}/scratchpad`, {
|
|
222
219
|
method: 'PUT',
|
|
223
220
|
headers: { 'Content-Type': 'application/json' },
|
|
224
|
-
body: JSON.stringify({ document, origin:
|
|
221
|
+
body: JSON.stringify({ document, origin: BROWSER_TAB_ID })
|
|
225
222
|
}).catch(() => {})
|
|
226
223
|
}, [workspaceId])
|
|
227
224
|
|
|
@@ -233,7 +230,7 @@ function WorkspaceScratchpad({ workspaceId }: { workspaceId: string }) {
|
|
|
233
230
|
// autosave timer) so this stale tab can't save over the newer file.
|
|
234
231
|
useWorkspaceEvent((e: WorkspaceEvent) => {
|
|
235
232
|
if (e.type !== 'scratchpad:updated' || e.workspaceId !== workspaceId) return
|
|
236
|
-
if (e.origin && e.origin ===
|
|
233
|
+
if (e.origin && e.origin === BROWSER_TAB_ID) return
|
|
237
234
|
if (!editorRef.current) return
|
|
238
235
|
fetch(`/api/workspaces/${workspaceId}/scratchpad`)
|
|
239
236
|
.then(r => r.json())
|
|
@@ -4,6 +4,7 @@ import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
|
4
4
|
import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
|
|
5
5
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
6
6
|
import type { WorkspaceLayoutResponse } from '@/client/features/workspace/api'
|
|
7
|
+
import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
|
|
7
8
|
import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
|
|
8
9
|
import type { AppSettings, WorkspaceEntry, WorkspaceEnvView, WorkspaceIcon } from '@/lib/types'
|
|
9
10
|
|
|
@@ -86,13 +87,15 @@ type WorkspaceIconMutation =
|
|
|
86
87
|
|
|
87
88
|
export function useUpdateWorkspaceIcon(workspaceId: string) {
|
|
88
89
|
const queryClient = useQueryClient()
|
|
90
|
+
const mutationKey = ['workspace-icon', workspaceId]
|
|
89
91
|
return useMutation<void, Error, WorkspaceIconMutation>({
|
|
92
|
+
mutationKey,
|
|
90
93
|
scope: { id: `workspace-icon:${workspaceId}` },
|
|
91
94
|
mutationFn: async update => {
|
|
92
95
|
if (update.kind === 'set') {
|
|
93
96
|
await requestVoid(
|
|
94
97
|
`/api/workspaces/${workspaceId}/config`,
|
|
95
|
-
jsonRequest('PUT', { icon: update.icon }),
|
|
98
|
+
jsonRequest('PUT', { icon: update.icon, origin: BROWSER_TAB_ID }),
|
|
96
99
|
'Failed to save icon'
|
|
97
100
|
)
|
|
98
101
|
return
|
|
@@ -111,8 +114,13 @@ export function useUpdateWorkspaceIcon(workspaceId: string) {
|
|
|
111
114
|
body: update.file
|
|
112
115
|
})
|
|
113
116
|
},
|
|
114
|
-
onMutate: update => {
|
|
117
|
+
onMutate: async update => {
|
|
115
118
|
if (update.kind !== 'set') return
|
|
119
|
+
// Exact on the list: a prefix cancel would abort every workspace query.
|
|
120
|
+
await Promise.all([
|
|
121
|
+
queryClient.cancelQueries({ queryKey: workspaceKeys.layout(workspaceId) }),
|
|
122
|
+
queryClient.cancelQueries({ queryKey: workspaceKeys.all, exact: true })
|
|
123
|
+
])
|
|
116
124
|
const presentation = { icon: update.icon }
|
|
117
125
|
queryClient.setQueryData<WorkspaceLayoutResponse>(
|
|
118
126
|
workspaceKeys.layout(workspaceId),
|
|
@@ -124,14 +132,12 @@ export function useUpdateWorkspaceIcon(workspaceId: string) {
|
|
|
124
132
|
)
|
|
125
133
|
)
|
|
126
134
|
},
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
// Sync once the last queued change settles: refetching after an earlier
|
|
136
|
+
// one would land its icon over a newer optimistic pick.
|
|
137
|
+
onSettled: () => {
|
|
138
|
+
if (queryClient.isMutating({ mutationKey }) > 1) return
|
|
129
139
|
queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(workspaceId) })
|
|
130
140
|
queryClient.invalidateQueries({ queryKey: workspaceKeys.all, exact: true })
|
|
131
|
-
},
|
|
132
|
-
onSuccess: () => {
|
|
133
|
-
queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(workspaceId) })
|
|
134
|
-
queryClient.invalidateQueries({ queryKey: workspaceKeys.all })
|
|
135
141
|
}
|
|
136
142
|
})
|
|
137
143
|
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { useEffect } from 'react'
|
|
2
|
-
|
|
3
1
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
4
2
|
|
|
5
3
|
import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
6
4
|
import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
|
|
7
5
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
useWorkspaceEvent
|
|
11
|
-
} from '@/client/runtime/use-workspace-events'
|
|
6
|
+
import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
|
|
7
|
+
import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
|
|
12
8
|
import type {
|
|
13
9
|
WorkspaceAgent,
|
|
14
10
|
WorkspaceLayout,
|
|
@@ -39,13 +35,6 @@ export function useWorkspaceLayout(workspaceId: string) {
|
|
|
39
35
|
// focus refetches pick up model changes after a CLI update.
|
|
40
36
|
export function useWorkspaceAgent(workspaceId: string) {
|
|
41
37
|
const queryClient = useQueryClient()
|
|
42
|
-
useEffect(
|
|
43
|
-
() =>
|
|
44
|
-
onWorkspaceEventsReconnect(() => {
|
|
45
|
-
void queryClient.invalidateQueries({ queryKey: workspaceKeys.agent(workspaceId) })
|
|
46
|
-
}),
|
|
47
|
-
[queryClient, workspaceId]
|
|
48
|
-
)
|
|
49
38
|
useWorkspaceEvent(event => {
|
|
50
39
|
if (event.type === 'harness:updated' && event.workspaceId === workspaceId) {
|
|
51
40
|
queryClient.setQueryData<WorkspaceAgent>(workspaceKeys.agent(workspaceId), prev =>
|
|
@@ -62,8 +51,15 @@ export function useWorkspaceAgent(workspaceId: string) {
|
|
|
62
51
|
queryFn: async ({ signal }) => {
|
|
63
52
|
const key = workspaceKeys.agent(workspaceId)
|
|
64
53
|
const previous = queryClient.getQueryData<WorkspaceAgent>(key)
|
|
54
|
+
// `refresh=true` makes the server re-probe the CLI (three child
|
|
55
|
+
// processes, seconds) instead of answering from its 30s cache. Only
|
|
56
|
+
// worth it when the last snapshot was a failure: the user may have
|
|
57
|
+
// signed in or installed the agent since, and that is also the only
|
|
58
|
+
// state with a "check again" button. A working agent is reconfirmed
|
|
59
|
+
// from the cache.
|
|
60
|
+
const refresh = previous !== undefined && previous.availability.status !== 'available'
|
|
65
61
|
const result = await requestJson<WorkspaceAgent>(
|
|
66
|
-
`/api/workspaces/${workspaceId}/agent?refresh=true`,
|
|
62
|
+
`/api/workspaces/${workspaceId}/agent${refresh ? '?refresh=true' : ''}`,
|
|
67
63
|
{ signal }
|
|
68
64
|
)
|
|
69
65
|
// A live auth event received during this request is newer than its snapshot.
|
|
@@ -136,11 +132,11 @@ export function useSaveLayout(workspaceId: string) {
|
|
|
136
132
|
mutationFn: layout =>
|
|
137
133
|
requestVoid(
|
|
138
134
|
`/api/workspaces/${workspaceId}`,
|
|
139
|
-
jsonRequest('PUT', layout),
|
|
135
|
+
jsonRequest('PUT', { ...layout, origin: BROWSER_TAB_ID }),
|
|
140
136
|
'Failed to save layout'
|
|
141
137
|
),
|
|
142
138
|
onSuccess: () => {
|
|
143
|
-
queryClient.invalidateQueries({ queryKey: workspaceKeys.
|
|
139
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.previews })
|
|
144
140
|
}
|
|
145
141
|
})
|
|
146
142
|
}
|
|
@@ -76,7 +76,7 @@ export function WorkspaceLoginState({
|
|
|
76
76
|
<Spinner className="size-6 self-center text-muted-foreground" stroke={1.5} />
|
|
77
77
|
) : checkError ? (
|
|
78
78
|
<div role="alert" className="flex flex-col items-start gap-2">
|
|
79
|
-
<p>Could not check agent
|
|
79
|
+
<p>Could not check agent sign-in status.</p>
|
|
80
80
|
<Button
|
|
81
81
|
variant="secondary"
|
|
82
82
|
disabled={auth.isFetching}
|
|
@@ -104,8 +104,8 @@ export function WorkspaceLoginState({
|
|
|
104
104
|
<>
|
|
105
105
|
<p role="status" className="text-sm text-muted-foreground">
|
|
106
106
|
{pending.codeUrl && !waitingForBrowser
|
|
107
|
-
?
|
|
108
|
-
:
|
|
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
109
|
</p>
|
|
110
110
|
<a
|
|
111
111
|
className={buttonVariants({ variant: 'secondary' })}
|
|
@@ -113,7 +113,7 @@ export function WorkspaceLoginState({
|
|
|
113
113
|
target="_blank"
|
|
114
114
|
rel="noopener noreferrer"
|
|
115
115
|
>
|
|
116
|
-
Open
|
|
116
|
+
Open {name}
|
|
117
117
|
</a>
|
|
118
118
|
{waitingForBrowser && pending.codeUrl && (
|
|
119
119
|
<Button variant="ghost" onClick={() => setManualLogin(true)}>
|
|
@@ -36,7 +36,6 @@ import { ViewManager } from '@/client/features/views/view-manager'
|
|
|
36
36
|
import { getViewIcon, getViewLabel } from '@/client/features/views/view-presentation'
|
|
37
37
|
import { useViewActions } from '@/client/features/views/use-view-actions'
|
|
38
38
|
import { useViewDrafts } from '@/client/features/views/use-view-drafts'
|
|
39
|
-
import { useFitsSplitLayout } from '@/client/features/workspace/use-fits-split-layout'
|
|
40
39
|
import { useWorkspaceComposerState } from '@/client/features/chat/composer/use-workspace-composer-state'
|
|
41
40
|
import { resolveWorkspaceTheme } from '@/lib/themes'
|
|
42
41
|
import {
|
|
@@ -48,7 +47,6 @@ import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-lay
|
|
|
48
47
|
import { WorkspaceMenu } from '@/client/features/workspace/workspace-menu'
|
|
49
48
|
import { effectiveOpenTabs, tabAvailable } from '@/client/features/workspace/tab-resolution'
|
|
50
49
|
import { useWorkspaceNavigation } from '@/client/features/workspace/use-workspace-navigation'
|
|
51
|
-
import { cn } from '@/client/lib/cn'
|
|
52
50
|
import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
|
|
53
51
|
import { useUiStore } from '@/client/store/ui'
|
|
54
52
|
import {
|
|
@@ -58,17 +56,10 @@ import {
|
|
|
58
56
|
} from '@/client/features/workspace/workspace-tabs'
|
|
59
57
|
import { isDefaultWidget } from '@/lib/default-widgets'
|
|
60
58
|
import { composerDraftKey, draftSessionId } from '@/lib/session-drafts'
|
|
61
|
-
import type {
|
|
62
|
-
CompiledView,
|
|
63
|
-
LayoutMode,
|
|
64
|
-
PendingView,
|
|
65
|
-
ViewInfo,
|
|
66
|
-
WidgetInfo,
|
|
67
|
-
WorkspaceTabId
|
|
68
|
-
} from '@/lib/types'
|
|
59
|
+
import type { CompiledView, PendingView, ViewInfo, WidgetInfo, WorkspaceTabId } from '@/lib/types'
|
|
69
60
|
import { viewIdFromTab, viewTabId } from '@/lib/workspace-tabs'
|
|
70
61
|
|
|
71
|
-
import {
|
|
62
|
+
import { WorkspaceFrame, WorkspacePane, useWorkspaceFrame } from './workspace-frame'
|
|
72
63
|
import { UnavailablePage } from './unavailable-page'
|
|
73
64
|
|
|
74
65
|
const Scratchpad = lazy(() =>
|
|
@@ -124,20 +115,15 @@ function tabItemFor(
|
|
|
124
115
|
}
|
|
125
116
|
|
|
126
117
|
export function WorkspaceContent({ widgets, views: allViews }: WorkspaceContentProps) {
|
|
127
|
-
const { layout,
|
|
118
|
+
const { layout, workspaceId } = useWorkspaceLayoutCtx()
|
|
128
119
|
const theme = resolveWorkspaceTheme(layout.theme)
|
|
129
120
|
const viewActions = useViewActions()
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
fits: canUseSplit,
|
|
133
|
-
constraints: splitLayoutConstraints
|
|
134
|
-
} = useFitsSplitLayout<HTMLDivElement>()
|
|
121
|
+
const frame = useWorkspaceFrame()
|
|
122
|
+
const { mode, canUseSplit, setMode } = frame
|
|
135
123
|
const [widgetMode, setWidgetMode] = useState<WidgetMode>('idle')
|
|
136
124
|
const [floatingChatOpen, setFloatingChatOpen] = useState(false)
|
|
137
125
|
const [chatFocusRequest, setChatFocusRequest] = useState(0)
|
|
138
126
|
const pendingViewRefs = useRef(new Map<string, PendingViewHandle>())
|
|
139
|
-
const dockedChatWidth = useUiStore(state => state.dockedChatWidth)
|
|
140
|
-
const setDockedChatWidth = useUiStore(state => state.setDockedChatWidth)
|
|
141
127
|
const sessionActivity = useLive(state => state.activity)
|
|
142
128
|
const views = allViews.filter((view): view is CompiledView => view.status === 'compiled')
|
|
143
129
|
const pendingViews = allViews.filter((view): view is PendingView => view.status !== 'compiled')
|
|
@@ -151,9 +137,6 @@ export function WorkspaceContent({ widgets, views: allViews }: WorkspaceContentP
|
|
|
151
137
|
const hasAppletWidgets = widgets.some(widget => !isDefaultWidget(widget.id))
|
|
152
138
|
const hasWorkspaceApplets = hasAppletWidgets || views.length > 0
|
|
153
139
|
|
|
154
|
-
// Split needs enough row width; the saved mode remains the user's intent.
|
|
155
|
-
const wantsSplit = layout.layoutMode === 'split'
|
|
156
|
-
const mode: LayoutMode = wantsSplit && canUseSplit ? 'split' : 'fullscreen'
|
|
157
140
|
const revealChat = useCallback(() => {
|
|
158
141
|
setFloatingChatOpen(true)
|
|
159
142
|
setChatFocusRequest(request => request + 1)
|
|
@@ -207,10 +190,6 @@ export function WorkspaceContent({ widgets, views: allViews }: WorkspaceContentP
|
|
|
207
190
|
const openTabIds = effectiveOpenTabs(tabsState, allViews)
|
|
208
191
|
const openSet = new Set(tabsState.open)
|
|
209
192
|
|
|
210
|
-
const setMode = (m: LayoutMode) => {
|
|
211
|
-
setLayout({ layoutMode: m })
|
|
212
|
-
}
|
|
213
|
-
|
|
214
193
|
const canCloseTabs = openTabIds.length > 1
|
|
215
194
|
const tabItems = openTabIds
|
|
216
195
|
.map(tab =>
|
|
@@ -462,12 +441,7 @@ export function WorkspaceContent({ widgets, views: allViews }: WorkspaceContentP
|
|
|
462
441
|
)
|
|
463
442
|
|
|
464
443
|
const workspacePanel = (
|
|
465
|
-
<
|
|
466
|
-
className={cn(
|
|
467
|
-
'@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',
|
|
468
|
-
mode === 'split' && 'rounded-xl'
|
|
469
|
-
)}
|
|
470
|
-
>
|
|
444
|
+
<WorkspacePane mode={mode}>
|
|
471
445
|
<div className="relative flex min-h-0 flex-1">
|
|
472
446
|
<div
|
|
473
447
|
ref={annotationTargetRef}
|
|
@@ -590,30 +564,16 @@ export function WorkspaceContent({ widgets, views: allViews }: WorkspaceContentP
|
|
|
590
564
|
</Tooltip>
|
|
591
565
|
)}
|
|
592
566
|
</PanelHeader>
|
|
593
|
-
</
|
|
567
|
+
</WorkspacePane>
|
|
594
568
|
)
|
|
595
569
|
|
|
596
570
|
return (
|
|
597
|
-
<
|
|
571
|
+
<WorkspaceFrame
|
|
572
|
+
frame={frame}
|
|
573
|
+
workspace={workspacePanel}
|
|
574
|
+
chat={dockedChat}
|
|
598
575
|
onClick={onNavigationClick}
|
|
599
|
-
className="relative flex h-full min-h-0 flex-col font-sans text-foreground"
|
|
600
576
|
>
|
|
601
|
-
<div ref={rowRef} className="flex min-h-0 flex-1">
|
|
602
|
-
{canUseSplit && splitLayoutConstraints ? (
|
|
603
|
-
<WorkspaceSplitLayout
|
|
604
|
-
{...splitLayoutConstraints}
|
|
605
|
-
workspace={workspacePanel}
|
|
606
|
-
chat={dockedChat}
|
|
607
|
-
open={mode === 'split'}
|
|
608
|
-
chatWidth={dockedChatWidth}
|
|
609
|
-
onCollapse={() => setMode('fullscreen')}
|
|
610
|
-
onChatWidthChange={setDockedChatWidth}
|
|
611
|
-
/>
|
|
612
|
-
) : (
|
|
613
|
-
workspacePanel
|
|
614
|
-
)}
|
|
615
|
-
</div>
|
|
616
|
-
|
|
617
577
|
{mode === 'fullscreen' && (
|
|
618
578
|
<ChatPopup
|
|
619
579
|
agent={theme.agent}
|
|
@@ -636,6 +596,6 @@ export function WorkspaceContent({ widgets, views: allViews }: WorkspaceContentP
|
|
|
636
596
|
)}
|
|
637
597
|
</ChatPopup>
|
|
638
598
|
)}
|
|
639
|
-
</
|
|
599
|
+
</WorkspaceFrame>
|
|
640
600
|
)
|
|
641
601
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { MouseEventHandler, ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import { cn } from '@/client/lib/cn'
|
|
4
|
+
import { useUiStore } from '@/client/store/ui'
|
|
5
|
+
import type { LayoutMode } from '@/lib/types'
|
|
6
|
+
|
|
7
|
+
import { useFitsSplitLayout } from './use-fits-split-layout'
|
|
8
|
+
import { useWorkspaceLayoutCtx } from './workspace-layout-context'
|
|
9
|
+
import { WorkspaceSplitLayout } from './workspace-split-layout'
|
|
10
|
+
|
|
11
|
+
export function useWorkspaceFrame(expanded = false) {
|
|
12
|
+
const { layout, setLayout } = useWorkspaceLayoutCtx()
|
|
13
|
+
const { ref, fits, constraints } = useFitsSplitLayout<HTMLDivElement>()
|
|
14
|
+
const chatWidth = useUiStore(state => state.dockedChatWidth)
|
|
15
|
+
const setChatWidth = useUiStore(state => state.setDockedChatWidth)
|
|
16
|
+
const mode: LayoutMode =
|
|
17
|
+
!expanded && fits && layout.layoutMode === 'split' ? 'split' : 'fullscreen'
|
|
18
|
+
const setMode = (layoutMode: LayoutMode) => setLayout({ layoutMode })
|
|
19
|
+
|
|
20
|
+
return { ref, canUseSplit: fits, constraints, mode, setMode, chatWidth, setChatWidth }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type WorkspaceFrameProps = {
|
|
24
|
+
frame: ReturnType<typeof useWorkspaceFrame>
|
|
25
|
+
workspace: ReactNode
|
|
26
|
+
chat?: ReactNode
|
|
27
|
+
children?: ReactNode
|
|
28
|
+
onClick?: MouseEventHandler<HTMLDivElement>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Loading and ready content share the same pane geometry and saved chat width.
|
|
32
|
+
export function WorkspaceFrame({ frame, workspace, chat, children, onClick }: WorkspaceFrameProps) {
|
|
33
|
+
const { ref, canUseSplit, constraints, mode, setMode, chatWidth, setChatWidth } = frame
|
|
34
|
+
return (
|
|
35
|
+
<div
|
|
36
|
+
onClick={onClick}
|
|
37
|
+
className="relative flex h-full min-h-0 flex-1 flex-col font-sans text-foreground"
|
|
38
|
+
>
|
|
39
|
+
<div ref={ref} className="flex min-h-0 flex-1">
|
|
40
|
+
{canUseSplit && constraints ? (
|
|
41
|
+
<WorkspaceSplitLayout
|
|
42
|
+
{...constraints}
|
|
43
|
+
workspace={workspace}
|
|
44
|
+
chat={chat}
|
|
45
|
+
open={mode === 'split'}
|
|
46
|
+
chatWidth={chatWidth}
|
|
47
|
+
onCollapse={() => setMode('fullscreen')}
|
|
48
|
+
onChatWidthChange={setChatWidth}
|
|
49
|
+
/>
|
|
50
|
+
) : (
|
|
51
|
+
workspace
|
|
52
|
+
)}
|
|
53
|
+
</div>
|
|
54
|
+
{children}
|
|
55
|
+
</div>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type WorkspacePaneProps = {
|
|
60
|
+
mode: LayoutMode
|
|
61
|
+
children: ReactNode
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function WorkspacePane({ mode, children }: WorkspacePaneProps) {
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
data-slot="workspace-pane"
|
|
68
|
+
className={cn(
|
|
69
|
+
'@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',
|
|
70
|
+
mode === 'split' && 'rounded-xl'
|
|
71
|
+
)}
|
|
72
|
+
>
|
|
73
|
+
{children}
|
|
74
|
+
</div>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
@@ -82,6 +82,8 @@ export function WorkspaceLayoutProvider({ id, children }: WorkspaceLayoutProvide
|
|
|
82
82
|
const key = workspaceKeys.layout(id)
|
|
83
83
|
const prev = qc.getQueryData<WorkspaceLayoutResponse>(key)
|
|
84
84
|
if (!prev) return
|
|
85
|
+
// A GET already in flight would land the pre-change layout over this edit.
|
|
86
|
+
void qc.cancelQueries({ queryKey: key })
|
|
85
87
|
// Optimistic: the grid/theme reflects the change before the PUT lands.
|
|
86
88
|
const next = { ...prev, ...update }
|
|
87
89
|
qc.setQueryData<WorkspaceLayoutResponse>(key, next)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import { WorkspaceSetupPanel } from './setup/workspace-setup-panel'
|
|
4
|
+
import { WorkspaceFrame, WorkspacePane, useWorkspaceFrame } from './workspace-frame'
|
|
5
|
+
|
|
6
|
+
type WorkspacePendingScreenProps = {
|
|
7
|
+
setupRequired?: boolean
|
|
8
|
+
children: ReactNode
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function WorkspacePendingScreen({
|
|
12
|
+
setupRequired = false,
|
|
13
|
+
children
|
|
14
|
+
}: WorkspacePendingScreenProps) {
|
|
15
|
+
const frame = useWorkspaceFrame(setupRequired)
|
|
16
|
+
return (
|
|
17
|
+
<WorkspaceFrame
|
|
18
|
+
frame={frame}
|
|
19
|
+
workspace={
|
|
20
|
+
<WorkspacePane mode={frame.mode}>
|
|
21
|
+
{setupRequired ? <WorkspaceSetupPanel>{children}</WorkspaceSetupPanel> : children}
|
|
22
|
+
</WorkspacePane>
|
|
23
|
+
}
|
|
24
|
+
/>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -2,8 +2,8 @@ import type { ViewInfo, WidgetInfo } from '@/lib/types'
|
|
|
2
2
|
|
|
3
3
|
import { useWorkspaceLayoutCtx } from './workspace-layout-context'
|
|
4
4
|
import { WorkspaceContent } from './workspace-content'
|
|
5
|
-
import { WorkspaceSetupPanel } from './setup/workspace-setup-panel'
|
|
6
5
|
import { useWorkspaceSetup } from './setup/workspace-setup'
|
|
6
|
+
import { WorkspacePendingScreen } from './workspace-pending-screen'
|
|
7
7
|
|
|
8
8
|
type WorkspaceScreenProps = {
|
|
9
9
|
contentPending: boolean
|
|
@@ -13,7 +13,7 @@ type WorkspaceScreenProps = {
|
|
|
13
13
|
|
|
14
14
|
export function WorkspaceScreen({ contentPending, widgets, views }: WorkspaceScreenProps) {
|
|
15
15
|
const { layout, workspaceId, name, provider } = useWorkspaceLayoutCtx()
|
|
16
|
-
const { content, ready } = useWorkspaceSetup(workspaceId, contentPending, {
|
|
16
|
+
const { content, ready, setupRequired } = useWorkspaceSetup(workspaceId, contentPending, {
|
|
17
17
|
name: name ?? 'Workspace',
|
|
18
18
|
icon: layout.icon,
|
|
19
19
|
workspaceType: provider,
|
|
@@ -23,6 +23,6 @@ export function WorkspaceScreen({ contentPending, widgets, views }: WorkspaceScr
|
|
|
23
23
|
return ready ? (
|
|
24
24
|
<WorkspaceContent widgets={widgets} views={views} />
|
|
25
25
|
) : (
|
|
26
|
-
<
|
|
26
|
+
<WorkspacePendingScreen setupRequired={setupRequired}>{content}</WorkspacePendingScreen>
|
|
27
27
|
)
|
|
28
28
|
}
|
package/client/index.html
CHANGED
|
@@ -20,21 +20,40 @@
|
|
|
20
20
|
}
|
|
21
21
|
</style>
|
|
22
22
|
<link rel="icon" type="image/png" href="./assets/favicon.png" />
|
|
23
|
-
<!-- React is vendored locally (client/vendor/react
|
|
24
|
-
scripts/build-vendor.ts
|
|
25
|
-
runs fully offline — no CDN fetch. The
|
|
26
|
-
|
|
23
|
+
<!-- React is vendored locally (client/vendor/react/<version>, generated by
|
|
24
|
+
scripts/build-vendor.ts, which also rewrites these URLs) and served by
|
|
25
|
+
the /vendor/react route, so moi runs fully offline — no CDN fetch. The
|
|
26
|
+
version and build mode in the path let the browser cache them forever;
|
|
27
|
+
this source names the development build and scripts/build-client.ts
|
|
28
|
+
switches it to production in dist/. -->
|
|
27
29
|
<script type="importmap">
|
|
28
30
|
{
|
|
29
31
|
"imports": {
|
|
30
|
-
"react": "/vendor/react/react.js",
|
|
31
|
-
"react/jsx-runtime": "/vendor/react/react-jsx-runtime.js",
|
|
32
|
-
"react/jsx-dev-runtime": "/vendor/react/react-jsx-dev-runtime.js",
|
|
33
|
-
"react-dom": "/vendor/react/react-dom.js",
|
|
34
|
-
"react-dom/client": "/vendor/react/react-dom-client.js"
|
|
32
|
+
"react": "/vendor/react/19.2.4/development/react.js",
|
|
33
|
+
"react/jsx-runtime": "/vendor/react/19.2.4/development/react-jsx-runtime.js",
|
|
34
|
+
"react/jsx-dev-runtime": "/vendor/react/19.2.4/development/react-jsx-dev-runtime.js",
|
|
35
|
+
"react-dom": "/vendor/react/19.2.4/development/react-dom.js",
|
|
36
|
+
"react-dom/client": "/vendor/react/19.2.4/development/react-dom-client.js"
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
</script>
|
|
40
|
+
<!-- Fetch React (the wrappers and the _impl files they import) as soon as
|
|
41
|
+
the HTML is parsed, instead of two round trips later when the preload
|
|
42
|
+
script below gets to run. Must stay after the importmap: a module
|
|
43
|
+
fetch that starts before the map is parsed disables the map. -->
|
|
44
|
+
<link rel="modulepreload" href="/vendor/react/19.2.4/development/react.js" />
|
|
45
|
+
<link rel="modulepreload" href="/vendor/react/19.2.4/development/_impl/react.js" />
|
|
46
|
+
<link rel="modulepreload" href="/vendor/react/19.2.4/development/react-jsx-runtime.js" />
|
|
47
|
+
<link rel="modulepreload" href="/vendor/react/19.2.4/development/_impl/react-jsx-runtime.js" />
|
|
48
|
+
<link rel="modulepreload" href="/vendor/react/19.2.4/development/react-jsx-dev-runtime.js" />
|
|
49
|
+
<link
|
|
50
|
+
rel="modulepreload"
|
|
51
|
+
href="/vendor/react/19.2.4/development/_impl/react-jsx-dev-runtime.js"
|
|
52
|
+
/>
|
|
53
|
+
<link rel="modulepreload" href="/vendor/react/19.2.4/development/react-dom.js" />
|
|
54
|
+
<link rel="modulepreload" href="/vendor/react/19.2.4/development/_impl/react-dom.js" />
|
|
55
|
+
<link rel="modulepreload" href="/vendor/react/19.2.4/development/react-dom-client.js" />
|
|
56
|
+
<link rel="modulepreload" href="/vendor/react/19.2.4/development/_impl/react-dom-client.js" />
|
|
38
57
|
<link rel="stylesheet" href="./index.css" />
|
|
39
58
|
</head>
|
|
40
59
|
<body>
|
package/client/index.tsx
CHANGED
|
@@ -4,7 +4,11 @@ import './structured-clone-shim'
|
|
|
4
4
|
import 'blobatar/motion.css'
|
|
5
5
|
import './index.css'
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
initializeLocalUser,
|
|
9
|
+
installHostApi,
|
|
10
|
+
subscribeLocalProfileStorage
|
|
11
|
+
} from './features/collab/host-state'
|
|
8
12
|
|
|
9
13
|
import { startHmrWatchdog } from './runtime/hmr-watchdog'
|
|
10
14
|
|
|
@@ -27,6 +31,7 @@ if (import.meta.hot) {
|
|
|
27
31
|
// script runs right after this bundle and calls `window.moi.collab.publishUsers`
|
|
28
32
|
// straight away, before the async startup below has finished.
|
|
29
33
|
installHostApi()
|
|
34
|
+
subscribeLocalProfileStorage()
|
|
30
35
|
|
|
31
36
|
export async function init(el: HTMLElement) {
|
|
32
37
|
// Startup config and any proxy-verified user load in parallel with the
|
|
@@ -36,7 +41,7 @@ export async function init(el: HTMLElement) {
|
|
|
36
41
|
import('./api/app-config').then(m => m.loadAppConfig()),
|
|
37
42
|
import('./features/collab/proxy-user').then(m => m.loadProxyUser())
|
|
38
43
|
])
|
|
39
|
-
initializeLocalUser(config?.
|
|
44
|
+
initializeLocalUser(config?.environment === 'local' && !config.demo, proxyUser)
|
|
40
45
|
mount(el)
|
|
41
46
|
}
|
|
42
47
|
|