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.
Files changed (82) hide show
  1. package/client/api/app-config.ts +0 -1
  2. package/client/app/routes/workspace-route.tsx +4 -7
  3. package/client/features/account/account-test-utils.tsx +13 -5
  4. package/client/features/account/api.ts +4 -2
  5. package/client/features/account/profile-actions.ts +1 -1
  6. package/client/features/app-settings/avatar-upload.tsx +62 -0
  7. package/client/features/app-settings/profile-settings.tsx +10 -0
  8. package/client/features/chat/applet-chat-intents.ts +4 -4
  9. package/client/features/chat/sessions/api.ts +5 -5
  10. package/client/features/chat/sessions/use-selected-session.ts +3 -3
  11. package/client/features/chat/use-chat.ts +4 -4
  12. package/client/features/collab/applet-api.ts +1 -1
  13. package/client/features/collab/components/cursors.tsx +6 -1
  14. package/client/features/collab/components/presence-avatars.tsx +1 -1
  15. package/client/features/collab/components/presence-frame.tsx +1 -1
  16. package/client/features/collab/components/presence-group.tsx +1 -1
  17. package/client/features/collab/components/presence-helpers.ts +2 -2
  18. package/client/features/collab/components/user-avatar-group.tsx +1 -1
  19. package/client/features/collab/components/user-avatar.tsx +1 -1
  20. package/client/features/collab/components/user.tsx +1 -1
  21. package/client/features/collab/index.ts +3 -3
  22. package/client/features/{workspace-members → collab/members}/api.ts +6 -3
  23. package/client/features/{workspace-members → collab/members}/hooks.ts +11 -35
  24. package/client/features/{workspace-members → collab/members}/store.ts +4 -4
  25. package/client/features/{workspace-members → collab/members}/types.ts +2 -2
  26. package/client/features/collab/{client.ts → presence/client.ts} +2 -2
  27. package/client/features/collab/{provider.tsx → presence/provider.tsx} +1 -12
  28. package/client/features/collab/{users.ts → presence/users.ts} +19 -21
  29. package/client/features/collab/sharing/agent-invite.tsx +30 -0
  30. package/client/features/collab/sharing/workspace-members.tsx +277 -0
  31. package/client/features/collab/sharing/workspace-sharing-menu.tsx +179 -0
  32. package/client/features/collab/testing/component-fixtures.tsx +3 -3
  33. package/client/features/collab/testing/fake-engine.ts +2 -2
  34. package/client/features/dev/collab/collab-playground.tsx +2 -2
  35. package/client/features/dev/dev-index-page.tsx +0 -6
  36. package/client/features/dev/dev-routes.tsx +0 -2
  37. package/client/features/dev/workspace-setup-mocks.ts +0 -1
  38. package/client/features/identity/host-api.ts +2 -2
  39. package/client/features/identity/store.ts +1 -1
  40. package/client/features/views/use-view-actions.ts +3 -3
  41. package/client/features/workspace/browser-tab-state.ts +6 -6
  42. package/client/features/workspace/workspace-content.tsx +10 -6
  43. package/dist/{chunk-00s35r33.js → chunk-3smkkcfw.js} +76 -76
  44. package/dist/chunk-47h9c2qy.js +2 -0
  45. package/dist/chunk-8qed2gqp.js +75 -0
  46. package/dist/{chunk-7rz6g7g7.js → chunk-8zy3vesm.js} +1 -1
  47. package/dist/{chunk-s5s1vzdw.js → chunk-a47zy276.js} +2 -2
  48. package/dist/chunk-g4c1nte9.css +1 -0
  49. package/dist/chunk-kcactdr4.js +2 -0
  50. package/dist/chunk-m8bhx6tw.js +1 -0
  51. package/dist/{chunk-svxhxfeq.js → chunk-pf19zcrn.js} +2 -2
  52. package/dist/{chunk-kdgk4dac.js → chunk-th91xfnp.js} +1 -1
  53. package/dist/chunk-ygzxah0e.js +1 -0
  54. package/dist/index.html +1 -1
  55. package/lib/types.ts +0 -1
  56. package/package.json +1 -1
  57. package/server/app-config.ts +2 -7
  58. package/server/applets/declarations.ts +6 -7
  59. package/server/cli/commands/init.ts +0 -11
  60. package/server/collab/config.ts +1 -5
  61. package/server/collab/manager.ts +5 -2
  62. package/server/collab/skill/index.ts +1 -47
  63. package/server/skills/template.ts +3 -2
  64. package/server/skills/update.ts +1 -1
  65. package/server/skills/workspace.ts +0 -2
  66. package/server/web.ts +1 -2
  67. package/server/workspaces/scaffold.ts +1 -0
  68. package/skill/SKILL.md +1 -1
  69. package/client/features/collab/workspace-users-menu.tsx +0 -190
  70. package/client/features/dev/cloud-avatar-upload.tsx +0 -58
  71. package/client/features/dev/cloud-page.tsx +0 -363
  72. package/dist/chunk-af2jyddf.js +0 -2
  73. package/dist/chunk-cekekc3f.css +0 -1
  74. package/dist/chunk-ep5vh16c.js +0 -75
  75. package/dist/chunk-t0r0bds1.js +0 -1
  76. package/dist/chunk-vp2qzc0d.js +0 -1
  77. package/dist/chunk-wz5qv1bn.js +0 -2
  78. /package/client/features/{workspace-members → collab/members}/keys.ts +0 -0
  79. /package/client/features/collab/{hooks.tsx → presence/hooks.tsx} +0 -0
  80. /package/client/features/collab/{presence-publisher.ts → presence/presence-publisher.ts} +0 -0
  81. /package/client/features/collab/{presence-target.ts → presence/presence-target.ts} +0 -0
  82. /package/client/features/collab/{store.ts → presence/store.ts} +0 -0
@@ -1,363 +0,0 @@
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
- }