moi-computer 0.11.1-next.4 → 0.12.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.
Files changed (131) hide show
  1. package/client/api/app-config.ts +7 -4
  2. package/client/app/AppRouter.tsx +2 -2
  3. package/client/app/routes/WorkspaceRoute.tsx +27 -19
  4. package/client/features/applets/{AppletMount.tsx → AppletContainer.tsx} +7 -5
  5. package/client/features/applets/WidgetShell.tsx +3 -3
  6. package/client/features/applets/applet-cache.ts +3 -5
  7. package/client/features/applets/applet-runtime.ts +27 -12
  8. package/client/features/applets/applet-thumbnail.ts +2 -1
  9. package/client/features/chat/applet-chat-intents.ts +14 -6
  10. package/client/features/chat/composer/attachments/draft-attachments.ts +21 -4
  11. package/client/features/chat/messages/MarkdownContent.tsx +5 -2
  12. package/client/features/chat/sessions/browser-tab-state.ts +18 -0
  13. package/client/features/chat/sessions/useSelectedSession.ts +55 -21
  14. package/client/features/chat/useChat.ts +4 -0
  15. package/client/features/collab/applet-api.ts +34 -0
  16. package/client/features/collab/client.ts +239 -0
  17. package/client/features/collab/components/cursors.tsx +199 -0
  18. package/client/features/collab/components/presence-avatars.tsx +61 -0
  19. package/client/features/collab/components/presence-frame.tsx +126 -0
  20. package/client/features/collab/components/presence-group.tsx +23 -0
  21. package/client/features/collab/components/presence-helpers.ts +50 -0
  22. package/client/features/collab/components/user-avatar-group.tsx +22 -0
  23. package/client/features/collab/components/user-avatar.tsx +40 -0
  24. package/client/features/collab/components/user.tsx +50 -0
  25. package/client/features/collab/hooks.tsx +164 -0
  26. package/client/features/collab/host-state.ts +254 -0
  27. package/client/features/collab/index.ts +5 -0
  28. package/client/features/collab/local-user.ts +46 -0
  29. package/client/features/collab/presence-publisher.ts +30 -0
  30. package/client/features/collab/presence-target.ts +8 -0
  31. package/client/features/collab/provider.tsx +79 -0
  32. package/client/features/collab/proxy-user.ts +35 -0
  33. package/client/features/collab/store.ts +156 -0
  34. package/client/features/collab/testing/component-fixtures.tsx +54 -0
  35. package/client/features/collab/testing/fake-engine.ts +129 -0
  36. package/client/features/collab/users.ts +106 -0
  37. package/client/features/collab/workspace-users-menu.tsx +194 -0
  38. package/client/features/connectors/mcp-icons.ts +0 -2
  39. package/client/features/dev/DevIndexPage.tsx +5 -0
  40. package/client/features/dev/DevRoutes.tsx +16 -4
  41. package/client/features/dev/collab/collab-page.tsx +24 -0
  42. package/client/features/dev/collab/collab-playground.tsx +614 -0
  43. package/client/features/dev/collab/local-user-settings.tsx +166 -0
  44. package/client/features/dev/collab/playground-room.ts +33 -0
  45. package/client/features/dev/{UiComponentsPage.tsx → ui-components/ui-components-page.tsx} +1 -1
  46. package/client/features/overview/WidgetCanvas.tsx +3 -1
  47. package/client/features/views/ViewManager.tsx +12 -7
  48. package/client/features/views/api.ts +2 -2
  49. package/client/features/views/useViewBuilderActions.ts +3 -0
  50. package/client/features/workspace/WorkspaceContext.tsx +1 -1
  51. package/client/features/workspace/WorkspaceLayoutContext.tsx +8 -2
  52. package/client/features/workspace/WorkspaceScreen.tsx +19 -11
  53. package/client/features/workspace/WorkspaceTabs.tsx +3 -3
  54. package/client/features/workspace/api.ts +2 -1
  55. package/client/features/workspace/browser-tab-state.ts +44 -0
  56. package/client/features/workspace/layout-save.ts +13 -0
  57. package/client/features/workspace/moi-context.ts +2 -1
  58. package/client/features/workspace/useWorkspaceNavigation.ts +20 -8
  59. package/client/index.css +45 -0
  60. package/client/index.tsx +9 -4
  61. package/client/main.tsx +1 -11
  62. package/client/theme.css +4 -1
  63. package/dist/chunk-2jncyq65.js +1 -0
  64. package/dist/{chunk-brr0zbeh.js → chunk-3a48fyf7.js} +2 -2
  65. package/dist/{chunk-tzz101ea.js → chunk-97eg9mjn.js} +1 -1
  66. package/dist/chunk-e2q5ken7.js +68 -0
  67. package/dist/{chunk-zs4mte79.js → chunk-efdyz6xp.js} +1 -1
  68. package/dist/chunk-h2kj1ysj.js +1 -0
  69. package/dist/chunk-jf6czgrz.js +2 -0
  70. package/dist/chunk-nez8sdta.js +1 -0
  71. package/dist/chunk-nzwgm8vc.css +1 -0
  72. package/dist/chunk-ph0h6h86.js +1 -0
  73. package/dist/chunk-ryg9z3kn.js +10 -0
  74. package/dist/chunk-tpn177bt.js +2 -0
  75. package/dist/chunk-vfpsc75k.js +2 -0
  76. package/dist/{chunk-m1fvqssh.js → chunk-z3byfve5.js} +2 -2
  77. package/dist/index.html +1 -1
  78. package/lib/collab/colors.ts +30 -0
  79. package/lib/collab/protocol.ts +84 -0
  80. package/lib/collab/types.ts +52 -0
  81. package/lib/experimental.ts +14 -0
  82. package/lib/moi-context.ts +11 -3
  83. package/lib/navigation.ts +25 -5
  84. package/lib/types.ts +20 -33
  85. package/package.json +2 -2
  86. package/server/AGENTS.md +1 -1
  87. package/server/api.ts +28 -5
  88. package/server/app-config.ts +127 -34
  89. package/server/applet-typecheck.ts +8 -3
  90. package/server/applets/applet-css.ts +1 -1
  91. package/server/applets/build-applet.ts +9 -3
  92. package/server/applets/declarations/base.d.ts +75 -0
  93. package/server/applets/declarations/collab.d.ts +88 -0
  94. package/server/applets/declarations.ts +46 -0
  95. package/server/applets/index.ts +8 -8
  96. package/server/applets/runtime/collab.ts +94 -0
  97. package/server/applets/runtime/moi.ts +12 -19
  98. package/server/applets/runtime/rpc.ts +2 -4
  99. package/server/chat-selection.ts +22 -0
  100. package/server/cli.ts +86 -21
  101. package/server/collab/cloudflare-access.ts +78 -0
  102. package/server/collab/config.ts +18 -0
  103. package/server/collab/manager.ts +407 -0
  104. package/server/collab/service.ts +136 -0
  105. package/server/collab/skill/index.ts +53 -0
  106. package/server/collab/worker-messages.ts +10 -0
  107. package/server/collab/worker.ts +52 -0
  108. package/server/layout.ts +10 -3
  109. package/server/moi-scaffold.ts +55 -84
  110. package/server/preview.ts +1 -1
  111. package/server/skill-update.ts +7 -9
  112. package/server/skills-template.ts +14 -2
  113. package/server/web.ts +65 -17
  114. package/server/workspace-init.ts +6 -3
  115. package/ui-components/avatar.tsx +24 -11
  116. package/ui-components/button.tsx +9 -9
  117. package/ui-components/docs/avatar.md +11 -30
  118. package/workspace/.claude/skills/moi-workspace/SKILL.md +14 -11
  119. package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +262 -0
  120. package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +10 -7
  121. package/client/assets/mcp/agentation.png +0 -0
  122. package/dist/agentation-4s0nn45p.png +0 -0
  123. package/dist/chunk-2gs8jjx4.css +0 -1
  124. package/dist/chunk-7vvg5fyz.js +0 -68
  125. package/dist/chunk-94m3q9ce.js +0 -1
  126. package/dist/chunk-by2wqgak.js +0 -1
  127. package/dist/chunk-p34hvqt3.js +0 -1
  128. package/dist/chunk-p83f0jnj.js +0 -2
  129. package/dist/chunk-xg01f6pn.js +0 -10
  130. /package/client/features/dev/{UiComponentPreviews.tsx → ui-components/ui-component-previews.tsx} +0 -0
  131. /package/server/applets/{runtime/base.ts → api-base.ts} +0 -0
@@ -176,28 +176,6 @@ Use the `className` prop to add custom styles to the badge such as custom colors
176
176
  </Avatar>
177
177
  ```
178
178
 
179
- ## Badge with Icon
180
-
181
- You can also use an icon inside `<AvatarBadge>`.
182
-
183
- ```tsx
184
- import { IconPlus } from '@tabler/icons-react'
185
-
186
- import { Avatar, AvatarBadge, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
187
-
188
- export function AvatarBadgeIconExample() {
189
- return (
190
- <Avatar className="grayscale">
191
- <AvatarImage src="https://github.com/pranathip.png" alt="@pranathip" />
192
- <AvatarFallback>PP</AvatarFallback>
193
- <AvatarBadge>
194
- <IconPlus stroke={1.75} />
195
- </AvatarBadge>
196
- </Avatar>
197
- )
198
- }
199
- ```
200
-
201
179
  ## Avatar Group
202
180
 
203
181
  Use the `AvatarGroup` component to add a group of avatars.
@@ -299,7 +277,7 @@ export function AvatarGroupCountIconExample() {
299
277
 
300
278
  ## Sizes
301
279
 
302
- Use the `size` prop to change the size of the avatar.
280
+ Use the `size` prop to change the size of the avatar and the group count.
303
281
 
304
282
  ```tsx
305
283
  import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
@@ -445,10 +423,10 @@ export function AvatarRtl() {
445
423
 
446
424
  The `Avatar` component is the root component that wraps the avatar image and fallback.
447
425
 
448
- | Prop | Type | Default |
449
- | ----------- | --------------------------- | ----------- |
450
- | `size` | `"default" \| "sm" \| "lg"` | `"default"` |
451
- | `className` | `string` | - |
426
+ | Prop | Type | Default |
427
+ | ----------- | ----------------------------------- | ----------- |
428
+ | `size` | `"default" \| "sm" \| "lg" \| "xs"` | `"default"` |
429
+ | `className` | `string` | - |
452
430
 
453
431
  ### AvatarImage
454
432
 
@@ -480,6 +458,8 @@ The `AvatarBadge` component displays a badge indicator on the avatar, typically
480
458
 
481
459
  The `AvatarGroup` component displays a group of avatars with overlapping styling.
482
460
 
461
+ Use the same size for all avatars and the count in a group. Transparent cutouts separate overlapping avatars, so the gaps show the surrounding background.
462
+
483
463
  | Prop | Type | Default |
484
464
  | ----------- | -------- | ------- |
485
465
  | `className` | `string` | - |
@@ -488,8 +468,9 @@ The `AvatarGroup` component displays a group of avatars with overlapping styling
488
468
 
489
469
  The `AvatarGroupCount` component displays a count indicator in an avatar group, typically showing the number of additional avatars.
490
470
 
491
- | Prop | Type | Default |
492
- | ----------- | -------- | ------- |
493
- | `className` | `string` | - |
471
+ | Prop | Type | Default |
472
+ | ----------- | ----------------------------------- | ----------- |
473
+ | `className` | `string` | - |
474
+ | `size` | `"xs" \| "sm" \| "default" \| "lg"` | `"default"` |
494
475
 
495
476
  For more information about Base UI Avatar props, see the [Base UI documentation](https://base-ui.com/react/components/avatar#api-reference).
@@ -141,8 +141,8 @@ moi navigate 'moi:/views/orders?order=o-1024'
141
141
  The CLI moves the most recently focused browser showing this workspace and waits for its URL
142
142
  acknowledgement. A timeout may mean navigation happened; inspect the browser before retrying.
143
143
 
144
- For applet `navigate(href)` and `resolveHref(href)` usage, see
145
- [Applet intents](references/INTENTS.md#navigation-navigatehref-and-resolvehrefhref).
144
+ For applet `navigate(url)` and `resolveUrl(url)` usage, see
145
+ [Applet intents](references/INTENTS.md#navigation-and-files).
146
146
 
147
147
  After building or editing an applet, follow [Verification and handoff](#verification-and-handoff).
148
148
 
@@ -375,20 +375,23 @@ It's plain Bun — every Bun API is available with no setup: `bun:sqlite`, `Bun.
375
375
  - **Bundled asset** — `import logo from './logo.png'` resolves to a URL at build time (images &
376
376
  fonts: `png jpg gif svg webp avif ico woff woff2 ttf otf`). For small art shipped beside the
377
377
  `.tsx`.
378
- - **Workspace file** — stream a file from the workspace via `fileUrl` from the **`moi`** package:
378
+ - **Workspace file** — stream a file from the workspace via `resolveUrl` from the **`moi`** package:
379
379
 
380
380
  ```tsx
381
- import { fileUrl } from 'moi'
382
- ;<video src={fileUrl('clips/intro.mp4')} controls />
381
+ import { resolveUrl } from 'moi'
382
+ ;<video src={resolveUrl('moi:/files/clips/intro.mp4')} controls />
383
383
  ```
384
384
 
385
- `fileUrl(path)` maps a **workspace-root-relative** path to a streaming URL (HTTP range — media
386
- seeks, nothing is base64-inlined). Media/asset extensions only; `.env`, source, JSON and dotfiles
387
- are rejected. The path is plain data, so a `.server.ts` can return it and the component renders
388
- `fileUrl(clip.file)`.
385
+ Paths are relative to the workspace root. Files stream with HTTP range support for media seeking.
386
+ Only media/asset extensions are served; dotfiles, source, and JSON are rejected.
387
+ File URLs can be resolved at module load.
389
388
 
390
- Rule of thumb: small own art → `import`; structured data → `.server.ts` returns it; large/streamable
391
- media → `.server.ts` returns the **path**, render with `fileUrl()`.
389
+ For a dynamic path, such as one returned by a server function, encode each segment:
390
+
391
+ ```tsx
392
+ const fileAddress = `moi:/files/${clip.file.split('/').map(encodeURIComponent).join('/')}`
393
+ ;<video src={resolveUrl(fileAddress)} controls />
394
+ ```
392
395
 
393
396
  ### Applet intents
394
397
 
@@ -0,0 +1,262 @@
1
+ # Collab
2
+
3
+ moi workspaces can be shared with multiple users. Use `moi/collab` in views and widgets to
4
+ show users and share cursors, focus, selections, and custom presence. moi supplies identity,
5
+ workspace membership, and the connection. Import the API directly; no provider or socket
6
+ setup is needed.
7
+
8
+ See `.moi/collab.d.ts` for the full types and props.
9
+
10
+ ## Users
11
+
12
+ Store **only** user IDs in application records, such as `authorId` or `assigneeIds`. Resolve their
13
+ current profiles through hooks or components. Keep applet-specific roles and preferences
14
+ separately, keyed by user ID. The host owns profile updates and workspace membership.
15
+
16
+ User results include a `status`:
17
+
18
+ - `active`: at least one connected browser tab is visible in this workspace.
19
+ - `away`: connected, with no visible tab in this workspace.
20
+ - `offline`: no connection in this workspace.
21
+
22
+ This tracks tab visibility, not idle time. A user on another page can still be active.
23
+
24
+ ### Hooks
25
+
26
+ #### `useMe` and `useUser`
27
+
28
+ Use `useMe()` when an action needs the current user's identity, such as assigning a task
29
+ to yourself. Use `useUser(id)` to resolve a stored author or assignee, including an offline
30
+ member. Both return `undefined` when the profile cannot be resolved, including while the
31
+ workspace directory loads. Handle that before reading profile fields.
32
+
33
+ #### `useWorkspaceUsers` and `usePeers`
34
+
35
+ Use `useWorkspaceUsers()` for assignee pickers and member lists. It includes your own user
36
+ and offline members. Filter with `status: 'active'`, `'away'`, or `'offline'`.
37
+
38
+ Use `usePeers()` to find other connected users on the current page. It excludes your own
39
+ user and combines multiple browser tabs into one user. Set `scope: 'workspace'` to include
40
+ other pages; its status filter accepts `'active'` or `'away'`.
41
+
42
+ A host-supplied directory is authoritative, including an empty list. Without one, user
43
+ lookups fall back to your profile and connected users; they cannot discover offline members.
44
+
45
+ ### Components
46
+
47
+ #### `User` and `UserAvatar`
48
+
49
+ `User` shows an avatar and name, with optional secondary `description` text. `UserAvatar` shows
50
+ only the avatar. Pass a user ID; both handle missing names and unknown users.
51
+
52
+ `User` and `UserAvatar` hide the status badge by default; pass `showStatusBadge` to show it
53
+ for active users.
54
+
55
+ #### `UserAvatarGroup`
56
+
57
+ Show several users together. IDs are deduplicated; `max` limits the visible avatars and
58
+ remaining users appear as an overflow count.
59
+
60
+ ## Presence
61
+
62
+ Presence describes temporary activity: pointer positions, focused fields, selected items,
63
+ or custom state. It is removed when its publishing component unmounts, the applet becomes
64
+ inactive, or the browser tab is hidden.
65
+
66
+ Save durable application content through your applet's `.server.ts` functions and storage.
67
+ Presence does not persist it. With live presence disabled, user lookups remain available
68
+ and applet content still renders.
69
+
70
+ Presence is scoped to the current page and applet. Matching IDs or channels in another
71
+ view or widget do not share activity.
72
+
73
+ Add presence where knowing what someone is working on helps people coordinate. Choose the
74
+ smallest meaningful target: a field, document block, task row, or selected card. Several
75
+ controls can share a target when they belong to one activity. Keep static content and
76
+ routine navigation free of presence indicators unless activity there matters to others.
77
+ Presence communicates activity; it does not lock records or prevent conflicting edits.
78
+
79
+ ### Hooks
80
+
81
+ #### `usePresence` and `usePublishPresence`
82
+
83
+ Use these hooks when activity needs a custom value or display, such as an editing summary,
84
+ an active tool, or a drag preview. Publish near the interaction and read the channel wherever
85
+ that information is useful in the applet. `usePublishPresence(channel, value)` publishes a
86
+ value and replaces it when it changes. Values must be JSON and no larger than 4 KiB.
87
+
88
+ `usePresence<T>(channel)` reads other connections' `{ connectionId, userId, value }` entries.
89
+ Reading never publishes presence. One user can have multiple entries, including another tab
90
+ of your own user. Resolve each `userId` with `User` or `useUser`.
91
+
92
+ ```tsx
93
+ import { usePresence, usePublishPresence, User } from 'moi/collab'
94
+
95
+ type TaskPresenceProps = { taskId: string }
96
+
97
+ // Mount this component only while the viewer is editing the task.
98
+ function EditingPresence({ taskId }: TaskPresenceProps) {
99
+ usePublishPresence('editing', { taskId })
100
+ return null
101
+ }
102
+
103
+ function TaskEditors({ taskId }: TaskPresenceProps) {
104
+ const editors = usePresence<{ taskId: string }>('editing')
105
+ return editors
106
+ .filter(entry => entry.value.taskId === taskId)
107
+ .map(entry => <User key={entry.connectionId} id={entry.userId} />)
108
+ }
109
+ ```
110
+
111
+ Channel names are local to the applet. Include record IDs in your values when activity belongs
112
+ to a particular record. Unmount the publishing component to stop publishing;
113
+ `false` and `null` are valid custom values, not removal signals.
114
+
115
+ ### Components
116
+
117
+ #### `Cursors`
118
+
119
+ Use `Cursors` for spatial work where seeing someone point or move helps, such as a board,
120
+ canvas, or arrangement of cards. For ordinary forms and lists, presence at the active field
121
+ or row is often enough.
122
+
123
+ Wrap the shared surface once, keeping local menus and navigation outside the cursor area.
124
+ It can contain many `PresenceFrame` or `PresenceAvatars` targets: cursors show movement,
125
+ while those targets show where someone is focused or present. Give separate cursor areas
126
+ distinct `id` values. A single area can omit `id`, which defaults to `"default"`.
127
+
128
+ ```tsx
129
+ import { Cursors } from 'moi/collab'
130
+
131
+ <Cursors id="board">{children}</Cursors>
132
+ ```
133
+
134
+ #### `PresenceFrame` and `PresenceAvatars`
135
+
136
+ Both components show other participants at a target and support the same automatic and
137
+ controlled modes below. Choose the appearance that fits the target's shape and how much
138
+ attention the activity needs.
139
+
140
+ Use `PresenceFrame` for a compact target whose boundaries should stand out, such as a form
141
+ field, a small group of controls, or a selected card. It draws an outline and shows user
142
+ names above it. A frame around a very wide or tall block can dominate the screen; keep the
143
+ target to the specific field or block being worked on.
144
+
145
+ Use `PresenceAvatars` for a quieter cue beside short content, such as a document line, list
146
+ row, compact field, or low-height block. It reserves a left gutter for avatars and works
147
+ well with wide rows because it marks one spot along the edge. For tall content, split it
148
+ into meaningful targets so the avatar stays close to the activity.
149
+
150
+ Both components accept `align` to position their user indicators. For `PresenceFrame`,
151
+ it aligns the name badge above the frame: `"start"` (left) or `"end"` (right, default).
152
+ For `PresenceAvatars`, it aligns avatars vertically in the left gutter: `"start"` (top),
153
+ `"center"` (default), or `"end"` (bottom).
154
+
155
+ Use the same `id` across clients for the same activity. Give separate activities distinct IDs.
156
+ Each component publishes your own presence and displays other connections, including another
157
+ tab of your own user. Multiple connections for one user display once at each target.
158
+
159
+ ##### Automatic focus
160
+
161
+ Without `present`, the component automatically publishes your presence while a descendant
162
+ has focus. Children can be any React content, including lists and fragments. All children
163
+ share one target; moving focus between them keeps it active. The nearest automatic wrapper
164
+ owns focus when wrappers are nested.
165
+
166
+ ```tsx
167
+ import { PresenceFrame, PresenceAvatars } from 'moi/collab'
168
+ import { Input } from '../ui/input'
169
+ import { Textarea } from '../ui/textarea'
170
+
171
+ <>
172
+ <PresenceFrame id="title" align="start">
173
+ <label htmlFor="title">Title</label>
174
+ <Input id="title" />
175
+ </PresenceFrame>
176
+ <PresenceAvatars id="notes">
177
+ <Textarea aria-label="Notes" />
178
+ </PresenceAvatars>
179
+ </>
180
+ ```
181
+
182
+ ##### Controlled presence
183
+
184
+ Pass `present` when application state determines presence, such as selecting an item or editing
185
+ a record. `true` publishes your presence; `false` clears it. Focus tracking is disabled, and
186
+ other participants still appear when your own value is false.
187
+
188
+ ```tsx
189
+ <>
190
+ <PresenceFrame id={`selection/${task.id}`} present={selected}>
191
+ <TaskCard onClick={() => setSelected(value => !value)} />
192
+ </PresenceFrame>
193
+ <PresenceAvatars id={`editing/${task.id}`} present={editing}>
194
+ <TaskEditor />
195
+ </PresenceAvatars>
196
+ </>
197
+ ```
198
+
199
+ Controlled presence lasts while `present` is true, subject to the cleanup described above.
200
+ Each mounted component owns its publication; clearing one leaves other publications intact.
201
+
202
+ #### `PresenceGroup`
203
+
204
+ An optional wrapper for related presence targets. It has two jobs:
205
+
206
+ - Prefix descendant target IDs so repeated fields can use the same names.
207
+ - Let automatic `PresenceAvatars` glide between targets in a shared animation scope.
208
+
209
+ It adds no DOM element and does not publish presence itself. Frames and avatars work
210
+ without it.
211
+
212
+ ##### Scope repeated fields
213
+
214
+ Wrap each record in a group so its fields belong to that record.
215
+
216
+ ```tsx
217
+ import { PresenceGroup, PresenceFrame } from 'moi/collab'
218
+ import { Input } from '../ui/input'
219
+
220
+ <PresenceGroup id={task.id}>
221
+ <PresenceFrame id="title">
222
+ <Input aria-label="Task title" defaultValue={task.title} />
223
+ </PresenceFrame>
224
+ <PresenceFrame id="assignee">
225
+ <AssigneePicker />
226
+ </PresenceFrame>
227
+ </PresenceGroup>
228
+ ```
229
+
230
+ For task `42`, these targets become `42/title` and `42/assignee`. Groups can nest: adding
231
+ an outer group `tasks` gives `tasks/42/title`. Use stable record IDs and field names;
232
+ IDs must be nonblank and unique within their group. When a dialog switches records,
233
+ change its group ID.
234
+
235
+ ##### Move avatars between targets
236
+
237
+ Put the targets in one common group. When another connection moves focus between them,
238
+ its avatar glides from the previous target to the next.
239
+
240
+ ```tsx
241
+ import { PresenceGroup, PresenceAvatars } from 'moi/collab'
242
+ import { Input } from '../ui/input'
243
+
244
+ <PresenceGroup id="tasks">
245
+ {tasks.map(task => (
246
+ <PresenceAvatars key={task.id} id={task.id}>
247
+ <Input aria-label={task.title} defaultValue={task.title} />
248
+ </PresenceAvatars>
249
+ ))}
250
+ </PresenceGroup>
251
+ ```
252
+
253
+ Use record IDs for both React `key` and presence `id`. A nested group creates its own
254
+ animation scope, so avatars glide between targets within that group. Separate row groups
255
+ will not animate movement across rows. Without a group, avatars animate their appearance
256
+ at each target. Movement respects the user's reduced-motion preference.
257
+
258
+ Controlled avatars do not glide between targets: a user can be present at several at once.
259
+ `PresenceFrame` does not share movement between targets.
260
+
261
+ Group IDs apply to `PresenceFrame` and `PresenceAvatars`. Cursor area IDs and custom
262
+ hook channels are independent of groups.
@@ -4,29 +4,32 @@ Intents let an applet act beyond its own UI: open another view, add context to c
4
4
  agent to do something. Import these functions from `moi` and call them from user event handlers,
5
5
  such as a button click; moi handles the action in the workspace.
6
6
 
7
- ## Navigation: `navigate(href)` and `resolveHref(href)`
7
+ ## Navigation and files
8
8
 
9
- Use the shared [workspace navigation convention](../SKILL.md#workspace-navigation) for addresses
10
- and query params. Applets navigate through these functions:
9
+ Use [workspace addresses](../SKILL.md#workspace-navigation) and query params for pages.
10
+ `resolveUrl` also accepts workspace files and HTTP(S) addresses:
11
11
 
12
12
  ```ts
13
- function navigate(href: string): void
14
- function resolveHref(href: string): string
13
+ function navigate(url: string): void
14
+ function resolveUrl(url: string): string
15
15
  ```
16
16
 
17
17
  ```tsx
18
- import { navigate, resolveHref } from 'moi'
18
+ import { navigate, resolveUrl } from 'moi'
19
19
 
20
20
  const query = new URLSearchParams({ order: 'o-1024' })
21
21
  const href = `moi:/views/orders?${query}`
22
22
 
23
23
  // Prefer anchors for links: copy, middle-click, and new browser tabs work.
24
- <a href={resolveHref(href)}>Open order</a>
24
+ <a href={resolveUrl(href)}>Open order</a>
25
25
 
26
26
  // Use the same address from an event handler.
27
27
  <button onClick={() => navigate(href)}>Open order</button>
28
28
  ```
29
29
 
30
+ `navigate` opens workspace pages within moi and files or HTTP(S) URLs in the current browser tab.
31
+ See [Files and assets](../SKILL.md#files-and-assets) for file examples and path encoding.
32
+
30
33
  ### View params and history
31
34
 
32
35
  The host passes query values to the view's `params` prop. Missing keys are absent. Decode numbers
Binary file
Binary file