moi-computer 0.11.1-dev.1c52199 → 0.11.1-dev.be1ed10
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 +1 -2
- package/client/app/routes/WorkspaceRoute.tsx +19 -27
- package/client/features/applets/AppletMount.tsx +1 -4
- package/client/features/applets/applet-runtime.ts +2 -13
- package/client/features/chat/applet-chat-intents.ts +6 -15
- package/client/features/chat/sessions/useSelectedSession.ts +20 -64
- package/client/features/chat/useChat.ts +0 -4
- package/client/features/dev/DevIndexPage.tsx +0 -5
- package/client/features/dev/DevRoutes.tsx +1 -14
- package/client/features/views/ViewManager.tsx +1 -4
- package/client/features/views/api.ts +2 -2
- package/client/features/views/useViewBuilderActions.ts +0 -3
- package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -18
- package/client/features/workspace/WorkspaceScreen.tsx +11 -19
- package/client/features/workspace/api.ts +1 -3
- package/client/features/workspace/moi-context.ts +2 -7
- package/client/features/workspace/useWorkspaceNavigation.ts +3 -12
- package/client/index.tsx +3 -4
- package/dist/chunk-691pqsj6.js +2 -0
- package/dist/chunk-7a5nm4k9.css +1 -0
- package/dist/chunk-amb8y04y.js +1 -0
- package/dist/chunk-cf3pgy7j.js +546 -0
- package/dist/{chunk-wnmf38ta.js → chunk-mzrgr577.js} +1 -1
- package/dist/chunk-q6a0g26x.js +1 -0
- package/dist/chunk-twgdemkc.js +74 -0
- package/dist/chunk-x90k0f5c.js +2 -0
- package/dist/chunk-yq00csvd.js +2 -0
- package/dist/index.html +1 -1
- package/lib/moi-context.ts +0 -7
- package/lib/types.ts +6 -12
- package/package.json +1 -3
- package/server/api.ts +2 -23
- package/server/app-config.ts +34 -127
- package/server/applet-typecheck.ts +1 -6
- package/server/applets/build-applet.ts +0 -10
- package/server/cli.ts +12 -57
- package/server/layout.ts +3 -16
- package/server/skills-template.ts +2 -14
- package/server/web.ts +17 -62
- package/ui-components/avatar.tsx +4 -5
- package/ui-components/docs/avatar.md +5 -5
- package/client/features/collab/DevCollabIdentity.tsx +0 -170
- package/client/features/collab/DevCollabKit.tsx +0 -501
- package/client/features/collab/DevCollabPage.tsx +0 -25
- package/client/features/collab/WorkspaceCollabControls.tsx +0 -313
- package/client/features/collab/client.ts +0 -146
- package/client/features/collab/components.tsx +0 -307
- package/client/features/collab/dev-persona.ts +0 -66
- package/client/features/collab/engine.ts +0 -96
- package/client/features/collab/entry.tsx +0 -35
- package/client/features/collab/facehash-avatar.ts +0 -132
- package/client/features/collab/fake-engine.ts +0 -130
- package/client/features/collab/hooks.tsx +0 -253
- package/client/features/collab/identity.ts +0 -305
- package/client/features/collab/index.ts +0 -45
- package/client/features/collab/people.ts +0 -102
- package/client/features/collab/personal-state.ts +0 -61
- package/client/features/collab/presence-publisher.ts +0 -29
- package/client/features/collab/presence-target.ts +0 -10
- package/client/features/collab/primitives.tsx +0 -398
- package/client/features/collab/proxy-identity.ts +0 -24
- package/client/features/collab/store.ts +0 -156
- package/client/features/workspace/layout-save.ts +0 -13
- package/dist/chunk-1ftessc8.js +0 -2
- package/dist/chunk-3802vh2p.js +0 -2
- package/dist/chunk-542a2m9m.js +0 -1
- package/dist/chunk-5745d83v.js +0 -2
- package/dist/chunk-5zxdsjym.js +0 -1
- package/dist/chunk-7r4z77ry.js +0 -2
- package/dist/chunk-9cm0wjah.js +0 -79
- package/dist/chunk-cvgdm1hq.js +0 -2
- package/dist/chunk-gptm4jpd.js +0 -546
- package/dist/chunk-xaehhr1j.css +0 -1
- package/dist/chunk-xpt063fx.js +0 -1
- package/lib/collab/colors.ts +0 -24
- package/lib/collab/protocol.ts +0 -83
- package/lib/collab/types.ts +0 -63
- package/lib/experimental.ts +0 -14
- package/server/chat-selection.ts +0 -23
- package/server/collab/applet-module.ts +0 -50
- package/server/collab/cloudflare-access.ts +0 -77
- package/server/collab/config.ts +0 -18
- package/server/collab/ipc.ts +0 -10
- package/server/collab/manager.ts +0 -407
- package/server/collab/service.ts +0 -137
- package/server/collab/skill/collab-env.d.ts +0 -92
- package/server/collab/skill/index.ts +0 -59
- package/server/collab/worker.ts +0 -52
- package/workspace/.claude/skills/moi-workspace/references/COLLABORATIVE.md +0 -151
package/client/api/app-config.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useSyncExternalStore } from 'react'
|
|
2
2
|
|
|
3
3
|
import type { ClientAppConfig } from '@/lib/types'
|
|
4
|
-
import { EXPERIMENTAL_DEFAULTS } from '@/lib/experimental'
|
|
5
4
|
|
|
6
5
|
import { onWorkspaceEventsReconnect } from '@/client/runtime/useWorkspaceEvents'
|
|
7
6
|
|
|
@@ -15,7 +14,7 @@ import { requestJson } from './http'
|
|
|
15
14
|
|
|
16
15
|
const DEFAULTS: ClientAppConfig = {
|
|
17
16
|
cloudDemo: false,
|
|
18
|
-
|
|
17
|
+
experiments: [],
|
|
19
18
|
demoInstallUrl: 'https://moi.computer'
|
|
20
19
|
}
|
|
21
20
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { CollabProvider, useCollabIdentityEnabled } from '@/client/features/collab/entry'
|
|
2
1
|
import { useQueryClient } from '@tanstack/react-query'
|
|
3
2
|
|
|
4
3
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
5
|
-
import { useAppConfig } from '@/client/api/app-config'
|
|
6
4
|
import { LedLogo } from '@/client/components/shared/LedLogo'
|
|
7
5
|
import { SidebarLayout } from '@/client/app/shell/SidebarLayout'
|
|
8
6
|
import { useSelectedSession } from '@/client/features/chat/sessions/useSelectedSession'
|
|
@@ -21,24 +19,19 @@ type WorkspaceRouteProps = {
|
|
|
21
19
|
id: string
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
//
|
|
25
|
-
//
|
|
22
|
+
// The URL's tab segment is not threaded down — useWorkspaceNavigation reads it
|
|
23
|
+
// off the matched route with wouter's `useParams`.
|
|
26
24
|
export function WorkspaceRoute({ id }: WorkspaceRouteProps) {
|
|
27
|
-
const { experimental } = useAppConfig()
|
|
28
|
-
|
|
29
25
|
return (
|
|
30
26
|
<Workspace id={id}>
|
|
31
27
|
<WorkspaceLayoutProvider id={id}>
|
|
32
|
-
<
|
|
33
|
-
<WorkspaceContent id={id} />
|
|
34
|
-
</CollabProvider>
|
|
28
|
+
<WorkspaceLoader id={id} />
|
|
35
29
|
</WorkspaceLayoutProvider>
|
|
36
30
|
</Workspace>
|
|
37
31
|
)
|
|
38
32
|
}
|
|
39
33
|
|
|
40
|
-
function
|
|
41
|
-
const personal = useCollabIdentityEnabled()
|
|
34
|
+
function WorkspaceLoader({ id }: WorkspaceRouteProps) {
|
|
42
35
|
const queryClient = useQueryClient()
|
|
43
36
|
const [selectedSessionId] = useSelectedSession()
|
|
44
37
|
const { isLoading: layoutLoading } = useWorkspaceLayoutCtx()
|
|
@@ -69,21 +62,20 @@ function WorkspaceContent({ id }: WorkspaceRouteProps) {
|
|
|
69
62
|
builders.isLoading
|
|
70
63
|
|
|
71
64
|
return (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
</SidebarLayout>
|
|
65
|
+
<>
|
|
66
|
+
<SidebarLayout>
|
|
67
|
+
{fresh ? (
|
|
68
|
+
<div className="flex h-full items-center justify-center">
|
|
69
|
+
<LedLogo sprite="moi" effect="chaos" />
|
|
70
|
+
</div>
|
|
71
|
+
) : (
|
|
72
|
+
<WorkspaceScreen
|
|
73
|
+
widgets={widgets.data}
|
|
74
|
+
views={views.data ?? []}
|
|
75
|
+
builders={builders.data ?? []}
|
|
76
|
+
/>
|
|
77
|
+
)}
|
|
78
|
+
</SidebarLayout>
|
|
79
|
+
</>
|
|
88
80
|
)
|
|
89
81
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react'
|
|
2
2
|
|
|
3
|
-
import { AppletScope } from '@/client/features/collab/entry'
|
|
4
3
|
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
5
4
|
|
|
6
5
|
import { type AppletSegment, appletScope, appletStyleKey } from './applet-cache'
|
|
@@ -26,9 +25,7 @@ export function AppletMount({ segment, name, version, children }: AppletMountPro
|
|
|
26
25
|
|
|
27
26
|
return (
|
|
28
27
|
<div data-applet={appletScope(segment, name)} className="size-full">
|
|
29
|
-
|
|
30
|
-
{children}
|
|
31
|
-
</AppletScope>
|
|
28
|
+
{children}
|
|
32
29
|
</div>
|
|
33
30
|
)
|
|
34
31
|
}
|
|
@@ -14,18 +14,12 @@
|
|
|
14
14
|
// — no central handlers object assembled by the screen. Applet → host only;
|
|
15
15
|
// if a host → applet direction is ever added (`moi.on(...)`), `dispose` must
|
|
16
16
|
// also unbind those listeners or a disposed module leaks.
|
|
17
|
-
import { getAppletCollabApi } from '@/client/features/collab/entry'
|
|
18
17
|
import {
|
|
19
18
|
MAX_ATTACHMENT_LABEL_CHARS,
|
|
20
19
|
MAX_TEXT_ATTACHMENT_CHARS,
|
|
21
20
|
snapshotTextAttachment
|
|
22
21
|
} from '@/lib/moi-attachments'
|
|
23
|
-
import type {
|
|
24
|
-
AppletBridge as SharedAppletBridge,
|
|
25
|
-
AppletKind,
|
|
26
|
-
AttachmentInput,
|
|
27
|
-
AttachmentOrigin
|
|
28
|
-
} from '@/lib/types'
|
|
22
|
+
import type { AppletBridge, AppletKind, AttachmentInput, AttachmentOrigin } from '@/lib/types'
|
|
29
23
|
import { isWorkspaceAttachmentPath, MAX_UPLOAD_BYTES } from '@/lib/message-attachments'
|
|
30
24
|
import { useEffect } from 'react'
|
|
31
25
|
|
|
@@ -38,9 +32,7 @@ import { useLatestRef } from '@/client/lib/use-latest-ref'
|
|
|
38
32
|
import { isParamsRecord } from '@/lib/workspace-tabs'
|
|
39
33
|
import { resolveWorkspaceHref } from '@/lib/navigation'
|
|
40
34
|
|
|
41
|
-
export type AppletBridge
|
|
42
|
-
collab?: ReturnType<typeof getAppletCollabApi>
|
|
43
|
-
}
|
|
35
|
+
export type { AppletBridge } from '@/lib/types'
|
|
44
36
|
|
|
45
37
|
// Which applet a bridge belongs to, supplied by the host at attach time.
|
|
46
38
|
export type AppletIdentity = { kind: AppletKind; name: string }
|
|
@@ -127,9 +119,6 @@ function createRuntime(workspaceId: string) {
|
|
|
127
119
|
let alive = true
|
|
128
120
|
const source = appletSource(identity)
|
|
129
121
|
const bridge: AppletBridge = {
|
|
130
|
-
get collab() {
|
|
131
|
-
return alive ? getAppletCollabApi() : undefined
|
|
132
|
-
},
|
|
133
122
|
addChatAttachment(input) {
|
|
134
123
|
if (!alive) return
|
|
135
124
|
try {
|
|
@@ -12,9 +12,8 @@ import {
|
|
|
12
12
|
import { prepareChatAttachments, type ChatSendOptions, type PreparedAttachments } from './chat-send'
|
|
13
13
|
import { useLayoutEffect } from 'react'
|
|
14
14
|
import { useQueryClient, type QueryClient } from '@tanstack/react-query'
|
|
15
|
+
import { appUiKeys } from '@/client/api/app-ui-keys'
|
|
15
16
|
import { toast } from '@/client/components/ui/toast'
|
|
16
|
-
import { selectedSessionKey } from '@/client/features/chat/sessions/useSelectedSession'
|
|
17
|
-
import { useCollabIdentityEnabled } from '@/client/features/collab/entry'
|
|
18
17
|
import { useLatestRef } from '@/client/lib/use-latest-ref'
|
|
19
18
|
import type { SelectedSessionState } from '@/lib/types'
|
|
20
19
|
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
@@ -52,15 +51,13 @@ export function appletSendBlockedReason(availability: AgentAvailability): string
|
|
|
52
51
|
export function createAppletMessageHandler(
|
|
53
52
|
workspaceId: string,
|
|
54
53
|
queryClient: QueryClient,
|
|
55
|
-
getOptions: () => UseAppletChatMessageOptions
|
|
56
|
-
personalSelection = false
|
|
54
|
+
getOptions: () => UseAppletChatMessageOptions
|
|
57
55
|
) {
|
|
58
56
|
const pending = new Set<() => void>()
|
|
59
57
|
let disposed = false
|
|
60
58
|
const selectedSession = () =>
|
|
61
|
-
queryClient.getQueryData<SelectedSessionState>(
|
|
62
|
-
|
|
63
|
-
)?.sessionId ?? null
|
|
59
|
+
queryClient.getQueryData<SelectedSessionState>(appUiKeys.selectedSession(workspaceId))
|
|
60
|
+
?.sessionId ?? null
|
|
64
61
|
|
|
65
62
|
async function handle(event: AppletChatMessage): Promise<void> {
|
|
66
63
|
if (disposed) return
|
|
@@ -151,15 +148,9 @@ export function createAppletMessageHandler(
|
|
|
151
148
|
export function useAppletChatMessage(options: UseAppletChatMessageOptions): void {
|
|
152
149
|
const workspaceId = useWorkspaceId()
|
|
153
150
|
const queryClient = useQueryClient()
|
|
154
|
-
const personalSelection = useCollabIdentityEnabled()
|
|
155
151
|
const latest = useLatestRef(options)
|
|
156
152
|
useLayoutEffect(() => {
|
|
157
|
-
const handler = createAppletMessageHandler(
|
|
158
|
-
workspaceId,
|
|
159
|
-
queryClient,
|
|
160
|
-
() => latest.current,
|
|
161
|
-
personalSelection
|
|
162
|
-
)
|
|
153
|
+
const handler = createAppletMessageHandler(workspaceId, queryClient, () => latest.current)
|
|
163
154
|
const unsubscribe = appletRuntime(workspaceId).on('sendChatMessage', event => {
|
|
164
155
|
void handler.handle(event)
|
|
165
156
|
})
|
|
@@ -167,7 +158,7 @@ export function useAppletChatMessage(options: UseAppletChatMessageOptions): void
|
|
|
167
158
|
unsubscribe()
|
|
168
159
|
handler.dispose()
|
|
169
160
|
}
|
|
170
|
-
}, [workspaceId, queryClient, latest
|
|
161
|
+
}, [workspaceId, queryClient, latest])
|
|
171
162
|
}
|
|
172
163
|
|
|
173
164
|
export function useAppletChatAttachment(sessionId: string | null, revealChat: () => void): void {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { useCollabIdentityEnabled } from '@/client/features/collab/entry'
|
|
2
|
-
import { readPersonalSession, writePersonalSession } from '@/client/features/collab/personal-state'
|
|
3
1
|
import { useCallback, useMemo } from 'react'
|
|
4
2
|
|
|
5
3
|
import { useIsMutating, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
@@ -26,22 +24,16 @@ type SelectedSessionResult = readonly [
|
|
|
26
24
|
|
|
27
25
|
export type SelectedSessionSaveResult = 'applied' | 'conflict' | 'ignored'
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return personal ? ([...key, 'collab-tab'] as const) : key
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function selectedSessionMutationKey(workspaceId: string, personal: boolean) {
|
|
35
|
-
return [...selectedSessionKey(workspaceId, personal), 'save'] as const
|
|
27
|
+
function selectedSessionMutationKey(workspaceId: string) {
|
|
28
|
+
return [...appUiKeys.selectedSession(workspaceId), 'save'] as const
|
|
36
29
|
}
|
|
37
30
|
|
|
38
31
|
export function optimisticallySetSelectedSession(
|
|
39
32
|
queryClient: QueryClient,
|
|
40
33
|
workspaceId: string,
|
|
41
|
-
sessionId: string | null
|
|
42
|
-
personal = false
|
|
34
|
+
sessionId: string | null
|
|
43
35
|
): SaveSelectedSessionInput | null {
|
|
44
|
-
const queryKey =
|
|
36
|
+
const queryKey = appUiKeys.selectedSession(workspaceId)
|
|
45
37
|
const current = queryClient.getQueryData<SelectedSessionState>(queryKey)
|
|
46
38
|
const previousSessionId = current?.sessionId ?? null
|
|
47
39
|
if (current && previousSessionId === sessionId) return null
|
|
@@ -54,10 +46,9 @@ export function settleSelectedSessionSave(
|
|
|
54
46
|
queryClient: QueryClient,
|
|
55
47
|
workspaceId: string,
|
|
56
48
|
saved: SelectedSessionState,
|
|
57
|
-
input: SaveSelectedSessionInput
|
|
58
|
-
personal = false
|
|
49
|
+
input: SaveSelectedSessionInput
|
|
59
50
|
): SelectedSessionSaveResult {
|
|
60
|
-
const queryKey =
|
|
51
|
+
const queryKey = appUiKeys.selectedSession(workspaceId)
|
|
61
52
|
const current = queryClient.getQueryData<SelectedSessionState>(queryKey)
|
|
62
53
|
|
|
63
54
|
if (saved.sessionId !== input.sessionId && current?.sessionId !== saved.sessionId) {
|
|
@@ -89,38 +80,24 @@ export function renameSelectedSessionInCache(
|
|
|
89
80
|
from: string,
|
|
90
81
|
to: string
|
|
91
82
|
): void {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
current => (current?.sessionId === from ? { sessionId: to } : current)
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
if (readPersonalSession(workspaceId) === from) writePersonalSession(workspaceId, to)
|
|
83
|
+
queryClient.setQueryData<SelectedSessionState>(appUiKeys.selectedSession(workspaceId), current =>
|
|
84
|
+
current?.sessionId === from ? { sessionId: to } : current
|
|
85
|
+
)
|
|
99
86
|
}
|
|
100
87
|
|
|
101
88
|
export function useSelectedSession(): SelectedSessionResult {
|
|
102
89
|
const workspaceId = useWorkspaceId()
|
|
103
|
-
const collabEnabled = useCollabIdentityEnabled()
|
|
104
90
|
const queryClient = useQueryClient()
|
|
105
|
-
const queryKey = useMemo(
|
|
106
|
-
|
|
107
|
-
[workspaceId, collabEnabled]
|
|
108
|
-
)
|
|
109
|
-
const mutationKey = useMemo(
|
|
110
|
-
() => selectedSessionMutationKey(workspaceId, collabEnabled),
|
|
111
|
-
[workspaceId, collabEnabled]
|
|
112
|
-
)
|
|
91
|
+
const queryKey = useMemo(() => appUiKeys.selectedSession(workspaceId), [workspaceId])
|
|
92
|
+
const mutationKey = useMemo(() => selectedSessionMutationKey(workspaceId), [workspaceId])
|
|
113
93
|
const pendingSaves = useIsMutating({ mutationKey, exact: true })
|
|
114
94
|
|
|
115
|
-
//
|
|
95
|
+
// WorkspaceLoader remains an observer for the active workspace. Nested hook
|
|
116
96
|
// users reuse its result without refetching; once the route unmounts, dropping
|
|
117
97
|
// the cache makes the next visit load the server-owned selection again.
|
|
118
98
|
const query = useQuery<SelectedSessionState>({
|
|
119
99
|
queryKey,
|
|
120
|
-
queryFn: () =>
|
|
121
|
-
collabEnabled
|
|
122
|
-
? Promise.resolve({ sessionId: readPersonalSession(workspaceId) })
|
|
123
|
-
: requestJson(`/api/workspaces/${workspaceId}/selected-session`),
|
|
100
|
+
queryFn: () => requestJson(`/api/workspaces/${workspaceId}/selected-session`),
|
|
124
101
|
staleTime: Infinity,
|
|
125
102
|
gcTime: 0,
|
|
126
103
|
refetchOnMount: false,
|
|
@@ -134,25 +111,14 @@ export function useSelectedSession(): SelectedSessionResult {
|
|
|
134
111
|
>({
|
|
135
112
|
mutationKey,
|
|
136
113
|
scope: { id: `selected-session:${workspaceId}` },
|
|
137
|
-
mutationFn: input =>
|
|
138
|
-
|
|
139
|
-
writePersonalSession(workspaceId, input.sessionId)
|
|
140
|
-
return Promise.resolve({ sessionId: input.sessionId })
|
|
141
|
-
}
|
|
142
|
-
return requestJson<SelectedSessionState>(
|
|
114
|
+
mutationFn: input =>
|
|
115
|
+
requestJson(
|
|
143
116
|
`/api/workspaces/${workspaceId}/selected-session`,
|
|
144
117
|
jsonRequest('PUT', input),
|
|
145
118
|
'Couldn’t save selected chat'
|
|
146
|
-
)
|
|
147
|
-
},
|
|
119
|
+
),
|
|
148
120
|
onSuccess: (saved, input) => {
|
|
149
|
-
const result = settleSelectedSessionSave(
|
|
150
|
-
queryClient,
|
|
151
|
-
workspaceId,
|
|
152
|
-
saved,
|
|
153
|
-
input,
|
|
154
|
-
collabEnabled
|
|
155
|
-
)
|
|
121
|
+
const result = settleSelectedSessionSave(queryClient, workspaceId, saved, input)
|
|
156
122
|
if (result !== 'conflict') return
|
|
157
123
|
|
|
158
124
|
toast.add({ title: 'Couldn’t save selected chat', type: 'error' })
|
|
@@ -169,24 +135,14 @@ export function useSelectedSession(): SelectedSessionResult {
|
|
|
169
135
|
|
|
170
136
|
const setSelectedSessionId = useCallback<SetSelectedSession>(
|
|
171
137
|
sessionId => {
|
|
172
|
-
const input = optimisticallySetSelectedSession(
|
|
173
|
-
queryClient,
|
|
174
|
-
workspaceId,
|
|
175
|
-
sessionId,
|
|
176
|
-
collabEnabled
|
|
177
|
-
)
|
|
138
|
+
const input = optimisticallySetSelectedSession(queryClient, workspaceId, sessionId)
|
|
178
139
|
if (input) saveSelectedSession(input)
|
|
179
140
|
},
|
|
180
|
-
[queryClient, saveSelectedSession, workspaceId
|
|
141
|
+
[queryClient, saveSelectedSession, workspaceId]
|
|
181
142
|
)
|
|
182
143
|
|
|
183
144
|
useWorkspaceEvent(event => {
|
|
184
|
-
if (
|
|
185
|
-
collabEnabled ||
|
|
186
|
-
event.type !== 'selected-session:updated' ||
|
|
187
|
-
event.workspaceId !== workspaceId
|
|
188
|
-
)
|
|
189
|
-
return
|
|
145
|
+
if (event.type !== 'selected-session:updated' || event.workspaceId !== workspaceId) return
|
|
190
146
|
applySelectedSessionEvent(queryClient, workspaceId, event.sessionId, pendingSaves > 0)
|
|
191
147
|
})
|
|
192
148
|
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
} from '@/client/features/chat/sessions/api'
|
|
11
11
|
import { useWorkspaceAgent } from '@/client/features/workspace/api'
|
|
12
12
|
import { useSelectedSession } from '@/client/features/chat/sessions/useSelectedSession'
|
|
13
|
-
import { useCollabIdentityEnabled } from '@/client/features/collab/entry'
|
|
14
13
|
import {
|
|
15
14
|
type WorkspaceTabAddress,
|
|
16
15
|
useMoiUserMessageContext
|
|
@@ -54,7 +53,6 @@ export function useChat(address: WorkspaceTabAddress) {
|
|
|
54
53
|
const qc = useQueryClient()
|
|
55
54
|
const { layout } = useWorkspaceLayoutCtx()
|
|
56
55
|
const [selectedSession, selectSession] = useSelectedSession()
|
|
57
|
-
const personalSelection = useCollabIdentityEnabled()
|
|
58
56
|
const modelsData = useWorkspaceAgent(workspaceId).data
|
|
59
57
|
const sessions = useWorkspaceSessions(workspaceId).data
|
|
60
58
|
const selectedSessionMissing =
|
|
@@ -175,7 +173,6 @@ export function useChat(address: WorkspaceTabAddress) {
|
|
|
175
173
|
content: text,
|
|
176
174
|
sessionId: sid,
|
|
177
175
|
isNew,
|
|
178
|
-
personalSelection,
|
|
179
176
|
optimisticId,
|
|
180
177
|
model,
|
|
181
178
|
effort,
|
|
@@ -208,7 +205,6 @@ export function useChat(address: WorkspaceTabAddress) {
|
|
|
208
205
|
sessionConfig?.effort,
|
|
209
206
|
sessionConfig?.fastMode,
|
|
210
207
|
selectSession,
|
|
211
|
-
personalSelection,
|
|
212
208
|
modelsData
|
|
213
209
|
]
|
|
214
210
|
)
|
|
@@ -7,11 +7,6 @@ type DevRouteEntry = {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const DEV_ROUTES: DevRouteEntry[] = [
|
|
10
|
-
{
|
|
11
|
-
path: '/dev/collab',
|
|
12
|
-
title: 'Collab',
|
|
13
|
-
description: 'Collaboration components, live hook previews, and optional dev identity setup.'
|
|
14
|
-
},
|
|
15
10
|
{
|
|
16
11
|
path: '/dev/blobatar-shapes',
|
|
17
12
|
title: 'Blobatar shape builder',
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Redirect, Route, Switch } from 'wouter'
|
|
1
|
+
import { Route, Switch } from 'wouter'
|
|
3
2
|
|
|
4
3
|
import { ChatStatesPage } from './ChatStatesPage'
|
|
5
4
|
import { BlobatarShapesPage } from './BlobatarShapesPage'
|
|
@@ -13,21 +12,9 @@ import { UiComponentsPage } from './UiComponentsPage'
|
|
|
13
12
|
// (and its dependencies) lives in this folder and loads as one lazy chunk —
|
|
14
13
|
// see the dynamic import in AppRouter. /dev itself is the index; list new
|
|
15
14
|
// routes there too.
|
|
16
|
-
const DevCollabPage = lazy(() =>
|
|
17
|
-
import('../collab/DevCollabPage').then(module => ({ default: module.DevCollabPage }))
|
|
18
|
-
)
|
|
19
|
-
|
|
20
15
|
export default function DevRoutes() {
|
|
21
16
|
return (
|
|
22
17
|
<Switch>
|
|
23
|
-
<Route path="/dev/collab-kit">
|
|
24
|
-
<Redirect to="/dev/collab" />
|
|
25
|
-
</Route>
|
|
26
|
-
<Route path="/dev/collab">
|
|
27
|
-
<Suspense fallback={null}>
|
|
28
|
-
<DevCollabPage />
|
|
29
|
-
</Suspense>
|
|
30
|
-
</Route>
|
|
31
18
|
<Route path="/dev/harness" component={HarnessDebugPage} />
|
|
32
19
|
<Route path="/dev/blobatar-shapes" component={BlobatarShapesPage} />
|
|
33
20
|
<Route path="/dev/chat-states" component={ChatStatesPage} />
|
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
useView
|
|
26
26
|
} from '@/client/features/applets/useApplet'
|
|
27
27
|
import { WidgetErrorBoundary } from '@/client/features/applets/WidgetErrorBoundary'
|
|
28
|
-
import { AppletScope } from '@/client/features/collab/entry'
|
|
29
28
|
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
30
29
|
import { cn } from '@/client/lib/cn'
|
|
31
30
|
import { useLatestRef } from '@/client/lib/use-latest-ref'
|
|
@@ -226,9 +225,7 @@ function ViewFrame({ view, build, params, entering, thumbnailTarget }: ViewFrame
|
|
|
226
225
|
workspaceId={workspaceId}
|
|
227
226
|
resetKey={build.version}
|
|
228
227
|
>
|
|
229
|
-
<
|
|
230
|
-
<build.Component params={params} />
|
|
231
|
-
</AppletScope>
|
|
228
|
+
<build.Component params={params} />
|
|
232
229
|
</WidgetErrorBoundary>
|
|
233
230
|
</div>
|
|
234
231
|
</div>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MessageAttachment } from '@/lib/types'
|
|
1
2
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
2
3
|
|
|
3
4
|
import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
@@ -5,7 +6,7 @@ import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
|
|
|
5
6
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
6
7
|
import { APP_ICON_IDS } from '@/client/lib/app-icon-registry'
|
|
7
8
|
import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
|
|
8
|
-
import type {
|
|
9
|
+
import type { ViewBuilder, ViewInfo } from '@/lib/types'
|
|
9
10
|
|
|
10
11
|
export function useViews(workspaceId: string) {
|
|
11
12
|
return useQuery<ViewInfo[]>({
|
|
@@ -113,7 +114,6 @@ export type SubmitViewBuilderInput = {
|
|
|
113
114
|
builderId: string
|
|
114
115
|
requirements: string
|
|
115
116
|
optimisticId: string
|
|
116
|
-
personalSelection?: boolean
|
|
117
117
|
attachments?: MessageAttachment[]
|
|
118
118
|
model?: string
|
|
119
119
|
effort?: string
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
} from '@/client/features/chat/chat-send'
|
|
10
10
|
import { liveStore } from '@/client/features/chat/chat-store'
|
|
11
11
|
import { useSelectedSession } from '@/client/features/chat/sessions/useSelectedSession'
|
|
12
|
-
import { useCollabIdentityEnabled } from '@/client/features/collab/entry'
|
|
13
12
|
import { useWorkspaceAgent } from '@/client/features/workspace/api'
|
|
14
13
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
15
14
|
import {
|
|
@@ -24,7 +23,6 @@ export function useViewBuilderActions() {
|
|
|
24
23
|
const queryClient = useQueryClient()
|
|
25
24
|
const { workspaceId, layout } = useWorkspaceLayoutCtx()
|
|
26
25
|
const [, selectSession] = useSelectedSession()
|
|
27
|
-
const personalSelection = useCollabIdentityEnabled()
|
|
28
26
|
const modelData = useWorkspaceAgent(workspaceId).data
|
|
29
27
|
const createMutation = useCreateViewBuilder(workspaceId)
|
|
30
28
|
const saveMutation = useSaveViewBuilder(workspaceId)
|
|
@@ -72,7 +70,6 @@ export function useViewBuilderActions() {
|
|
|
72
70
|
builderId: builder.id,
|
|
73
71
|
requirements: text,
|
|
74
72
|
optimisticId,
|
|
75
|
-
personalSelection,
|
|
76
73
|
...(attachments.length > 0
|
|
77
74
|
? {
|
|
78
75
|
attachments: prepared.attachments
|
|
@@ -9,11 +9,9 @@ import {
|
|
|
9
9
|
} from '@/client/features/workspace/api'
|
|
10
10
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
11
11
|
import { useLatestRef } from '@/client/lib/use-latest-ref'
|
|
12
|
-
import type { WorkspaceLayout,
|
|
12
|
+
import type { WorkspaceLayout, WorkspaceType } from '@/lib/types'
|
|
13
13
|
import { createDefaultWorkspaceLayout } from '@/lib/workspace-layout'
|
|
14
14
|
|
|
15
|
-
import { accumulateLayoutSave } from './layout-save'
|
|
16
|
-
|
|
17
15
|
export type WorkspaceLayoutContextValue = {
|
|
18
16
|
// The persisted layout (widget grid, layout mode, theme). Falls back to an
|
|
19
17
|
// empty default while the query is still loading.
|
|
@@ -31,7 +29,6 @@ export type WorkspaceLayoutContextValue = {
|
|
|
31
29
|
// The workspace's registry id (the route param), so descendants can key
|
|
32
30
|
// their own queries (e.g. the model picker) without prop-drilling.
|
|
33
31
|
workspaceId: string
|
|
34
|
-
collabReference?: string
|
|
35
32
|
isLoading: boolean
|
|
36
33
|
}
|
|
37
34
|
|
|
@@ -56,14 +53,7 @@ export function useWorkspaceThemeSetting(): WorkspaceLayout['theme'] {
|
|
|
56
53
|
// Strip the server-only metadata so what we PUT back (and expose as `layout`)
|
|
57
54
|
// is just the persisted `WorkspaceLayout`.
|
|
58
55
|
function stripMeta(data: WorkspaceLayoutResponse): WorkspaceLayout {
|
|
59
|
-
const {
|
|
60
|
-
cwd: _cwd,
|
|
61
|
-
name: _name,
|
|
62
|
-
provider: _provider,
|
|
63
|
-
agentId: _agentId,
|
|
64
|
-
collabReference: _collabReference,
|
|
65
|
-
...layout
|
|
66
|
-
} = data
|
|
56
|
+
const { cwd: _cwd, name: _name, provider: _provider, agentId: _agentId, ...layout } = data
|
|
67
57
|
return layout
|
|
68
58
|
}
|
|
69
59
|
|
|
@@ -83,7 +73,6 @@ export function WorkspaceLayoutProvider({ id, children }: WorkspaceLayoutProvide
|
|
|
83
73
|
// reconcile), so reach the latest mutate via a ref instead of closing over it.
|
|
84
74
|
const saveRef = useLatestRef(save.mutate)
|
|
85
75
|
const timer = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
86
|
-
const pendingSave = useRef<WorkspaceLayoutSave | null>(null)
|
|
87
76
|
|
|
88
77
|
const setLayout = useCallback(
|
|
89
78
|
(update: Partial<WorkspaceLayout>) => {
|
|
@@ -93,7 +82,6 @@ export function WorkspaceLayoutProvider({ id, children }: WorkspaceLayoutProvide
|
|
|
93
82
|
// Optimistic: the grid/theme reflects the change before the PUT lands.
|
|
94
83
|
const next = { ...prev, ...update }
|
|
95
84
|
qc.setQueryData<WorkspaceLayoutResponse>(key, next)
|
|
96
|
-
pendingSave.current = accumulateLayoutSave(stripMeta(next), update, pendingSave.current)
|
|
97
85
|
|
|
98
86
|
if (timer.current) clearTimeout(timer.current)
|
|
99
87
|
// Persist the value captured at call time, NOT the cache at fire time: a
|
|
@@ -104,9 +92,7 @@ export function WorkspaceLayoutProvider({ id, children }: WorkspaceLayoutProvide
|
|
|
104
92
|
// optimistic write.
|
|
105
93
|
timer.current = setTimeout(() => {
|
|
106
94
|
timer.current = null
|
|
107
|
-
|
|
108
|
-
pendingSave.current = null
|
|
109
|
-
if (payload) saveRef.current(payload)
|
|
95
|
+
saveRef.current(stripMeta(next))
|
|
110
96
|
}, 600)
|
|
111
97
|
},
|
|
112
98
|
[id, qc, saveRef]
|
|
@@ -124,7 +110,6 @@ export function WorkspaceLayoutProvider({ id, children }: WorkspaceLayoutProvide
|
|
|
124
110
|
cwd: query.data?.cwd ?? null,
|
|
125
111
|
provider: query.data?.provider ?? null,
|
|
126
112
|
workspaceId: id,
|
|
127
|
-
collabReference: query.data?.collabReference,
|
|
128
113
|
isLoading: query.isLoading
|
|
129
114
|
}),
|
|
130
115
|
[query.data, query.isLoading, setLayout, id]
|
|
@@ -21,7 +21,6 @@ import type { WelcomeDestination } from '@/client/features/chat/messages/ChatEmp
|
|
|
21
21
|
import { ChatPopup } from '@/client/features/chat/ChatPopup'
|
|
22
22
|
import { ThemePanel } from '@/client/features/workspace/ThemePanel'
|
|
23
23
|
import { Overview } from '@/client/features/overview/Overview'
|
|
24
|
-
import { CollabControls } from '@/client/features/collab/entry'
|
|
25
24
|
import { PanelHeader } from '@/client/components/shared/PanelHeader'
|
|
26
25
|
import { WorkspaceIcon } from '@/client/components/shared/WorkspaceIcon'
|
|
27
26
|
import { Button } from '@/client/components/ui/button'
|
|
@@ -246,11 +245,9 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
246
245
|
// Split needs the open set to decide whether it's available at all, and the
|
|
247
246
|
// navigation hook needs split to resolve the active tab — so the open set is
|
|
248
247
|
// derived from the raw layout here, before either.
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
builders
|
|
253
|
-
).some(tab => tab !== 'agent')
|
|
248
|
+
const openTabIds = effectiveOpenTabs(normalizeTabsState(layout.tabs), views, builders)
|
|
249
|
+
const nonAgentOpenTabs = openTabIds.filter(tab => tab !== 'agent')
|
|
250
|
+
const hasWorkspaceContent = nonAgentOpenTabs.length > 0
|
|
254
251
|
const hasAppletWidgets = widgets.some(widget => !isDefaultWidget(widget.id))
|
|
255
252
|
const hasWorkspaceApplets = hasAppletWidgets || views.length > 0
|
|
256
253
|
|
|
@@ -303,8 +300,6 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
303
300
|
}
|
|
304
301
|
)
|
|
305
302
|
|
|
306
|
-
const openTabIds = effectiveOpenTabs(tabsState, views, builders)
|
|
307
|
-
const nonAgentOpenTabs = openTabIds.filter(tab => tab !== 'agent')
|
|
308
303
|
const openSet = new Set(tabsState.open)
|
|
309
304
|
|
|
310
305
|
// Entering split with the agent tab on screen needs no special-casing
|
|
@@ -363,11 +358,13 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
363
358
|
const open = tabsState.open.filter(tab => tabAvailable(tab, views, builders))
|
|
364
359
|
if (open.length === tabsState.open.length) return
|
|
365
360
|
const nextOpen = effectiveOpenTabs(tabsState, views, builders)
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
361
|
+
setLayout({
|
|
362
|
+
tabs: {
|
|
363
|
+
open: nextOpen,
|
|
364
|
+
active: nextOpen.includes(tabsState.active) ? tabsState.active : nextOpen[0]
|
|
365
|
+
}
|
|
369
366
|
})
|
|
370
|
-
}, [builders,
|
|
367
|
+
}, [builders, setLayout, tabsState, views])
|
|
371
368
|
|
|
372
369
|
useEffect(() => {
|
|
373
370
|
const replacements = new Map<WorkspaceTabId, WorkspaceTabId>()
|
|
@@ -401,8 +398,8 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
401
398
|
}
|
|
402
399
|
if (!changed) return
|
|
403
400
|
const active = replacements.get(tabsState.active) ?? tabsState.active
|
|
404
|
-
|
|
405
|
-
}, [activeTab, builders, navigateToTab,
|
|
401
|
+
setLayout({ tabs: { open: open.length > 0 ? open : ['overview'], active } })
|
|
402
|
+
}, [activeTab, builders, navigateToTab, setLayout, tabsState, views])
|
|
406
403
|
|
|
407
404
|
useEffect(() => {
|
|
408
405
|
if (mode !== 'fullscreen' || activeTab === 'agent') {
|
|
@@ -751,11 +748,6 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
751
748
|
onReorder={reorderTabs}
|
|
752
749
|
/>
|
|
753
750
|
</div>
|
|
754
|
-
<CollabControls
|
|
755
|
-
workspaceId={workspaceId}
|
|
756
|
-
describeTab={tab => tabItemFor(tab, views, builders, false, false, () => false)}
|
|
757
|
-
onOpenTab={openTab}
|
|
758
|
-
/>
|
|
759
751
|
{hasWorkspaceContent && canUseSplit && mode === 'fullscreen' && (
|
|
760
752
|
<Tooltip>
|
|
761
753
|
<TooltipTrigger
|
|
@@ -10,14 +10,12 @@ import type {
|
|
|
10
10
|
HarnessLogin,
|
|
11
11
|
WorkspaceAgent,
|
|
12
12
|
WorkspaceLayout,
|
|
13
|
-
WorkspaceLayoutSave,
|
|
14
13
|
WorkspaceSkillsStatus,
|
|
15
14
|
WorkspaceSkillsUpdateFailure,
|
|
16
15
|
WorkspaceType
|
|
17
16
|
} from '@/lib/types'
|
|
18
17
|
|
|
19
18
|
export type WorkspaceLayoutResponse = WorkspaceLayout & {
|
|
20
|
-
collabReference?: string
|
|
21
19
|
cwd: string
|
|
22
20
|
name: string
|
|
23
21
|
provider?: WorkspaceType
|
|
@@ -124,7 +122,7 @@ export function useUpdateWorkspaceSkills(workspaceId: string) {
|
|
|
124
122
|
|
|
125
123
|
export function useSaveLayout(workspaceId: string) {
|
|
126
124
|
const queryClient = useQueryClient()
|
|
127
|
-
return useMutation<void, Error,
|
|
125
|
+
return useMutation<void, Error, WorkspaceLayout>({
|
|
128
126
|
mutationFn: layout =>
|
|
129
127
|
requestVoid(
|
|
130
128
|
`/api/workspaces/${workspaceId}`,
|