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
@@ -0,0 +1,194 @@
1
+ import { useState, useSyncExternalStore } from 'react'
2
+
3
+ import { IconChevronDown } from '@tabler/icons-react'
4
+ import type { Icon as TabIcon } from '@tabler/icons-react'
5
+ import { useRouter } from 'wouter'
6
+ import { usePathname } from 'wouter/use-browser-location'
7
+
8
+ import { Button } from '@/client/components/ui/button'
9
+ import {
10
+ Popover,
11
+ PopoverContent,
12
+ PopoverTitle,
13
+ PopoverTrigger
14
+ } from '@/client/components/ui/popover'
15
+ import { cn } from '@/client/lib/cn'
16
+ import type { WorkspaceTabId } from '@/lib/types'
17
+ import { tabFromPath } from '@/lib/navigation'
18
+
19
+ import { User } from './components/user'
20
+ import { UserAvatarGroup } from './components/user-avatar-group'
21
+ import { pageFromPath, useCollabEnabled, useCollabEngine } from './provider'
22
+ import { useConnectionState, useWorkspaceUsers, useWorkspaceDirectory } from './hooks'
23
+ import { summarizeWorkspaceUsers } from './users'
24
+ import type { WorkspaceUserInfo } from './users'
25
+
26
+ export type TabInfo = { label: string; Icon: TabIcon }
27
+ type DescribeTab = (tab: WorkspaceTabId) => TabInfo | null
28
+ const USER_STATUS_ORDER = { active: 0, away: 1, offline: 2 }
29
+
30
+ type WorkspaceUsersMenuProps = {
31
+ workspaceId: string
32
+ describeTab: DescribeTab
33
+ onOpenTab: (tab: WorkspaceTabId) => void
34
+ }
35
+
36
+ export function WorkspaceUsersMenu({
37
+ workspaceId,
38
+ describeTab,
39
+ onOpenTab
40
+ }: WorkspaceUsersMenuProps) {
41
+ const enabled = useCollabEnabled()
42
+ const engine = useCollabEngine()
43
+ const state = useConnectionState()
44
+ const workspaceUsers = useWorkspaceUsers()
45
+ const directory = useWorkspaceDirectory()
46
+ const currentUser = useSyncExternalStore(
47
+ engine.subscribeCurrentUser,
48
+ engine.getCurrentUser,
49
+ engine.getCurrentUser
50
+ )
51
+ const router = useRouter()
52
+ const page = pageFromPath(usePathname(router), workspaceId, router.base)
53
+ const users = summarizeWorkspaceUsers(state.connections, {
54
+ currentUser,
55
+ connectionId: state.connectionId,
56
+ users: workspaceUsers,
57
+ page
58
+ })
59
+ const avatarIds = users
60
+ .filter(user => user.self || user.status !== 'offline')
61
+ .map(user => user.profile.id)
62
+ const [open, setOpen] = useState(false)
63
+
64
+ if (!enabled) return null
65
+
66
+ return (
67
+ <Popover open={open} onOpenChange={setOpen}>
68
+ <PopoverTrigger
69
+ render={
70
+ <Button
71
+ variant="ghost"
72
+ size="sm"
73
+ aria-label="Users in this workspace"
74
+ className="gap-0.5 rounded-full pr-1 pl-1 data-popup-open:bg-accent"
75
+ />
76
+ }
77
+ >
78
+ <UserAvatarGroup ids={avatarIds} size="xs" max={4} />
79
+ <IconChevronDown stroke={2.5} className="size-3! text-muted-foreground" />
80
+ </PopoverTrigger>
81
+ <PopoverContent align="end" className="max-w-64 p-1">
82
+ <PopoverTitle className="sr-only">Users in this workspace</PopoverTitle>
83
+ <WorkspaceUsersList
84
+ users={users}
85
+ page={page}
86
+ describeTab={describeTab}
87
+ onOpenTab={tab => {
88
+ setOpen(false)
89
+ onOpenTab(tab)
90
+ }}
91
+ />
92
+ {directory?.status === 'loading' && (
93
+ <p className="px-2 py-1 text-xs text-muted-foreground">Loading workspace users…</p>
94
+ )}
95
+ {users.length === 0 && directory?.status !== 'loading' && (
96
+ <p className="px-2 py-1 text-xs text-muted-foreground">No workspace users to show.</p>
97
+ )}
98
+ </PopoverContent>
99
+ </Popover>
100
+ )
101
+ }
102
+
103
+ type WorkspaceUsersListProps = {
104
+ users: WorkspaceUserInfo[]
105
+ page: string
106
+ describeTab: DescribeTab
107
+ onOpenTab: (tab: WorkspaceTabId) => void
108
+ }
109
+
110
+ export function WorkspaceUsersList({
111
+ users,
112
+ page,
113
+ describeTab,
114
+ onOpenTab
115
+ }: WorkspaceUsersListProps) {
116
+ const sorted = users.toSorted(
117
+ (a, b) =>
118
+ USER_STATUS_ORDER[a.status] - USER_STATUS_ORDER[b.status] || Number(b.self) - Number(a.self)
119
+ )
120
+ return (
121
+ <ul className="flex max-h-80 scroll-fade flex-col overflow-y-auto">
122
+ {sorted.map(user => (
123
+ <UserRow
124
+ key={user.profile.id}
125
+ user={user}
126
+ page={page}
127
+ describeTab={describeTab}
128
+ onOpenTab={onOpenTab}
129
+ />
130
+ ))}
131
+ </ul>
132
+ )
133
+ }
134
+
135
+ type UserRowProps = Omit<WorkspaceUsersListProps, 'users'> & { user: WorkspaceUserInfo }
136
+
137
+ function UserRow({ user, page, describeTab, onOpenTab }: UserRowProps) {
138
+ const tabs = user.pages.map(candidate => {
139
+ const tab = tabFromPath(candidate)
140
+ return { tab, info: tab ? describeTab(tab) : null }
141
+ })
142
+ const destination =
143
+ user.self || user.status === 'offline'
144
+ ? undefined
145
+ : tabs.find(({ tab, info }) => tab !== null && info !== null && tab !== page)
146
+ const target = destination?.tab
147
+ const labels = [
148
+ ...new Set(tabs.map(({ tab, info }) => info?.label ?? tab ?? 'Another tab'))
149
+ ].join(', ')
150
+ const where =
151
+ user.status === 'offline'
152
+ ? 'Offline'
153
+ : user.status === 'away'
154
+ ? labels
155
+ ? `${labels} · Away`
156
+ : 'Away'
157
+ : labels || 'Another tab'
158
+ const Icon = user.status === 'offline' ? undefined : tabs[0]?.info?.Icon
159
+ const content = (
160
+ <User
161
+ id={user.profile.id}
162
+ className="flex-1"
163
+ size="sm"
164
+ showYouLabel
165
+ description={
166
+ <span className="flex items-center gap-1 text-xs">
167
+ {Icon && <Icon size={12} stroke={1.75} className="shrink-0" />}
168
+ <span className="truncate">{where}</span>
169
+ </span>
170
+ }
171
+ />
172
+ )
173
+ const row = 'flex w-full items-center gap-2.5 rounded-md px-2 py-1 text-left'
174
+
175
+ return (
176
+ <li>
177
+ {target ? (
178
+ <button
179
+ type="button"
180
+ title={`Go to ${destination?.info?.label}`}
181
+ className={cn(
182
+ row,
183
+ 'cursor-pointer outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50'
184
+ )}
185
+ onClick={() => onOpenTab(target)}
186
+ >
187
+ {content}
188
+ </button>
189
+ ) : (
190
+ <div className={row}>{content}</div>
191
+ )}
192
+ </li>
193
+ )
194
+ }
@@ -10,7 +10,6 @@
10
10
  // that prefix is stripped before lookup so the underlying service resolves.
11
11
  // Unknown servers fall back to a generic tabler icon — see
12
12
  // `client/components/TurnView.tsx`.
13
- import agentationIcon from '@/client/assets/mcp/agentation.png'
14
13
  import airtableIcon from '@/client/assets/mcp/airtable.png'
15
14
  import apolloIcon from '@/client/assets/mcp/apollo.png'
16
15
  import asanaIcon from '@/client/assets/mcp/asana.png'
@@ -63,7 +62,6 @@ import vercelIcon from '@/client/assets/mcp/vercel.png'
63
62
  import zapierIcon from '@/client/assets/mcp/zapier.png'
64
63
 
65
64
  const ICONS: Record<string, string> = {
66
- agentation: agentationIcon,
67
65
  airtable: airtableIcon,
68
66
  apollo: apolloIcon,
69
67
  asana: asanaIcon,
@@ -7,6 +7,11 @@ type DevRouteEntry = {
7
7
  }
8
8
 
9
9
  const DEV_ROUTES: DevRouteEntry[] = [
10
+ {
11
+ path: '/dev/collab',
12
+ title: 'Collab',
13
+ description: 'Collaboration components, live hook previews, and local user settings.'
14
+ },
10
15
  {
11
16
  path: '/dev/blobatar-shapes',
12
17
  title: 'Blobatar shape builder',
@@ -1,4 +1,5 @@
1
- import { Route, Switch } from 'wouter'
1
+ import { lazy, Suspense } from 'react'
2
+ import { Redirect, Route, Switch } from 'wouter'
2
3
 
3
4
  import { ChatStatesPage } from './ChatStatesPage'
4
5
  import { BlobatarShapesPage } from './BlobatarShapesPage'
@@ -6,15 +7,26 @@ import { DevIndexPage } from './DevIndexPage'
6
7
  import { HarnessDebugPage } from './HarnessDebugPage'
7
8
  import { TextureLabPage } from './TextureLabPage'
8
9
  import { ToolCallsPage } from './ToolCallsPage'
9
- import { UiComponentsPage } from './UiComponentsPage'
10
+ import { UiComponentsPage } from './ui-components/ui-components-page'
10
11
 
11
- // All /dev/* routes, colocated with their pages so the whole dev playground
12
- // (and its dependencies) lives in this folder and loads as one lazy chunk —
12
+ // All /dev/* routes live with their pages here and load only in development;
13
13
  // see the dynamic import in AppRouter. /dev itself is the index; list new
14
14
  // routes there too.
15
+ const CollabPage = lazy(() =>
16
+ import('./collab/collab-page').then(module => ({ default: module.CollabPage }))
17
+ )
18
+
15
19
  export default function DevRoutes() {
16
20
  return (
17
21
  <Switch>
22
+ <Route path="/dev/collab-kit">
23
+ <Redirect to="/dev/collab" />
24
+ </Route>
25
+ <Route path="/dev/collab">
26
+ <Suspense fallback={null}>
27
+ <CollabPage />
28
+ </Suspense>
29
+ </Route>
18
30
  <Route path="/dev/harness" component={HarnessDebugPage} />
19
31
  <Route path="/dev/blobatar-shapes" component={BlobatarShapesPage} />
20
32
  <Route path="/dev/chat-states" component={ChatStatesPage} />
@@ -0,0 +1,24 @@
1
+ import { Link } from 'wouter'
2
+
3
+ import { LocalUserSettings } from './local-user-settings'
4
+ import { CollabPlayground } from './collab-playground'
5
+
6
+ export function CollabPage() {
7
+ return (
8
+ <main className="mx-auto flex w-full max-w-6xl flex-col gap-10 px-6 py-10">
9
+ <div>
10
+ <Link href="/dev" className="text-sm text-muted-foreground hover:text-foreground">
11
+ ← Dev pages
12
+ </Link>
13
+ <header className="mt-5">
14
+ <h1 className="text-xl font-medium">Collab</h1>
15
+ <p className="mt-1 text-sm text-muted-foreground">
16
+ Try collaboration components and hooks, and edit your local user for workspace testing.
17
+ </p>
18
+ </header>
19
+ </div>
20
+ <LocalUserSettings />
21
+ <CollabPlayground />
22
+ </main>
23
+ )
24
+ }