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.
- package/client/AGENTS.md +3 -2
- package/client/api/app-config.ts +3 -9
- package/client/api/workspace-keys.ts +2 -1
- package/client/app/app-provider.tsx +25 -0
- package/client/app/app-router.tsx +2 -0
- package/client/app/routes/settings-route.tsx +10 -0
- package/client/app/routes/workspace-route.tsx +4 -0
- package/client/app/shell/sidebar-layout.tsx +38 -51
- package/client/dev/index.html +5 -5
- package/client/features/account/account-menu.tsx +96 -0
- package/client/features/account/account-provider.tsx +142 -0
- package/client/features/account/account-test-utils.tsx +293 -0
- package/client/features/account/api.ts +142 -0
- package/client/features/account/identity.ts +23 -0
- package/client/features/applets/api.ts +1 -1
- package/client/features/chat/connection/chat-frames.ts +2 -2
- package/client/features/chat/sessions/api.ts +1 -1
- package/client/features/chat/use-chat.ts +1 -1
- package/client/features/collab/applet-api.ts +15 -14
- package/client/features/collab/components/cursors.tsx +61 -24
- package/client/features/collab/components/presence-avatars.tsx +25 -12
- package/client/features/collab/components/presence-frame.tsx +20 -24
- package/client/features/collab/components/presence-group.tsx +15 -7
- package/client/features/collab/components/user-avatar-group.tsx +21 -8
- package/client/features/collab/components/user-avatar.tsx +38 -7
- package/client/features/collab/components/user.tsx +31 -12
- package/client/features/collab/host-state.ts +24 -7
- package/client/features/collab/local-user.ts +1 -1
- package/client/features/collab/proxy-user.ts +4 -9
- package/client/features/collab/users.ts +0 -5
- package/client/features/collab/workspace-users-menu.tsx +3 -3
- package/client/features/demo/demo-dialog.tsx +25 -79
- package/client/features/dev/collab/collab-playground.tsx +7 -7
- package/client/features/dev/collab/local-user-settings.tsx +7 -53
- package/client/features/dev/workspace-setup-preview.tsx +43 -16
- package/client/features/harness/device-login-steps.tsx +2 -2
- package/client/features/home/api.ts +29 -9
- package/client/features/home/home-page.tsx +7 -4
- package/client/features/scratchpad/scratchpad.tsx +3 -6
- package/client/features/settings/api.ts +14 -8
- package/client/features/settings/connectors-settings.tsx +3 -3
- package/client/features/settings/environment-settings.tsx +3 -3
- package/client/features/settings/general-settings.tsx +1 -1
- package/client/features/settings/profile-settings.tsx +95 -0
- package/client/features/settings/settings-page.tsx +44 -0
- package/client/features/settings/settings-section.tsx +26 -0
- package/client/features/settings/users-settings.tsx +195 -0
- package/client/features/update/update-control.tsx +1 -1
- package/client/features/workspace/add/create-workspace-dialog.tsx +5 -2
- package/client/features/workspace/api.ts +12 -16
- package/client/features/workspace/setup/workspace-login-state.tsx +4 -4
- package/client/features/workspace/setup/workspace-setup.tsx +2 -1
- package/client/features/workspace/workspace-content.tsx +12 -52
- package/client/features/workspace/workspace-frame.tsx +76 -0
- package/client/features/workspace/workspace-layout-context.tsx +2 -0
- package/client/features/workspace/workspace-pending-screen.tsx +26 -0
- package/client/features/workspace/workspace-screen.tsx +3 -3
- package/client/index.html +28 -9
- package/client/index.tsx +7 -2
- package/client/lib/browser-tab-id.ts +4 -0
- package/client/lib/user-display-name.ts +6 -0
- package/client/main.tsx +12 -6
- package/client/runtime/app-context.ts +20 -0
- package/client/runtime/use-workspace-events.ts +29 -153
- package/client/runtime/workspace-events.ts +151 -0
- package/dist/chunk-20ynagd4.js +2 -0
- package/dist/chunk-42tde9a6.js +1 -0
- package/dist/chunk-9w543s0r.js +2 -0
- package/dist/{chunk-q0gbdts4.js → chunk-a5372n61.js} +71 -71
- package/dist/chunk-aja9y1vn.js +68 -0
- package/dist/chunk-fvcvrh3d.css +1 -0
- package/dist/chunk-gtfjw3nx.js +1 -0
- package/dist/{chunk-hvh9f5h0.js → chunk-j39y2aky.js} +1 -1
- package/dist/chunk-pja30km3.js +1 -0
- package/dist/{chunk-d7cbm65e.js → chunk-rm894bc2.js} +1 -1
- package/dist/chunk-tevvtfbk.js +10 -0
- package/dist/{chunk-jvyvwwv3.js → chunk-tgt9zd0r.js} +1 -1
- package/dist/chunk-tv5k5z00.js +1 -0
- package/dist/chunk-zq2ae5dx.js +2 -0
- package/dist/index.html +29 -10
- package/lib/ids.ts +2 -2
- package/lib/types.ts +1 -1
- package/package.json +1 -1
- package/server/api/index.ts +43 -28
- package/server/app-config.ts +7 -0
- package/server/applets/thumbnails.ts +8 -5
- package/server/harness/codex/thread-list.ts +4 -0
- package/server/static.ts +4 -2
- package/server/vendor.ts +23 -30
- package/server/web.ts +4 -2
- package/server/workspaces/init.ts +0 -10
- package/server/workspaces/layout.ts +11 -6
- package/server/workspaces/registry.ts +31 -9
- package/dist/chunk-08ndj2rg.js +0 -2
- package/dist/chunk-2x040tmg.js +0 -68
- package/dist/chunk-3smxq0ts.js +0 -1
- package/dist/chunk-68ch5hs8.js +0 -2
- package/dist/chunk-9vg3xa81.js +0 -2
- package/dist/chunk-c2p00p9j.css +0 -1
- package/dist/chunk-cs833y9j.js +0 -1
- package/dist/chunk-nwevqe86.js +0 -10
- package/dist/chunk-rt30jbcm.js +0 -1
- package/dist/chunk-y5y3kj67.js +0 -1
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-dom-client.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-dom.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/_impl/react.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-dom-client.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-dom.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{development → 19.2.4/development}/react.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom-client.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-dom.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/_impl/react.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-dom-client.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-dom.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-dev-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react-jsx-runtime.js +0 -0
- /package/client/vendor/react/{production → 19.2.4/production}/react.js +0 -0
|
@@ -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 {
|
|
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'
|
|
@@ -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
|
-
<
|
|
156
|
+
<UserContainer
|
|
157
157
|
id={user.profile.id}
|
|
158
158
|
className="flex-1"
|
|
159
159
|
size="sm"
|
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type MouseEvent as ReactMouseEvent,
|
|
3
|
-
type ReactElement,
|
|
4
|
-
useEffect,
|
|
5
|
-
useRef,
|
|
6
|
-
useState
|
|
7
|
-
} from 'react'
|
|
1
|
+
import { type MouseEvent as ReactMouseEvent, type ReactElement, useRef } from 'react'
|
|
8
2
|
|
|
9
3
|
import {
|
|
4
|
+
IconArrowRight,
|
|
10
5
|
IconArrowUpRight,
|
|
11
|
-
|
|
12
|
-
IconCopy,
|
|
13
|
-
IconFolderOpen,
|
|
6
|
+
IconBrowserPlus,
|
|
14
7
|
IconMessageChatbot,
|
|
15
8
|
IconX
|
|
16
9
|
} from '@tabler/icons-react'
|
|
17
10
|
|
|
18
11
|
import claudeIcon from '@/client/assets/claude.svg'
|
|
19
12
|
import floppyDisk from '@/client/assets/floppy-disk.webp'
|
|
20
|
-
import hermesIcon from '@/client/assets/hermes.png'
|
|
21
13
|
import openaiIcon from '@/client/assets/openai.svg'
|
|
22
|
-
import openclawIcon from '@/client/assets/openclaw.svg'
|
|
23
14
|
import { Button, buttonVariants } from '@/client/components/ui/button'
|
|
24
15
|
import {
|
|
25
16
|
Dialog,
|
|
@@ -31,11 +22,6 @@ import {
|
|
|
31
22
|
} from '@/client/components/ui/dialog'
|
|
32
23
|
import { useAppConfig } from '@/client/api/app-config'
|
|
33
24
|
|
|
34
|
-
// The canonical setup prompt from moi.computer — pasted into any agent, it
|
|
35
|
-
// fetches INSTALL.md and walks itself through the install.
|
|
36
|
-
const AGENT_COMMAND =
|
|
37
|
-
'Set up the Moi workspace for this project. Fetch https://moi.computer/INSTALL.md, and follow the steps.'
|
|
38
|
-
|
|
39
25
|
type DemoDialogProps = {
|
|
40
26
|
// Trigger-owned (uncontrolled) or controlled via open/onOpenChange — the
|
|
41
27
|
// create-workspace buttons use the former, programmatic opens the latter.
|
|
@@ -45,7 +31,7 @@ type DemoDialogProps = {
|
|
|
45
31
|
}
|
|
46
32
|
|
|
47
33
|
// Shown in the cloud demo wherever a workspace would be created: the demo is
|
|
48
|
-
// limited to its built-in workspaces,
|
|
34
|
+
// limited to its built-in workspaces, with login opening the full app.
|
|
49
35
|
export function DemoDialog({ trigger, open, onOpenChange }: DemoDialogProps) {
|
|
50
36
|
return (
|
|
51
37
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
@@ -91,7 +77,7 @@ function FloppyArtwork({ demoInstallUrl }: FloppyArtworkProps) {
|
|
|
91
77
|
href={demoInstallUrl}
|
|
92
78
|
target="_blank"
|
|
93
79
|
rel="noreferrer"
|
|
94
|
-
className="group absolute top-1/2 left-1/2 w-
|
|
80
|
+
className="group absolute top-1/2 left-1/2 w-40 -translate-x-1/2 -translate-y-1/2 rotate-4 [transform:translate3d(var(--floppy-x,0px),var(--floppy-y,0px),0)] rounded-lg transition-transform duration-150 ease-out will-change-transform outline-none focus-visible:ring-3 focus-visible:ring-ring/50 motion-reduce:transform-none motion-reduce:transition-none md:w-36"
|
|
95
81
|
>
|
|
96
82
|
<img src={floppyDisk} alt="" className="w-full drop-shadow-xl" />
|
|
97
83
|
<div
|
|
@@ -108,28 +94,8 @@ function FloppyArtwork({ demoInstallUrl }: FloppyArtworkProps) {
|
|
|
108
94
|
)
|
|
109
95
|
}
|
|
110
96
|
|
|
111
|
-
function useCopyCommand() {
|
|
112
|
-
const [copied, setCopied] = useState(false)
|
|
113
|
-
|
|
114
|
-
useEffect(() => {
|
|
115
|
-
if (!copied) return
|
|
116
|
-
const t = setTimeout(() => setCopied(false), 1500)
|
|
117
|
-
return () => clearTimeout(t)
|
|
118
|
-
}, [copied])
|
|
119
|
-
|
|
120
|
-
const copy = () => {
|
|
121
|
-
navigator.clipboard
|
|
122
|
-
?.writeText(AGENT_COMMAND)
|
|
123
|
-
.then(() => setCopied(true))
|
|
124
|
-
.catch(() => {})
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return { copied, copy }
|
|
128
|
-
}
|
|
129
|
-
|
|
130
97
|
function DemoDialogContent() {
|
|
131
98
|
const { demoInstallUrl } = useAppConfig()
|
|
132
|
-
const { copied, copy } = useCopyCommand()
|
|
133
99
|
|
|
134
100
|
return (
|
|
135
101
|
<DialogContent
|
|
@@ -157,21 +123,20 @@ function DemoDialogContent() {
|
|
|
157
123
|
<div className="relative grid max-h-[calc(100dvh-2rem)] overflow-y-auto md:grid-cols-[3fr_2fr] md:overflow-visible">
|
|
158
124
|
<div className="rounded-xl bg-background p-6 text-foreground shadow-sm md:p-8">
|
|
159
125
|
<div className="flex flex-col gap-0.5">
|
|
160
|
-
<DialogTitle>
|
|
126
|
+
<DialogTitle>Set up your personal Moi</DialogTitle>
|
|
161
127
|
<DialogDescription className="mt-1">
|
|
162
|
-
This is a demo
|
|
163
|
-
agent.
|
|
128
|
+
This is a demo workspace. Sign in and connect your agent to unlock all features.
|
|
164
129
|
</DialogDescription>
|
|
165
130
|
</div>
|
|
166
131
|
|
|
167
132
|
<ul className="mt-4 flex flex-col gap-3">
|
|
168
133
|
<li className="flex items-center gap-3">
|
|
169
|
-
<
|
|
134
|
+
<IconBrowserPlus
|
|
170
135
|
stroke={0.75}
|
|
171
136
|
className="mt-0.5 size-8 shrink-0 text-muted-foreground"
|
|
172
137
|
/>
|
|
173
138
|
<span className="text-sm text-foreground">
|
|
174
|
-
|
|
139
|
+
Create as many workspaces, views, and widgets as you want
|
|
175
140
|
</span>
|
|
176
141
|
</li>
|
|
177
142
|
<li className="flex items-center gap-3">
|
|
@@ -179,45 +144,26 @@ function DemoDialogContent() {
|
|
|
179
144
|
stroke={0.75}
|
|
180
145
|
className="mt-0.5 size-8 shrink-0 text-muted-foreground"
|
|
181
146
|
/>
|
|
182
|
-
<span className="
|
|
183
|
-
|
|
184
|
-
<span className="inline-flex items-
|
|
185
|
-
<img src={claudeIcon} alt="" className="size-3.5 object-contain" />
|
|
186
|
-
Claude
|
|
187
|
-
</span>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
Hermes,
|
|
195
|
-
</span>
|
|
196
|
-
<span className="inline-flex items-center gap-1 font-medium">
|
|
197
|
-
<img src={openclawIcon} alt="" className="size-3.5 object-contain" />
|
|
198
|
-
OpenClaw,
|
|
199
|
-
</span>
|
|
200
|
-
<span>and more</span>
|
|
147
|
+
<span className="text-sm text-foreground">
|
|
148
|
+
Build with{' '}
|
|
149
|
+
<span className="inline-flex items-baseline gap-1">
|
|
150
|
+
<img src={claudeIcon} alt="" className="size-3.5 self-center object-contain" />
|
|
151
|
+
<strong className="font-medium">Claude</strong>
|
|
152
|
+
</span>{' '}
|
|
153
|
+
or{' '}
|
|
154
|
+
<span className="inline-flex items-baseline gap-1">
|
|
155
|
+
<img src={openaiIcon} alt="" className="size-3.5 self-center object-contain" />
|
|
156
|
+
<strong className="font-medium">ChatGPT</strong>
|
|
157
|
+
</span>{' '}
|
|
158
|
+
using your subscription and app connectors
|
|
201
159
|
</span>
|
|
202
160
|
</li>
|
|
203
161
|
</ul>
|
|
204
162
|
|
|
205
|
-
<
|
|
206
|
-
|
|
207
|
-
<
|
|
208
|
-
|
|
209
|
-
{AGENT_COMMAND}
|
|
210
|
-
</code>
|
|
211
|
-
<Button type="button" onClick={copy} className="absolute right-4 -bottom-4">
|
|
212
|
-
{copied ? (
|
|
213
|
-
<IconCheck data-icon="inline-start" stroke={1.5} />
|
|
214
|
-
) : (
|
|
215
|
-
<IconCopy data-icon="inline-start" stroke={1.5} />
|
|
216
|
-
)}
|
|
217
|
-
{copied ? 'Copied' : 'Copy prompt'}
|
|
218
|
-
</Button>
|
|
219
|
-
</div>
|
|
220
|
-
</div>
|
|
163
|
+
<Button render={<a href="/cloud/login" />} className="mt-6">
|
|
164
|
+
Sign in
|
|
165
|
+
<IconArrowRight data-icon="inline-end" stroke={1.5} />
|
|
166
|
+
</Button>
|
|
221
167
|
</div>
|
|
222
168
|
|
|
223
169
|
<FloppyArtwork demoInstallUrl={demoInstallUrl} />
|
|
@@ -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 {
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useSyncExternalStore } from 'react'
|
|
2
2
|
|
|
3
|
-
import { IconArrowsShuffle } from '@tabler/icons-react'
|
|
4
|
-
|
|
5
|
-
import { Button } from '@/client/components/ui/button'
|
|
6
|
-
import { Input } from '@/client/components/ui/input'
|
|
7
|
-
import { useAppConfig } from '@/client/api/app-config'
|
|
8
3
|
import { USER_COLORS } from '@/lib/collab/colors'
|
|
9
4
|
import type { UserProfile } from '@/lib/collab/types'
|
|
10
5
|
import { User } from '@/client/features/collab/components/user'
|
|
11
6
|
import { UserAvatar } from '@/client/features/collab/components/user-avatar'
|
|
12
|
-
import { randomLocalUser } from '@/client/features/collab/local-user'
|
|
13
7
|
import {
|
|
14
8
|
getCurrentUser,
|
|
15
9
|
getCurrentUserSource,
|
|
@@ -18,7 +12,6 @@ import {
|
|
|
18
12
|
} from '@/client/features/collab/host-state'
|
|
19
13
|
|
|
20
14
|
export function LocalUserSettings() {
|
|
21
|
-
const { experimental } = useAppConfig()
|
|
22
15
|
const source = useSyncExternalStore(
|
|
23
16
|
subscribeCurrentUserStore,
|
|
24
17
|
getCurrentUserSource,
|
|
@@ -34,14 +27,7 @@ export function LocalUserSettings() {
|
|
|
34
27
|
Local user
|
|
35
28
|
</h2>
|
|
36
29
|
<p className="text-sm text-muted-foreground">
|
|
37
|
-
|
|
38
|
-
'Couldn’t resolve your user identity. Reload Moi to try again.'
|
|
39
|
-
) : (
|
|
40
|
-
<>
|
|
41
|
-
Start Moi with <code className="font-mono">--experimental-collab</code> to create a
|
|
42
|
-
local user automatically. The playground below uses its own sample users.
|
|
43
|
-
</>
|
|
44
|
-
)}
|
|
30
|
+
Couldn’t resolve your user identity. Reload Moi to try again.
|
|
45
31
|
</p>
|
|
46
32
|
</section>
|
|
47
33
|
)
|
|
@@ -64,7 +50,7 @@ function AccessUser({ profile }: AccessUserProps) {
|
|
|
64
50
|
: 'This server uses Cloudflare Access, but this page wasn’t opened through it. Open Moi at its Cloudflare Access address to appear in workspaces.'}
|
|
65
51
|
</p>
|
|
66
52
|
</header>
|
|
67
|
-
{profile && <User
|
|
53
|
+
{profile && <User profile={profile} />}
|
|
68
54
|
</section>
|
|
69
55
|
)
|
|
70
56
|
}
|
|
@@ -72,9 +58,6 @@ function AccessUser({ profile }: AccessUserProps) {
|
|
|
72
58
|
type LocalUserEditorProps = { profile: UserProfile }
|
|
73
59
|
|
|
74
60
|
function LocalUserEditor({ profile }: LocalUserEditorProps) {
|
|
75
|
-
// Keep raw input so normalization doesn't eat spaces while a name is being typed.
|
|
76
|
-
const [name, setName] = useState(profile.name ?? '')
|
|
77
|
-
|
|
78
61
|
return (
|
|
79
62
|
<section aria-labelledby="local-user-title" className="flex flex-col gap-5">
|
|
80
63
|
<header>
|
|
@@ -82,8 +65,7 @@ function LocalUserEditor({ profile }: LocalUserEditorProps) {
|
|
|
82
65
|
Local user
|
|
83
66
|
</h2>
|
|
84
67
|
<p className="mt-1 text-sm text-muted-foreground">
|
|
85
|
-
|
|
86
|
-
users, open Moi in another browser tab.
|
|
68
|
+
Change your avatar color here. Edit your name in Settings.
|
|
87
69
|
</p>
|
|
88
70
|
</header>
|
|
89
71
|
<div className="flex flex-col gap-5">
|
|
@@ -94,23 +76,9 @@ function LocalUserEditor({ profile }: LocalUserEditorProps) {
|
|
|
94
76
|
aria-label="Local user preview"
|
|
95
77
|
className="size-16 shrink-0 overflow-hidden rounded-full"
|
|
96
78
|
>
|
|
97
|
-
<UserAvatar
|
|
79
|
+
<UserAvatar profile={profile} className="data-[size=default]:size-full" />
|
|
98
80
|
</div>
|
|
99
81
|
<div className="flex w-full max-w-sm min-w-0 flex-col gap-4">
|
|
100
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
101
|
-
Name (optional)
|
|
102
|
-
<Input
|
|
103
|
-
value={name}
|
|
104
|
-
maxLength={80}
|
|
105
|
-
placeholder="Type a name"
|
|
106
|
-
autoComplete="off"
|
|
107
|
-
spellCheck={false}
|
|
108
|
-
onChange={event => {
|
|
109
|
-
setName(event.target.value)
|
|
110
|
-
setLocalUser({ ...profile, name: event.target.value })
|
|
111
|
-
}}
|
|
112
|
-
/>
|
|
113
|
-
</label>
|
|
114
82
|
<div className="flex flex-col gap-1.5 text-sm">
|
|
115
83
|
<span id="collab-color-label">Color</span>
|
|
116
84
|
<div
|
|
@@ -140,25 +108,11 @@ function LocalUserEditor({ profile }: LocalUserEditorProps) {
|
|
|
140
108
|
))}
|
|
141
109
|
</div>
|
|
142
110
|
</div>
|
|
143
|
-
<div className="flex flex-wrap gap-2">
|
|
144
|
-
<Button
|
|
145
|
-
type="button"
|
|
146
|
-
variant="secondary"
|
|
147
|
-
size="sm"
|
|
148
|
-
onClick={() => {
|
|
149
|
-
const next = randomLocalUser({ name, color: profile.color })
|
|
150
|
-
setName(next.name)
|
|
151
|
-
setLocalUser({ ...profile, ...next })
|
|
152
|
-
}}
|
|
153
|
-
>
|
|
154
|
-
<IconArrowsShuffle stroke={1.75} />
|
|
155
|
-
Randomize
|
|
156
|
-
</Button>
|
|
157
|
-
</div>
|
|
158
111
|
</div>
|
|
159
112
|
</div>
|
|
160
113
|
<p className="text-sm text-muted-foreground">
|
|
161
|
-
Your user is saved in this browser
|
|
114
|
+
Your user is saved in this browser and shared across tabs. The playground below uses its
|
|
115
|
+
own sample users.
|
|
162
116
|
</p>
|
|
163
117
|
</div>
|
|
164
118
|
</section>
|
|
@@ -15,7 +15,9 @@ import {
|
|
|
15
15
|
} from '@/client/components/ui/dialog'
|
|
16
16
|
import { TooltipProvider } from '@/client/components/ui/tooltip'
|
|
17
17
|
import { Toaster } from '@/client/components/ui/toast'
|
|
18
|
-
import {
|
|
18
|
+
import { WorkspacePendingScreen } from '@/client/features/workspace/workspace-pending-screen'
|
|
19
|
+
import { WorkspaceLayoutContext } from '@/client/features/workspace/workspace-layout-context'
|
|
20
|
+
import { createDefaultWorkspaceLayout } from '@/lib/workspace-layout'
|
|
19
21
|
import { useWorkspaceSetup } from '@/client/features/workspace/setup/workspace-setup'
|
|
20
22
|
import { WorkspaceWelcomeState } from '@/client/features/workspace/setup/workspace-welcome-state'
|
|
21
23
|
import { WorkspaceLoadingState } from '@/client/features/workspace/setup/workspace-recovery-states'
|
|
@@ -50,6 +52,7 @@ type SetupPreviewProps = {
|
|
|
50
52
|
function SetupPreview({ mocks, client, environment, harness, scenario }: SetupPreviewProps) {
|
|
51
53
|
const [provider, setProvider] = useState<'browser' | 'code' | 'closed'>()
|
|
52
54
|
const [deviceCode, setDeviceCode] = useState('')
|
|
55
|
+
const [layout, setLayout] = useState(createDefaultWorkspaceLayout)
|
|
53
56
|
const auth = useHarnessAuth(harness)
|
|
54
57
|
const pendingId = auth.data?.login?.state === 'pending' ? auth.data.login.id : undefined
|
|
55
58
|
// Both local harnesses open the browser automatically.
|
|
@@ -112,20 +115,44 @@ function SetupPreview({ mocks, client, environment, harness, scenario }: SetupPr
|
|
|
112
115
|
</Button>
|
|
113
116
|
))}
|
|
114
117
|
</div>
|
|
118
|
+
<div className="flex flex-wrap gap-2" role="group" aria-label="Layout">
|
|
119
|
+
{(['split', 'fullscreen'] as const).map(layoutMode => (
|
|
120
|
+
<Button
|
|
121
|
+
key={layoutMode}
|
|
122
|
+
size="sm"
|
|
123
|
+
variant={layout.layoutMode === layoutMode ? 'default' : 'secondary'}
|
|
124
|
+
onClick={() => setLayout(current => ({ ...current, layoutMode }))}
|
|
125
|
+
>
|
|
126
|
+
{layoutMode === 'split' ? 'Split' : 'Fullscreen'}
|
|
127
|
+
</Button>
|
|
128
|
+
))}
|
|
129
|
+
</div>
|
|
115
130
|
</header>
|
|
116
|
-
<
|
|
117
|
-
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
131
|
+
<WorkspaceLayoutContext
|
|
132
|
+
value={{
|
|
133
|
+
workspaceId: PREVIEW_WORKSPACE_ID,
|
|
134
|
+
layout,
|
|
135
|
+
setLayout: update => setLayout(current => ({ ...current, ...update })),
|
|
136
|
+
name: 'My workspace',
|
|
137
|
+
cwd: null,
|
|
138
|
+
provider: harness,
|
|
139
|
+
isLoading: false
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<main className="flex min-h-0 flex-1 overflow-y-auto bg-muted">
|
|
143
|
+
{scenario === 'welcome' ? (
|
|
144
|
+
<WorkspacePendingScreen setupRequired>
|
|
145
|
+
<WorkspaceWelcomeState name="My workspace" workspaceType={harness} />
|
|
146
|
+
</WorkspacePendingScreen>
|
|
147
|
+
) : scenario === 'loading' ? (
|
|
148
|
+
<WorkspacePendingScreen>
|
|
149
|
+
<WorkspaceLoadingState />
|
|
150
|
+
</WorkspacePendingScreen>
|
|
151
|
+
) : (
|
|
152
|
+
<SetupScreen />
|
|
153
|
+
)}
|
|
154
|
+
</main>
|
|
155
|
+
</WorkspaceLayoutContext>
|
|
129
156
|
<Dialog
|
|
130
157
|
open={providerPage !== 'closed'}
|
|
131
158
|
onOpenChange={open => !open && setProvider('closed')}
|
|
@@ -172,7 +199,7 @@ function SetupPreview({ mocks, client, environment, harness, scenario }: SetupPr
|
|
|
172
199
|
|
|
173
200
|
function SetupScreen() {
|
|
174
201
|
const [path] = useLocation()
|
|
175
|
-
const { content, ready } = useWorkspaceSetup(PREVIEW_WORKSPACE_ID)
|
|
202
|
+
const { content, ready, setupRequired } = useWorkspaceSetup(PREVIEW_WORKSPACE_ID)
|
|
176
203
|
if (ready) return null
|
|
177
204
|
return path === '/' ? (
|
|
178
205
|
<div
|
|
@@ -182,7 +209,7 @@ function SetupScreen() {
|
|
|
182
209
|
Workspace removed
|
|
183
210
|
</div>
|
|
184
211
|
) : (
|
|
185
|
-
<
|
|
212
|
+
<WorkspacePendingScreen setupRequired={setupRequired}>{content}</WorkspacePendingScreen>
|
|
186
213
|
)
|
|
187
214
|
}
|
|
188
215
|
|
|
@@ -86,9 +86,9 @@ export function DeviceLoginSteps({ code, url }: DeviceLoginStepsProps) {
|
|
|
86
86
|
<li className="flex flex-col items-start gap-3 lg:items-center">
|
|
87
87
|
<IconCircleNumber3 size={24} stroke={1.5} className="shrink-0" />
|
|
88
88
|
<div className="flex min-w-0 flex-col items-start gap-3 lg:items-center">
|
|
89
|
-
<p>Sign
|
|
89
|
+
<p>Sign in to ChatGPT, paste the code, and then come back to Moi</p>
|
|
90
90
|
<a href={url} target="_blank" rel="noopener noreferrer" className={buttonVariants()}>
|
|
91
|
-
Open
|
|
91
|
+
Open ChatGPT
|
|
92
92
|
</a>
|
|
93
93
|
</div>
|
|
94
94
|
</li>
|
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
1
|
+
import { queryOptions, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
2
2
|
|
|
3
3
|
import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
4
4
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
5
|
+
import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
|
|
5
6
|
import type { DiscoveredWorkspace, WorkspaceEntry, WorkspacePreview } from '@/lib/types'
|
|
6
7
|
|
|
7
8
|
export function useWorkspaces() {
|
|
8
9
|
return useQuery<WorkspaceEntry[]>({
|
|
9
10
|
queryKey: workspaceKeys.all,
|
|
10
11
|
queryFn: () => requestJson('/api/workspaces'),
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
// Live events invalidate the list on every change. This only bounds how
|
|
13
|
+
// long a missed event (socket down) can leave it wrong; route switches
|
|
14
|
+
// within the window reuse the cache.
|
|
15
|
+
staleTime: 5 * 60_000
|
|
13
16
|
})
|
|
14
17
|
}
|
|
15
18
|
|
|
19
|
+
const workspacePreviewsOptions = queryOptions({
|
|
20
|
+
queryKey: workspaceKeys.previews,
|
|
21
|
+
queryFn: () => requestJson<Record<string, WorkspacePreview>>('/api/workspaces/previews'),
|
|
22
|
+
staleTime: 60_000
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
// Every card's preview in one request. The home page starts it beside the
|
|
26
|
+
// workspace list so it doesn't wait for the cards to mount.
|
|
27
|
+
export function useWorkspacePreviews() {
|
|
28
|
+
return useQuery(workspacePreviewsOptions)
|
|
29
|
+
}
|
|
30
|
+
|
|
16
31
|
export function useWorkspacePreview(workspaceId: string) {
|
|
17
|
-
return useQuery
|
|
18
|
-
queryKey: workspaceKeys.preview(workspaceId),
|
|
19
|
-
queryFn: () => requestJson(`/api/workspaces/${workspaceId}/preview`),
|
|
20
|
-
staleTime: 60_000
|
|
21
|
-
})
|
|
32
|
+
return useQuery({ ...workspacePreviewsOptions, select: previews => previews[workspaceId] })
|
|
22
33
|
}
|
|
23
34
|
|
|
24
35
|
export function useDiscoveredWorkspaces() {
|
|
@@ -28,11 +39,18 @@ export function useDiscoveredWorkspaces() {
|
|
|
28
39
|
})
|
|
29
40
|
}
|
|
30
41
|
|
|
42
|
+
const REORDER_KEY = ['workspaces-reorder']
|
|
43
|
+
|
|
31
44
|
export function useReorderWorkspaces() {
|
|
32
45
|
const queryClient = useQueryClient()
|
|
33
46
|
return useMutation<WorkspaceEntry[], Error, string[], { previous?: WorkspaceEntry[] }>({
|
|
47
|
+
mutationKey: REORDER_KEY,
|
|
34
48
|
mutationFn: ids =>
|
|
35
|
-
requestJson(
|
|
49
|
+
requestJson(
|
|
50
|
+
'/api/workspaces/order',
|
|
51
|
+
jsonRequest('PUT', { ids, origin: BROWSER_TAB_ID }),
|
|
52
|
+
'Failed to reorder spaces'
|
|
53
|
+
),
|
|
36
54
|
onMutate: async ids => {
|
|
37
55
|
// Exact: only pause the workspace list itself — a prefix cancel would
|
|
38
56
|
// abort unrelated in-flight fetches (transcripts, widgets) that never
|
|
@@ -55,6 +73,8 @@ export function useReorderWorkspaces() {
|
|
|
55
73
|
queryClient.invalidateQueries({ queryKey: workspaceKeys.all, exact: true })
|
|
56
74
|
},
|
|
57
75
|
onSuccess: entries => {
|
|
76
|
+
// An earlier drag's response must not land over a newer optimistic order.
|
|
77
|
+
if (queryClient.isMutating({ mutationKey: REORDER_KEY }) > 1) return
|
|
58
78
|
queryClient.setQueryData(workspaceKeys.all, entries)
|
|
59
79
|
}
|
|
60
80
|
})
|
|
@@ -3,8 +3,12 @@ import { useState } from 'react'
|
|
|
3
3
|
import { IconChevronRight, IconEggCracked, IconLoader2, IconPlus } from '@tabler/icons-react'
|
|
4
4
|
import { Link, useLocation } from 'wouter'
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
useDiscoveredWorkspaces,
|
|
8
|
+
useWorkspacePreview,
|
|
9
|
+
useWorkspacePreviews,
|
|
10
|
+
useWorkspaces
|
|
11
|
+
} from './api'
|
|
8
12
|
import { CreateWorkspaceDialog } from '@/client/features/workspace/add/create-workspace-dialog'
|
|
9
13
|
import { ImportWorkspaceDialog } from '@/client/features/workspace/add/import-workspace-dialog'
|
|
10
14
|
import { DemoDialog } from '@/client/features/demo/demo-dialog'
|
|
@@ -38,6 +42,7 @@ export function HomePage() {
|
|
|
38
42
|
usePreloadWorkspaceFonts()
|
|
39
43
|
const [, navigate] = useLocation()
|
|
40
44
|
const workspacesQuery = useWorkspaces()
|
|
45
|
+
useWorkspacePreviews()
|
|
41
46
|
const discoveredQuery = useDiscoveredWorkspaces()
|
|
42
47
|
const importFlow = useWorkspaceImport({
|
|
43
48
|
onSuccess: entry => navigate(`/workspace/${entry.id}`)
|
|
@@ -170,8 +175,6 @@ type WorkspaceCardProps = {
|
|
|
170
175
|
}
|
|
171
176
|
|
|
172
177
|
function WorkspaceCard({ workspace }: WorkspaceCardProps) {
|
|
173
|
-
// Warm the shared readiness cache before the user enters this workspace.
|
|
174
|
-
useWorkspaceAgent(workspace.id)
|
|
175
178
|
const name = workspaceDisplayName(workspace)
|
|
176
179
|
const previewQuery = useWorkspacePreview(workspace.id)
|
|
177
180
|
const theme = workspace.theme ?? previewQuery.data?.theme
|
|
@@ -22,6 +22,7 @@ import 'tldraw/tldraw.css'
|
|
|
22
22
|
import { useWorkspaceId } from '@/client/features/workspace/workspace-context'
|
|
23
23
|
import { setScratchExecutor } from '@/client/features/scratchpad/scratch-executor'
|
|
24
24
|
import { persistScratchSession } from '@/client/features/scratchpad/scratch-session'
|
|
25
|
+
import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
|
|
25
26
|
import { type WorkspaceEvent, useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
|
|
26
27
|
import type { ScratchOp, ScratchOpResult } from '@/lib/types'
|
|
27
28
|
import {
|
|
@@ -32,10 +33,6 @@ import {
|
|
|
32
33
|
} from './use-scratchpad-snapshot'
|
|
33
34
|
import { ScratchStyleBar, ScratchToolbar } from './scratchpad-controls'
|
|
34
35
|
|
|
35
|
-
// Identifies this tab's writes so it can ignore the `scratchpad:updated` echo of
|
|
36
|
-
// its own save (see the MEI reload below). Per page load.
|
|
37
|
-
const ORIGIN_ID = Math.random().toString(36).slice(2)
|
|
38
|
-
|
|
39
36
|
const AUTOSAVE_MS = 500
|
|
40
37
|
|
|
41
38
|
// tldraw license key, inlined at build time from the PUBLIC_TLDRAW_LICENSE_KEY
|
|
@@ -221,7 +218,7 @@ function WorkspaceScratchpad({ workspaceId }: { workspaceId: string }) {
|
|
|
221
218
|
void fetch(`/api/workspaces/${workspaceId}/scratchpad`, {
|
|
222
219
|
method: 'PUT',
|
|
223
220
|
headers: { 'Content-Type': 'application/json' },
|
|
224
|
-
body: JSON.stringify({ document, origin:
|
|
221
|
+
body: JSON.stringify({ document, origin: BROWSER_TAB_ID })
|
|
225
222
|
}).catch(() => {})
|
|
226
223
|
}, [workspaceId])
|
|
227
224
|
|
|
@@ -233,7 +230,7 @@ function WorkspaceScratchpad({ workspaceId }: { workspaceId: string }) {
|
|
|
233
230
|
// autosave timer) so this stale tab can't save over the newer file.
|
|
234
231
|
useWorkspaceEvent((e: WorkspaceEvent) => {
|
|
235
232
|
if (e.type !== 'scratchpad:updated' || e.workspaceId !== workspaceId) return
|
|
236
|
-
if (e.origin && e.origin ===
|
|
233
|
+
if (e.origin && e.origin === BROWSER_TAB_ID) return
|
|
237
234
|
if (!editorRef.current) return
|
|
238
235
|
fetch(`/api/workspaces/${workspaceId}/scratchpad`)
|
|
239
236
|
.then(r => r.json())
|
|
@@ -4,6 +4,7 @@ import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
|
4
4
|
import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
|
|
5
5
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
6
6
|
import type { WorkspaceLayoutResponse } from '@/client/features/workspace/api'
|
|
7
|
+
import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
|
|
7
8
|
import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
|
|
8
9
|
import type { AppSettings, WorkspaceEntry, WorkspaceEnvView, WorkspaceIcon } from '@/lib/types'
|
|
9
10
|
|
|
@@ -86,13 +87,15 @@ type WorkspaceIconMutation =
|
|
|
86
87
|
|
|
87
88
|
export function useUpdateWorkspaceIcon(workspaceId: string) {
|
|
88
89
|
const queryClient = useQueryClient()
|
|
90
|
+
const mutationKey = ['workspace-icon', workspaceId]
|
|
89
91
|
return useMutation<void, Error, WorkspaceIconMutation>({
|
|
92
|
+
mutationKey,
|
|
90
93
|
scope: { id: `workspace-icon:${workspaceId}` },
|
|
91
94
|
mutationFn: async update => {
|
|
92
95
|
if (update.kind === 'set') {
|
|
93
96
|
await requestVoid(
|
|
94
97
|
`/api/workspaces/${workspaceId}/config`,
|
|
95
|
-
jsonRequest('PUT', { icon: update.icon }),
|
|
98
|
+
jsonRequest('PUT', { icon: update.icon, origin: BROWSER_TAB_ID }),
|
|
96
99
|
'Failed to save icon'
|
|
97
100
|
)
|
|
98
101
|
return
|
|
@@ -111,8 +114,13 @@ export function useUpdateWorkspaceIcon(workspaceId: string) {
|
|
|
111
114
|
body: update.file
|
|
112
115
|
})
|
|
113
116
|
},
|
|
114
|
-
onMutate: update => {
|
|
117
|
+
onMutate: async update => {
|
|
115
118
|
if (update.kind !== 'set') return
|
|
119
|
+
// Exact on the list: a prefix cancel would abort every workspace query.
|
|
120
|
+
await Promise.all([
|
|
121
|
+
queryClient.cancelQueries({ queryKey: workspaceKeys.layout(workspaceId) }),
|
|
122
|
+
queryClient.cancelQueries({ queryKey: workspaceKeys.all, exact: true })
|
|
123
|
+
])
|
|
116
124
|
const presentation = { icon: update.icon }
|
|
117
125
|
queryClient.setQueryData<WorkspaceLayoutResponse>(
|
|
118
126
|
workspaceKeys.layout(workspaceId),
|
|
@@ -124,14 +132,12 @@ export function useUpdateWorkspaceIcon(workspaceId: string) {
|
|
|
124
132
|
)
|
|
125
133
|
)
|
|
126
134
|
},
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
// Sync once the last queued change settles: refetching after an earlier
|
|
136
|
+
// one would land its icon over a newer optimistic pick.
|
|
137
|
+
onSettled: () => {
|
|
138
|
+
if (queryClient.isMutating({ mutationKey }) > 1) return
|
|
129
139
|
queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(workspaceId) })
|
|
130
140
|
queryClient.invalidateQueries({ queryKey: workspaceKeys.all, exact: true })
|
|
131
|
-
},
|
|
132
|
-
onSuccess: () => {
|
|
133
|
-
queryClient.invalidateQueries({ queryKey: workspaceKeys.layout(workspaceId) })
|
|
134
|
-
queryClient.invalidateQueries({ queryKey: workspaceKeys.all })
|
|
135
141
|
}
|
|
136
142
|
})
|
|
137
143
|
}
|