moi-computer 0.13.1-next.0 → 0.13.1-next.1
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 +0 -1
- package/client/app/routes/workspace-route.tsx +4 -7
- package/client/features/account/account-test-utils.tsx +13 -5
- package/client/features/account/api.ts +4 -2
- package/client/features/account/profile-actions.ts +1 -1
- package/client/features/app-settings/avatar-upload.tsx +62 -0
- package/client/features/app-settings/profile-settings.tsx +10 -0
- package/client/features/chat/applet-chat-intents.ts +4 -4
- package/client/features/chat/sessions/api.ts +5 -5
- package/client/features/chat/sessions/use-selected-session.ts +3 -3
- package/client/features/chat/use-chat.ts +4 -4
- package/client/features/collab/applet-api.ts +1 -1
- package/client/features/collab/components/cursors.tsx +6 -1
- package/client/features/collab/components/presence-avatars.tsx +1 -1
- package/client/features/collab/components/presence-frame.tsx +1 -1
- package/client/features/collab/components/presence-group.tsx +1 -1
- package/client/features/collab/components/presence-helpers.ts +2 -2
- package/client/features/collab/components/user-avatar-group.tsx +1 -1
- package/client/features/collab/components/user-avatar.tsx +1 -1
- package/client/features/collab/components/user.tsx +1 -1
- package/client/features/collab/index.ts +3 -3
- package/client/features/{workspace-members → collab/members}/api.ts +6 -3
- package/client/features/{workspace-members → collab/members}/hooks.ts +11 -35
- package/client/features/{workspace-members → collab/members}/store.ts +4 -4
- package/client/features/{workspace-members → collab/members}/types.ts +2 -2
- package/client/features/collab/{client.ts → presence/client.ts} +2 -2
- package/client/features/collab/{provider.tsx → presence/provider.tsx} +1 -12
- package/client/features/collab/{users.ts → presence/users.ts} +19 -21
- package/client/features/collab/sharing/agent-invite.tsx +30 -0
- package/client/features/collab/sharing/workspace-members.tsx +277 -0
- package/client/features/collab/sharing/workspace-sharing-menu.tsx +179 -0
- package/client/features/collab/testing/component-fixtures.tsx +3 -3
- package/client/features/collab/testing/fake-engine.ts +2 -2
- package/client/features/dev/collab/collab-playground.tsx +2 -2
- package/client/features/dev/dev-index-page.tsx +0 -6
- package/client/features/dev/dev-routes.tsx +0 -2
- package/client/features/dev/workspace-setup-mocks.ts +0 -1
- package/client/features/identity/host-api.ts +2 -2
- package/client/features/identity/store.ts +1 -1
- package/client/features/views/use-view-actions.ts +3 -3
- package/client/features/workspace/browser-tab-state.ts +6 -6
- package/client/features/workspace/workspace-content.tsx +10 -6
- package/dist/{chunk-00s35r33.js → chunk-3smkkcfw.js} +76 -76
- package/dist/chunk-47h9c2qy.js +2 -0
- package/dist/chunk-8qed2gqp.js +75 -0
- package/dist/{chunk-7rz6g7g7.js → chunk-8zy3vesm.js} +1 -1
- package/dist/{chunk-s5s1vzdw.js → chunk-a47zy276.js} +2 -2
- package/dist/chunk-g4c1nte9.css +1 -0
- package/dist/chunk-kcactdr4.js +2 -0
- package/dist/chunk-m8bhx6tw.js +1 -0
- package/dist/{chunk-svxhxfeq.js → chunk-pf19zcrn.js} +2 -2
- package/dist/{chunk-kdgk4dac.js → chunk-th91xfnp.js} +1 -1
- package/dist/chunk-ygzxah0e.js +1 -0
- package/dist/index.html +1 -1
- package/lib/types.ts +0 -1
- package/package.json +1 -1
- package/server/app-config.ts +2 -7
- package/server/applets/declarations.ts +6 -7
- package/server/cli/commands/init.ts +0 -11
- package/server/collab/config.ts +1 -5
- package/server/collab/manager.ts +5 -2
- package/server/collab/skill/index.ts +1 -47
- package/server/skills/template.ts +3 -2
- package/server/skills/update.ts +1 -1
- package/server/skills/workspace.ts +0 -2
- package/server/web.ts +1 -2
- package/server/workspaces/scaffold.ts +1 -0
- package/skill/SKILL.md +1 -1
- package/client/features/collab/workspace-users-menu.tsx +0 -190
- package/client/features/dev/cloud-avatar-upload.tsx +0 -58
- package/client/features/dev/cloud-page.tsx +0 -363
- package/dist/chunk-af2jyddf.js +0 -2
- package/dist/chunk-cekekc3f.css +0 -1
- package/dist/chunk-ep5vh16c.js +0 -75
- package/dist/chunk-t0r0bds1.js +0 -1
- package/dist/chunk-vp2qzc0d.js +0 -1
- package/dist/chunk-wz5qv1bn.js +0 -2
- /package/client/features/{workspace-members → collab/members}/keys.ts +0 -0
- /package/client/features/collab/{hooks.tsx → presence/hooks.tsx} +0 -0
- /package/client/features/collab/{presence-publisher.ts → presence/presence-publisher.ts} +0 -0
- /package/client/features/collab/{presence-target.ts → presence/presence-target.ts} +0 -0
- /package/client/features/collab/{store.ts → presence/store.ts} +0 -0
|
@@ -54,12 +54,11 @@ export function resolvePeers(
|
|
|
54
54
|
export type WorkspaceUserInfo = {
|
|
55
55
|
profile: UserProfile
|
|
56
56
|
self: boolean
|
|
57
|
-
|
|
57
|
+
page: string | undefined
|
|
58
58
|
status: UserStatus
|
|
59
59
|
}
|
|
60
60
|
export type CurrentUserContext = {
|
|
61
61
|
currentUser: UserProfile | undefined
|
|
62
|
-
connectionId: string | null
|
|
63
62
|
page: string | null
|
|
64
63
|
users: readonly UserProfile[]
|
|
65
64
|
}
|
|
@@ -67,23 +66,22 @@ export function summarizeWorkspaceUsers(
|
|
|
67
66
|
connections: Connection[],
|
|
68
67
|
context: CurrentUserContext
|
|
69
68
|
): WorkspaceUserInfo[] {
|
|
70
|
-
|
|
71
|
-
(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
})
|
|
69
|
+
return context.users
|
|
70
|
+
.map(profile => {
|
|
71
|
+
const isSelf = profile.id === context.currentUser?.id
|
|
72
|
+
const activeConnection = connections.find(
|
|
73
|
+
connection => connection.userId === profile.id && connection.location?.status === 'active'
|
|
74
|
+
)
|
|
75
|
+
return {
|
|
76
|
+
profile,
|
|
77
|
+
self: isSelf,
|
|
78
|
+
page: isSelf ? (context.page ?? undefined) : activeConnection?.location?.page,
|
|
79
|
+
status: userStatus(connections, profile.id)
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
.toSorted(
|
|
83
|
+
(a, b) =>
|
|
84
|
+
Number(b.self) - Number(a.self) ||
|
|
85
|
+
Number(b.status === 'active') - Number(a.status === 'active')
|
|
86
|
+
)
|
|
89
87
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useId } from 'react'
|
|
2
|
+
import { Button } from '@/client/components/ui/button'
|
|
3
|
+
|
|
4
|
+
export function AgentInvite() {
|
|
5
|
+
const headingId = useId()
|
|
6
|
+
const availabilityId = useId()
|
|
7
|
+
return (
|
|
8
|
+
<section
|
|
9
|
+
aria-labelledby={headingId}
|
|
10
|
+
className="flex flex-col gap-3 rounded-2xl bg-popover p-5 shadow-md"
|
|
11
|
+
>
|
|
12
|
+
<div className="flex items-start gap-3">
|
|
13
|
+
<div className="min-w-0 flex-1 space-y-1">
|
|
14
|
+
<h3 id={headingId} className="text-sm font-medium">
|
|
15
|
+
Invite your agent
|
|
16
|
+
</h3>
|
|
17
|
+
<p className="text-sm text-muted-foreground">
|
|
18
|
+
Give your agent a prompt to work in this workspace on your behalf
|
|
19
|
+
</p>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
<Button variant="secondary" className="self-start" disabled aria-describedby={availabilityId}>
|
|
23
|
+
Copy prompt
|
|
24
|
+
</Button>
|
|
25
|
+
<span id={availabilityId} className="sr-only">
|
|
26
|
+
Agent invitations aren’t available yet
|
|
27
|
+
</span>
|
|
28
|
+
</section>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { IconX } from '@tabler/icons-react'
|
|
3
|
+
import { Button } from '@/client/components/ui/button'
|
|
4
|
+
import { Input } from '@/client/components/ui/input'
|
|
5
|
+
import { Spinner } from '@/client/components/ui/spinner'
|
|
6
|
+
import { PopoverTitle } from '@/client/components/ui/popover'
|
|
7
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
8
|
+
import { toast } from '@/client/components/ui/toast'
|
|
9
|
+
import { cn } from '@/client/lib/cn'
|
|
10
|
+
import { colorForId } from '@/lib/collab/colors'
|
|
11
|
+
import { CloudApiError } from '../../account/api'
|
|
12
|
+
import { useIdentity } from '../../identity/use-identity'
|
|
13
|
+
import { collabIdentityId, identityKey } from '../../identity/types'
|
|
14
|
+
import { getAccountGeneration } from '../../identity/store'
|
|
15
|
+
import { User } from '../components/user'
|
|
16
|
+
import {
|
|
17
|
+
type useWorkspaceMembers,
|
|
18
|
+
useMembershipAction,
|
|
19
|
+
type MembershipAction
|
|
20
|
+
} from '../members/hooks'
|
|
21
|
+
import type { WorkspaceMember, WorkspaceInvitation } from '../members/types'
|
|
22
|
+
import type { WorkspaceUserInfo } from '../presence/users'
|
|
23
|
+
|
|
24
|
+
export type WorkspaceMembersProps = {
|
|
25
|
+
workspaceId: string
|
|
26
|
+
users: WorkspaceUserInfo[]
|
|
27
|
+
membership: ReturnType<typeof useWorkspaceMembers>
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function WorkspaceMembers({ workspaceId, users, membership }: WorkspaceMembersProps) {
|
|
31
|
+
const identity = useIdentity()
|
|
32
|
+
const membersById =
|
|
33
|
+
membership.members &&
|
|
34
|
+
new Map(membership.members.map(member => [collabIdentityId(member), member]))
|
|
35
|
+
return (
|
|
36
|
+
<div className="flex flex-col rounded-2xl bg-popover p-5 shadow-md">
|
|
37
|
+
<PopoverTitle>Share this workspace</PopoverTitle>
|
|
38
|
+
<InviteForm
|
|
39
|
+
className="mt-3"
|
|
40
|
+
key={`${workspaceId}:${identity ? identityKey(identity) : ''}`}
|
|
41
|
+
workspaceId={workspaceId}
|
|
42
|
+
members={membership.members ?? []}
|
|
43
|
+
invitations={membership.invitations ?? []}
|
|
44
|
+
/>
|
|
45
|
+
<MembersList
|
|
46
|
+
className="-mx-2 -my-1 mt-3"
|
|
47
|
+
workspaceId={workspaceId}
|
|
48
|
+
users={users}
|
|
49
|
+
membersById={membersById}
|
|
50
|
+
invitations={membership.invitations ?? []}
|
|
51
|
+
/>
|
|
52
|
+
{membership.isError && (
|
|
53
|
+
<div className="px-2 py-1 text-xs text-muted-foreground">
|
|
54
|
+
<p>Couldn’t refresh workspace members</p>
|
|
55
|
+
<Button variant="ghost" size="sm" onClick={() => void membership.refetch()}>
|
|
56
|
+
Retry
|
|
57
|
+
</Button>
|
|
58
|
+
</div>
|
|
59
|
+
)}
|
|
60
|
+
{membership.isPending && (
|
|
61
|
+
<div className="flex items-center justify-center py-6">
|
|
62
|
+
<Spinner className="text-muted-foreground" aria-label="Loading workspace members" />
|
|
63
|
+
</div>
|
|
64
|
+
)}
|
|
65
|
+
</div>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type InviteFormProps = {
|
|
70
|
+
className?: string
|
|
71
|
+
workspaceId: string
|
|
72
|
+
members: WorkspaceMember[]
|
|
73
|
+
invitations: WorkspaceInvitation[]
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function InviteForm({ className, workspaceId, members, invitations }: InviteFormProps) {
|
|
77
|
+
const [email, setEmail] = useState('')
|
|
78
|
+
const invite = useMembershipAction(workspaceId)
|
|
79
|
+
async function submit() {
|
|
80
|
+
const address = email.trim().toLowerCase()
|
|
81
|
+
if (!address || invite.isPending) return
|
|
82
|
+
const generation = getAccountGeneration()
|
|
83
|
+
setEmail('')
|
|
84
|
+
const existingMember = members.some(
|
|
85
|
+
member => member.type === 'user' && member.email.trim().toLowerCase() === address
|
|
86
|
+
)
|
|
87
|
+
const existingInvitation = invitations.some(
|
|
88
|
+
invitation => invitation.email.trim().toLowerCase() === address
|
|
89
|
+
)
|
|
90
|
+
if (existingMember || existingInvitation) {
|
|
91
|
+
toast.add({
|
|
92
|
+
title: existingMember
|
|
93
|
+
? 'The user is already in this workspace'
|
|
94
|
+
: 'The user is already invited',
|
|
95
|
+
type: 'info'
|
|
96
|
+
})
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
await invite.mutateAsync({ type: 'invite', email: address })
|
|
101
|
+
if (generation !== getAccountGeneration()) return
|
|
102
|
+
toast.add({ title: 'Invitation sent', description: `Sent to ${address}`, type: 'success' })
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (generation !== getAccountGeneration()) return
|
|
105
|
+
if (
|
|
106
|
+
error instanceof CloudApiError &&
|
|
107
|
+
(error.code === 'ALREADY_MEMBER' ||
|
|
108
|
+
error.code === 'ALREADY_OWNER' ||
|
|
109
|
+
error.code === 'ALREADY_INVITED')
|
|
110
|
+
) {
|
|
111
|
+
toast.add({
|
|
112
|
+
title:
|
|
113
|
+
error.code === 'ALREADY_INVITED'
|
|
114
|
+
? 'The user is already invited'
|
|
115
|
+
: 'The user is already in this workspace',
|
|
116
|
+
type: 'info'
|
|
117
|
+
})
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
setEmail(email)
|
|
121
|
+
toast.add({
|
|
122
|
+
title: 'Couldn’t send invitation',
|
|
123
|
+
description: error instanceof Error ? error.message : 'Try again',
|
|
124
|
+
type: 'error'
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return (
|
|
129
|
+
<form
|
|
130
|
+
className={cn('flex', className)}
|
|
131
|
+
onSubmit={event => {
|
|
132
|
+
event.preventDefault()
|
|
133
|
+
void submit()
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
<Input
|
|
137
|
+
id="invite-email"
|
|
138
|
+
type="email"
|
|
139
|
+
aria-label="Email"
|
|
140
|
+
placeholder="Email"
|
|
141
|
+
autoComplete="off"
|
|
142
|
+
className="min-w-0 flex-1"
|
|
143
|
+
value={email}
|
|
144
|
+
onChange={event => setEmail(event.target.value)}
|
|
145
|
+
disabled={invite.isPending}
|
|
146
|
+
/>
|
|
147
|
+
<Button className="ms-2" type="submit" disabled={invite.isPending || !email.trim()}>
|
|
148
|
+
Invite
|
|
149
|
+
</Button>
|
|
150
|
+
</form>
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
type MembersListProps = {
|
|
155
|
+
className?: string
|
|
156
|
+
workspaceId: string
|
|
157
|
+
membersById?: Map<string, WorkspaceMember>
|
|
158
|
+
invitations: WorkspaceInvitation[]
|
|
159
|
+
users: WorkspaceUserInfo[]
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function MembersList({
|
|
163
|
+
className,
|
|
164
|
+
workspaceId,
|
|
165
|
+
membersById,
|
|
166
|
+
invitations,
|
|
167
|
+
users
|
|
168
|
+
}: MembersListProps) {
|
|
169
|
+
return (
|
|
170
|
+
<ul
|
|
171
|
+
aria-label="Who has access"
|
|
172
|
+
className={cn('flex max-h-80 scroll-fade flex-col gap-0.5 overflow-y-auto', className)}
|
|
173
|
+
>
|
|
174
|
+
{users.map(user => (
|
|
175
|
+
<MemberRow
|
|
176
|
+
key={user.profile.id}
|
|
177
|
+
user={user}
|
|
178
|
+
workspaceId={workspaceId}
|
|
179
|
+
membershipId={membersById?.get(user.profile.id)?.membershipId}
|
|
180
|
+
/>
|
|
181
|
+
))}
|
|
182
|
+
{invitations.map(invitation => (
|
|
183
|
+
<InvitationRow key={invitation.id} workspaceId={workspaceId} invitation={invitation} />
|
|
184
|
+
))}
|
|
185
|
+
</ul>
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
type MemberRowProps = {
|
|
190
|
+
user: WorkspaceUserInfo
|
|
191
|
+
workspaceId: string
|
|
192
|
+
membershipId?: string
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function MemberRow({ user, workspaceId, membershipId }: MemberRowProps) {
|
|
196
|
+
return (
|
|
197
|
+
<li className="flex min-w-0 items-center gap-2 px-2 py-1">
|
|
198
|
+
<User
|
|
199
|
+
profile={user.profile}
|
|
200
|
+
className="flex-1"
|
|
201
|
+
size="sm"
|
|
202
|
+
showYouLabel={user.self}
|
|
203
|
+
description={user.profile.email}
|
|
204
|
+
/>
|
|
205
|
+
{membershipId && (
|
|
206
|
+
<RemoveButton workspaceId={workspaceId} action={{ type: 'remove', membershipId }} />
|
|
207
|
+
)}
|
|
208
|
+
</li>
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
type InvitationRowProps = { workspaceId: string; invitation: WorkspaceInvitation }
|
|
213
|
+
function InvitationRow({ workspaceId, invitation }: InvitationRowProps) {
|
|
214
|
+
return (
|
|
215
|
+
<li className="flex min-w-0 items-center gap-2 px-2 py-1">
|
|
216
|
+
<User
|
|
217
|
+
className="flex-1 text-muted-foreground **:data-[slot=avatar]:opacity-30"
|
|
218
|
+
size="sm"
|
|
219
|
+
profile={{
|
|
220
|
+
id: invitation.id,
|
|
221
|
+
email: invitation.email,
|
|
222
|
+
color: colorForId(invitation.email)
|
|
223
|
+
}}
|
|
224
|
+
description={invitation.email}
|
|
225
|
+
/>
|
|
226
|
+
<RemoveButton
|
|
227
|
+
workspaceId={workspaceId}
|
|
228
|
+
disabled={invitation.pending}
|
|
229
|
+
action={{ type: 'revoke', invitationId: invitation.id }}
|
|
230
|
+
/>
|
|
231
|
+
</li>
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
type RemoveButtonProps = {
|
|
236
|
+
workspaceId: string
|
|
237
|
+
action: Exclude<MembershipAction, { type: 'invite' }>
|
|
238
|
+
disabled?: boolean
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function RemoveButton({ workspaceId, action, disabled }: RemoveButtonProps) {
|
|
242
|
+
const mutation = useMembershipAction(workspaceId)
|
|
243
|
+
const label = action.type === 'remove' ? 'Remove' : 'Revoke invitation'
|
|
244
|
+
async function submit() {
|
|
245
|
+
if (mutation.isPending || disabled) return
|
|
246
|
+
const generation = getAccountGeneration()
|
|
247
|
+
try {
|
|
248
|
+
await mutation.mutateAsync(action)
|
|
249
|
+
} catch (error) {
|
|
250
|
+
if (generation !== getAccountGeneration()) return
|
|
251
|
+
toast.add({
|
|
252
|
+
title: action.type === 'remove' ? 'Couldn’t remove member' : 'Couldn’t revoke invitation',
|
|
253
|
+
description: error instanceof Error ? error.message : 'Try again',
|
|
254
|
+
type: 'error'
|
|
255
|
+
})
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return (
|
|
259
|
+
<Tooltip>
|
|
260
|
+
<TooltipTrigger
|
|
261
|
+
render={
|
|
262
|
+
<Button
|
|
263
|
+
variant="ghost"
|
|
264
|
+
size="icon-sm"
|
|
265
|
+
className="shrink-0 text-muted-foreground"
|
|
266
|
+
aria-label={label}
|
|
267
|
+
disabled={disabled || mutation.isPending}
|
|
268
|
+
onClick={() => void submit()}
|
|
269
|
+
/>
|
|
270
|
+
}
|
|
271
|
+
>
|
|
272
|
+
<IconX stroke={1.75} />
|
|
273
|
+
</TooltipTrigger>
|
|
274
|
+
<TooltipContent>{label}</TooltipContent>
|
|
275
|
+
</Tooltip>
|
|
276
|
+
)
|
|
277
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { useRef, useState } from 'react'
|
|
2
|
+
import { IconChevronDown } from '@tabler/icons-react'
|
|
3
|
+
import { useRouter } from 'wouter'
|
|
4
|
+
import { usePathname } from 'wouter/use-browser-location'
|
|
5
|
+
import { Button } from '@/client/components/ui/button'
|
|
6
|
+
import { Popover, PopoverContent, PopoverTrigger } from '@/client/components/ui/popover'
|
|
7
|
+
import type { Icon as TabIcon } from '@tabler/icons-react'
|
|
8
|
+
import type { WorkspaceTabId } from '@/lib/types'
|
|
9
|
+
import { tabFromPath } from '@/lib/workspace-tabs'
|
|
10
|
+
import { userDisplayName } from '@/client/lib/user-display-name'
|
|
11
|
+
import { Tooltip, TooltipTrigger, TooltipContent } from '@/client/components/ui/tooltip'
|
|
12
|
+
import { UserAvatar } from '../components/user-avatar'
|
|
13
|
+
import { AvatarGroup, AvatarGroupCount } from '@/ui-components/avatar'
|
|
14
|
+
import { useWorkspaceMembers } from '../members/hooks'
|
|
15
|
+
import { collabIdentityId } from '../../identity/types'
|
|
16
|
+
import { pageFromPath } from '../presence/provider'
|
|
17
|
+
import { useConnectionState, useWorkspaceUsers, useMe } from '../presence/hooks'
|
|
18
|
+
import { summarizeWorkspaceUsers, type WorkspaceUserInfo } from '../presence/users'
|
|
19
|
+
import { WorkspaceMembers } from './workspace-members'
|
|
20
|
+
// import { AgentInvite } from './agent-invite'
|
|
21
|
+
|
|
22
|
+
export type TabInfo = { label: string; Icon: TabIcon }
|
|
23
|
+
type WorkspaceSharingMenuProps = {
|
|
24
|
+
workspaceId: string
|
|
25
|
+
describeTab: (tab: WorkspaceTabId) => TabInfo | null
|
|
26
|
+
onOpenTab: (tab: WorkspaceTabId) => void
|
|
27
|
+
}
|
|
28
|
+
export function WorkspaceSharingMenu({
|
|
29
|
+
workspaceId,
|
|
30
|
+
describeTab,
|
|
31
|
+
onOpenTab
|
|
32
|
+
}: WorkspaceSharingMenuProps) {
|
|
33
|
+
const state = useConnectionState()
|
|
34
|
+
const workspaceUsers = useWorkspaceUsers()
|
|
35
|
+
const currentUser = useMe()
|
|
36
|
+
const router = useRouter()
|
|
37
|
+
const page = pageFromPath(usePathname(router), workspaceId, router.base)
|
|
38
|
+
const membership = useWorkspaceMembers(workspaceId)
|
|
39
|
+
const memberIds = membership.members && new Set(membership.members.map(collabIdentityId))
|
|
40
|
+
const members = memberIds
|
|
41
|
+
? workspaceUsers.filter(user => user.id === currentUser?.id || memberIds.has(user.id))
|
|
42
|
+
: workspaceUsers
|
|
43
|
+
const users = summarizeWorkspaceUsers(state.connections, {
|
|
44
|
+
currentUser,
|
|
45
|
+
users:
|
|
46
|
+
membership.isSuccess && currentUser && !members.some(user => user.id === currentUser.id)
|
|
47
|
+
? [currentUser, ...members]
|
|
48
|
+
: members,
|
|
49
|
+
page
|
|
50
|
+
})
|
|
51
|
+
const active = users.filter(user => user.status === 'active')
|
|
52
|
+
const shown = active.slice(0, 4).toReversed()
|
|
53
|
+
const hidden = active.length - shown.length
|
|
54
|
+
const [open, setOpen] = useState(false)
|
|
55
|
+
const headerRef = useRef<HTMLDivElement>(null)
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Popover
|
|
59
|
+
open={open}
|
|
60
|
+
onOpenChange={(nextOpen, details) => {
|
|
61
|
+
// Sibling avatar controls handle their own clicks, including toggling sharing.
|
|
62
|
+
if (
|
|
63
|
+
details.reason === 'outside-press' &&
|
|
64
|
+
details.event.target instanceof Node &&
|
|
65
|
+
headerRef.current?.contains(details.event.target)
|
|
66
|
+
) {
|
|
67
|
+
details.cancel()
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
setOpen(nextOpen)
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
<div ref={headerRef} className="group/sharing relative inline-flex items-center rounded-full">
|
|
74
|
+
<PopoverTrigger
|
|
75
|
+
render={
|
|
76
|
+
<Button
|
|
77
|
+
variant="ghost"
|
|
78
|
+
size="sm"
|
|
79
|
+
aria-label="Users in this workspace"
|
|
80
|
+
className="absolute inset-0 h-full w-full justify-end gap-0.5 rounded-full pr-1 pl-1 group-hover/sharing:bg-accent data-popup-open:bg-accent"
|
|
81
|
+
/>
|
|
82
|
+
}
|
|
83
|
+
>
|
|
84
|
+
<IconChevronDown stroke={2.5} className="size-3! text-muted-foreground" />
|
|
85
|
+
</PopoverTrigger>
|
|
86
|
+
<div className="pointer-events-none flex h-7 items-center gap-0.5 px-1">
|
|
87
|
+
<AvatarGroup>
|
|
88
|
+
{hidden > 0 && (
|
|
89
|
+
<Button
|
|
90
|
+
variant={null}
|
|
91
|
+
size="icon-xs"
|
|
92
|
+
data-slot="avatar"
|
|
93
|
+
data-size="xs"
|
|
94
|
+
className="pointer-events-auto relative size-5 rounded-full p-0"
|
|
95
|
+
aria-label={`${hidden} more active users`}
|
|
96
|
+
onClick={() => setOpen(value => !value)}
|
|
97
|
+
>
|
|
98
|
+
<AvatarGroupCount size="xs">+{hidden}</AvatarGroupCount>
|
|
99
|
+
</Button>
|
|
100
|
+
)}
|
|
101
|
+
{shown.map(user => (
|
|
102
|
+
<MemberAvatar
|
|
103
|
+
key={user.profile.id}
|
|
104
|
+
user={user}
|
|
105
|
+
page={page}
|
|
106
|
+
describeTab={describeTab}
|
|
107
|
+
onToggleSharing={() => setOpen(value => !value)}
|
|
108
|
+
onOpenTab={tab => {
|
|
109
|
+
setOpen(false)
|
|
110
|
+
onOpenTab(tab)
|
|
111
|
+
}}
|
|
112
|
+
/>
|
|
113
|
+
))}
|
|
114
|
+
</AvatarGroup>
|
|
115
|
+
<span aria-hidden="true" className="size-3" />
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
<PopoverContent
|
|
119
|
+
initialFocus={false}
|
|
120
|
+
align="end"
|
|
121
|
+
className="w-96 max-w-[calc(100vw-2rem)] gap-2 bg-transparent p-0 shadow-none"
|
|
122
|
+
>
|
|
123
|
+
<WorkspaceMembers workspaceId={workspaceId} users={users} membership={membership} />
|
|
124
|
+
{/* Enable once agent invitations are functional and the card is polished. */}
|
|
125
|
+
{/* <AgentInvite /> */}
|
|
126
|
+
</PopoverContent>
|
|
127
|
+
</Popover>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
type MemberAvatarProps = Pick<WorkspaceSharingMenuProps, 'describeTab' | 'onOpenTab'> & {
|
|
132
|
+
user: WorkspaceUserInfo
|
|
133
|
+
page: string
|
|
134
|
+
onToggleSharing: () => void
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function MemberAvatar({ user, page, describeTab, onOpenTab, onToggleSharing }: MemberAvatarProps) {
|
|
138
|
+
const tab = user.page ? tabFromPath(user.page) : null
|
|
139
|
+
const info = tab ? describeTab(tab) : null
|
|
140
|
+
const name = userDisplayName(user.profile)
|
|
141
|
+
return (
|
|
142
|
+
<div data-slot="avatar" data-size="xs" className="relative size-5 shrink-0">
|
|
143
|
+
<Tooltip>
|
|
144
|
+
<TooltipTrigger
|
|
145
|
+
render={
|
|
146
|
+
<Button
|
|
147
|
+
variant={null}
|
|
148
|
+
size="icon-xs"
|
|
149
|
+
data-slot="avatar"
|
|
150
|
+
data-size="xs"
|
|
151
|
+
className="pointer-events-auto relative size-5 rounded-full p-0"
|
|
152
|
+
aria-label={user.self ? `${name} (You), open sharing` : name}
|
|
153
|
+
onClick={() => {
|
|
154
|
+
if (user.self) onToggleSharing()
|
|
155
|
+
else if (tab && info && tab !== page) {
|
|
156
|
+
onOpenTab(tab)
|
|
157
|
+
}
|
|
158
|
+
}}
|
|
159
|
+
/>
|
|
160
|
+
}
|
|
161
|
+
>
|
|
162
|
+
<UserAvatar profile={user.profile} size="xs" />
|
|
163
|
+
</TooltipTrigger>
|
|
164
|
+
<TooltipContent className="flex-col gap-1 text-center">
|
|
165
|
+
<div>
|
|
166
|
+
{name}
|
|
167
|
+
{user.self ? ' (You)' : ''}
|
|
168
|
+
</div>
|
|
169
|
+
{info && (
|
|
170
|
+
<div className="flex items-center justify-center gap-0.5 text-muted-foreground">
|
|
171
|
+
<info.Icon size={12} stroke={1.75} />
|
|
172
|
+
{info.label}
|
|
173
|
+
</div>
|
|
174
|
+
)}
|
|
175
|
+
</TooltipContent>
|
|
176
|
+
</Tooltip>
|
|
177
|
+
</div>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
@@ -3,9 +3,9 @@ import { renderToStaticMarkup } from 'react-dom/server'
|
|
|
3
3
|
|
|
4
4
|
import type { PresenceRegistration, UserProfile } from '@/lib/collab/types'
|
|
5
5
|
|
|
6
|
-
import { AppletPresenceProvider, CollabContext } from '../provider'
|
|
7
|
-
import { presenceChannels } from '../hooks'
|
|
8
|
-
import { presenceTarget } from '../presence-target'
|
|
6
|
+
import { AppletPresenceProvider, CollabContext } from '../presence/provider'
|
|
7
|
+
import { presenceChannels } from '../presence/hooks'
|
|
8
|
+
import { presenceTarget } from '../presence/presence-target'
|
|
9
9
|
import { createFakeEngine } from './fake-engine'
|
|
10
10
|
import type { FakeEngine } from './fake-engine'
|
|
11
11
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { UserProfile, Connection, PresenceRegistration } from '@/lib/collab/types'
|
|
2
2
|
import { COLLAB_PROTOCOL_VERSION } from '@/lib/collab/protocol'
|
|
3
|
-
import type { CollabEngineApi } from '../client'
|
|
3
|
+
import type { CollabEngineApi } from '../presence/client'
|
|
4
4
|
import { normalizeUserProfile } from '../host-state'
|
|
5
|
-
import { CollabStore } from '../store'
|
|
5
|
+
import { CollabStore } from '../presence/store'
|
|
6
6
|
|
|
7
7
|
function normalizeUsers(users: readonly UserProfile[]): readonly UserProfile[] {
|
|
8
8
|
if (!Array.isArray(users)) throw new Error('Users must be an array.')
|
|
@@ -44,8 +44,8 @@ import {
|
|
|
44
44
|
usePublishPresence,
|
|
45
45
|
useUser,
|
|
46
46
|
useWorkspaceUsers
|
|
47
|
-
} from '@/client/features/collab/hooks'
|
|
48
|
-
import { AppletPresenceProvider, CollabContext } from '@/client/features/collab/provider'
|
|
47
|
+
} from '@/client/features/collab/presence/hooks'
|
|
48
|
+
import { AppletPresenceProvider, CollabContext } from '@/client/features/collab/presence/provider'
|
|
49
49
|
import { connectPlaygroundParticipants } from './playground-room'
|
|
50
50
|
|
|
51
51
|
const YOU: UserProfile = {
|
|
@@ -7,12 +7,6 @@ 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
|
-
},
|
|
16
10
|
{
|
|
17
11
|
path: '/dev/onboarding',
|
|
18
12
|
title: 'Onboarding ideas',
|
|
@@ -10,7 +10,6 @@ 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'
|
|
14
13
|
|
|
15
14
|
// All /dev/* routes live with their pages here and load only in development;
|
|
16
15
|
// see the dynamic import in AppRouter. /dev itself is the index; list new
|
|
@@ -22,7 +21,6 @@ const CollabPage = lazy(() =>
|
|
|
22
21
|
export default function DevRoutes() {
|
|
23
22
|
return (
|
|
24
23
|
<Switch>
|
|
25
|
-
<Route path="/dev/cloud" component={CloudPage} />
|
|
26
24
|
<Route path="/dev/onboarding" component={OnboardingPreviewPage} />
|
|
27
25
|
<Route path="/dev/collab-kit">
|
|
28
26
|
<Redirect to="/dev/collab" />
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
removeWorkspaceMembers,
|
|
6
6
|
clearWorkspaceMembers,
|
|
7
7
|
getWorkspaceMembersRevision
|
|
8
|
-
} from '../
|
|
8
|
+
} from '../collab/members/store'
|
|
9
9
|
import type { Identity } from './types'
|
|
10
|
-
import type { WorkspaceMembers, WorkspaceMembersSnapshot } from '../
|
|
10
|
+
import type { WorkspaceMembers, WorkspaceMembersSnapshot } from '../collab/members/types'
|
|
11
11
|
|
|
12
12
|
export type IdentityHostApi = {
|
|
13
13
|
identity: { set: (identity: Identity | null) => void; getRevision: () => number }
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
changeWorkspaceStateCache,
|
|
20
20
|
getCachedWorkspaceState
|
|
21
21
|
} from '@/client/features/workspace/workspace-state'
|
|
22
|
-
import {
|
|
22
|
+
import { useAppConfig } from '@/client/api/app-config'
|
|
23
23
|
import { useWorkspaceHarness } from '@/client/features/workspace/api'
|
|
24
24
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-layout-context'
|
|
25
25
|
import {
|
|
@@ -34,8 +34,8 @@ import { viewTabId } from '@/lib/workspace-tabs'
|
|
|
34
34
|
|
|
35
35
|
export function useViewActions() {
|
|
36
36
|
const queryClient = useQueryClient()
|
|
37
|
-
const
|
|
38
|
-
const selectionScope =
|
|
37
|
+
const cloud = useAppConfig().environment === 'cloud'
|
|
38
|
+
const selectionScope = cloud ? 'browser-tab' : 'shared'
|
|
39
39
|
const { workspaceId, layout } = useWorkspaceLayoutCtx()
|
|
40
40
|
const { pinnedSessionId } = usePinnedSession()
|
|
41
41
|
const modelData = useWorkspaceHarness(workspaceId).data
|