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/collab/worker.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { CollabServerMessage } from '@/lib/collab/types'
|
|
2
|
-
|
|
3
|
-
import type { ParentMessage, WorkerMessage } from './ipc'
|
|
4
|
-
import { CollabService } from './service'
|
|
5
|
-
|
|
6
|
-
const workspacePath = process.env.MOI_COLLAB_WORKSPACE
|
|
7
|
-
const generation = process.env.MOI_COLLAB_GENERATION
|
|
8
|
-
if (!workspacePath || !generation || !process.send) throw new Error('Missing collab worker context')
|
|
9
|
-
|
|
10
|
-
function send(message: WorkerMessage) {
|
|
11
|
-
process.send?.(message)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const service = new CollabService((connectionId, message) => {
|
|
15
|
-
send({ type: 'client', generation, connectionId, message })
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
function errorInfo(error: unknown): { code: string; message: string } {
|
|
19
|
-
return {
|
|
20
|
-
code: error instanceof Error && 'code' in error ? String(error.code) : 'invalid_request',
|
|
21
|
-
message: error instanceof Error ? error.message : 'Collab request failed'
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
process.on('message', (message: ParentMessage) => {
|
|
26
|
-
if (message.type === 'shutdown') return shutdown()
|
|
27
|
-
if (message.type === 'leave') return service.leave(message.connectionId)
|
|
28
|
-
if (message.type === 'client') {
|
|
29
|
-
try {
|
|
30
|
-
service.receive(message.connectionId, message.message)
|
|
31
|
-
} catch (error) {
|
|
32
|
-
const response: CollabServerMessage = {
|
|
33
|
-
type: 'error',
|
|
34
|
-
...errorInfo(error)
|
|
35
|
-
}
|
|
36
|
-
send({ type: 'client', generation, connectionId: message.connectionId, message: response })
|
|
37
|
-
}
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
let shuttingDown = false
|
|
43
|
-
function shutdown() {
|
|
44
|
-
if (shuttingDown) return
|
|
45
|
-
shuttingDown = true
|
|
46
|
-
service.close()
|
|
47
|
-
process.exit(0)
|
|
48
|
-
}
|
|
49
|
-
process.on('disconnect', shutdown)
|
|
50
|
-
process.on('SIGTERM', shutdown)
|
|
51
|
-
process.on('SIGINT', shutdown)
|
|
52
|
-
send({ type: 'ready', generation })
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
# Collaborative applets
|
|
2
|
-
|
|
3
|
-
moi workspaces can be shared with multiple users. This guide explains the primitives in
|
|
4
|
-
`moi/collab` that make views and widgets ready for real-time collaboration: user lookup,
|
|
5
|
-
connected users, cursors, focus, and selections.
|
|
6
|
-
|
|
7
|
-
## Concepts
|
|
8
|
-
|
|
9
|
-
### User identity
|
|
10
|
-
|
|
11
|
-
Every user has a unique, stable `id` and a `color`. A profile can also include `name`, `email`,
|
|
12
|
-
and `avatar`; these fields are optional, and a name can be empty.
|
|
13
|
-
|
|
14
|
-
**Store only user IDs when writing user references to the server**, such as `authorId` or
|
|
15
|
-
`assigneeIds`. Do not copy names, emails, colors, or avatars into application records. Resolve
|
|
16
|
-
current profiles through the hooks and components below. Applet-specific data, such as a user's
|
|
17
|
-
preferences or role in a project, can be stored separately and keyed by user ID.
|
|
18
|
-
|
|
19
|
-
```tsx
|
|
20
|
-
import { User, Facepile } from 'moi/collab'
|
|
21
|
-
|
|
22
|
-
<User id={authorId} />
|
|
23
|
-
<Facepile ids={assigneeIds} max={3} />
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
These components resolve profiles and handle missing names and unknown IDs for you.
|
|
27
|
-
|
|
28
|
-
### Workspace members and connected users
|
|
29
|
-
|
|
30
|
-
Workspace members are registered users, including people who are offline. Use the full member
|
|
31
|
-
list for assignee pickers and other user references. Query connected users to show who is here
|
|
32
|
-
or working on the same page.
|
|
33
|
-
|
|
34
|
-
| Hook | Returns |
|
|
35
|
-
| ------------------------------------------ | -------------------------------------------------------------------- |
|
|
36
|
-
| `useMe()` | The current user. |
|
|
37
|
-
| `useUser(id)` | A user by ID, including an offline member. |
|
|
38
|
-
| `useWorkspaceUsers()` | All available workspace members, including you. |
|
|
39
|
-
| `useWorkspaceUsers({ status: 'offline' })` | Members who are offline. The filter also accepts `active` or `away`. |
|
|
40
|
-
| `useWorkspaceUsersStatus()` | Whether the member list is `loading`, `ready`, or `unavailable`. |
|
|
41
|
-
| `usePeers()` | Other connected users on the current page. |
|
|
42
|
-
| `usePeers({ scope: 'workspace' })` | Other connected users anywhere in the workspace. |
|
|
43
|
-
|
|
44
|
-
User results include `status`: `active` when at least one workspace connection has a visible
|
|
45
|
-
page, `away` when connected without a visible page, or `offline` when disconnected. A user on
|
|
46
|
-
another page can still be active. `usePeers` excludes your own user, combines multiple tabs
|
|
47
|
-
into one user, and can filter by `status: 'active'` or `'away'`.
|
|
48
|
-
|
|
49
|
-
`useMe()` and `useUser(id)` return `null` when the user cannot be resolved. When the member list
|
|
50
|
-
is unavailable, user enumeration falls back to your identity and connected users; it cannot
|
|
51
|
-
discover offline members.
|
|
52
|
-
|
|
53
|
-
### Provided by moi
|
|
54
|
-
|
|
55
|
-
moi supplies identity, the user directory, and the connection between applets. You do not need
|
|
56
|
-
to set up transport, sockets, or providers. Use the exports from `moi/collab` directly; applets
|
|
57
|
-
read user profiles rather than creating or updating them.
|
|
58
|
-
|
|
59
|
-
## Presence
|
|
60
|
-
|
|
61
|
-
Presence is ephemeral state that describes what connected people are doing: where their pointer
|
|
62
|
-
is, which field they are editing, or which item they selected. It is not persisted and only
|
|
63
|
-
works while people are connected. Registrations are removed when their applet becomes inactive,
|
|
64
|
-
the browser tab is hidden, or the publishing component unmounts.
|
|
65
|
-
|
|
66
|
-
Presence does not save or synchronize application content. Continue saving documents, tasks,
|
|
67
|
-
and other durable data through your applet's `.server.ts` functions and storage.
|
|
68
|
-
|
|
69
|
-
### Built-in presence
|
|
70
|
-
|
|
71
|
-
| Component | Use |
|
|
72
|
-
| ---------------- | ----------------------------------------------------------------------------------------- |
|
|
73
|
-
| `Activity` | Show you and other connected users; use `scope="workspace"` to include other pages. |
|
|
74
|
-
| `Cursors` | Wrap an area to share and display pointers. Give separate areas distinct `surface` names. |
|
|
75
|
-
| `PresenceFrame` | Wrap one element to show an outline and users focused inside it. |
|
|
76
|
-
| `PresenceGutter` | Wrap one element to show focused users beside it. |
|
|
77
|
-
| `PresenceGroup` | Scope descendant frame, gutter, and selection IDs. Adds no DOM element. |
|
|
78
|
-
| `Selection` | Wrap an item with an `id` and controlled `selected` boolean to share its selection. |
|
|
79
|
-
|
|
80
|
-
```tsx
|
|
81
|
-
import { Cursors, PresenceGroup, PresenceFrame, PresenceGutter } from 'moi/collab'
|
|
82
|
-
|
|
83
|
-
;<Cursors surface="task-details">
|
|
84
|
-
<PresenceGroup id={task.id}>
|
|
85
|
-
<PresenceFrame id="title">
|
|
86
|
-
<Input defaultValue={task.title} />
|
|
87
|
-
</PresenceFrame>
|
|
88
|
-
<PresenceGutter id="notes">
|
|
89
|
-
<Textarea defaultValue={task.notes} />
|
|
90
|
-
</PresenceGutter>
|
|
91
|
-
</PresenceGroup>
|
|
92
|
-
</Cursors>
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Frame and gutter each accept exactly one React element, such as an input, label, or card with
|
|
96
|
-
controls inside it; do not use a fragment. They handle focus and user lookup automatically.
|
|
97
|
-
Use ordinary elements for layout; a group only provides scoping.
|
|
98
|
-
|
|
99
|
-
Use stable record IDs and field names for `id`. Groups can nest: a field `title` inside task
|
|
100
|
-
`42` inside group `tasks` identifies `tasks/42/title`. IDs must be nonblank and unique within
|
|
101
|
-
their group. In lists, give each item a React `key` as well as a presence `id`; use record IDs,
|
|
102
|
-
not array positions. When a dialog switches records, change its group ID.
|
|
103
|
-
|
|
104
|
-
Focus, selections, and cursors are scoped to the current page and applet. Matching IDs in an
|
|
105
|
-
unrelated view or widget do not share presence.
|
|
106
|
-
|
|
107
|
-
### Custom presence
|
|
108
|
-
|
|
109
|
-
Use a named channel for activity that the built-in components do not cover. Inside a component:
|
|
110
|
-
|
|
111
|
-
```tsx
|
|
112
|
-
import { usePresence, usePublishPresence } from 'moi/collab'
|
|
113
|
-
|
|
114
|
-
usePublishPresence('editing', { taskId })
|
|
115
|
-
const editors = usePresence<{ taskId: string }>('editing')
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
`usePublishPresence` publishes the current value and replaces it when it changes. Mount the
|
|
119
|
-
publishing component only while that activity is happening. Values must be JSON and no larger
|
|
120
|
-
than 4 KiB.
|
|
121
|
-
|
|
122
|
-
`usePresence` only reads. It returns `{ connectionId, userId, value }[]` for other connections
|
|
123
|
-
on the same page and applet. Resolve each `userId` with `User` or `useUser`. One user can have
|
|
124
|
-
separate presence values in multiple tabs.
|
|
125
|
-
|
|
126
|
-
Channel names are local to the applet, not to `PresenceGroup`. Include record IDs in your
|
|
127
|
-
values when an activity belongs to a particular record.
|
|
128
|
-
|
|
129
|
-
## Component props cheat sheet
|
|
130
|
-
|
|
131
|
-
All components accept optional `className: string` except `PresenceGroup`. The last column
|
|
132
|
-
lists optional props, with defaults where applicable.
|
|
133
|
-
|
|
134
|
-
| Component | Required props | Optional props and defaults |
|
|
135
|
-
| ---------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
136
|
-
| `User` | `id: string` | `size="md"` (`xs`, `sm`, `md`, `lg`); `avatarOnly=false`; `you=false`; `detail: ReactNode`; `showStatus=true`; `label: string` |
|
|
137
|
-
| `Facepile` | `ids: readonly string[]` | `size="sm"` (`xs`, `sm`, `md`); `max=3`; `showStatus=false` |
|
|
138
|
-
| `Activity` | None | `scope="page"` (`page`, `workspace`) |
|
|
139
|
-
| `Cursors` | `children: ReactNode` | `surface="default"` (string) |
|
|
140
|
-
| `PresenceFrame` / `PresenceGutter` | `id: string`; `children`: exactly one React element | None beyond `className` |
|
|
141
|
-
| `PresenceGroup` | `id: string`; `children: ReactNode` | None |
|
|
142
|
-
| `Selection` | `id: string`; `selected: boolean`; `children: ReactNode` | None beyond `className` |
|
|
143
|
-
|
|
144
|
-
- `User`: `avatarOnly` hides the visible name and detail; `you` adds a manual “(you)” suffix;
|
|
145
|
-
`detail` adds secondary content. `label` sets the avatar tooltip and accessible label, not
|
|
146
|
-
the visible user name. `showStatus` shows a dot for active users.
|
|
147
|
-
- `Facepile`: duplicate IDs appear once; users beyond `max` become a `+N` overflow indicator.
|
|
148
|
-
- Only `User` and `Facepile` accept `size`. `Activity` shows all matching users and has no
|
|
149
|
-
`size` or `max` prop.
|
|
150
|
-
|
|
151
|
-
See `.moi/collab-env.d.ts` for the complete public types and component props.
|