moi-computer 0.12.1-next.4 → 0.13.1-next.0
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/query-client.ts +5 -0
- package/client/app/app-router.tsx +1 -1
- package/client/app/routes/workspace-route.tsx +2 -0
- package/client/features/account/account-provider.tsx +28 -77
- package/client/features/account/account-test-utils.tsx +95 -93
- package/client/features/account/api.ts +32 -109
- package/client/features/account/profile-actions.ts +31 -0
- package/client/features/app-settings/settings-page.tsx +0 -4
- package/client/features/chat/messages/tool-group/subagent-card.tsx +1 -0
- package/client/features/collab/client.ts +38 -13
- package/client/features/collab/components/user-avatar.tsx +4 -10
- package/client/features/collab/hooks.tsx +9 -8
- package/client/features/collab/host-state.ts +45 -85
- package/client/features/collab/testing/fake-engine.ts +13 -1
- package/client/features/collab/users.ts +0 -12
- package/client/features/connectors/api.ts +12 -4
- package/client/features/connectors/mcp-server-cards.tsx +17 -7
- package/client/features/connectors/read-connectors.ts +35 -0
- package/client/features/dev/cloud-avatar-upload.tsx +58 -0
- package/client/features/dev/cloud-page.tsx +363 -0
- package/client/features/dev/collab/local-user-settings.tsx +1 -1
- package/client/features/dev/dev-index-page.tsx +6 -0
- package/client/features/dev/dev-routes.tsx +2 -0
- package/client/features/identity/host-api.ts +34 -0
- package/client/features/identity/store.ts +32 -0
- package/client/features/identity/types.ts +41 -0
- package/client/features/identity/use-identity.ts +6 -0
- package/client/features/workspace/harness-transition.ts +1 -0
- package/client/features/workspace/settings/connectors-settings.tsx +31 -10
- package/client/features/workspace/settings/general-settings.tsx +17 -14
- package/client/features/workspace-members/api.ts +20 -0
- package/client/features/workspace-members/hooks.ts +127 -0
- package/client/features/workspace-members/keys.ts +6 -0
- package/client/features/workspace-members/store.ts +123 -0
- package/client/features/workspace-members/types.ts +53 -0
- package/client/index.html +1 -1
- package/client/index.tsx +5 -9
- package/client/main.tsx +2 -2
- package/dist/{chunk-71fn6rmj.js → chunk-00s35r33.js} +68 -68
- package/dist/{chunk-g0tcwqxc.js → chunk-7rz6g7g7.js} +1 -1
- package/dist/chunk-af2jyddf.js +2 -0
- package/dist/chunk-cekekc3f.css +1 -0
- package/dist/chunk-ep5vh16c.js +75 -0
- package/dist/{chunk-2y59vrxg.js → chunk-kdgk4dac.js} +1 -1
- package/dist/chunk-s5s1vzdw.js +2 -0
- package/dist/{chunk-58dyt9bk.js → chunk-svxhxfeq.js} +2 -2
- package/dist/chunk-t0r0bds1.js +1 -0
- package/dist/chunk-vp2qzc0d.js +1 -0
- package/dist/chunk-wz5qv1bn.js +2 -0
- package/dist/index.html +2 -2
- package/lib/types.ts +4 -2
- package/package.json +7 -4
- package/server/api/index.ts +26 -1
- package/server/app-config.ts +3 -1
- package/server/harness/claude-code/index.ts +3 -6
- package/server/harness/claude-code/mcp.ts +17 -0
- package/server/harness/codex/NOTES.md +9 -2
- package/server/harness/codex/client.ts +8 -5
- package/server/harness/codex/connectors.ts +92 -0
- package/server/harness/codex/index.ts +2 -1
- package/server/harness/codex/pagination.ts +8 -5
- package/server/harness/codex/transport.ts +13 -6
- package/server/harness/types.ts +4 -1
- package/server/onboarding/prompt.md +2 -2
- package/skill/references/DESIGN.md +22 -3
- package/client/features/account/identity.ts +0 -23
- package/client/features/app-settings/users-settings.tsx +0 -195
- package/dist/chunk-0mjzg20x.js +0 -2
- package/dist/chunk-5aj040e5.css +0 -1
- package/dist/chunk-7yg1m8hx.js +0 -2
- package/dist/chunk-825hys3h.js +0 -1
- package/dist/chunk-9bb8m9rx.js +0 -2
- package/dist/chunk-n0nab26d.js +0 -1
- package/dist/chunk-v88n1bay.js +0 -74
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { Link } from 'wouter'
|
|
3
|
+
import { IconArrowLeft, IconMail, IconUserPlus } from '@tabler/icons-react'
|
|
4
|
+
import { Button } from '@/client/components/ui/button'
|
|
5
|
+
import { Input } from '@/client/components/ui/input'
|
|
6
|
+
import { Skeleton } from '@/client/components/ui/skeleton'
|
|
7
|
+
import { Alert, AlertDescription } from '@/ui-components/alert'
|
|
8
|
+
import { Badge } from '@/ui-components/badge'
|
|
9
|
+
import {
|
|
10
|
+
AlertDialog,
|
|
11
|
+
AlertDialogAction,
|
|
12
|
+
AlertDialogCancel,
|
|
13
|
+
AlertDialogContent,
|
|
14
|
+
AlertDialogDescription,
|
|
15
|
+
AlertDialogFooter,
|
|
16
|
+
AlertDialogHeader,
|
|
17
|
+
AlertDialogTitle
|
|
18
|
+
} from '@/ui-components/alert-dialog'
|
|
19
|
+
import {
|
|
20
|
+
Select,
|
|
21
|
+
SelectContent,
|
|
22
|
+
SelectItem,
|
|
23
|
+
SelectTrigger,
|
|
24
|
+
SelectValue
|
|
25
|
+
} from '@/ui-components/select'
|
|
26
|
+
import { useAppConfig } from '@/client/api/app-config'
|
|
27
|
+
import { UserAvatar } from '../collab/components/user-avatar'
|
|
28
|
+
import { normalizeUserProfile } from '../collab/host-state'
|
|
29
|
+
import { collabIdentityId } from '../identity/types'
|
|
30
|
+
import { useIdentity } from '../identity/use-identity'
|
|
31
|
+
import { useWorkspaces } from '../home/api'
|
|
32
|
+
import {
|
|
33
|
+
useWorkspaceMembers,
|
|
34
|
+
useInviteMember,
|
|
35
|
+
useRemoveMember,
|
|
36
|
+
useRevokeInvitation
|
|
37
|
+
} from '../workspace-members/hooks'
|
|
38
|
+
import type { WorkspaceMember } from '../workspace-members/types'
|
|
39
|
+
import { CloudAvatarUpload } from './cloud-avatar-upload'
|
|
40
|
+
|
|
41
|
+
export function CloudPage() {
|
|
42
|
+
const { environment } = useAppConfig()
|
|
43
|
+
if (environment !== 'cloud')
|
|
44
|
+
return (
|
|
45
|
+
<main className="mx-auto max-w-xl space-y-4 px-6 py-10 text-sm">
|
|
46
|
+
<h1 className="text-xl font-medium">Share workspace</h1>
|
|
47
|
+
<p className="text-muted-foreground">
|
|
48
|
+
Workspace sharing is available when you sign in to Moi Run
|
|
49
|
+
</p>
|
|
50
|
+
<Button variant="outline" nativeButton={false} render={<Link href="/" />}>
|
|
51
|
+
Back to workspaces
|
|
52
|
+
</Button>
|
|
53
|
+
</main>
|
|
54
|
+
)
|
|
55
|
+
return <WorkspaceSharing />
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function WorkspaceSharing() {
|
|
59
|
+
const workspaces = useWorkspaces()
|
|
60
|
+
const [selected, setSelected] = useState<string>()
|
|
61
|
+
const workspace = workspaces.data?.find(item => item.id === selected) ?? workspaces.data?.[0]
|
|
62
|
+
const name = workspace?.name || 'Workspace'
|
|
63
|
+
return (
|
|
64
|
+
<main className="mx-auto flex max-w-xl flex-col gap-8 px-5 py-8 text-sm sm:px-6 sm:py-12">
|
|
65
|
+
<header className="space-y-5">
|
|
66
|
+
<Button
|
|
67
|
+
variant="ghost"
|
|
68
|
+
size="sm"
|
|
69
|
+
className="-ml-2 w-fit"
|
|
70
|
+
nativeButton={false}
|
|
71
|
+
render={<Link href="/" />}
|
|
72
|
+
>
|
|
73
|
+
<IconArrowLeft stroke={1.75} /> Workspaces
|
|
74
|
+
</Button>
|
|
75
|
+
<div className="space-y-2">
|
|
76
|
+
<h1 className="text-xl font-medium">Share workspace</h1>
|
|
77
|
+
<p className="text-muted-foreground">Invite people to work alongside you</p>
|
|
78
|
+
</div>
|
|
79
|
+
</header>
|
|
80
|
+
<section className="space-y-2" aria-label="Choose workspace">
|
|
81
|
+
<label className="font-medium" id="sharing-workspace-label">
|
|
82
|
+
Workspace
|
|
83
|
+
</label>
|
|
84
|
+
{workspaces.isError ? (
|
|
85
|
+
<Alert variant="destructive">
|
|
86
|
+
<AlertDescription>{workspaces.error.message}</AlertDescription>
|
|
87
|
+
</Alert>
|
|
88
|
+
) : workspaces.isPending ? (
|
|
89
|
+
<Skeleton className="h-10 w-full" />
|
|
90
|
+
) : !workspace ? (
|
|
91
|
+
<p className="text-muted-foreground">Create a workspace to invite people</p>
|
|
92
|
+
) : (
|
|
93
|
+
<Select value={workspace.id} onValueChange={value => setSelected(value ?? undefined)}>
|
|
94
|
+
<SelectTrigger className="w-full" aria-labelledby="sharing-workspace-label">
|
|
95
|
+
<SelectValue>{name}</SelectValue>
|
|
96
|
+
</SelectTrigger>
|
|
97
|
+
<SelectContent align="start">
|
|
98
|
+
{workspaces.data.map(item => (
|
|
99
|
+
<SelectItem key={item.id} value={item.id}>
|
|
100
|
+
{item.name || 'Workspace'}
|
|
101
|
+
</SelectItem>
|
|
102
|
+
))}
|
|
103
|
+
</SelectContent>
|
|
104
|
+
</Select>
|
|
105
|
+
)}
|
|
106
|
+
</section>
|
|
107
|
+
{workspace && (
|
|
108
|
+
<SharingMembers key={workspace.id} workspaceId={workspace.id} workspaceName={name} />
|
|
109
|
+
)}
|
|
110
|
+
</main>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
type SharingMembersProps = { workspaceId: string; workspaceName: string }
|
|
115
|
+
type Removal =
|
|
116
|
+
| { type: 'member'; id: string; name: string }
|
|
117
|
+
| { type: 'invitation'; id: string; email: string }
|
|
118
|
+
function SharingMembers({ workspaceId, workspaceName }: SharingMembersProps) {
|
|
119
|
+
const identity = useIdentity()
|
|
120
|
+
const snapshot = useWorkspaceMembers(workspaceId)
|
|
121
|
+
const invite = useInviteMember(workspaceId)
|
|
122
|
+
const remove = useRemoveMember(workspaceId)
|
|
123
|
+
const revoke = useRevokeInvitation(workspaceId)
|
|
124
|
+
const [email, setEmail] = useState('')
|
|
125
|
+
const [removal, setRemoval] = useState<Removal>()
|
|
126
|
+
const [notice, setNotice] = useState<string>()
|
|
127
|
+
const removing = remove.isPending || revoke.isPending
|
|
128
|
+
const removalError = remove.error ?? revoke.error
|
|
129
|
+
async function sendInvitation() {
|
|
130
|
+
setNotice(undefined)
|
|
131
|
+
try {
|
|
132
|
+
await invite.mutateAsync({ email })
|
|
133
|
+
setEmail('')
|
|
134
|
+
setNotice(`Invitation sent to ${email.trim().toLowerCase()}`)
|
|
135
|
+
} catch {
|
|
136
|
+
/* Keep the address so the invitation can be retried. */
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function chooseRemoval(next: Removal) {
|
|
140
|
+
remove.reset()
|
|
141
|
+
revoke.reset()
|
|
142
|
+
setRemoval(next)
|
|
143
|
+
}
|
|
144
|
+
async function confirmRemoval() {
|
|
145
|
+
if (!removal) return
|
|
146
|
+
try {
|
|
147
|
+
if (removal.type === 'member') await remove.mutateAsync({ membershipId: removal.id })
|
|
148
|
+
else await revoke.mutateAsync({ invitationId: removal.id })
|
|
149
|
+
setNotice(removal.type === 'member' ? 'Member removed' : 'Invitation revoked')
|
|
150
|
+
setRemoval(undefined)
|
|
151
|
+
} catch {
|
|
152
|
+
/* The dialog keeps the error visible and allows retry. */
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const inviteError = invite.error ?? snapshot.error
|
|
156
|
+
return (
|
|
157
|
+
<>
|
|
158
|
+
<section className="space-y-3" aria-labelledby="invite-heading">
|
|
159
|
+
<h2 className="font-medium" id="invite-heading">
|
|
160
|
+
Invite someone
|
|
161
|
+
</h2>
|
|
162
|
+
<form
|
|
163
|
+
className="flex flex-col gap-2 sm:flex-row"
|
|
164
|
+
onSubmit={event => {
|
|
165
|
+
event.preventDefault()
|
|
166
|
+
void sendInvitation()
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
169
|
+
<Input
|
|
170
|
+
type="email"
|
|
171
|
+
required
|
|
172
|
+
aria-label="Email address"
|
|
173
|
+
placeholder="Email address"
|
|
174
|
+
autoComplete="email"
|
|
175
|
+
value={email}
|
|
176
|
+
className="min-w-0 flex-1"
|
|
177
|
+
onChange={event => {
|
|
178
|
+
setEmail(event.target.value)
|
|
179
|
+
setNotice(undefined)
|
|
180
|
+
}}
|
|
181
|
+
disabled={invite.isPending || !snapshot.data}
|
|
182
|
+
/>
|
|
183
|
+
<Button type="submit" disabled={invite.isPending || !snapshot.data || !email.trim()}>
|
|
184
|
+
<IconUserPlus stroke={1.5} /> {invite.isPending ? 'Sending…' : 'Send invite'}
|
|
185
|
+
</Button>
|
|
186
|
+
</form>
|
|
187
|
+
<p className="text-muted-foreground">
|
|
188
|
+
Members can view and edit everything in this workspace
|
|
189
|
+
</p>
|
|
190
|
+
{notice && <p role="status">{notice}</p>}
|
|
191
|
+
{inviteError && (
|
|
192
|
+
<Alert variant="destructive">
|
|
193
|
+
<AlertDescription>{inviteError.message}</AlertDescription>
|
|
194
|
+
</Alert>
|
|
195
|
+
)}
|
|
196
|
+
{snapshot.isError && (
|
|
197
|
+
<Button size="sm" variant="outline" onClick={() => void snapshot.refetch()}>
|
|
198
|
+
Try again
|
|
199
|
+
</Button>
|
|
200
|
+
)}
|
|
201
|
+
</section>
|
|
202
|
+
<section aria-labelledby="members-heading" className="space-y-3">
|
|
203
|
+
<h2 id="members-heading" className="flex items-center gap-2 font-medium">
|
|
204
|
+
Members{' '}
|
|
205
|
+
{snapshot.members && (
|
|
206
|
+
<span className="font-normal text-muted-foreground">{snapshot.members.length}</span>
|
|
207
|
+
)}
|
|
208
|
+
</h2>
|
|
209
|
+
{snapshot.isPending ? (
|
|
210
|
+
<div className="space-y-4" aria-label="Loading members">
|
|
211
|
+
{[0, 1].map(row => (
|
|
212
|
+
<div key={row} className="flex items-center gap-3">
|
|
213
|
+
<Skeleton className="size-8 rounded-full" />
|
|
214
|
+
<Skeleton className="h-4 w-40" />
|
|
215
|
+
</div>
|
|
216
|
+
))}
|
|
217
|
+
</div>
|
|
218
|
+
) : (
|
|
219
|
+
<ul className="divide-y divide-border">
|
|
220
|
+
{snapshot.members?.map(member => {
|
|
221
|
+
const isMe = identity?.type === member.type && identity.id === member.id
|
|
222
|
+
const displayName = member.name || (member.type === 'user' ? member.email : 'Agent')
|
|
223
|
+
return (
|
|
224
|
+
<li
|
|
225
|
+
key={`${member.type}:${member.id}`}
|
|
226
|
+
className="flex min-w-0 items-center gap-3 py-3"
|
|
227
|
+
>
|
|
228
|
+
{isMe && identity?.type === 'user' ? (
|
|
229
|
+
<CloudAvatarUpload>
|
|
230
|
+
<MemberAvatar member={{ ...member, ...identity }} />
|
|
231
|
+
</CloudAvatarUpload>
|
|
232
|
+
) : (
|
|
233
|
+
<MemberAvatar member={member} />
|
|
234
|
+
)}
|
|
235
|
+
<div className="min-w-0 flex-1">
|
|
236
|
+
<p className="truncate font-medium">
|
|
237
|
+
{displayName}
|
|
238
|
+
{isMe && <span className="font-normal text-muted-foreground"> (you)</span>}
|
|
239
|
+
</p>
|
|
240
|
+
{member.type === 'user' && (
|
|
241
|
+
<p className="truncate text-muted-foreground">{member.email}</p>
|
|
242
|
+
)}
|
|
243
|
+
{member.type === 'agent' && <p className="text-muted-foreground">Agent</p>}
|
|
244
|
+
</div>
|
|
245
|
+
{!member.membershipId ? (
|
|
246
|
+
<Badge variant="secondary">Owner</Badge>
|
|
247
|
+
) : (
|
|
248
|
+
<Button
|
|
249
|
+
size="sm"
|
|
250
|
+
variant="ghost"
|
|
251
|
+
onClick={() =>
|
|
252
|
+
chooseRemoval({
|
|
253
|
+
type: 'member',
|
|
254
|
+
id: member.membershipId!,
|
|
255
|
+
name: displayName
|
|
256
|
+
})
|
|
257
|
+
}
|
|
258
|
+
>
|
|
259
|
+
Remove
|
|
260
|
+
</Button>
|
|
261
|
+
)}
|
|
262
|
+
</li>
|
|
263
|
+
)
|
|
264
|
+
})}
|
|
265
|
+
</ul>
|
|
266
|
+
)}
|
|
267
|
+
</section>
|
|
268
|
+
{!!snapshot.invitations?.length && (
|
|
269
|
+
<section aria-labelledby="invitations-heading" className="space-y-3">
|
|
270
|
+
<h2 id="invitations-heading" className="flex items-center gap-2 font-medium">
|
|
271
|
+
Pending invitations{' '}
|
|
272
|
+
<span className="font-normal text-muted-foreground">{snapshot.invitations.length}</span>
|
|
273
|
+
</h2>
|
|
274
|
+
<ul className="divide-y divide-border">
|
|
275
|
+
{snapshot.invitations.map(invitation => (
|
|
276
|
+
<li key={invitation.id} className="flex min-w-0 items-center gap-3 py-3">
|
|
277
|
+
<span className="flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground">
|
|
278
|
+
<IconMail size={16} stroke={1.75} />
|
|
279
|
+
</span>
|
|
280
|
+
<div className="min-w-0 flex-1">
|
|
281
|
+
<p className="truncate font-medium">{invitation.email}</p>
|
|
282
|
+
<p className="text-muted-foreground">
|
|
283
|
+
{invitation.pending
|
|
284
|
+
? 'Sending invitation…'
|
|
285
|
+
: `Invited · Expires ${new Date(invitation.expiresAt).toLocaleDateString(undefined, { month: 'short', day: 'numeric' })}`}
|
|
286
|
+
</p>
|
|
287
|
+
</div>
|
|
288
|
+
{!invitation.pending && (
|
|
289
|
+
<Button
|
|
290
|
+
size="sm"
|
|
291
|
+
variant="ghost"
|
|
292
|
+
onClick={() =>
|
|
293
|
+
chooseRemoval({
|
|
294
|
+
type: 'invitation',
|
|
295
|
+
id: invitation.id,
|
|
296
|
+
email: invitation.email
|
|
297
|
+
})
|
|
298
|
+
}
|
|
299
|
+
>
|
|
300
|
+
Revoke
|
|
301
|
+
</Button>
|
|
302
|
+
)}
|
|
303
|
+
</li>
|
|
304
|
+
))}
|
|
305
|
+
</ul>
|
|
306
|
+
</section>
|
|
307
|
+
)}
|
|
308
|
+
<AlertDialog
|
|
309
|
+
open={!!removal}
|
|
310
|
+
onOpenChange={open => {
|
|
311
|
+
if (!open && !removing) setRemoval(undefined)
|
|
312
|
+
}}
|
|
313
|
+
>
|
|
314
|
+
<AlertDialogContent>
|
|
315
|
+
<AlertDialogHeader>
|
|
316
|
+
<AlertDialogTitle>
|
|
317
|
+
{removal?.type === 'member' ? `Remove ${removal.name}?` : 'Revoke invitation?'}
|
|
318
|
+
</AlertDialogTitle>
|
|
319
|
+
<AlertDialogDescription>
|
|
320
|
+
{removal?.type === 'member'
|
|
321
|
+
? `They’ll lose access to ${workspaceName}. You can invite them again later.`
|
|
322
|
+
: `The invitation for ${removal?.email ?? ''} will no longer work.`}
|
|
323
|
+
</AlertDialogDescription>
|
|
324
|
+
</AlertDialogHeader>
|
|
325
|
+
{removalError && (
|
|
326
|
+
<Alert variant="destructive">
|
|
327
|
+
<AlertDescription>{removalError.message}</AlertDescription>
|
|
328
|
+
</Alert>
|
|
329
|
+
)}
|
|
330
|
+
<AlertDialogFooter>
|
|
331
|
+
<AlertDialogCancel disabled={removing}>Cancel</AlertDialogCancel>
|
|
332
|
+
<AlertDialogAction
|
|
333
|
+
variant="destructive"
|
|
334
|
+
disabled={removing}
|
|
335
|
+
onClick={() => void confirmRemoval()}
|
|
336
|
+
>
|
|
337
|
+
{removing
|
|
338
|
+
? 'Saving…'
|
|
339
|
+
: removal?.type === 'member'
|
|
340
|
+
? 'Remove member'
|
|
341
|
+
: 'Revoke invitation'}
|
|
342
|
+
</AlertDialogAction>
|
|
343
|
+
</AlertDialogFooter>
|
|
344
|
+
</AlertDialogContent>
|
|
345
|
+
</AlertDialog>
|
|
346
|
+
</>
|
|
347
|
+
)
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
type MemberAvatarProps = { member: WorkspaceMember }
|
|
351
|
+
function MemberAvatar({ member }: MemberAvatarProps) {
|
|
352
|
+
return (
|
|
353
|
+
<UserAvatar
|
|
354
|
+
profile={normalizeUserProfile({
|
|
355
|
+
id: collabIdentityId(member),
|
|
356
|
+
name: member.name || undefined,
|
|
357
|
+
avatar: member.avatar,
|
|
358
|
+
email: member.type === 'user' ? member.email : undefined
|
|
359
|
+
})}
|
|
360
|
+
size="default"
|
|
361
|
+
/>
|
|
362
|
+
)
|
|
363
|
+
}
|
|
@@ -65,7 +65,7 @@ function LocalUserEditor({ profile }: LocalUserEditorProps) {
|
|
|
65
65
|
Local user
|
|
66
66
|
</h2>
|
|
67
67
|
<p className="mt-1 text-sm text-muted-foreground">
|
|
68
|
-
Change your
|
|
68
|
+
Change your collaboration color here. Edit your name in Settings.
|
|
69
69
|
</p>
|
|
70
70
|
</header>
|
|
71
71
|
<div className="flex flex-col gap-5">
|
|
@@ -7,6 +7,12 @@ type DevRouteEntry = {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const DEV_ROUTES: DevRouteEntry[] = [
|
|
10
|
+
{
|
|
11
|
+
path: '/dev/cloud',
|
|
12
|
+
title: 'Workspace sharing',
|
|
13
|
+
description:
|
|
14
|
+
'Inspect identity and workspace members, update your profile, and test invitations.'
|
|
15
|
+
},
|
|
10
16
|
{
|
|
11
17
|
path: '/dev/onboarding',
|
|
12
18
|
title: 'Onboarding ideas',
|
|
@@ -10,6 +10,7 @@ import { TextureLabPage } from './texture-lab-page'
|
|
|
10
10
|
import { ToolCallsPage } from './tool-calls-page'
|
|
11
11
|
import { UiComponentsPage } from './ui-components/ui-components-page'
|
|
12
12
|
import { OnboardingPreviewPage } from './onboarding-preview-page'
|
|
13
|
+
import { CloudPage } from './cloud-page'
|
|
13
14
|
|
|
14
15
|
// All /dev/* routes live with their pages here and load only in development;
|
|
15
16
|
// see the dynamic import in AppRouter. /dev itself is the index; list new
|
|
@@ -21,6 +22,7 @@ const CollabPage = lazy(() =>
|
|
|
21
22
|
export default function DevRoutes() {
|
|
22
23
|
return (
|
|
23
24
|
<Switch>
|
|
25
|
+
<Route path="/dev/cloud" component={CloudPage} />
|
|
24
26
|
<Route path="/dev/onboarding" component={OnboardingPreviewPage} />
|
|
25
27
|
<Route path="/dev/collab-kit">
|
|
26
28
|
<Redirect to="/dev/collab" />
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { setIdentity, getIdentityRevision } from './store'
|
|
2
|
+
import {
|
|
3
|
+
setWorkspaceMembers,
|
|
4
|
+
setAllWorkspaceMembers,
|
|
5
|
+
removeWorkspaceMembers,
|
|
6
|
+
clearWorkspaceMembers,
|
|
7
|
+
getWorkspaceMembersRevision
|
|
8
|
+
} from '../workspace-members/store'
|
|
9
|
+
import type { Identity } from './types'
|
|
10
|
+
import type { WorkspaceMembers, WorkspaceMembersSnapshot } from '../workspace-members/types'
|
|
11
|
+
|
|
12
|
+
export type IdentityHostApi = {
|
|
13
|
+
identity: { set: (identity: Identity | null) => void; getRevision: () => number }
|
|
14
|
+
workspaceMembers: {
|
|
15
|
+
set: (workspaceId: string, data: WorkspaceMembers) => void
|
|
16
|
+
setAll: (workspaces: WorkspaceMembersSnapshot[]) => void
|
|
17
|
+
remove: (workspaceId: string) => void
|
|
18
|
+
clear: () => void
|
|
19
|
+
getRevision: () => number
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function installIdentityHostApi() {
|
|
23
|
+
if (typeof window === 'undefined') return
|
|
24
|
+
const host = window as Window & { moi?: Partial<IdentityHostApi> & Record<string, unknown> }
|
|
25
|
+
host.moi ??= {}
|
|
26
|
+
host.moi.identity = { set: setIdentity, getRevision: getIdentityRevision }
|
|
27
|
+
host.moi.workspaceMembers = {
|
|
28
|
+
set: setWorkspaceMembers,
|
|
29
|
+
setAll: setAllWorkspaceMembers,
|
|
30
|
+
remove: removeWorkspaceMembers,
|
|
31
|
+
clear: clearWorkspaceMembers,
|
|
32
|
+
getRevision: getWorkspaceMembersRevision
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { queryClient } from '@/client/api/query-client'
|
|
2
|
+
import { memberKeys } from '../workspace-members/keys'
|
|
3
|
+
import { identityKey, parseIdentity } from './types'
|
|
4
|
+
import type { Identity } from './types'
|
|
5
|
+
|
|
6
|
+
let current: Identity | null | undefined
|
|
7
|
+
// Changes only when the account changes; guards requests from a previous account.
|
|
8
|
+
let accountGeneration = 0
|
|
9
|
+
// Changes on every identity write; guards against older profile responses.
|
|
10
|
+
let identityRevision = 0
|
|
11
|
+
const listeners = new Set<() => void>()
|
|
12
|
+
export const getIdentity = () => current
|
|
13
|
+
export const getIdentityRevision = () => identityRevision
|
|
14
|
+
export const getAccountGeneration = () => accountGeneration
|
|
15
|
+
export function subscribeIdentity(listener: () => void) {
|
|
16
|
+
listeners.add(listener)
|
|
17
|
+
return () => {
|
|
18
|
+
listeners.delete(listener)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function setIdentity(value: Identity | null): void {
|
|
22
|
+
const next = value === null ? null : parseIdentity(value)
|
|
23
|
+
const changedAccount = (current && identityKey(current)) !== (next && identityKey(next))
|
|
24
|
+
if (changedAccount) {
|
|
25
|
+
accountGeneration++
|
|
26
|
+
void queryClient.cancelQueries({ queryKey: memberKeys.all })
|
|
27
|
+
queryClient.removeQueries({ queryKey: memberKeys.all })
|
|
28
|
+
}
|
|
29
|
+
identityRevision++
|
|
30
|
+
current = next
|
|
31
|
+
listeners.forEach(listener => listener())
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isRecord } from '@/lib/collab/protocol'
|
|
2
|
+
|
|
3
|
+
export type Identity =
|
|
4
|
+
| { id: string; type: 'user'; name: string; email: string; avatar?: string; isAnonymous: boolean }
|
|
5
|
+
| { id: string; type: 'agent'; name: string; avatar?: string }
|
|
6
|
+
|
|
7
|
+
function text(value: unknown, max: number): value is string {
|
|
8
|
+
return typeof value === 'string' && value.length <= max && !value.includes('\0')
|
|
9
|
+
}
|
|
10
|
+
function isAvatar(value: unknown): value is string {
|
|
11
|
+
if (!text(value, 2048)) return false
|
|
12
|
+
try {
|
|
13
|
+
return ['http:', 'https:'].includes(new URL(value).protocol)
|
|
14
|
+
} catch {
|
|
15
|
+
return false
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function parseIdentity(value: unknown): Identity {
|
|
19
|
+
if (
|
|
20
|
+
!isRecord(value) ||
|
|
21
|
+
!text(value.id, 240) ||
|
|
22
|
+
!value.id.trim() ||
|
|
23
|
+
value.id !== value.id.trim() ||
|
|
24
|
+
!text(value.name, 256) ||
|
|
25
|
+
(value.avatar !== undefined && !isAvatar(value.avatar))
|
|
26
|
+
)
|
|
27
|
+
throw new Error('Invalid identity')
|
|
28
|
+
const common = {
|
|
29
|
+
id: value.id,
|
|
30
|
+
name: value.name,
|
|
31
|
+
...(value.avatar !== undefined ? { avatar: value.avatar } : {})
|
|
32
|
+
}
|
|
33
|
+
if (value.type === 'agent') return { ...common, type: 'agent' }
|
|
34
|
+
if (value.type === 'user' && text(value.email, 320) && typeof value.isAnonymous === 'boolean')
|
|
35
|
+
return { ...common, type: 'user', email: value.email, isAnonymous: value.isAnonymous }
|
|
36
|
+
throw new Error('Invalid identity')
|
|
37
|
+
}
|
|
38
|
+
export const identityKey = (identity: Identity) => `${identity.type}:${identity.id}`
|
|
39
|
+
// Existing human collaboration ids stay compatible; agent ids cannot collide.
|
|
40
|
+
export const collabIdentityId = (identity: Identity) =>
|
|
41
|
+
identity.type === 'agent' ? `agent:${identity.id}` : identity.id
|
|
@@ -39,6 +39,7 @@ export async function receiveWorkspaceHarness(
|
|
|
39
39
|
await queryClient.cancelQueries(affected)
|
|
40
40
|
// Discard the old provider snapshot before rendering the new harness status.
|
|
41
41
|
void queryClient.resetQueries({ queryKey: workspaceKeys.harness(id), exact: true })
|
|
42
|
+
void queryClient.resetQueries({ queryKey: workspaceKeys.mcp(id), exact: true })
|
|
42
43
|
queryClient.setQueryData<WorkspaceLayoutResponse>(workspaceKeys.layout(id), previous =>
|
|
43
44
|
previous
|
|
44
45
|
? {
|
|
@@ -33,7 +33,7 @@ function ConnectorsContent({ connectors }: ConnectorsContentProps) {
|
|
|
33
33
|
)
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
if (connectors.isError) {
|
|
36
|
+
if (connectors.isError && !connectors.data?.length) {
|
|
37
37
|
return (
|
|
38
38
|
<ConnectorsState>
|
|
39
39
|
<p className="text-sm text-muted-foreground">Could not load connectors</p>
|
|
@@ -44,7 +44,7 @@ function ConnectorsContent({ connectors }: ConnectorsContentProps) {
|
|
|
44
44
|
)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
if (connectors.data.length === 0) {
|
|
47
|
+
if (connectors.data.length === 0 && !connectors.isFetching) {
|
|
48
48
|
return (
|
|
49
49
|
<ConnectorsState>
|
|
50
50
|
<IconPlugConnected size={24} stroke={1.5} className="text-muted-foreground" />
|
|
@@ -54,11 +54,26 @@ function ConnectorsContent({ connectors }: ConnectorsContentProps) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
return (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
<>
|
|
58
|
+
<McpServerGrid>
|
|
59
|
+
{sortMcpServers(connectors.data).map(connector => (
|
|
60
|
+
<McpServerCard key={connector.name} server={connector} />
|
|
61
|
+
))}
|
|
62
|
+
</McpServerGrid>
|
|
63
|
+
{connectors.isFetching && (
|
|
64
|
+
<p role="status" className="text-sm text-muted-foreground">
|
|
65
|
+
Loading connectors…
|
|
66
|
+
</p>
|
|
67
|
+
)}
|
|
68
|
+
{connectors.isError && (
|
|
69
|
+
<ConnectorsState>
|
|
70
|
+
<p className="text-sm text-muted-foreground">Couldn’t load all connectors</p>
|
|
71
|
+
<Button variant="outline" size="sm" onClick={() => connectors.refetch()}>
|
|
72
|
+
Retry
|
|
73
|
+
</Button>
|
|
74
|
+
</ConnectorsState>
|
|
75
|
+
)}
|
|
76
|
+
</>
|
|
62
77
|
)
|
|
63
78
|
}
|
|
64
79
|
|
|
@@ -68,20 +83,26 @@ type ConnectorsStateProps = {
|
|
|
68
83
|
|
|
69
84
|
function ConnectorsState({ children }: ConnectorsStateProps) {
|
|
70
85
|
return (
|
|
71
|
-
<div className="flex min-h-48 flex-col items-center justify-center gap-3
|
|
86
|
+
<div className="flex min-h-48 flex-col items-center justify-center gap-3 px-8 py-12 text-center">
|
|
72
87
|
{children}
|
|
73
88
|
</div>
|
|
74
89
|
)
|
|
75
90
|
}
|
|
76
91
|
|
|
77
92
|
export function ConnectorsSettings() {
|
|
78
|
-
const { workspaceId } = useWorkspaceLayoutCtx()
|
|
93
|
+
const { workspaceId, provider } = useWorkspaceLayoutCtx()
|
|
79
94
|
const connectors = useWorkspaceMcp(workspaceId, true)
|
|
80
95
|
|
|
81
96
|
return (
|
|
82
97
|
<SettingsPage
|
|
83
98
|
title="Connectors"
|
|
84
|
-
description=
|
|
99
|
+
description={
|
|
100
|
+
provider === 'codex'
|
|
101
|
+
? 'Manage your connectors in the ChatGPT app'
|
|
102
|
+
: provider === 'claude-code'
|
|
103
|
+
? 'Manage your connectors in the Claude app'
|
|
104
|
+
: 'Manage your connectors in your agent’s settings'
|
|
105
|
+
}
|
|
85
106
|
>
|
|
86
107
|
<ConnectorsContent connectors={connectors} />
|
|
87
108
|
</SettingsPage>
|
|
@@ -32,7 +32,7 @@ import { useChangeWorkspaceHarness } from '@/client/features/workspace/api'
|
|
|
32
32
|
import { SettingsPage, SettingsRow, SettingsSection } from './settings-layout'
|
|
33
33
|
|
|
34
34
|
export function GeneralSettings() {
|
|
35
|
-
const { demo } = useAppConfig()
|
|
35
|
+
const { demo, environment } = useAppConfig()
|
|
36
36
|
const { name, cwd, workspaceId } = useWorkspaceLayoutCtx()
|
|
37
37
|
const [, navigate] = useLocation()
|
|
38
38
|
const removeWorkspace = useRemoveWorkspace()
|
|
@@ -45,18 +45,20 @@ export function GeneralSettings() {
|
|
|
45
45
|
return (
|
|
46
46
|
<SettingsPage title="General" description="Basic details for this space">
|
|
47
47
|
<SettingsSection>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
{environment === 'local' && (
|
|
49
|
+
<SettingsRow
|
|
50
|
+
title="Path"
|
|
51
|
+
control={
|
|
52
|
+
<Input
|
|
53
|
+
value={cwd ?? ''}
|
|
54
|
+
aria-label="Workspace path"
|
|
55
|
+
title={cwd ?? undefined}
|
|
56
|
+
className="w-56"
|
|
57
|
+
readOnly
|
|
58
|
+
/>
|
|
59
|
+
}
|
|
60
|
+
/>
|
|
61
|
+
)}
|
|
60
62
|
<WorkspaceHarnessSetting />
|
|
61
63
|
</SettingsSection>
|
|
62
64
|
|
|
@@ -64,7 +66,7 @@ export function GeneralSettings() {
|
|
|
64
66
|
<SettingsSection label="Danger zone">
|
|
65
67
|
<SettingsRow
|
|
66
68
|
title="Remove space"
|
|
67
|
-
description="
|
|
69
|
+
description="Removes this space from Moi, its folder and chats stay on disk"
|
|
68
70
|
control={
|
|
69
71
|
<AlertDialog>
|
|
70
72
|
<AlertDialogTrigger
|
|
@@ -135,6 +137,7 @@ function WorkspaceHarnessSetting() {
|
|
|
135
137
|
<>
|
|
136
138
|
<SettingsRow
|
|
137
139
|
title="Agent"
|
|
140
|
+
description="Changing the agent changes which chats you see in this space"
|
|
138
141
|
control={
|
|
139
142
|
<Tooltip disabled={!reason}>
|
|
140
143
|
<TooltipTrigger render={<span tabIndex={reason ? 0 : undefined} aria-label={reason} />}>
|