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/server/web.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import type { CollabIdentity } from '@/lib/collab/types'
|
|
2
1
|
import { isMessageAttachments } from '@/lib/message-attachments'
|
|
3
2
|
import type { ClientMessage, StatusSnapshotMessage } from '@/lib/types'
|
|
4
|
-
import { isMoiContext
|
|
3
|
+
import { isMoiContext } from '@/lib/moi-context'
|
|
5
4
|
|
|
6
5
|
import index from '../client/index.html'
|
|
7
6
|
import { api } from './api'
|
|
8
7
|
import { AttachmentUploadError } from './attachment-message'
|
|
9
8
|
import { PORT } from './constants'
|
|
10
9
|
import { control } from './control'
|
|
11
|
-
import {
|
|
12
|
-
import { getCollabReferencePath, isCollabEnabled } from './collab/config'
|
|
13
|
-
import { selectChatSession } from './chat-selection'
|
|
14
|
-
import { collabManager } from './collab/manager'
|
|
15
|
-
import { EVENTS_TOPIC, setEventServer } from './events'
|
|
10
|
+
import { EVENTS_TOPIC, publishEvent, setEventServer } from './events'
|
|
16
11
|
import { killBuildWorkers } from './applets/build-worker'
|
|
17
12
|
import { killAllWorkers } from './functions'
|
|
18
13
|
import { startScratchpadSweeper } from './scratchpad'
|
|
@@ -20,6 +15,7 @@ import { navigationRelay } from './navigation-relay'
|
|
|
20
15
|
import { resolveScratchOp } from './scratchpad-relay'
|
|
21
16
|
import { allHarnesses, harnessFor } from './harness/registry'
|
|
22
17
|
import { getWorkspace } from './registry'
|
|
18
|
+
import { saveSelectedSession } from './selected-session'
|
|
23
19
|
import {
|
|
24
20
|
addClient,
|
|
25
21
|
broadcast,
|
|
@@ -33,13 +29,7 @@ import { distShell, prebuilt } from './static'
|
|
|
33
29
|
import { renderStatus } from './status'
|
|
34
30
|
import { serveVendorEmojibase, serveVendorReact } from './vendor'
|
|
35
31
|
|
|
36
|
-
type WsData = {
|
|
37
|
-
channel: 'chat' | 'events' | 'collab'
|
|
38
|
-
workspaceId: string
|
|
39
|
-
workspacePath?: string
|
|
40
|
-
// The collab profile a proxy (Cloudflare Access) verified for the upgrade.
|
|
41
|
-
identity?: CollabIdentity
|
|
42
|
-
}
|
|
32
|
+
type WsData = { channel: 'chat' | 'events'; workspaceId: string }
|
|
43
33
|
|
|
44
34
|
function isClientMessage(value: unknown): value is ClientMessage {
|
|
45
35
|
if (typeof value !== 'object' || value === null || !('type' in value)) return false
|
|
@@ -49,7 +39,6 @@ function isClientMessage(value: unknown): value is ClientMessage {
|
|
|
49
39
|
sessionId?: unknown
|
|
50
40
|
content?: unknown
|
|
51
41
|
isNew?: unknown
|
|
52
|
-
personalSelection?: unknown
|
|
53
42
|
optimisticId?: unknown
|
|
54
43
|
model?: unknown
|
|
55
44
|
effort?: unknown
|
|
@@ -65,7 +54,6 @@ function isClientMessage(value: unknown): value is ClientMessage {
|
|
|
65
54
|
typeof v.content === 'string' &&
|
|
66
55
|
typeof v.sessionId === 'string' &&
|
|
67
56
|
typeof v.isNew === 'boolean' &&
|
|
68
|
-
(v.personalSelection === undefined || typeof v.personalSelection === 'boolean') &&
|
|
69
57
|
(v.optimisticId === undefined || typeof v.optimisticId === 'string') &&
|
|
70
58
|
(v.model === undefined || typeof v.model === 'string') &&
|
|
71
59
|
(v.effort === undefined || typeof v.effort === 'string') &&
|
|
@@ -141,37 +129,14 @@ export const app = Bun.serve<WsData>({
|
|
|
141
129
|
// routes it ahead of the Hono-served `/api/workspaces/:id`; the upgrade
|
|
142
130
|
// happens in-handler via the route's `server` argument.
|
|
143
131
|
'/api/workspaces/ws': (req: Request, server: Bun.Server<WsData>) =>
|
|
144
|
-
upgrade(server, req, { channel: 'events', workspaceId: '' })
|
|
145
|
-
|
|
146
|
-
'/api/workspaces/:id/collab/ws': async (req: Request, server: Bun.Server<WsData>) => {
|
|
147
|
-
const workspaceId = decodeURIComponent(new URL(req.url).pathname.split('/')[3] ?? '')
|
|
148
|
-
const workspace = await getWorkspace(workspaceId)
|
|
149
|
-
if (!workspace) return new Response('Workspace not found', { status: 404 })
|
|
150
|
-
if (!isCollabEnabled()) {
|
|
151
|
-
return new Response('Collab is not enabled for this workspace', { status: 403 })
|
|
152
|
-
}
|
|
153
|
-
// Behind Cloudflare Access, presence is joined only as the verified viewer.
|
|
154
|
-
const { provider, identity } = await proxyIdentity(req)
|
|
155
|
-
if (provider && !identity) {
|
|
156
|
-
return new Response('Sign in through Cloudflare Access to join', { status: 401 })
|
|
157
|
-
}
|
|
158
|
-
return upgrade(server, req, {
|
|
159
|
-
channel: 'collab',
|
|
160
|
-
workspaceId,
|
|
161
|
-
workspacePath: workspace.path,
|
|
162
|
-
...(identity ? { identity } : {})
|
|
163
|
-
})
|
|
164
|
-
}
|
|
132
|
+
upgrade(server, req, { channel: 'events', workspaceId: '' })
|
|
165
133
|
},
|
|
166
134
|
// Anything not matched above (the whole HTTP API + prod static assets + 404)
|
|
167
135
|
// is handled by Hono.
|
|
168
136
|
fetch: req => api.fetch(req),
|
|
169
137
|
websocket: {
|
|
170
138
|
open(ws) {
|
|
171
|
-
if (ws.data.channel === '
|
|
172
|
-
if (ws.data.workspacePath) collabManager.open(ws, ws.data.workspacePath, ws.data.identity)
|
|
173
|
-
else ws.close(1008, 'Missing workspace')
|
|
174
|
-
} else if (ws.data.channel === 'chat') {
|
|
139
|
+
if (ws.data.channel === 'chat') {
|
|
175
140
|
addClient(ws)
|
|
176
141
|
// Authoritative snapshot of every non-idle session across all
|
|
177
142
|
// harnesses so the client can light/clear spinners correctly even for
|
|
@@ -182,10 +147,6 @@ export const app = Bun.serve<WsData>({
|
|
|
182
147
|
}
|
|
183
148
|
},
|
|
184
149
|
async message(ws, message) {
|
|
185
|
-
if (ws.data.channel === 'collab') {
|
|
186
|
-
collabManager.message(ws, message)
|
|
187
|
-
return
|
|
188
|
-
}
|
|
189
150
|
if (ws.data.channel === 'events') {
|
|
190
151
|
try {
|
|
191
152
|
navigationRelay.receive(ws, JSON.parse(String(message)))
|
|
@@ -200,16 +161,15 @@ export const app = Bun.serve<WsData>({
|
|
|
200
161
|
if (data.type === 'chat' && (data.content?.trim() || data.attachments?.length)) {
|
|
201
162
|
const workspace = await getWorkspace(data.workspaceId)
|
|
202
163
|
if (!workspace) return
|
|
203
|
-
const collabReference = await getCollabReferencePath(workspace.path, workspace.type)
|
|
204
|
-
const context: MoiContext | undefined =
|
|
205
|
-
data.context || collabReference
|
|
206
|
-
? {
|
|
207
|
-
...(data.context ?? { activeTab: 'agent' }),
|
|
208
|
-
collabReference
|
|
209
|
-
}
|
|
210
|
-
: undefined
|
|
211
164
|
if (data.isNew) {
|
|
212
|
-
await
|
|
165
|
+
const selection = await saveSelectedSession(workspace.path, data.sessionId, null)
|
|
166
|
+
if (selection.changed) {
|
|
167
|
+
publishEvent({
|
|
168
|
+
type: 'selected-session:updated',
|
|
169
|
+
workspaceId: workspace.id,
|
|
170
|
+
sessionId: selection.sessionId
|
|
171
|
+
})
|
|
172
|
+
}
|
|
213
173
|
}
|
|
214
174
|
// Harnesses ignore fields they don't support (see SendMessageInput).
|
|
215
175
|
// Their failures surface internally; attachment resolution happens
|
|
@@ -227,7 +187,7 @@ export const app = Bun.serve<WsData>({
|
|
|
227
187
|
effort: data.effort,
|
|
228
188
|
fastMode: data.fastMode,
|
|
229
189
|
stream: data.stream,
|
|
230
|
-
context,
|
|
190
|
+
context: data.context,
|
|
231
191
|
agentId: workspace.agentId
|
|
232
192
|
})
|
|
233
193
|
.catch(error => {
|
|
@@ -254,8 +214,7 @@ export const app = Bun.serve<WsData>({
|
|
|
254
214
|
} catch {}
|
|
255
215
|
},
|
|
256
216
|
close(ws) {
|
|
257
|
-
if (ws.data.channel === '
|
|
258
|
-
else if (ws.data.channel === 'chat') removeClient(ws)
|
|
217
|
+
if (ws.data.channel === 'chat') removeClient(ws)
|
|
259
218
|
else {
|
|
260
219
|
navigationRelay.remove(ws)
|
|
261
220
|
ws.unsubscribe(EVENTS_TOPIC)
|
|
@@ -289,10 +248,7 @@ startServiceLogMaintenance()
|
|
|
289
248
|
// changes; in any context Ctrl-C sends SIGINT. Close both servers and kill the
|
|
290
249
|
// per-workspace function workers and any in-flight applet build child so no
|
|
291
250
|
// child processes are orphaned.
|
|
292
|
-
|
|
293
|
-
async function shutdown() {
|
|
294
|
-
if (shuttingDown) return
|
|
295
|
-
shuttingDown = true
|
|
251
|
+
function shutdown() {
|
|
296
252
|
try {
|
|
297
253
|
app.stop(true)
|
|
298
254
|
} catch {}
|
|
@@ -302,7 +258,6 @@ async function shutdown() {
|
|
|
302
258
|
for (const h of allHarnesses()) h.shutdown?.()
|
|
303
259
|
killAllWorkers()
|
|
304
260
|
killBuildWorkers()
|
|
305
|
-
await collabManager.shutdown()
|
|
306
261
|
process.exit()
|
|
307
262
|
}
|
|
308
263
|
process.on('SIGTERM', shutdown)
|
package/ui-components/avatar.tsx
CHANGED
|
@@ -7,14 +7,14 @@ function Avatar({
|
|
|
7
7
|
size = 'default',
|
|
8
8
|
...props
|
|
9
9
|
}: AvatarPrimitive.Root.Props & {
|
|
10
|
-
size?: 'default' | 'sm' | 'lg'
|
|
10
|
+
size?: 'default' | 'sm' | 'lg'
|
|
11
11
|
}) {
|
|
12
12
|
return (
|
|
13
13
|
<AvatarPrimitive.Root
|
|
14
14
|
data-slot="avatar"
|
|
15
15
|
data-size={size}
|
|
16
16
|
className={cn(
|
|
17
|
-
'group/avatar relative flex shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=
|
|
17
|
+
'group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten',
|
|
18
18
|
className
|
|
19
19
|
)}
|
|
20
20
|
{...props}
|
|
@@ -37,7 +37,7 @@ function AvatarFallback({ className, ...props }: AvatarPrimitive.Fallback.Props)
|
|
|
37
37
|
<AvatarPrimitive.Fallback
|
|
38
38
|
data-slot="avatar-fallback"
|
|
39
39
|
className={cn(
|
|
40
|
-
'flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs
|
|
40
|
+
'flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs',
|
|
41
41
|
className
|
|
42
42
|
)}
|
|
43
43
|
{...props}
|
|
@@ -52,7 +52,6 @@ function AvatarBadge({ className, ...props }: React.ComponentProps<'span'>) {
|
|
|
52
52
|
className={cn(
|
|
53
53
|
'absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none',
|
|
54
54
|
'group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden',
|
|
55
|
-
'group-data-[size=xs]/avatar:size-2 group-data-[size=xs]/avatar:[&>svg]:hidden',
|
|
56
55
|
'group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2',
|
|
57
56
|
'group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2',
|
|
58
57
|
className
|
|
@@ -80,7 +79,7 @@ function AvatarGroupCount({ className, ...props }: React.ComponentProps<'div'>)
|
|
|
80
79
|
<div
|
|
81
80
|
data-slot="avatar-group-count"
|
|
82
81
|
className={cn(
|
|
83
|
-
'relative flex shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background [&>svg]:size-4 [:where([class~="group/avatar-group"]):has([data-size=lg])_&]:size-10 [:where([class~="group/avatar-group"]):has([data-size=lg])_&]:[&>svg]:size-5 [:where([class~="group/avatar-group"]):has([data-size=sm])_&]:size-6 [:where([class~="group/avatar-group"]):has([data-size=sm])_&]:[&>svg]:size-3
|
|
82
|
+
'relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background [&>svg]:size-4 [:where([class~="group/avatar-group"]):has([data-size=lg])_&]:size-10 [:where([class~="group/avatar-group"]):has([data-size=lg])_&]:[&>svg]:size-5 [:where([class~="group/avatar-group"]):has([data-size=sm])_&]:size-6 [:where([class~="group/avatar-group"]):has([data-size=sm])_&]:[&>svg]:size-3',
|
|
84
83
|
className
|
|
85
84
|
)}
|
|
86
85
|
{...props}
|
|
@@ -299,7 +299,7 @@ export function AvatarGroupCountIconExample() {
|
|
|
299
299
|
|
|
300
300
|
## Sizes
|
|
301
301
|
|
|
302
|
-
Use the `size` prop to change the size of the avatar.
|
|
302
|
+
Use the `size` prop to change the size of the avatar.
|
|
303
303
|
|
|
304
304
|
```tsx
|
|
305
305
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
|
@@ -445,10 +445,10 @@ export function AvatarRtl() {
|
|
|
445
445
|
|
|
446
446
|
The `Avatar` component is the root component that wraps the avatar image and fallback.
|
|
447
447
|
|
|
448
|
-
| Prop | Type
|
|
449
|
-
| ----------- |
|
|
450
|
-
| `size` | `"default" \| "sm" \| "lg"
|
|
451
|
-
| `className` | `string`
|
|
448
|
+
| Prop | Type | Default |
|
|
449
|
+
| ----------- | --------------------------- | ----------- |
|
|
450
|
+
| `size` | `"default" \| "sm" \| "lg"` | `"default"` |
|
|
451
|
+
| `className` | `string` | - |
|
|
452
452
|
|
|
453
453
|
### AvatarImage
|
|
454
454
|
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { useMemo, useState, useSyncExternalStore } from 'react'
|
|
2
|
-
|
|
3
|
-
import { IconArrowsShuffle } from '@tabler/icons-react'
|
|
4
|
-
|
|
5
|
-
import { Button } from '@/client/components/ui/button'
|
|
6
|
-
import { Input } from '@/client/components/ui/input'
|
|
7
|
-
import { PERSONA_COLORS } from '@/lib/collab/colors'
|
|
8
|
-
import type { CollabIdentity } from '@/lib/collab/types'
|
|
9
|
-
import { Avatar, AvatarFallback, AvatarImage } from '@/ui-components/avatar'
|
|
10
|
-
|
|
11
|
-
import { createDevIdentity, personaIdentity, randomPersona } from './dev-persona'
|
|
12
|
-
import type { Persona } from './dev-persona'
|
|
13
|
-
import { facehashDataUrl } from './facehash-avatar'
|
|
14
|
-
import { getIdentity, getIdentitySource, setDevIdentity, subscribeIdentityStore } from './identity'
|
|
15
|
-
import { userDisplayName } from './people'
|
|
16
|
-
|
|
17
|
-
export function DevCollabIdentity() {
|
|
18
|
-
const source = useSyncExternalStore(subscribeIdentityStore, getIdentitySource, getIdentitySource)
|
|
19
|
-
const identity = useSyncExternalStore(subscribeIdentityStore, getIdentity, getIdentity)
|
|
20
|
-
if (source === 'external') return null
|
|
21
|
-
if (source === 'cloudflare-access') return <AccessIdentity identity={identity} />
|
|
22
|
-
return <DevIdentityForm key={identity?.id ?? 'setup'} savedIdentity={identity} />
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
type AccessIdentityProps = { identity: CollabIdentity | null }
|
|
26
|
-
|
|
27
|
-
// Behind Cloudflare Access the profile is inherited, so there is nothing to edit.
|
|
28
|
-
// Access profiles carry no name, so the label is the email, as in workspaces.
|
|
29
|
-
function AccessIdentity({ identity }: AccessIdentityProps) {
|
|
30
|
-
const label = identity ? userDisplayName(identity) : null
|
|
31
|
-
const avatar = useMemo(
|
|
32
|
-
() => (identity && label ? (identity.avatar ?? facehashDataUrl(label, identity.color)) : null),
|
|
33
|
-
[identity, label]
|
|
34
|
-
)
|
|
35
|
-
return (
|
|
36
|
-
<section aria-labelledby="dev-identity-title" className="flex flex-col gap-5">
|
|
37
|
-
<header>
|
|
38
|
-
<h2 id="dev-identity-title" className="text-base font-medium">
|
|
39
|
-
Cloudflare Access identity
|
|
40
|
-
</h2>
|
|
41
|
-
<p className="mt-1 text-sm text-muted-foreground">
|
|
42
|
-
{identity
|
|
43
|
-
? 'This server inherits identities from Cloudflare Access. You appear by your email, with a color picked from your Access user ID.'
|
|
44
|
-
: 'This server inherits identities from Cloudflare Access, but this page wasn’t opened through it. Open moi at its Cloudflare Access address to appear in workspaces.'}
|
|
45
|
-
</p>
|
|
46
|
-
</header>
|
|
47
|
-
{label && (
|
|
48
|
-
<div className="flex items-center gap-3">
|
|
49
|
-
<Avatar size="lg">
|
|
50
|
-
{avatar && <AvatarImage src={avatar} alt="" />}
|
|
51
|
-
<AvatarFallback>{label.slice(0, 2).toUpperCase()}</AvatarFallback>
|
|
52
|
-
</Avatar>
|
|
53
|
-
<span className="min-w-0 truncate text-sm font-medium">{label}</span>
|
|
54
|
-
</div>
|
|
55
|
-
)}
|
|
56
|
-
</section>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
type DevIdentityFormProps = { savedIdentity: CollabIdentity | null }
|
|
61
|
-
|
|
62
|
-
function DevIdentityForm({ savedIdentity }: DevIdentityFormProps) {
|
|
63
|
-
const [initial] = useState(() => savedIdentity ?? createDevIdentity())
|
|
64
|
-
const [persona, setPersona] = useState<Persona>({
|
|
65
|
-
name: initial.name ?? '',
|
|
66
|
-
color: initial.color
|
|
67
|
-
})
|
|
68
|
-
const name = persona.name.trim()
|
|
69
|
-
const identity = useMemo(
|
|
70
|
-
() => personaIdentity(initial.id, { name, color: persona.color }),
|
|
71
|
-
[initial.id, name, persona.color]
|
|
72
|
-
)
|
|
73
|
-
const changed = name !== (savedIdentity?.name ?? '') || persona.color !== savedIdentity?.color
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<section aria-labelledby="dev-identity-title" className="flex flex-col gap-5">
|
|
77
|
-
<header>
|
|
78
|
-
<h2 id="dev-identity-title" className="text-base font-medium">
|
|
79
|
-
Dev identity
|
|
80
|
-
</h2>
|
|
81
|
-
<p className="mt-1 text-sm text-muted-foreground">
|
|
82
|
-
Use a local profile in real workspaces. To test with two people, set up another profile in
|
|
83
|
-
a second browser tab.
|
|
84
|
-
</p>
|
|
85
|
-
</header>
|
|
86
|
-
<form
|
|
87
|
-
className="flex flex-col gap-5"
|
|
88
|
-
onSubmit={event => {
|
|
89
|
-
event.preventDefault()
|
|
90
|
-
setDevIdentity(identity)
|
|
91
|
-
}}
|
|
92
|
-
>
|
|
93
|
-
<div className="flex flex-col items-start gap-5 sm:flex-row">
|
|
94
|
-
{identity.avatar ? (
|
|
95
|
-
<img
|
|
96
|
-
src={identity.avatar}
|
|
97
|
-
alt="Identity preview"
|
|
98
|
-
className="size-16 shrink-0 rounded-full"
|
|
99
|
-
/>
|
|
100
|
-
) : (
|
|
101
|
-
<div aria-hidden="true" className="size-16 shrink-0 rounded-full bg-muted" />
|
|
102
|
-
)}
|
|
103
|
-
<div className="flex w-full max-w-sm min-w-0 flex-col gap-4">
|
|
104
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
105
|
-
Name (optional)
|
|
106
|
-
<Input
|
|
107
|
-
value={persona.name}
|
|
108
|
-
maxLength={80}
|
|
109
|
-
placeholder="Type a name"
|
|
110
|
-
autoComplete="off"
|
|
111
|
-
spellCheck={false}
|
|
112
|
-
onChange={event => setPersona({ ...persona, name: event.target.value })}
|
|
113
|
-
/>
|
|
114
|
-
</label>
|
|
115
|
-
<div className="flex flex-col gap-1.5 text-sm">
|
|
116
|
-
<span id="collab-color-label">Color</span>
|
|
117
|
-
<div
|
|
118
|
-
role="radiogroup"
|
|
119
|
-
aria-labelledby="collab-color-label"
|
|
120
|
-
className="flex flex-wrap gap-2"
|
|
121
|
-
>
|
|
122
|
-
{PERSONA_COLORS.map(([label, hex]) => (
|
|
123
|
-
<label key={hex} className="cursor-pointer">
|
|
124
|
-
<input
|
|
125
|
-
type="radio"
|
|
126
|
-
name="color"
|
|
127
|
-
value={hex}
|
|
128
|
-
aria-label={label}
|
|
129
|
-
checked={persona.color === hex}
|
|
130
|
-
onChange={() => setPersona({ ...persona, color: hex })}
|
|
131
|
-
className="peer sr-only"
|
|
132
|
-
/>
|
|
133
|
-
<svg
|
|
134
|
-
viewBox="0 0 24 24"
|
|
135
|
-
aria-hidden="true"
|
|
136
|
-
className="size-6 rounded-full ring-foreground ring-offset-2 ring-offset-background transition-shadow peer-checked:ring-2 peer-focus-visible:ring-2 peer-focus-visible:ring-ring"
|
|
137
|
-
>
|
|
138
|
-
<circle cx="12" cy="12" r="12" fill={hex} />
|
|
139
|
-
</svg>
|
|
140
|
-
</label>
|
|
141
|
-
))}
|
|
142
|
-
</div>
|
|
143
|
-
</div>
|
|
144
|
-
<div className="flex flex-wrap gap-2">
|
|
145
|
-
<Button type="submit" size="sm" disabled={!changed}>
|
|
146
|
-
{savedIdentity ? 'Save identity' : 'Use dev identity'}
|
|
147
|
-
</Button>
|
|
148
|
-
<Button
|
|
149
|
-
type="button"
|
|
150
|
-
variant="secondary"
|
|
151
|
-
size="sm"
|
|
152
|
-
onClick={() => setPersona(randomPersona(persona))}
|
|
153
|
-
>
|
|
154
|
-
<IconArrowsShuffle stroke={1.75} />
|
|
155
|
-
Randomize
|
|
156
|
-
</Button>
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
</div>
|
|
160
|
-
<p className="text-sm text-muted-foreground">
|
|
161
|
-
{savedIdentity
|
|
162
|
-
? 'Your dev identity is saved in this browser tab. '
|
|
163
|
-
: 'Creating a profile is optional. '}
|
|
164
|
-
Start moi with <code className="font-mono">--experimental-collab</code> to use it in
|
|
165
|
-
workspaces. The playground below uses its own sample people.
|
|
166
|
-
</p>
|
|
167
|
-
</form>
|
|
168
|
-
</section>
|
|
169
|
-
)
|
|
170
|
-
}
|