moi-computer 0.12.1-next.1 → 0.12.1-next.3

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 (123) hide show
  1. package/client/AGENTS.md +3 -2
  2. package/client/api/app-config.ts +3 -9
  3. package/client/api/workspace-keys.ts +2 -1
  4. package/client/app/app-provider.tsx +25 -0
  5. package/client/app/app-router.tsx +2 -0
  6. package/client/app/routes/settings-route.tsx +10 -0
  7. package/client/app/routes/workspace-route.tsx +4 -0
  8. package/client/app/shell/sidebar-layout.tsx +38 -51
  9. package/client/dev/index.html +5 -5
  10. package/client/features/account/account-menu.tsx +96 -0
  11. package/client/features/account/account-provider.tsx +142 -0
  12. package/client/features/account/account-test-utils.tsx +293 -0
  13. package/client/features/account/api.ts +142 -0
  14. package/client/features/account/identity.ts +23 -0
  15. package/client/features/applets/api.ts +1 -1
  16. package/client/features/chat/connection/chat-frames.ts +2 -2
  17. package/client/features/chat/sessions/api.ts +1 -1
  18. package/client/features/chat/use-chat.ts +1 -1
  19. package/client/features/collab/applet-api.ts +15 -14
  20. package/client/features/collab/components/cursors.tsx +61 -24
  21. package/client/features/collab/components/presence-avatars.tsx +25 -12
  22. package/client/features/collab/components/presence-frame.tsx +20 -24
  23. package/client/features/collab/components/presence-group.tsx +15 -7
  24. package/client/features/collab/components/user-avatar-group.tsx +21 -8
  25. package/client/features/collab/components/user-avatar.tsx +38 -7
  26. package/client/features/collab/components/user.tsx +31 -12
  27. package/client/features/collab/host-state.ts +24 -7
  28. package/client/features/collab/local-user.ts +1 -1
  29. package/client/features/collab/proxy-user.ts +4 -9
  30. package/client/features/collab/users.ts +0 -5
  31. package/client/features/collab/workspace-users-menu.tsx +3 -3
  32. package/client/features/demo/demo-dialog.tsx +25 -79
  33. package/client/features/dev/collab/collab-playground.tsx +7 -7
  34. package/client/features/dev/collab/local-user-settings.tsx +7 -53
  35. package/client/features/dev/workspace-setup-preview.tsx +43 -16
  36. package/client/features/harness/device-login-steps.tsx +2 -2
  37. package/client/features/home/api.ts +29 -9
  38. package/client/features/home/home-page.tsx +7 -4
  39. package/client/features/scratchpad/scratchpad.tsx +3 -6
  40. package/client/features/settings/api.ts +14 -8
  41. package/client/features/settings/connectors-settings.tsx +3 -3
  42. package/client/features/settings/environment-settings.tsx +3 -3
  43. package/client/features/settings/general-settings.tsx +1 -1
  44. package/client/features/settings/profile-settings.tsx +95 -0
  45. package/client/features/settings/settings-page.tsx +44 -0
  46. package/client/features/settings/settings-section.tsx +26 -0
  47. package/client/features/settings/users-settings.tsx +195 -0
  48. package/client/features/update/update-control.tsx +1 -1
  49. package/client/features/workspace/add/create-workspace-dialog.tsx +5 -2
  50. package/client/features/workspace/api.ts +12 -16
  51. package/client/features/workspace/setup/workspace-login-state.tsx +4 -4
  52. package/client/features/workspace/setup/workspace-setup.tsx +2 -1
  53. package/client/features/workspace/workspace-content.tsx +12 -52
  54. package/client/features/workspace/workspace-frame.tsx +76 -0
  55. package/client/features/workspace/workspace-layout-context.tsx +2 -0
  56. package/client/features/workspace/workspace-pending-screen.tsx +26 -0
  57. package/client/features/workspace/workspace-screen.tsx +3 -3
  58. package/client/index.html +28 -9
  59. package/client/index.tsx +7 -2
  60. package/client/lib/browser-tab-id.ts +4 -0
  61. package/client/lib/user-display-name.ts +6 -0
  62. package/client/main.tsx +12 -6
  63. package/client/runtime/app-context.ts +20 -0
  64. package/client/runtime/use-workspace-events.ts +29 -153
  65. package/client/runtime/workspace-events.ts +151 -0
  66. package/dist/chunk-20ynagd4.js +2 -0
  67. package/dist/chunk-42tde9a6.js +1 -0
  68. package/dist/chunk-9w543s0r.js +2 -0
  69. package/dist/{chunk-q0gbdts4.js → chunk-a5372n61.js} +71 -71
  70. package/dist/chunk-aja9y1vn.js +68 -0
  71. package/dist/chunk-fvcvrh3d.css +1 -0
  72. package/dist/chunk-gtfjw3nx.js +1 -0
  73. package/dist/{chunk-hvh9f5h0.js → chunk-j39y2aky.js} +1 -1
  74. package/dist/chunk-pja30km3.js +1 -0
  75. package/dist/{chunk-d7cbm65e.js → chunk-rm894bc2.js} +1 -1
  76. package/dist/chunk-tevvtfbk.js +10 -0
  77. package/dist/{chunk-jvyvwwv3.js → chunk-tgt9zd0r.js} +1 -1
  78. package/dist/chunk-tv5k5z00.js +1 -0
  79. package/dist/chunk-zq2ae5dx.js +2 -0
  80. package/dist/index.html +29 -10
  81. package/lib/ids.ts +2 -2
  82. package/lib/types.ts +1 -1
  83. package/package.json +1 -1
  84. package/server/api/index.ts +43 -28
  85. package/server/app-config.ts +7 -0
  86. package/server/applets/thumbnails.ts +8 -5
  87. package/server/harness/codex/thread-list.ts +4 -0
  88. package/server/static.ts +4 -2
  89. package/server/vendor.ts +23 -30
  90. package/server/web.ts +4 -2
  91. package/server/workspaces/init.ts +0 -10
  92. package/server/workspaces/layout.ts +11 -6
  93. package/server/workspaces/registry.ts +31 -9
  94. package/dist/chunk-08ndj2rg.js +0 -2
  95. package/dist/chunk-2x040tmg.js +0 -68
  96. package/dist/chunk-3smxq0ts.js +0 -1
  97. package/dist/chunk-68ch5hs8.js +0 -2
  98. package/dist/chunk-9vg3xa81.js +0 -2
  99. package/dist/chunk-c2p00p9j.css +0 -1
  100. package/dist/chunk-cs833y9j.js +0 -1
  101. package/dist/chunk-nwevqe86.js +0 -10
  102. package/dist/chunk-rt30jbcm.js +0 -1
  103. package/dist/chunk-y5y3kj67.js +0 -1
  104. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-dom-client.js +0 -0
  105. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-dom.js +0 -0
  106. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-dev-runtime.js +0 -0
  107. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-runtime.js +0 -0
  108. /package/client/vendor/react/{development → 19.2.4/development}/_impl/react.js +0 -0
  109. /package/client/vendor/react/{development → 19.2.4/development}/react-dom-client.js +0 -0
  110. /package/client/vendor/react/{development → 19.2.4/development}/react-dom.js +0 -0
  111. /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-dev-runtime.js +0 -0
  112. /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-runtime.js +0 -0
  113. /package/client/vendor/react/{development → 19.2.4/development}/react.js +0 -0
  114. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom-client.js +0 -0
  115. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom.js +0 -0
  116. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-dev-runtime.js +0 -0
  117. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-runtime.js +0 -0
  118. /package/client/vendor/react/{production → 19.2.4/production}/_impl/react.js +0 -0
  119. /package/client/vendor/react/{production → 19.2.4/production}/react-dom-client.js +0 -0
  120. /package/client/vendor/react/{production → 19.2.4/production}/react-dom.js +0 -0
  121. /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-dev-runtime.js +0 -0
  122. /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-runtime.js +0 -0
  123. /package/client/vendor/react/{production → 19.2.4/production}/react.js +0 -0
@@ -0,0 +1,151 @@
1
+ import type { NavigationRequest } from '@/lib/navigation'
2
+ import type { AppSettings, HarnessAvailability, ViewInfo, WidgetInfo } from '@/lib/types'
3
+
4
+ export type WorkspaceEvent =
5
+ | { type: 'widget:updated'; name: string }
6
+ | { type: 'widget-layout:updated'; widgets: WidgetInfo[] }
7
+ // `moi refresh` — cache-bust and re-fetch applets without a rebuild. `only`
8
+ // narrows to one kind; absent means both widgets and views.
9
+ | { type: 'applets:refresh'; only?: 'widgets' | 'views' }
10
+ | { type: 'view:updated'; name: string }
11
+ | { type: 'view-layout:updated'; views: ViewInfo[] }
12
+ | { type: 'view:deleted'; workspaceId: string; name: string }
13
+ | { type: 'views:changed'; workspaceId: string }
14
+ | { type: 'selected-session:updated'; workspaceId: string; sessionId: string | null }
15
+ // `origin` on an event is the browser tab whose write caused it (absent for
16
+ // CLI and agent changes), so that tab can skip its own echo. See
17
+ // client/lib/browser-tab-id.ts.
18
+ | { type: 'theme:updated'; origin?: string }
19
+ | { type: 'workspace:updated'; origin?: string }
20
+ // The registry list changed (reorder, create) without touching any open
21
+ // workspace's layout — clients refetch just the sidebar list.
22
+ | { type: 'workspaces-list:updated'; origin?: string }
23
+ // A workspace's env changed outside the UI — refetch the env view.
24
+ | { type: 'env:updated'; workspaceId: string }
25
+ // Workspace readiness changed. Patch its cache without a refetch.
26
+ | {
27
+ type: 'harness:updated'
28
+ workspaceId: string
29
+ availability: HarnessAvailability
30
+ }
31
+ // The Scratchpad canvas for `workspaceId` was saved — open tabs reload from
32
+ // disk. `origin` is the tab that wrote it, so that tab can skip its own echo.
33
+ | { type: 'scratchpad:updated'; workspaceId: string; origin?: string }
34
+ // App settings changed (PATCH /api/settings from any client) — carries the
35
+ // new value so caches update without a refetch.
36
+ | { type: 'settings:updated'; settings: AppSettings }
37
+ | NavigationRequest
38
+
39
+ export type WorkspaceEventHandler = (event: WorkspaceEvent) => void
40
+
41
+ export type WorkspaceEventsClientOptions = {
42
+ // Delay before reopening after a drop. It doubles on repeated drops, up to
43
+ // the max, so a downed server isn't hammered; it resets once a socket opens.
44
+ reconnectBaseDelayMs?: number
45
+ reconnectMaxDelayMs?: number
46
+ }
47
+
48
+ // The page's workspace events socket. `AppProvider` opens it when the app
49
+ // mounts and closes it when the app unmounts; subscribers come and go freely
50
+ // in between without touching the connection. A dropped socket reopens on its
51
+ // own. Framework-free, so the connection logic is testable without React.
52
+ export class WorkspaceEventsClient {
53
+ private readonly listeners = new Set<WorkspaceEventHandler>()
54
+ private readonly baseDelayMs: number
55
+ private readonly maxDelayMs: number
56
+ // The socket being opened or open; undefined while disconnected.
57
+ private socket: WebSocket | undefined
58
+ private closed = true
59
+ private reconnectAttempt = 0
60
+ private reconnectTimer: ReturnType<typeof setTimeout> | undefined
61
+ private shownWorkspace: string | undefined
62
+
63
+ constructor(
64
+ private readonly url: string,
65
+ options: WorkspaceEventsClientOptions = {}
66
+ ) {
67
+ this.baseDelayMs = options.reconnectBaseDelayMs ?? 1000
68
+ this.maxDelayMs = options.reconnectMaxDelayMs ?? 30_000
69
+ }
70
+
71
+ connect() {
72
+ this.closed = false
73
+ this.open()
74
+ }
75
+
76
+ // Shut the connection down for good; no reconnect follows.
77
+ close() {
78
+ this.closed = true
79
+ clearTimeout(this.reconnectTimer)
80
+ const socket = this.socket
81
+ this.socket = undefined
82
+ socket?.close()
83
+ }
84
+
85
+ subscribe(handler: WorkspaceEventHandler): () => void {
86
+ this.listeners.add(handler)
87
+ return () => {
88
+ this.listeners.delete(handler)
89
+ }
90
+ }
91
+
92
+ send(message: object) {
93
+ if (this.socket?.readyState !== WebSocket.OPEN) return
94
+ this.socket.send(JSON.stringify(message))
95
+ }
96
+
97
+ // The workspace this tab shows, for the server's navigation relay. Sent now
98
+ // and again on every reconnect.
99
+ get navigationWorkspace(): string | undefined {
100
+ return this.shownWorkspace
101
+ }
102
+
103
+ setNavigationWorkspace(workspaceId: string | undefined) {
104
+ this.shownWorkspace = workspaceId
105
+ this.sendNavigationPresence()
106
+ }
107
+
108
+ sendNavigationPresence() {
109
+ this.send({
110
+ type: 'navigation:presence',
111
+ // The wire format uses `null` for "no workspace".
112
+ workspaceId: this.shownWorkspace ?? null,
113
+ focused: document.visibilityState === 'visible' && document.hasFocus()
114
+ })
115
+ }
116
+
117
+ private open() {
118
+ if (this.closed || this.socket) return
119
+ const socket = new WebSocket(this.url)
120
+ this.socket = socket
121
+
122
+ socket.onopen = () => {
123
+ this.reconnectAttempt = 0
124
+ this.sendNavigationPresence()
125
+ }
126
+
127
+ socket.onmessage = event => {
128
+ try {
129
+ const data = JSON.parse(event.data) as WorkspaceEvent
130
+ for (const handler of this.listeners) handler(data)
131
+ } catch {}
132
+ }
133
+
134
+ socket.onclose = () => {
135
+ // A socket this client already let go of (closed or replaced).
136
+ if (this.socket !== socket) return
137
+ this.socket = undefined
138
+ if (!this.closed) this.scheduleReconnect()
139
+ }
140
+
141
+ socket.onerror = () => {
142
+ socket.close()
143
+ }
144
+ }
145
+
146
+ private scheduleReconnect() {
147
+ const delay = Math.min(this.baseDelayMs * 2 ** this.reconnectAttempt, this.maxDelayMs)
148
+ this.reconnectAttempt++
149
+ this.reconnectTimer = setTimeout(() => this.open(), delay)
150
+ }
151
+ }
@@ -0,0 +1,2 @@
1
+ import{Oc as r}from"/chunk-zq2ae5dx.js";import{cd as E}from"/chunk-tgt9zd0r.js";import{fd as x}from"/chunk-rm894bc2.js";var p=x(r(),1);var a={collab:!1},F=Object.keys(a);var f={environment:"local",demo:!1,experimental:{...a},demoInstallUrl:"https://moi.computer"},o=f,t=new Set;function y(e){return t.add(e),()=>{t.delete(e)}}async function m(){try{o=await E("/api/config");for(let e of t)e();return o}catch{}}async function A(){return m()}function L(){return p.useSyncExternalStore(y,()=>o)}
2
+ export{A as Mc,L as Nc};
@@ -0,0 +1 @@
1
+ import{a}from"/chunk-pcnahct1.js";import"/chunk-rm894bc2.js";export{a as sanitizeSvg};
@@ -0,0 +1,2 @@
1
+ var T=["pink","orange","amber","lime","emerald","cyan","blue","violet"];function _(A){return typeof A==="string"&&T.includes(A)}function V(A){let C=2166136261;for(let f=0;f<A.length;f++)C^=A.charCodeAt(f),C=Math.imul(C,16777619);return T[(C>>>0)%T.length]??T[0]}var o=1;var D=8192,H=320;function Q(A){return typeof A==="object"&&A!==null&&!Array.isArray(A)}function y(A,C=256){return typeof A==="string"&&A.length>0&&!A.includes("\x00")&&new TextEncoder().encode(A).length<=C}function j(A){return Q(A)&&y(A.id,240)&&A.id.trim().length>0&&(A.name===void 0||y(A.name)&&A.name.trim().length>0)&&_(A.color)&&(A.avatar===void 0||y(A.avatar,D))&&(A.email===void 0||y(A.email,H))}var W=["Curious Kiwi","Cheerful Cherry","Sleepy Peach","Excited Banana","Cosmic Mango","Velvet Lemon","Electric Plum","Wandering Pear","Dramatic Papaya","Suspicious Pineapple","Confused Coconut","Sneaky Tangerine","Gentle Fig","Quiet Apricot","Mellow Melon","Dreamy Guava"];function I(A,C){let f=A.filter((n)=>n!==C);return f[Math.floor(Math.random()*f.length)]??A[0]}function Z(A){return{name:I(W,A?.name),color:I(T,A?.color)}}function $(A,C){let f=C.name.trim();return{id:A,...f?{name:f}:{},color:C.color}}function G(){return $(`local-${crypto.randomUUID().slice(0,8)}`,Z())}var k="moi:local-profile",L=Object.freeze([]),B,g,Y,p=!1,w=new Set,X=new Set;function J(A,C){return JSON.stringify(A)===JSON.stringify(C)}function N(A){if(!A||typeof A.id!=="string"||!A.id.trim())throw Error("A user profile needs an id.");if(A.name!==void 0&&typeof A.name!=="string")throw Error("A user profile name must be a string when provided.");if(A.color!==void 0&&!_(A.color))throw Error("A user profile color must be one of the user palette names.");let C=A.id.trim(),f=A.name?.trim(),n={id:C,...f?{name:f}:{},color:A.color??V(C),...A.avatar!==void 0?{avatar:A.avatar}:{},...A.email!==void 0?{email:A.email}:{}};if(!j(n))throw Error("Invalid user profile.");return Object.freeze(n)}function b(A){if(!Array.isArray(A))throw Error("Users must be an array.");let C=new Set,f=A.map((n)=>{let M=N(n);if(C.has(M.id))throw Error("Users must have unique ids.");return C.add(M.id),M});return Object.freeze(f)}function F(A){if(!A||typeof A!=="object")throw Error("Users must be published as an object.");let C=b(A.users),f;if(A.me!==void 0&&A.me!==null){if(typeof A.me!=="string")throw Error("The current user id must be a string.");let M=A.me.trim();if(f=C.find((q)=>q.id===M),!f)throw Error("The current user must be listed in users.")}let n=g!=="external"||!J(B,f);if(g="external",n)B=f;if(Y=f?C:L,n)w.forEach((M)=>M());X.forEach((M)=>M())}function i(){return Y}function d(A){return X.add(A),()=>{X.delete(A)}}function c(){return B}function U(A){return w.add(A),()=>{w.delete(A)}}function a(){return g}function u({provider:A,profile:C}){if(g==="external")return;if(A===void 0){if(g===void 0||g==="local")return;g=void 0,B=void 0}else{let f=C===void 0?void 0:N(C);if(g===A&&J(B,f))return;g=A,B=f}w.forEach((f)=>f())}function K(){try{localStorage.setItem(k,JSON.stringify(B))}catch{}}function E(A){if(g!==void 0&&g!=="local")return;let C=N(A);g="local",B=C,K(),w.forEach((f)=>f())}function v(A,C){if(!A||!C||C.provider!==void 0||g!==void 0)return;try{let f=localStorage.getItem(k);if(f){E(JSON.parse(f));return}}catch{}E(G())}function s(){if(typeof window>"u"||p)return;p=!0;let A=window;A.moi??={};let C={publishUsers:F};A.moi.collab=C}function O(A){if(A.key!==k||!A.newValue||g!=="local")return;try{let C=N(JSON.parse(A.newValue));if(J(C,B))return;B=C,w.forEach((f)=>f())}catch{}}function l(){return window.addEventListener("storage",O),()=>window.removeEventListener("storage",O)}
2
+ export{o as Pc,Q as Qc,j as Rc,N as Sc,F as Tc,i as Uc,d as Vc,c as Wc,U as Xc,a as Yc,u as Zc,E as _c,v as $c,s as ad,l as bd};