moi-computer 0.12.1-next.2 → 0.12.1-next.4

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 (243) hide show
  1. package/bunfig.toml +1 -5
  2. package/client/api/app-config.ts +1 -2
  3. package/client/api/app-ui-keys.ts +3 -1
  4. package/client/api/http.ts +4 -1
  5. package/client/api/workspace-keys.ts +3 -3
  6. package/client/app/app-provider.tsx +22 -2
  7. package/client/app/app-router.tsx +6 -0
  8. package/client/app/routes/home-route.tsx +14 -0
  9. package/client/app/routes/onboarding-route.tsx +11 -0
  10. package/client/app/routes/settings-route.tsx +10 -0
  11. package/client/app/routes/workspace-route.tsx +21 -19
  12. package/client/app/shell/sidebar-layout.tsx +34 -53
  13. package/client/components/shared/screen-shell.tsx +23 -0
  14. package/client/components/shared/ultrafast-icon.tsx +61 -0
  15. package/client/components/shared/workspace-icon.tsx +2 -2
  16. package/client/features/account/account-menu.tsx +96 -0
  17. package/client/features/account/account-provider.tsx +142 -0
  18. package/client/features/account/account-test-utils.tsx +294 -0
  19. package/client/features/account/api.ts +142 -0
  20. package/client/features/account/identity.ts +23 -0
  21. package/client/features/app-settings/api.ts +33 -0
  22. package/client/features/app-settings/general-settings.tsx +39 -0
  23. package/client/features/app-settings/profile-settings.tsx +95 -0
  24. package/client/features/app-settings/settings-page.tsx +48 -0
  25. package/client/features/app-settings/settings-section.tsx +26 -0
  26. package/client/features/app-settings/users-settings.tsx +195 -0
  27. package/client/features/chat/applet-chat-intents.ts +4 -20
  28. package/client/features/chat/chat-send.ts +17 -13
  29. package/client/features/chat/composer/model-order.ts +8 -4
  30. package/client/features/chat/composer/model-picker.tsx +88 -34
  31. package/client/features/chat/composer/use-workspace-composer-state.tsx +11 -3
  32. package/client/features/chat/composer/use-workspace-skill-updates.ts +1 -1
  33. package/client/features/chat/connection/chat-frames.ts +3 -15
  34. package/client/features/chat/messages/chat-empty-state.tsx +1 -4
  35. package/client/features/chat/messages/fork-history.ts +5 -5
  36. package/client/features/chat/messages/turn-view.tsx +3 -12
  37. package/client/features/chat/messages/user-message-bubble.tsx +63 -0
  38. package/client/features/chat/sessions/api.ts +121 -80
  39. package/client/features/chat/sessions/browser-tab-state.ts +14 -12
  40. package/client/features/chat/sessions/chat-selector.tsx +5 -6
  41. package/client/features/chat/sessions/use-selected-session.ts +172 -257
  42. package/client/features/chat/use-chat.ts +14 -19
  43. package/client/features/collab/applet-api.ts +15 -14
  44. package/client/features/collab/components/cursors.tsx +61 -24
  45. package/client/features/collab/components/presence-avatars.tsx +25 -12
  46. package/client/features/collab/components/presence-frame.tsx +20 -24
  47. package/client/features/collab/components/presence-group.tsx +15 -7
  48. package/client/features/collab/components/user-avatar-group.tsx +21 -8
  49. package/client/features/collab/components/user-avatar.tsx +38 -7
  50. package/client/features/collab/components/user.tsx +31 -12
  51. package/client/features/collab/users.ts +0 -5
  52. package/client/features/collab/workspace-users-menu.tsx +4 -4
  53. package/client/features/demo/demo-dialog.tsx +11 -3
  54. package/client/features/dev/collab/collab-playground.tsx +7 -7
  55. package/client/features/dev/collab/local-user-settings.tsx +7 -53
  56. package/client/features/dev/dev-index-page.tsx +5 -0
  57. package/client/features/dev/dev-routes.tsx +2 -0
  58. package/client/features/dev/harness-debug-page.tsx +3 -3
  59. package/client/features/dev/onboarding-preview-page.tsx +76 -0
  60. package/client/features/dev/workspace-setup-mocks.ts +16 -14
  61. package/client/features/dev/workspace-setup-preview.tsx +11 -17
  62. package/client/features/harness/api.ts +45 -15
  63. package/client/features/harness/device-login-steps.tsx +9 -3
  64. package/client/features/harness/harness-login-panel.tsx +228 -0
  65. package/client/features/harness/harness-presentation.ts +15 -0
  66. package/client/features/harness/harness-selector.tsx +119 -0
  67. package/client/features/harness/use-harness-login.ts +77 -0
  68. package/client/features/home/home-page.tsx +7 -7
  69. package/client/features/onboarding/agent-setup-step.tsx +57 -0
  70. package/client/features/onboarding/api.ts +42 -0
  71. package/client/features/onboarding/onboarding-idea-disk.tsx +129 -0
  72. package/client/features/onboarding/onboarding-page.tsx +32 -0
  73. package/client/features/onboarding/onboarding-screen.tsx +20 -0
  74. package/client/features/onboarding/onboarding-status.tsx +24 -0
  75. package/client/features/onboarding/workspace-setup-step.tsx +239 -0
  76. package/client/features/overview/default/registry.tsx +2 -2
  77. package/client/features/overview/default/views-widget.tsx +6 -5
  78. package/client/features/overview/overview.tsx +9 -11
  79. package/client/features/overview/widget-canvas.tsx +1 -1
  80. package/client/features/overview/workspace-name.tsx +2 -2
  81. package/client/features/update/update-control.tsx +1 -1
  82. package/client/features/views/api.ts +69 -16
  83. package/client/features/views/pending-view-screen.tsx +30 -9
  84. package/client/features/views/use-view-actions.ts +19 -20
  85. package/client/features/views/view-presentation.ts +2 -2
  86. package/client/features/views/view-submission.ts +28 -41
  87. package/client/features/workspace/add/api.ts +3 -23
  88. package/client/features/workspace/add/create-workspace-dialog.tsx +11 -7
  89. package/client/features/workspace/add/import-workspace-dialog.tsx +3 -3
  90. package/client/features/workspace/add/workspace-agent-options.ts +11 -12
  91. package/client/features/workspace/add/workspace-agent-selector.tsx +3 -132
  92. package/client/features/workspace/api.ts +32 -36
  93. package/client/features/workspace/harness-transition.ts +88 -0
  94. package/client/features/{settings → workspace/settings}/api.ts +1 -34
  95. package/client/features/{settings → workspace/settings}/connectors-settings.tsx +3 -3
  96. package/client/features/{settings → workspace/settings}/environment-settings.tsx +3 -3
  97. package/client/features/{settings → workspace/settings}/general-settings.tsx +77 -3
  98. package/client/features/{settings → workspace/settings}/use-env-vars.ts +1 -1
  99. package/client/features/{settings → workspace/settings}/workspace-icon-picker.tsx +3 -3
  100. package/client/features/workspace/setup/workspace-login-state.tsx +37 -156
  101. package/client/features/workspace/setup/workspace-recovery-states.tsx +0 -12
  102. package/client/features/workspace/setup/workspace-setup.tsx +34 -14
  103. package/client/features/workspace/setup/workspace-welcome-state.tsx +2 -2
  104. package/client/features/workspace/use-workspace-navigation.ts +25 -9
  105. package/client/features/workspace/workspace-content.tsx +11 -8
  106. package/client/features/workspace/workspace-frame.tsx +2 -1
  107. package/client/features/workspace/workspace-layout-context.tsx +5 -2
  108. package/client/features/workspace/workspace-menu.tsx +12 -8
  109. package/client/features/workspace/workspace-pending-screen.tsx +10 -10
  110. package/client/features/workspace/workspace-presentation.tsx +5 -13
  111. package/client/features/workspace/workspace-state.ts +169 -0
  112. package/client/features/workspace/workspace-tabs.tsx +22 -2
  113. package/client/index.css +2 -0
  114. package/client/index.tsx +3 -3
  115. package/client/lib/flags.ts +1 -1
  116. package/client/lib/{app-icon-registry.ts → identity-icon-registry.ts} +10 -14
  117. package/client/lib/user-display-name.ts +6 -0
  118. package/client/main.tsx +4 -1
  119. package/client/runtime/workspace-events.ts +21 -4
  120. package/client/runtime/workspace-theme.ts +9 -0
  121. package/client/tailwind-config.ts +43 -0
  122. package/dist/chunk-0mjzg20x.js +2 -0
  123. package/dist/chunk-2y59vrxg.js +5 -0
  124. package/dist/chunk-58dyt9bk.js +2 -0
  125. package/dist/chunk-5aj040e5.css +1 -0
  126. package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
  127. package/dist/chunk-71fn6rmj.js +546 -0
  128. package/dist/chunk-7yg1m8hx.js +2 -0
  129. package/dist/chunk-825hys3h.js +1 -0
  130. package/dist/chunk-9bb8m9rx.js +2 -0
  131. package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
  132. package/dist/chunk-g0tcwqxc.js +1 -0
  133. package/dist/chunk-n0nab26d.js +1 -0
  134. package/dist/chunk-nf2wkvf9.js +14 -0
  135. package/dist/chunk-v88n1bay.js +74 -0
  136. package/dist/index.html +1 -1
  137. package/lib/harness-instructions.ts +1 -1
  138. package/lib/{app-icons.ts → identity-icons.ts} +6 -7
  139. package/lib/onboarding.ts +41 -0
  140. package/lib/speed-mode.ts +5 -0
  141. package/lib/types.ts +72 -63
  142. package/lib/view-build-directives.ts +1 -2
  143. package/lib/workspace-icon.ts +2 -2
  144. package/lib/workspace-layout.ts +1 -1
  145. package/lib/workspace-name.ts +15 -12
  146. package/package.json +9 -8
  147. package/server/README.md +27 -25
  148. package/server/api/harnesses.ts +31 -8
  149. package/server/api/index.ts +164 -131
  150. package/server/api/onboarding.ts +46 -0
  151. package/server/app-config.ts +23 -24
  152. package/server/app-settings.ts +6 -2
  153. package/server/applets/config.ts +5 -5
  154. package/server/applets/views.ts +19 -17
  155. package/server/cli/commands/init.ts +3 -3
  156. package/server/cli/commands/skill.ts +16 -17
  157. package/server/cli/commands/start.ts +8 -34
  158. package/server/cli/server.ts +18 -6
  159. package/server/collab/config.ts +1 -2
  160. package/server/collab/manager.ts +4 -1
  161. package/server/collab/skill/index.ts +1 -1
  162. package/server/control.ts +3 -3
  163. package/server/data-dir.ts +1 -1
  164. package/server/harness/README.md +24 -8
  165. package/server/harness/acp/session.ts +8 -4
  166. package/server/harness/auth.ts +14 -17
  167. package/server/harness/claude-code/NOTES.md +4 -3
  168. package/server/harness/claude-code/index.ts +2 -0
  169. package/server/harness/claude-code/models.ts +2 -20
  170. package/server/harness/claude-code/run-action.ts +123 -0
  171. package/server/harness/claude-code/session-title.ts +5 -7
  172. package/server/harness/claude-code/session.ts +24 -16
  173. package/server/harness/codex/NOTES.md +14 -9
  174. package/server/harness/codex/adapter.ts +14 -17
  175. package/server/harness/codex/index.ts +2 -0
  176. package/server/harness/codex/run-action.ts +93 -0
  177. package/server/harness/codex/session-title.ts +6 -8
  178. package/server/harness/codex/session.ts +11 -11
  179. package/server/harness/command.ts +45 -0
  180. package/server/harness/executable.ts +5 -0
  181. package/server/harness/fork.ts +6 -4
  182. package/server/harness/install.ts +49 -0
  183. package/server/harness/openclaw/session.ts +1 -2
  184. package/server/harness/run-action.ts +85 -0
  185. package/server/harness/session-title.ts +0 -46
  186. package/server/harness/types.ts +26 -2
  187. package/server/onboarding/brief.ts +29 -0
  188. package/server/onboarding/ideas.ts +48 -0
  189. package/server/onboarding/jobs.ts +291 -0
  190. package/server/onboarding/prompt.md +49 -0
  191. package/server/sessions/archive.ts +5 -14
  192. package/server/sessions/config.ts +17 -16
  193. package/server/sessions/lifecycle.ts +15 -13
  194. package/server/sessions/pending-views.ts +79 -108
  195. package/server/sessions/selected.ts +75 -161
  196. package/server/sessions/store.ts +40 -113
  197. package/server/sessions/view-sessions.ts +128 -111
  198. package/server/skills/locations.ts +82 -0
  199. package/server/skills/lock.ts +29 -0
  200. package/server/skills/template.ts +36 -25
  201. package/server/skills/update.ts +52 -5
  202. package/server/skills/version.ts +17 -22
  203. package/server/skills/workspace.ts +121 -0
  204. package/server/web.ts +23 -8
  205. package/server/workspace-state/file.ts +177 -0
  206. package/server/workspace-state/index.ts +162 -0
  207. package/server/workspace-state/legacy-migration.ts +79 -0
  208. package/server/workspace-state/lock.ts +42 -0
  209. package/server/workspace-state/types.ts +16 -0
  210. package/server/workspaces/change-harness.ts +88 -0
  211. package/server/workspaces/harness-transition.ts +29 -0
  212. package/server/workspaces/init.ts +29 -16
  213. package/server/workspaces/layout.ts +3 -0
  214. package/server/workspaces/registry.ts +58 -10
  215. package/{workspace/.claude/skills/moi-workspace → skill}/SKILL.md +7 -5
  216. package/{workspace/.claude/skills/moi-workspace → skill}/references/COLLAB.md +4 -8
  217. package/skill/references/DESIGN.md +148 -0
  218. package/{workspace/.claude/skills/moi-workspace → skill}/references/SCRATCHPAD.md +2 -2
  219. package/{workspace/.claude/skills/moi-workspace → skill}/references/UI-COMPONENTS.md +3 -0
  220. package/ui-components/badge.tsx +1 -1
  221. package/client/accept-hmr-dependencies.ts +0 -22
  222. package/client/features/workspace/setup/workspace-setup-panel.tsx +0 -18
  223. package/dist/chunk-00rh9df4.js +0 -2
  224. package/dist/chunk-4nh7y1hq.css +0 -1
  225. package/dist/chunk-am4agx6v.js +0 -2
  226. package/dist/chunk-d7cbm65e.js +0 -2
  227. package/dist/chunk-hbpdv7vd.js +0 -1
  228. package/dist/chunk-hmka9rt5.js +0 -2
  229. package/dist/chunk-hvh9f5h0.js +0 -14
  230. package/dist/chunk-mjjregkn.js +0 -10
  231. package/dist/chunk-pcnahct1.js +0 -5
  232. package/dist/chunk-rt30jbcm.js +0 -1
  233. package/dist/chunk-vt6zybej.js +0 -2
  234. package/dist/chunk-wbkwf6cc.js +0 -68
  235. package/dist/chunk-xjyfyz64.js +0 -1
  236. package/dist/chunk-y8nbwp21.js +0 -546
  237. package/dist/chunk-ysfdcew7.js +0 -1
  238. package/lib/experimental.ts +0 -14
  239. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +0 -157
  240. /package/client/features/{settings → workspace/settings}/icon-picker-options.ts +0 -0
  241. /package/client/features/{settings → workspace/settings}/settings-layout.tsx +0 -0
  242. /package/client/features/{settings → workspace/settings}/workspace-settings-dialog.tsx +0 -0
  243. /package/{workspace/.claude/skills/moi-workspace → skill}/references/INTENTS.md +0 -0
@@ -1,17 +1,24 @@
1
- import type { CursorsProps } from 'moi/collab'
1
+ import type { CursorsProps as CursorsContainerProps } from 'moi/collab'
2
+ import type { UserProfile } from '@/lib/collab/types'
2
3
  import type { JsonValue } from 'moi'
3
4
  import { useLayoutEffect, useRef } from 'react'
4
- import type { PointerEvent, Ref, RefObject } from 'react'
5
+ import type { PointerEvent, ReactNode, Ref, RefObject } from 'react'
5
6
  import { IconPointer2 } from '@tabler/icons-react'
6
7
 
7
8
  import { cn } from '@/client/lib/cn'
8
9
  import { Badge } from '@/ui-components/badge'
9
10
 
10
- import { presenceChannels, usePresenceChannel, usePresencePublisher, useUser } from '../hooks'
11
- import { userDisplayName } from '../users'
11
+ import { presenceChannels, usePresenceChannel, usePresencePublisher, useUsers } from '../hooks'
12
+ import { userDisplayName } from '@/client/lib/user-display-name'
12
13
  import { hasPresence } from './presence-helpers'
13
14
 
14
- type PointerPosition = { x: number; y: number; target?: string; targetX?: number; targetY?: number }
15
+ export type PointerPosition = {
16
+ x: number
17
+ y: number
18
+ target?: string
19
+ targetX?: number
20
+ targetY?: number
21
+ }
15
22
  function pointerPosition(value: JsonValue): PointerPosition | null {
16
23
  if (!value || typeof value !== 'object' || Array.isArray(value)) return null
17
24
  if (typeof value.x !== 'number' || typeof value.y !== 'number') return null
@@ -29,7 +36,46 @@ function pointerPosition(value: JsonValue): PointerPosition | null {
29
36
  }
30
37
  }
31
38
 
32
- export function Cursors({ id = 'default', children, className }: CursorsProps) {
39
+ export function CursorsContainer({ id = 'default', ...props }: CursorsContainerProps) {
40
+ const channel = presenceChannels.cursor(id)
41
+ const cursors = usePresenceChannel<JsonValue>(channel)
42
+ const publish = usePresencePublisher<JsonValue>(channel, null, hasPresence)
43
+ const byConnection = new Map<string, { id: string; point: PointerPosition }>()
44
+ for (const { connectionId, userId, value } of cursors) {
45
+ const point = pointerPosition(value)
46
+ if (point) byConnection.set(connectionId, { id: userId, point })
47
+ }
48
+ const entries = [...byConnection]
49
+ const profiles = useUsers(entries.map(([, cursor]) => cursor.id))
50
+ return (
51
+ <Cursors
52
+ {...props}
53
+ id={id}
54
+ onPositionChange={publish}
55
+ cursors={entries.map(([connectionId, { point }], index) => ({
56
+ connectionId,
57
+ point,
58
+ profile: profiles[index]
59
+ }))}
60
+ />
61
+ )
62
+ }
63
+
64
+ export type CursorsProps = {
65
+ id?: string
66
+ children: ReactNode
67
+ className?: string
68
+ cursors: readonly { connectionId: string; point: PointerPosition; profile?: UserProfile }[]
69
+ onPositionChange?: (point: PointerPosition | null) => void
70
+ }
71
+
72
+ export function Cursors({
73
+ id = 'default',
74
+ children,
75
+ className,
76
+ cursors,
77
+ onPositionChange
78
+ }: CursorsProps) {
33
79
  const root = useRef<HTMLDivElement>(null)
34
80
  const layer = useRef<HTMLDivElement>(null)
35
81
  // Keep the overlay in the visible viewport when the cursor area itself scrolls.
@@ -44,14 +90,6 @@ export function Cursors({ id = 'default', children, className }: CursorsProps) {
44
90
  element.addEventListener('scroll', position)
45
91
  return () => element.removeEventListener('scroll', position)
46
92
  }, [])
47
- const channel = presenceChannels.cursor(id)
48
- const cursors = usePresenceChannel<JsonValue>(channel)
49
- const publish = usePresencePublisher<JsonValue>(channel, null, hasPresence)
50
- const byConnection = new Map<string, { id: string; point: PointerPosition }>()
51
- for (const { connectionId, userId, value } of cursors) {
52
- const point = pointerPosition(value)
53
- if (point) byConnection.set(connectionId, { id: userId, point })
54
- }
55
93
  const move = (event: PointerEvent<HTMLDivElement>) => {
56
94
  if (event.pointerType === 'touch') return
57
95
  const element = root.current
@@ -68,7 +106,7 @@ export function Cursors({ id = 'default', children, className }: CursorsProps) {
68
106
  : null
69
107
  const anchor = target && element.contains(target) ? target : null
70
108
  const rect = anchor?.getBoundingClientRect()
71
- publish({
109
+ onPositionChange?.({
72
110
  x: event.clientX - bounds.left - element.clientLeft + element.scrollLeft,
73
111
  y: event.clientY - bounds.top - element.clientTop + element.scrollTop,
74
112
  ...(anchor && rect
@@ -92,7 +130,7 @@ export function Cursors({ id = 'default', children, className }: CursorsProps) {
92
130
  event.target instanceof Element &&
93
131
  event.target.closest('[data-collab-cursors]') === event.currentTarget
94
132
  )
95
- publish(null)
133
+ onPositionChange?.(null)
96
134
  }}
97
135
  >
98
136
  {children}
@@ -101,8 +139,8 @@ export function Cursors({ id = 'default', children, className }: CursorsProps) {
101
139
  className="pointer-events-none absolute inset-0 overflow-hidden"
102
140
  aria-hidden="true"
103
141
  >
104
- {[...byConnection].map(([connectionId, { id, point }]) => (
105
- <RemoteCursor key={connectionId} root={root} point={point} id={id} />
142
+ {cursors.map(({ connectionId, point, profile }) => (
143
+ <RemoteCursor key={connectionId} root={root} point={point} profile={profile} />
106
144
  ))}
107
145
  </div>
108
146
  </div>
@@ -112,11 +150,11 @@ export function Cursors({ id = 'default', children, className }: CursorsProps) {
112
150
  type RemoteCursorProps = {
113
151
  root: RefObject<HTMLDivElement | null>
114
152
  point: PointerPosition
115
- id: string
153
+ profile?: UserProfile
116
154
  }
117
155
  // Semantic anchors follow their own data through scrolling and reordering.
118
156
  // A cursor on a different record's modal has no matching anchor and stays hidden.
119
- function RemoteCursor({ root, point, id }: RemoteCursorProps) {
157
+ function RemoteCursor({ root, point, profile }: RemoteCursorProps) {
120
158
  const marker = useRef<HTMLSpanElement>(null)
121
159
  useLayoutEffect(() => {
122
160
  const element = root.current
@@ -166,15 +204,14 @@ function RemoteCursor({ root, point, id }: RemoteCursorProps) {
166
204
  window.removeEventListener('resize', reposition)
167
205
  }
168
206
  }, [root, point])
169
- return <Cursor ref={marker} id={id} />
207
+ return <Cursor ref={marker} profile={profile} />
170
208
  }
171
209
 
172
210
  type CursorProps = {
173
- id: string
211
+ profile?: UserProfile
174
212
  ref?: Ref<HTMLSpanElement>
175
213
  }
176
- function Cursor({ id, ref }: CursorProps) {
177
- const user = useUser(id)
214
+ function Cursor({ profile: user, ref }: CursorProps) {
178
215
  return (
179
216
  <span
180
217
  ref={ref}
@@ -1,47 +1,56 @@
1
- import type { PresenceAvatarsProps } from 'moi/collab'
1
+ import type { PresenceAvatarsProps as PresenceAvatarsContainerProps } from 'moi/collab'
2
+ import type { UserProfile } from '@/lib/collab/types'
2
3
  import { useContext } from 'react'
3
4
  import type { HTMLAttributes, ReactNode, Ref } from 'react'
4
5
  import { motion } from 'motion/react'
5
6
  import { cn } from '@/client/lib/cn'
6
7
  import { PresenceGroupContext, usePresenceTarget, useTargetPresence } from './presence-helpers'
8
+ import { useUsers } from '../hooks'
7
9
  import { UserAvatar } from './user-avatar'
8
10
 
9
- export function PresenceAvatars({ id, present, align, children, className }: PresenceAvatarsProps) {
11
+ export function PresenceAvatarsContainer({
12
+ id,
13
+ present,
14
+ align,
15
+ children,
16
+ className
17
+ }: PresenceAvatarsContainerProps) {
10
18
  const target = usePresenceTarget(id)
11
19
  const presence = useTargetPresence(target, present)
20
+ const profiles = useUsers(presence.users.map(user => user.id))
12
21
  const grouped = useContext(PresenceGroupContext).length > 0
13
22
  return (
14
- <PresenceAvatarsPrimitive
23
+ <PresenceAvatars
15
24
  {...presence.props}
16
- users={presence.users}
25
+ users={presence.users.map((user, index) => ({ ...user, profile: profiles[index] }))}
17
26
  // Controlled presence can occupy several targets at once; only focus moves between them.
18
27
  animate={grouped && present === undefined}
19
28
  align={align}
20
29
  className={className}
21
30
  >
22
31
  {children}
23
- </PresenceAvatarsPrimitive>
32
+ </PresenceAvatars>
24
33
  )
25
34
  }
26
35
 
27
- type PresenceAvatarsPrimitiveProps = HTMLAttributes<HTMLDivElement> & {
36
+ export type PresenceAvatarsProps = HTMLAttributes<HTMLDivElement> & {
28
37
  ref?: Ref<HTMLDivElement>
29
- users: readonly { id: string; connectionId: string }[]
38
+ users: readonly { id: string; connectionId: string; profile?: UserProfile }[]
30
39
  children: ReactNode
31
40
  animate?: boolean
32
- align?: PresenceAvatarsProps['align']
41
+ align?: PresenceAvatarsContainerProps['align']
33
42
  }
34
43
 
35
44
  // A target owns its own gutter. Optional group-scoped layout IDs let the same
36
45
  // user's face glide between targets without searching or guessing DOM order.
37
- function PresenceAvatarsPrimitive({
46
+ export function PresenceAvatars({
38
47
  users,
39
48
  children,
40
49
  animate = false,
41
50
  align = 'center',
42
51
  className,
43
52
  ...rest
44
- }: PresenceAvatarsPrimitiveProps) {
53
+ }: PresenceAvatarsProps) {
45
54
  return (
46
55
  <div className={cn('relative pl-8', className)} {...rest}>
47
56
  {children}
@@ -50,9 +59,13 @@ function PresenceAvatarsPrimitive({
50
59
  className="pointer-events-none absolute inset-y-0 left-0 flex items-center -space-x-3 data-[align=end]:items-end data-[align=start]:items-start"
51
60
  aria-hidden="true"
52
61
  >
53
- {users.map(({ id, connectionId }) => (
62
+ {users.map(({ id, connectionId, profile }) => (
54
63
  <motion.span key={id} layoutId={animate ? `presence:${connectionId}` : undefined}>
55
- <UserAvatar id={id} size="sm" className="animate-in duration-200 zoom-in-75 fade-in" />
64
+ <UserAvatar
65
+ profile={profile}
66
+ size="sm"
67
+ className="animate-in duration-200 zoom-in-75 fade-in"
68
+ />
56
69
  </motion.span>
57
70
  ))}
58
71
  </div>
@@ -1,51 +1,47 @@
1
- import type { PresenceFrameProps } from 'moi/collab'
1
+ import type { PresenceFrameProps as PresenceFrameContainerProps } from 'moi/collab'
2
+ import type { UserProfile } from '@/lib/collab/types'
2
3
  import { useLayoutEffect, useRef } from 'react'
3
4
  import type { HTMLAttributes, ReactNode, Ref } from 'react'
4
5
  import { cn } from '@/client/lib/cn'
5
6
  import type { UserColor } from '@/lib/collab/colors'
6
7
  import { Badge } from '@/ui-components/badge'
7
8
  import { useUsers } from '../hooks'
8
- import { userDisplayName } from '../users'
9
+ import { userDisplayName } from '@/client/lib/user-display-name'
9
10
  import { usePresenceTarget, useTargetPresence } from './presence-helpers'
10
11
 
11
- export function PresenceFrame({ id, present, align, children, className }: PresenceFrameProps) {
12
+ export function PresenceFrameContainer({
13
+ id,
14
+ present,
15
+ align,
16
+ children,
17
+ className
18
+ }: PresenceFrameContainerProps) {
12
19
  const target = usePresenceTarget(id)
13
20
  const presence = useTargetPresence(target, present)
21
+ const users = useUsers(presence.users.map(user => user.id)).filter(user => user !== undefined)
14
22
  return (
15
- <PresenceOutline
16
- {...presence.props}
17
- ids={presence.users.map(user => user.id)}
18
- align={align}
19
- className={className}
20
- >
23
+ <PresenceFrame {...presence.props} users={users} align={align} className={className}>
21
24
  {children}
22
- </PresenceOutline>
25
+ </PresenceFrame>
23
26
  )
24
27
  }
25
28
 
26
- type PresenceOutlineProps = HTMLAttributes<HTMLDivElement> & {
29
+ export type PresenceFrameProps = HTMLAttributes<HTMLDivElement> & {
27
30
  ref?: Ref<HTMLDivElement>
28
31
  // Everyone at this element; the first user's color draws the frame.
29
- ids: readonly string[]
32
+ users: readonly UserProfile[]
30
33
  children: ReactNode
31
- align?: PresenceFrameProps['align']
34
+ align?: PresenceFrameContainerProps['align']
32
35
  }
33
36
 
34
37
  // One visible element gets a frame matching its shape; other content gets one shared frame.
35
- export function PresenceOutline({
36
- ids,
37
- align,
38
- children,
39
- className,
40
- ...rest
41
- }: PresenceOutlineProps) {
42
- const resolved = useUsers(ids).filter(user => user !== undefined)
38
+ export function PresenceFrame({ users, align, children, className, ...rest }: PresenceFrameProps) {
43
39
  return (
44
40
  <div className={cn('relative', className)} {...rest}>
45
41
  {/* Keep the overlay first so showing it never changes the content's spacing. */}
46
42
  <FrameOutline
47
- names={resolved.map(userDisplayName).join(', ')}
48
- color={resolved[0]?.color}
43
+ names={users.map(userDisplayName).join(', ')}
44
+ color={users[0]?.color}
49
45
  align={align}
50
46
  />
51
47
  {children}
@@ -66,7 +62,7 @@ const CORNERS = [
66
62
  type FrameOutlineProps = {
67
63
  names: string
68
64
  color: UserColor | undefined
69
- align?: PresenceFrameProps['align']
65
+ align?: PresenceFrameContainerProps['align']
70
66
  }
71
67
 
72
68
  function FrameOutline({ names, color, align = 'end' }: FrameOutlineProps) {
@@ -1,23 +1,31 @@
1
- import type { PresenceGroupProps } from 'moi/collab'
1
+ import type { PresenceGroupProps as PresenceGroupContainerProps } from 'moi/collab'
2
+ import type { ReactNode } from 'react'
2
3
  import { useContext, useId, useMemo } from 'react'
3
4
  import { LayoutGroup, MotionConfig } from 'motion/react'
4
5
  import { presenceTarget } from '../presence-target'
5
6
  import { PresenceGroupContext } from './presence-helpers'
6
7
 
7
- export function PresenceGroup({ id, children }: PresenceGroupProps) {
8
+ export function PresenceGroupContainer({ id, children }: PresenceGroupContainerProps) {
8
9
  const parent = useContext(PresenceGroupContext)
9
10
  const scope = useMemo(() => {
10
11
  presenceTarget(id)
11
12
  return [...parent, id]
12
13
  }, [parent, id])
13
- // The shared path identifies data across browsers; the generated ID keeps
14
- // avatar animations inside this particular rendered group.
14
+ return (
15
+ <PresenceGroup>
16
+ <PresenceGroupContext value={scope}>{children}</PresenceGroupContext>
17
+ </PresenceGroup>
18
+ )
19
+ }
20
+
21
+ export type PresenceGroupProps = { children: ReactNode }
22
+
23
+ export function PresenceGroup({ children }: PresenceGroupProps) {
24
+ // Keep avatar animations inside this particular rendered group.
15
25
  const animationId = useId()
16
26
  return (
17
27
  <MotionConfig reducedMotion="user">
18
- <LayoutGroup id={animationId}>
19
- <PresenceGroupContext value={scope}>{children}</PresenceGroupContext>
20
- </LayoutGroup>
28
+ <LayoutGroup id={animationId}>{children}</LayoutGroup>
21
29
  </MotionConfig>
22
30
  )
23
31
  }
@@ -1,16 +1,29 @@
1
- import type { UserAvatarGroupProps } from 'moi/collab'
1
+ import type { UserAvatarGroupProps as UserAvatarGroupContainerProps } from 'moi/collab'
2
+ import type { UserProfile } from '@/lib/collab/types'
2
3
  import { AvatarGroup as AvatarGroupPrimitive, AvatarGroupCount } from '@/ui-components/avatar'
3
4
  import { UserAvatar } from './user-avatar'
5
+ import type { UserAvatarProps } from './user-avatar'
6
+ import { useUsers } from '../hooks'
4
7
 
5
- export function UserAvatarGroup({ ids, max = 3, size = 'sm', className }: UserAvatarGroupProps) {
6
- const unique = [...new Set(ids)]
7
- const shown = unique.slice(0, max)
8
- const hidden = unique.length - shown.length
8
+ export function UserAvatarGroupContainer({ ids, ...props }: UserAvatarGroupContainerProps) {
9
+ const users = useUsers([...new Set(ids)])
10
+ return <UserAvatarGroup users={users} {...props} />
11
+ }
12
+
13
+ export type UserAvatarGroupProps = {
14
+ users: readonly (UserProfile | undefined)[]
15
+ max?: number
16
+ size?: UserAvatarProps['size']
17
+ className?: string
18
+ }
9
19
 
20
+ export function UserAvatarGroup({ users, max = 3, size = 'sm', className }: UserAvatarGroupProps) {
21
+ const shown = users.slice(0, max)
22
+ const hidden = users.length - shown.length
10
23
  return (
11
- <AvatarGroupPrimitive className={className} aria-label={`${unique.length} users`}>
12
- {shown.map(id => (
13
- <UserAvatar key={id} id={id} size={size} />
24
+ <AvatarGroupPrimitive className={className} aria-label={`${users.length} users`}>
25
+ {shown.map((profile, index) => (
26
+ <UserAvatar key={profile?.id ?? index} profile={profile} size={size} />
14
27
  ))}
15
28
  {hidden > 0 && (
16
29
  <AvatarGroupCount size={size} aria-label={`${hidden} more`}>
@@ -1,12 +1,42 @@
1
- import type { UserAvatarProps } from 'moi/collab'
1
+ import type { UserAvatarProps as UserAvatarContainerProps } from 'moi/collab'
2
+ import type { UserProfile } from '@/lib/collab/types'
2
3
  import { IconUser } from '@tabler/icons-react'
3
4
  import { Blobatar } from '@blobatar/react'
4
5
  import { Avatar, AvatarBadge, AvatarFallback, AvatarImage } from '@/ui-components/avatar'
6
+ import { cn } from '@/client/lib/cn'
7
+ import { userDisplayName } from '@/client/lib/user-display-name'
5
8
  import { useUser } from '../hooks'
6
- import { userDisplayName } from '../users'
7
9
 
8
- export function UserAvatar({ id, size = 'default', showStatusBadge, className }: UserAvatarProps) {
10
+ export function UserAvatarContainer({
11
+ id,
12
+ size,
13
+ showStatusBadge,
14
+ className
15
+ }: UserAvatarContainerProps) {
9
16
  const user = useUser(id)
17
+ return (
18
+ <UserAvatar
19
+ profile={user}
20
+ size={size}
21
+ active={showStatusBadge && user?.status === 'active'}
22
+ className={className}
23
+ />
24
+ )
25
+ }
26
+
27
+ export type UserAvatarProps = {
28
+ profile?: UserProfile
29
+ size?: 'xs' | 'sm' | 'default' | 'lg'
30
+ className?: string
31
+ active?: boolean
32
+ }
33
+
34
+ export function UserAvatar({
35
+ profile: user,
36
+ size = 'default',
37
+ className,
38
+ active
39
+ }: UserAvatarProps) {
10
40
  const name = user ? userDisplayName(user) : 'Unknown user'
11
41
 
12
42
  return (
@@ -14,16 +44,17 @@ export function UserAvatar({ id, size = 'default', showStatusBadge, className }:
14
44
  size={size}
15
45
  aria-label={name}
16
46
  data-collab-color={user?.color ?? 'unknown'}
17
- className={className}
47
+ className={cn('after:border-0', className)}
18
48
  >
19
49
  {user?.avatar && <AvatarImage src={user.avatar} alt="" />}
20
50
  <AvatarFallback>
21
51
  {user ? (
22
52
  <Blobatar
23
- name={id}
53
+ className="scale-150"
54
+ name={user.id}
24
55
  animate="hover"
25
56
  background="circle"
26
- traits={{ shape: 0, 'body.r': 1 }}
57
+ traits={{ 'eye.rx': 1 }}
27
58
  palette={{
28
59
  bg: 'var(--collab)',
29
60
  head: 'var(--collab)',
@@ -34,7 +65,7 @@ export function UserAvatar({ id, size = 'default', showStatusBadge, className }:
34
65
  <IconUser size={size === 'xs' || size === 'sm' ? 12 : 16} stroke={1.75} />
35
66
  )}
36
67
  </AvatarFallback>
37
- {showStatusBadge && user?.status === 'active' && <AvatarBadge className="bg-success" />}
68
+ {active && <AvatarBadge className="bg-success" />}
38
69
  </Avatar>
39
70
  )
40
71
  }
@@ -1,33 +1,52 @@
1
- import type { UserProps } from 'moi/collab'
1
+ import type { UserProps as UserContainerProps } from 'moi/collab'
2
+ import type { ReactNode } from 'react'
3
+ import type { UserProfile } from '@/lib/collab/types'
2
4
  import { cn } from '@/client/lib/cn'
3
5
  import { UserAvatar } from './user-avatar'
6
+ import { userDisplayName } from '@/client/lib/user-display-name'
4
7
  import { useMe, useUser } from '../hooks'
5
- import { userDisplayName } from '../users'
6
8
 
7
- const UNKNOWN_NAME = 'Unknown user'
9
+ export function UserContainer({ id, showStatusBadge, showYouLabel, ...props }: UserContainerProps) {
10
+ const user = useUser(id)
11
+ const me = useMe()
12
+ return (
13
+ <User
14
+ {...props}
15
+ profile={user}
16
+ active={showStatusBadge && user?.status === 'active'}
17
+ showYouLabel={showYouLabel && user !== undefined && user.id === me?.id}
18
+ />
19
+ )
20
+ }
21
+
22
+ export type UserProps = {
23
+ profile?: UserProfile
24
+ size?: 'xs' | 'sm' | 'default'
25
+ active?: boolean
26
+ showYouLabel?: boolean
27
+ description?: ReactNode
28
+ className?: string
29
+ }
8
30
 
9
31
  export function User({
10
- id,
32
+ profile: user,
11
33
  size = 'default',
12
- showStatusBadge,
34
+ active,
13
35
  showYouLabel,
14
36
  description,
15
37
  className
16
38
  }: UserProps) {
17
- const user = useUser(id)
18
- const me = useMe()
19
- const name = user ? userDisplayName(user) : UNKNOWN_NAME
20
- const isSelf = user !== undefined && user.id === me?.id
39
+ const name = user ? userDisplayName(user) : 'Unknown user'
21
40
 
22
41
  return (
23
- <span className={cn('inline-flex min-w-0 items-center gap-2', className)}>
24
- <UserAvatar id={id} size={size} showStatusBadge={showStatusBadge} />
42
+ <span className={cn('flex min-w-0 items-center gap-2', className)}>
43
+ <UserAvatar profile={user} size={size} active={active} />
25
44
  <span
26
45
  className={cn('flex min-w-0 flex-1 text-sm', size === 'xs' ? 'items-baseline' : 'flex-col')}
27
46
  >
28
47
  <span className="flex min-w-0 items-baseline gap-1">
29
48
  <span className={cn('truncate', !user && 'text-muted-foreground')}>{name}</span>
30
- {showYouLabel && isSelf && <span className="shrink-0 text-muted-foreground">(You)</span>}
49
+ {showYouLabel && <span className="shrink-0 text-muted-foreground">(You)</span>}
31
50
  </span>
32
51
  {description && (
33
52
  <span
@@ -13,11 +13,6 @@ export type UsersSource = {
13
13
  users: readonly UserProfile[]
14
14
  }
15
15
 
16
- // Presentation only: keep the supplied profile unchanged in applet APIs.
17
- export function userDisplayName(user: UserProfile): string {
18
- return user.name?.trim() || user.email?.trim() || user.id
19
- }
20
-
21
16
  export function userStatus(connections: readonly Connection[], id: string): UserStatus {
22
17
  const userConnections = connections.filter(connection => connection.userId === id)
23
18
  return userConnections.some(connection => connection.location?.status === 'active')
@@ -16,8 +16,8 @@ import { cn } from '@/client/lib/cn'
16
16
  import type { WorkspaceTabId } from '@/lib/types'
17
17
  import { tabFromPath } from '@/lib/workspace-tabs'
18
18
 
19
- import { User } from './components/user'
20
- import { UserAvatarGroup } from './components/user-avatar-group'
19
+ import { UserContainer } from './components/user'
20
+ import { UserAvatarGroupContainer as UserAvatarGroup } from './components/user-avatar-group'
21
21
  import { pageFromPath, useCollabEnabled, useCollabEngine } from './provider'
22
22
  import { useConnectionState, useWorkspaceUsers } from './hooks'
23
23
  import { summarizeWorkspaceUsers } from './users'
@@ -60,7 +60,7 @@ export function WorkspaceUsersMenu({
60
60
  .map(user => user.profile.id)
61
61
  const [open, setOpen] = useState(false)
62
62
 
63
- if (!enabled) return null
63
+ if (!enabled || workspaceUsers.length <= 1) return null
64
64
 
65
65
  return (
66
66
  <Popover open={open} onOpenChange={setOpen}>
@@ -153,7 +153,7 @@ function UserRow({ user, page, describeTab, onOpenTab }: UserRowProps) {
153
153
  : labels || 'Another tab'
154
154
  const Icon = user.status === 'offline' ? undefined : tabs[0]?.info?.Icon
155
155
  const content = (
156
- <User
156
+ <UserContainer
157
157
  id={user.profile.id}
158
158
  className="flex-1"
159
159
  size="sm"
@@ -5,6 +5,7 @@ import {
5
5
  IconArrowUpRight,
6
6
  IconBrowserPlus,
7
7
  IconMessageChatbot,
8
+ IconUsersGroup,
8
9
  IconX
9
10
  } from '@tabler/icons-react'
10
11
 
@@ -136,16 +137,23 @@ function DemoDialogContent() {
136
137
  className="mt-0.5 size-8 shrink-0 text-muted-foreground"
137
138
  />
138
139
  <span className="text-sm text-foreground">
139
- Create as many workspaces, views, and widgets as you want
140
+ Create without limits building as many workspaces as you want
140
141
  </span>
141
142
  </li>
143
+ <li className="flex items-center gap-3">
144
+ <IconUsersGroup
145
+ stroke={0.75}
146
+ className="mt-0.5 size-8 shrink-0 text-muted-foreground"
147
+ />
148
+ <span className="text-sm text-foreground">Share what you've built with anyone</span>
149
+ </li>
142
150
  <li className="flex items-center gap-3">
143
151
  <IconMessageChatbot
144
152
  stroke={0.75}
145
153
  className="mt-0.5 size-8 shrink-0 text-muted-foreground"
146
154
  />
147
155
  <span className="text-sm text-foreground">
148
- Build with{' '}
156
+ Use your{' '}
149
157
  <span className="inline-flex items-baseline gap-1">
150
158
  <img src={claudeIcon} alt="" className="size-3.5 self-center object-contain" />
151
159
  <strong className="font-medium">Claude</strong>
@@ -155,7 +163,7 @@ function DemoDialogContent() {
155
163
  <img src={openaiIcon} alt="" className="size-3.5 self-center object-contain" />
156
164
  <strong className="font-medium">ChatGPT</strong>
157
165
  </span>{' '}
158
- using your subscription and app connectors
166
+ subscription and app connectors
159
167
  </span>
160
168
  </li>
161
169
  </ul>
@@ -28,13 +28,13 @@ import {
28
28
  } from '@/ui-components/select'
29
29
  import type { UserProfile, Connection } from '@/lib/collab/types'
30
30
 
31
- import { PresenceFrame } from '@/client/features/collab/components/presence-frame'
32
- import { PresenceGroup } from '@/client/features/collab/components/presence-group'
33
- import { PresenceAvatars } from '@/client/features/collab/components/presence-avatars'
34
- import { Cursors } from '@/client/features/collab/components/cursors'
35
- import { UserAvatarGroup } from '@/client/features/collab/components/user-avatar-group'
36
- import { User } from '@/client/features/collab/components/user'
37
- import { UserAvatar } from '@/client/features/collab/components/user-avatar'
31
+ import { PresenceFrameContainer as PresenceFrame } from '@/client/features/collab/components/presence-frame'
32
+ import { PresenceGroupContainer as PresenceGroup } from '@/client/features/collab/components/presence-group'
33
+ import { PresenceAvatarsContainer as PresenceAvatars } from '@/client/features/collab/components/presence-avatars'
34
+ import { CursorsContainer as Cursors } from '@/client/features/collab/components/cursors'
35
+ import { UserAvatarGroupContainer as UserAvatarGroup } from '@/client/features/collab/components/user-avatar-group'
36
+ import { UserContainer as User } from '@/client/features/collab/components/user'
37
+ import { UserAvatarContainer as UserAvatar } from '@/client/features/collab/components/user-avatar'
38
38
  import { createFakeEngine } from '@/client/features/collab/testing/fake-engine'
39
39
  import type { FakeEngine } from '@/client/features/collab/testing/fake-engine'
40
40
  import {