moi-computer 0.13.1-next.0 → 0.13.1-next.2
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/api/app-config.ts +12 -2
- package/client/api/http.ts +11 -1
- package/client/app/app-router.tsx +3 -2
- package/client/app/routes/home-route.tsx +1 -1
- package/client/app/routes/workspace-registration.tsx +68 -0
- package/client/app/routes/workspace-route.tsx +37 -13
- package/client/app/shell/sidebar-layout.tsx +10 -5
- package/client/components/shared/workspace-icon.tsx +8 -17
- package/client/features/account/account-test-utils.tsx +18 -4
- package/client/features/account/api.ts +10 -8
- package/client/features/account/profile-actions.ts +5 -7
- package/client/features/app-settings/avatar-upload.tsx +62 -0
- package/client/features/app-settings/profile-settings.tsx +10 -0
- package/client/features/app-settings/settings-page.tsx +2 -1
- package/client/features/applets/api.ts +6 -6
- package/client/features/applets/applet-cache.ts +6 -5
- package/client/features/applets/applet-log.ts +2 -1
- package/client/features/applets/applet-runtime.ts +2 -1
- package/client/features/applets/use-applet.ts +73 -18
- package/client/features/applets/widget-shell.tsx +4 -2
- package/client/features/chat/applet-chat-intents.ts +5 -13
- package/client/features/chat/chat-popup.tsx +8 -4
- package/client/features/chat/chat-send.ts +2 -2
- package/client/features/chat/composer/model-order.ts +4 -4
- package/client/features/chat/composer/model-picker.tsx +12 -10
- package/client/features/chat/composer/use-workspace-composer-state.tsx +1 -1
- package/client/features/chat/sessions/api.ts +11 -28
- package/client/features/chat/sessions/use-selected-session.ts +18 -100
- package/client/features/chat/use-chat.ts +8 -12
- package/client/features/collab/applet-api.ts +1 -1
- package/client/features/collab/components/cursors.tsx +6 -1
- package/client/features/collab/components/presence-avatars.tsx +1 -1
- package/client/features/collab/components/presence-frame.tsx +1 -1
- package/client/features/collab/components/presence-group.tsx +1 -1
- package/client/features/collab/components/presence-helpers.ts +2 -2
- package/client/features/collab/components/user-avatar-group.tsx +1 -1
- package/client/features/collab/components/user-avatar.tsx +1 -1
- package/client/features/collab/components/user.tsx +1 -1
- package/client/features/collab/index.ts +3 -3
- package/client/features/collab/members/api.ts +17 -0
- package/client/features/collab/members/hooks.ts +97 -0
- package/client/features/collab/members/store.ts +148 -0
- package/client/features/{workspace-members → collab/members}/types.ts +7 -5
- package/client/features/collab/{client.ts → presence/client.ts} +4 -5
- package/client/features/collab/{hooks.tsx → presence/hooks.tsx} +1 -1
- package/client/features/collab/{provider.tsx → presence/provider.tsx} +1 -12
- package/client/features/collab/{users.ts → presence/users.ts} +19 -21
- package/client/features/collab/proxy-user.ts +1 -3
- package/client/features/collab/sharing/agent-invite.tsx +30 -0
- package/client/features/collab/sharing/workspace-members.tsx +269 -0
- package/client/features/collab/sharing/workspace-sharing-menu.tsx +179 -0
- package/client/features/collab/testing/component-fixtures.tsx +3 -3
- package/client/features/collab/testing/fake-engine.ts +2 -2
- package/client/features/dev/chat-states-page.tsx +3 -1
- package/client/features/dev/collab/collab-playground.tsx +2 -2
- package/client/features/dev/dev-index-page.tsx +0 -6
- package/client/features/dev/dev-routes.tsx +0 -2
- package/client/features/dev/harness-debug-page.tsx +7 -7
- package/client/features/dev/workspace-setup-mocks.ts +1 -2
- package/client/features/dev/workspace-setup-preview.tsx +6 -4
- package/client/features/harness/api.ts +13 -10
- package/client/features/harness/harness-login-panel.tsx +9 -5
- package/client/features/harness/harness-presentation.ts +4 -4
- package/client/features/harness/harness-selector.tsx +13 -13
- package/client/features/harness/use-harness-login.ts +5 -5
- package/client/features/home/api.ts +38 -2
- package/client/features/home/home-page.tsx +43 -13
- package/client/features/home/shared-workspaces.tsx +70 -0
- package/client/features/home/workspace-invitations.tsx +101 -0
- package/client/features/identity/host-api.ts +5 -4
- package/client/features/identity/store.ts +1 -7
- package/client/features/onboarding/agent-setup-step.tsx +8 -8
- package/client/features/onboarding/onboarding-page.tsx +3 -2
- package/client/features/onboarding/workspace-setup-step.tsx +1 -1
- package/client/features/overview/api.ts +3 -5
- package/client/features/overview/default/registry.tsx +1 -1
- package/client/features/overview/default/views-widget.tsx +2 -2
- package/client/features/overview/hidden-panel.tsx +7 -5
- package/client/features/overview/overview.tsx +18 -16
- package/client/features/overview/workspace-name.tsx +2 -2
- package/client/features/scratchpad/scratchpad.tsx +9 -7
- package/client/features/scratchpad/use-scratchpad-snapshot.tsx +13 -5
- package/client/features/views/api.ts +34 -16
- package/client/features/views/use-view-actions.ts +10 -20
- package/client/features/views/view-manager.tsx +1 -1
- package/client/features/views/view-submission.ts +2 -21
- package/client/features/workspace/add/api.ts +5 -4
- package/client/features/workspace/add/create-workspace-dialog.tsx +12 -9
- package/client/features/workspace/add/import-workspace-dialog.tsx +7 -7
- package/client/features/workspace/add/use-workspace-import.ts +10 -10
- package/client/features/workspace/add/workspace-agent-options.ts +21 -20
- package/client/features/workspace/add/workspace-agent-selector.tsx +11 -11
- package/client/features/workspace/api.ts +60 -13
- package/client/features/workspace/harness-transition.ts +7 -13
- package/client/features/workspace/remote.ts +25 -0
- package/client/features/workspace/settings/api.ts +7 -12
- package/client/features/workspace/settings/connectors-settings.tsx +3 -3
- package/client/features/workspace/settings/general-settings.tsx +8 -8
- package/client/features/workspace/setup/workspace-login-state.tsx +4 -4
- package/client/features/workspace/setup/workspace-recovery-states.tsx +43 -14
- package/client/features/workspace/setup/workspace-setup.tsx +6 -6
- package/client/features/workspace/tab-resolution.ts +2 -2
- package/client/features/workspace/use-workspace-navigation.ts +7 -4
- package/client/features/workspace/workspace-content.tsx +32 -26
- package/client/features/workspace/workspace-frame.tsx +13 -26
- package/client/features/workspace/workspace-layout-context.tsx +45 -12
- package/client/features/workspace/workspace-menu.tsx +2 -2
- package/client/features/workspace/workspace-pane.tsx +22 -0
- package/client/features/workspace/workspace-pending-screen.tsx +1 -1
- package/client/features/workspace/workspace-preferences.ts +34 -0
- package/client/features/workspace/workspace-presentation.tsx +12 -16
- package/client/features/workspace/workspace-screen.tsx +2 -2
- package/client/features/workspace/workspace-state.ts +2 -1
- package/client/features/workspace/workspace-tabs.tsx +1 -1
- package/client/features/workspace/workspace-test-utils.ts +23 -0
- package/client/runtime/use-workspace-events.ts +14 -0
- package/client/runtime/workspace-events.ts +9 -9
- package/client/store/ui.ts +29 -9
- package/dist/chunk-44khk4sp.js +2 -0
- package/dist/chunk-ba6mz56s.js +72 -0
- package/dist/chunk-ec5ennpv.js +1 -0
- package/dist/chunk-ectsnw81.js +2 -0
- package/dist/chunk-en7w5ypg.js +1 -0
- package/dist/chunk-f695wcx5.js +5 -0
- package/dist/chunk-kffcah9w.css +1 -0
- package/dist/{chunk-kdgk4dac.js → chunk-n0fawy9x.js} +1 -1
- package/dist/chunk-pdt9hxfw.js +2 -0
- package/dist/chunk-rmd0ctfx.js +546 -0
- package/dist/chunk-zv22wv0g.js +1 -0
- package/dist/index.html +1 -1
- package/lib/harness-instructions.ts +4 -4
- package/lib/harness-types.ts +13 -0
- package/lib/types.ts +34 -50
- package/lib/workspace-config.ts +48 -0
- package/lib/workspace-layout.ts +2 -4
- package/package.json +4 -2
- package/server/README.md +29 -27
- package/server/api/harnesses.ts +5 -5
- package/server/api/index.ts +170 -68
- package/server/app-config.ts +2 -7
- package/server/applets/declarations.ts +6 -7
- package/server/applets/index.ts +15 -9
- package/server/applets/views.ts +2 -17
- package/server/applets/widgets.ts +3 -2
- package/server/cli/commands/config.ts +8 -20
- package/server/cli/commands/hermes.ts +2 -2
- package/server/cli/commands/init.ts +96 -64
- package/server/cli/commands/openclaw.ts +2 -2
- package/server/cli/commands/refresh.ts +10 -1
- package/server/cli/commands/remote.ts +228 -0
- package/server/cli/commands/skill.ts +4 -4
- package/server/cli/commands/tabs.ts +5 -12
- package/server/cli/control.ts +35 -4
- package/server/cli/index.ts +10 -6
- package/server/cli/remote-command.ts +77 -0
- package/server/cli/remote-control.ts +70 -0
- package/server/cli/remote-operations.ts +244 -0
- package/server/collab/config.ts +4 -8
- package/server/collab/manager.ts +5 -2
- package/server/collab/skill/index.ts +4 -50
- package/server/control.ts +38 -11
- package/server/harness/acp/session.ts +4 -4
- package/server/harness/auth.ts +26 -31
- package/server/harness/claude-code/index.ts +1 -1
- package/server/harness/codex/discovery.ts +1 -1
- package/server/harness/codex/session.ts +1 -1
- package/server/harness/detect.ts +14 -19
- package/server/harness/executable.ts +10 -10
- package/server/harness/hermes/NOTES.md +2 -2
- package/server/harness/hermes/index.ts +1 -1
- package/server/harness/install.ts +11 -11
- package/server/harness/openclaw/index.ts +1 -1
- package/server/harness/registry.ts +7 -6
- package/server/harness/types.ts +4 -4
- package/server/onboarding/jobs.ts +1 -1
- package/server/operations/commands.ts +46 -0
- package/server/operations/files.ts +148 -0
- package/server/operations/server.ts +206 -0
- package/server/remote/agent.ts +103 -0
- package/server/remote/client.ts +665 -0
- package/server/remote/workspace.ts +34 -0
- package/server/scratchpad/document.ts +32 -12
- package/server/scratchpad/executor.ts +16 -7
- package/server/sessions/config.ts +8 -5
- package/server/sessions/pending-views.ts +16 -0
- package/server/sessions/view-sessions.ts +10 -12
- package/server/skills/locations.ts +4 -4
- package/server/skills/template.ts +3 -2
- package/server/skills/update.ts +12 -12
- package/server/skills/version.ts +7 -7
- package/server/skills/workspace.ts +13 -13
- package/server/web.ts +12 -10
- package/server/workspace-state/file.ts +2 -0
- package/server/workspace-state/index.ts +0 -4
- package/server/workspaces/api.ts +28 -0
- package/server/workspaces/change-harness.ts +15 -26
- package/server/workspaces/import.ts +4 -4
- package/server/workspaces/init.ts +15 -13
- package/server/workspaces/layout.ts +60 -66
- package/server/workspaces/registry.ts +43 -18
- package/server/workspaces/scaffold.ts +1 -0
- package/server/workspaces/shared.ts +74 -0
- package/server/workspaces/tabs.ts +6 -12
- package/skill/SKILL.md +24 -4
- package/client/api/app-ui-keys.ts +0 -6
- package/client/features/chat/sessions/browser-tab-state.ts +0 -43
- package/client/features/collab/workspace-users-menu.tsx +0 -190
- package/client/features/dev/cloud-avatar-upload.tsx +0 -58
- package/client/features/dev/cloud-page.tsx +0 -363
- package/client/features/workspace/browser-tab-state.ts +0 -51
- package/client/features/workspace/layout-save.ts +0 -13
- package/client/features/workspace-members/api.ts +0 -20
- package/client/features/workspace-members/hooks.ts +0 -127
- package/client/features/workspace-members/keys.ts +0 -6
- package/client/features/workspace-members/store.ts +0 -123
- package/dist/chunk-00s35r33.js +0 -546
- package/dist/chunk-7rz6g7g7.js +0 -1
- package/dist/chunk-af2jyddf.js +0 -2
- package/dist/chunk-cekekc3f.css +0 -1
- package/dist/chunk-ep5vh16c.js +0 -75
- package/dist/chunk-s5s1vzdw.js +0 -2
- package/dist/chunk-svxhxfeq.js +0 -2
- package/dist/chunk-t0r0bds1.js +0 -1
- package/dist/chunk-vp2qzc0d.js +0 -1
- package/dist/chunk-wz5qv1bn.js +0 -2
- package/lib/workspace-types.ts +0 -13
- package/server/workspace-state/legacy-migration.ts +0 -79
- /package/client/features/collab/{presence-publisher.ts → presence/presence-publisher.ts} +0 -0
- /package/client/features/collab/{presence-target.ts → presence/presence-target.ts} +0 -0
- /package/client/features/collab/{store.ts → presence/store.ts} +0 -0
package/client/api/app-config.ts
CHANGED
|
@@ -12,7 +12,6 @@ import { requestJson } from './http'
|
|
|
12
12
|
|
|
13
13
|
const DEFAULTS: ClientAppConfig = {
|
|
14
14
|
environment: 'local',
|
|
15
|
-
collab: false,
|
|
16
15
|
demo: false,
|
|
17
16
|
demoInstallUrl: 'https://moi.computer'
|
|
18
17
|
}
|
|
@@ -43,6 +42,17 @@ export async function loadAppConfig(): Promise<ClientAppConfig | undefined> {
|
|
|
43
42
|
return fetchAppConfig()
|
|
44
43
|
}
|
|
45
44
|
|
|
45
|
+
// Demo serves home at /demo: '/' belongs to whatever fronts the demo. A bare
|
|
46
|
+
// pathname, used as a route pattern and a navigation target; the config is
|
|
47
|
+
// frozen before mount, so this is safe in callbacks and render alike.
|
|
48
|
+
export function homePath(): string {
|
|
49
|
+
return current.demo ? '/demo' : '/'
|
|
50
|
+
}
|
|
51
|
+
|
|
46
52
|
export function useAppConfig(): ClientAppConfig {
|
|
47
|
-
return useSyncExternalStore(
|
|
53
|
+
return useSyncExternalStore(
|
|
54
|
+
subscribe,
|
|
55
|
+
() => current,
|
|
56
|
+
() => current
|
|
57
|
+
)
|
|
48
58
|
}
|
package/client/api/http.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
export class HttpError extends Error {
|
|
2
|
+
constructor(
|
|
3
|
+
public readonly status: number,
|
|
4
|
+
message: string
|
|
5
|
+
) {
|
|
6
|
+
super(message)
|
|
7
|
+
this.name = 'HttpError'
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
1
11
|
async function errorFrom(response: Response, fallback: string) {
|
|
2
12
|
const detail = await response.text()
|
|
3
|
-
return new
|
|
13
|
+
return new HttpError(response.status, detail || fallback)
|
|
4
14
|
}
|
|
5
15
|
|
|
6
16
|
export async function requestJson<T>(
|
|
@@ -3,6 +3,7 @@ import { Suspense, lazy, useEffect } from 'react'
|
|
|
3
3
|
|
|
4
4
|
import { Redirect, Route, Switch, useLocation } from 'wouter'
|
|
5
5
|
|
|
6
|
+
import { homePath } from '@/client/api/app-config'
|
|
6
7
|
import { setWorkspaceSwitchHandler } from '@/client/features/chat/connection/chat-connection'
|
|
7
8
|
import { useWorkspaceStateSync } from '@/client/features/workspace/workspace-state'
|
|
8
9
|
|
|
@@ -21,7 +22,7 @@ const DevRoutes =
|
|
|
21
22
|
: null
|
|
22
23
|
|
|
23
24
|
function DevLazy() {
|
|
24
|
-
if (!DevRoutes) return <Redirect to=
|
|
25
|
+
if (!DevRoutes) return <Redirect to={homePath()} />
|
|
25
26
|
return (
|
|
26
27
|
<Suspense fallback={null}>
|
|
27
28
|
<DevRoutes />
|
|
@@ -44,7 +45,7 @@ export function AppRouter() {
|
|
|
44
45
|
return (
|
|
45
46
|
<Switch>
|
|
46
47
|
<Route path="/dev/*?" component={DevLazy} />
|
|
47
|
-
<Route path=
|
|
48
|
+
<Route path={homePath()} component={HomeRoute} />
|
|
48
49
|
<Route path="/onboarding" component={OnboardingRoute} />
|
|
49
50
|
<Route path="/settings" component={SettingsRoute} />
|
|
50
51
|
{/* The wildcard is the destination path (`views/orders`, `overview`, …) —
|
|
@@ -5,7 +5,7 @@ import { OnboardingStatus } from '@/client/features/onboarding/onboarding-status
|
|
|
5
5
|
import { SidebarLayout } from '@/client/app/shell/sidebar-layout'
|
|
6
6
|
import { HomePage } from '@/client/features/home/home-page'
|
|
7
7
|
|
|
8
|
-
// The
|
|
8
|
+
// The home route (`/`, or `/demo` in demo mode): the app shell wrapping the workspaces view.
|
|
9
9
|
export function HomeRoute() {
|
|
10
10
|
const onboarding = useOnboardingSettings()
|
|
11
11
|
if (onboarding.loading || onboarding.error)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { homePath, useAppConfig } from '@/client/api/app-config'
|
|
2
|
+
import { useEffect } from 'react'
|
|
3
|
+
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
|
4
|
+
import { useLocation, useSearch } from 'wouter'
|
|
5
|
+
import { SidebarLayout } from '../shell/sidebar-layout'
|
|
6
|
+
import { requestJson, jsonRequest } from '@/client/api/http'
|
|
7
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
8
|
+
import {
|
|
9
|
+
WorkspaceOpenError,
|
|
10
|
+
WorkspaceLoadingState
|
|
11
|
+
} from '@/client/features/workspace/setup/workspace-recovery-states'
|
|
12
|
+
import { WorkspacePendingScreen } from '@/client/features/workspace/workspace-pending-screen'
|
|
13
|
+
import type { WorkspaceEntry } from '@/lib/types'
|
|
14
|
+
import { workspaceApiBase } from '@/lib/workspace-config'
|
|
15
|
+
import { workspaceInfoOptions } from '@/client/features/workspace/api'
|
|
16
|
+
|
|
17
|
+
type WorkspaceRegistrationProps = { userId: string; workspaceId: string }
|
|
18
|
+
export function WorkspaceRegistration({ userId, workspaceId }: WorkspaceRegistrationProps) {
|
|
19
|
+
const cloud = useAppConfig().environment === 'cloud'
|
|
20
|
+
const [location, navigate] = useLocation()
|
|
21
|
+
const search = useSearch()
|
|
22
|
+
const client = useQueryClient()
|
|
23
|
+
const query = useQuery({
|
|
24
|
+
queryKey: ['open-shared-workspace', userId, workspaceId],
|
|
25
|
+
queryFn: async () => {
|
|
26
|
+
// Recheck access even if discovery already cached the owner's info.
|
|
27
|
+
await client.fetchQuery({
|
|
28
|
+
...workspaceInfoOptions(workspaceApiBase(workspaceId, userId)),
|
|
29
|
+
staleTime: 0
|
|
30
|
+
})
|
|
31
|
+
return requestJson<WorkspaceEntry>(
|
|
32
|
+
'/api/workspaces',
|
|
33
|
+
jsonRequest('POST', { remote: { user_id: userId, workspace_id: workspaceId } })
|
|
34
|
+
)
|
|
35
|
+
},
|
|
36
|
+
enabled: cloud,
|
|
37
|
+
retry: false,
|
|
38
|
+
refetchOnWindowFocus: false,
|
|
39
|
+
gcTime: 0
|
|
40
|
+
})
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!cloud) {
|
|
43
|
+
navigate(homePath(), { replace: true })
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
if (!query.data) return
|
|
47
|
+
void client.invalidateQueries({ queryKey: workspaceKeys.all })
|
|
48
|
+
const destination = location.replace(/^\/workspace\/[^/]+/, `/workspace/${query.data.id}`)
|
|
49
|
+
navigate(`${destination}${search ? `?${search}` : ''}`, { replace: true })
|
|
50
|
+
}, [query.data, client, navigate, cloud, location, search])
|
|
51
|
+
return (
|
|
52
|
+
<SidebarLayout>
|
|
53
|
+
<WorkspacePendingScreen setupRequired={query.isError}>
|
|
54
|
+
{query.isError ? (
|
|
55
|
+
<WorkspaceOpenError
|
|
56
|
+
error={query.error}
|
|
57
|
+
retrying={query.isFetching}
|
|
58
|
+
onRetry={() => void query.refetch()}
|
|
59
|
+
/>
|
|
60
|
+
) : (
|
|
61
|
+
<div className="flex flex-1" role="status" aria-label="Opening shared workspace">
|
|
62
|
+
<WorkspaceLoadingState />
|
|
63
|
+
</div>
|
|
64
|
+
)}
|
|
65
|
+
</WorkspacePendingScreen>
|
|
66
|
+
</SidebarLayout>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WorkspaceRegistration } from './workspace-registration'
|
|
2
|
+
import { RecoveryMessage } from '@/client/features/workspace/setup/workspace-recovery-states'
|
|
3
|
+
import { WorkspacePendingScreen } from '@/client/features/workspace/workspace-pending-screen'
|
|
4
|
+
import { useWorkspaceMembers } from '@/client/features/collab/members/hooks'
|
|
2
5
|
import { useWorkspaceHarnessChanges } from '@/client/features/workspace/harness-transition'
|
|
3
6
|
import { useWorkspaceTheme } from '@/client/runtime/workspace-theme'
|
|
4
|
-
import { CollabProvider
|
|
7
|
+
import { CollabProvider } from '@/client/features/collab'
|
|
5
8
|
import { useQueryClient } from '@tanstack/react-query'
|
|
6
9
|
|
|
7
10
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
@@ -17,7 +20,7 @@ import {
|
|
|
17
20
|
import { WorkspaceScreen } from '@/client/features/workspace/workspace-screen'
|
|
18
21
|
import { useViews } from '@/client/features/views/api'
|
|
19
22
|
import { useWidgets } from '@/client/features/overview/api'
|
|
20
|
-
import {
|
|
23
|
+
import { useWorkspaceScopedEvent } from '@/client/runtime/use-workspace-events'
|
|
21
24
|
import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
|
|
22
25
|
|
|
23
26
|
type WorkspaceRouteProps = {
|
|
@@ -27,14 +30,20 @@ type WorkspaceRouteProps = {
|
|
|
27
30
|
// Navigation reads the raw browser address so encoded paths and query params
|
|
28
31
|
// are decoded exactly once; the route only owns the workspace ID.
|
|
29
32
|
export function WorkspaceRoute({ id }: WorkspaceRouteProps) {
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
+
const { environment } = useAppConfig()
|
|
34
|
+
const separator = id.indexOf(':')
|
|
35
|
+
if (separator !== -1)
|
|
36
|
+
return (
|
|
37
|
+
<WorkspaceRegistration
|
|
38
|
+
userId={id.slice(0, separator)}
|
|
39
|
+
workspaceId={id.slice(separator + 1)}
|
|
40
|
+
/>
|
|
41
|
+
)
|
|
33
42
|
return (
|
|
34
43
|
<SidebarLayout>
|
|
35
44
|
<Workspace id={id}>
|
|
36
45
|
<WorkspaceLayoutProvider id={id}>
|
|
37
|
-
<CollabProvider workspaceId={id} enabled={
|
|
46
|
+
<CollabProvider workspaceId={id} enabled={environment === 'cloud'}>
|
|
38
47
|
<WorkspaceContent id={id} />
|
|
39
48
|
</CollabProvider>
|
|
40
49
|
</WorkspaceLayoutProvider>
|
|
@@ -44,17 +53,17 @@ export function WorkspaceRoute({ id }: WorkspaceRouteProps) {
|
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
function WorkspaceContent({ id }: WorkspaceRouteProps) {
|
|
47
|
-
|
|
56
|
+
useWorkspaceMembers(id)
|
|
48
57
|
const queryClient = useQueryClient()
|
|
49
58
|
const [selectedSessionId] = useSelectedSession()
|
|
50
|
-
const { isLoading: layoutLoading, layout,
|
|
51
|
-
useWorkspaceHarnessChanges(id,
|
|
59
|
+
const { isLoading: layoutLoading, layout, harness } = useWorkspaceLayoutCtx()
|
|
60
|
+
useWorkspaceHarnessChanges(id, harness)
|
|
52
61
|
useWorkspaceTheme(layout.theme)
|
|
53
62
|
const widgets = useWidgets(id)
|
|
54
63
|
const views = useViews(id)
|
|
55
64
|
useAppletCacheInvalidation()
|
|
56
65
|
|
|
57
|
-
|
|
66
|
+
useWorkspaceScopedEvent(id, event => {
|
|
58
67
|
if (event.type === 'theme:updated' || event.type === 'workspace:updated') {
|
|
59
68
|
// Skip our own save: the cache already holds it, and the refetch could
|
|
60
69
|
// land an older value over a newer optimistic change.
|
|
@@ -74,10 +83,25 @@ function WorkspaceContent({ id }: WorkspaceRouteProps) {
|
|
|
74
83
|
const contentPending =
|
|
75
84
|
layoutLoading || selectedSessionId === undefined || widgets.isLoading || views.isLoading
|
|
76
85
|
|
|
86
|
+
if ((!views.data && views.isError) || (widgets.isError && !widgets.hasData)) {
|
|
87
|
+
return (
|
|
88
|
+
<WorkspacePendingScreen setupRequired>
|
|
89
|
+
<RecoveryMessage
|
|
90
|
+
title="Couldn’t load workspace content"
|
|
91
|
+
retrying={views.isFetching || widgets.isFetching}
|
|
92
|
+
onRetry={() => {
|
|
93
|
+
void views.refetch()
|
|
94
|
+
void widgets.refetch()
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
Please try again.
|
|
98
|
+
</RecoveryMessage>
|
|
99
|
+
</WorkspacePendingScreen>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
77
103
|
return (
|
|
78
|
-
// Reset the screen when switching between shared and browser tab state.
|
|
79
104
|
<WorkspaceScreen
|
|
80
|
-
key={collabEnabled ? 'browser-tab' : 'shared'}
|
|
81
105
|
contentPending={contentPending}
|
|
82
106
|
widgets={widgets.data}
|
|
83
107
|
views={views.data ?? []}
|
|
@@ -4,8 +4,12 @@ import { IconPlus, IconSandbox, IconSmartHome } from '@tabler/icons-react'
|
|
|
4
4
|
import { useQueryClient } from '@tanstack/react-query'
|
|
5
5
|
import { Link, useLocation } from 'wouter'
|
|
6
6
|
|
|
7
|
-
import { useAppConfig } from '@/client/api/app-config'
|
|
8
|
-
import {
|
|
7
|
+
import { homePath, useAppConfig } from '@/client/api/app-config'
|
|
8
|
+
import {
|
|
9
|
+
useReorderWorkspaces,
|
|
10
|
+
useWorkspaceMetadata,
|
|
11
|
+
useWorkspaces
|
|
12
|
+
} from '@/client/features/home/api'
|
|
9
13
|
import { BROWSER_TAB_ID } from '@/client/lib/browser-tab-id'
|
|
10
14
|
import {
|
|
11
15
|
UpdateButton as UpdateButtonComponent,
|
|
@@ -48,7 +52,8 @@ type SidebarLayoutProps = {
|
|
|
48
52
|
// App shell: a slim icon rail beside the page content. The page owns the panel's
|
|
49
53
|
// header and body.
|
|
50
54
|
export function SidebarLayout({ children, showWorkspaces = true }: SidebarLayoutProps) {
|
|
51
|
-
const { data:
|
|
55
|
+
const { data: entries } = useWorkspaces()
|
|
56
|
+
const workspaces = useWorkspaceMetadata(entries ?? [])
|
|
52
57
|
|
|
53
58
|
// Identity, theme, and registry changes can all alter a workspace's sidebar
|
|
54
59
|
// presentation. Refetch the list so the sidebar reflects them live. Exact:
|
|
@@ -92,7 +97,7 @@ function Sidebar({ workspaces }: SidebarProps) {
|
|
|
92
97
|
<Tooltip>
|
|
93
98
|
<TooltipTrigger
|
|
94
99
|
render={
|
|
95
|
-
<Link href=
|
|
100
|
+
<Link href={homePath()} aria-label="Home" className={sidebarNavButtonClass}>
|
|
96
101
|
<IconSmartHome stroke={1.5} />
|
|
97
102
|
</Link>
|
|
98
103
|
}
|
|
@@ -203,7 +208,7 @@ function WorkspaceButton({ workspace, dragOverlay = false, dragState }: Workspac
|
|
|
203
208
|
>
|
|
204
209
|
<WorkspaceIcon
|
|
205
210
|
icon={workspace.icon}
|
|
206
|
-
|
|
211
|
+
harness={workspace.harness}
|
|
207
212
|
workspaceTheme={workspace.theme}
|
|
208
213
|
className="size-7 shrink-0 rounded-md transition-[border-radius] duration-100 ease-out motion-reduce:transition-none"
|
|
209
214
|
/>
|
|
@@ -7,13 +7,9 @@ import openclawIcon from '@/client/assets/openclaw.svg'
|
|
|
7
7
|
import { resolveIdentityIcon } from '@/client/lib/identity-icon-registry'
|
|
8
8
|
import { cn } from '@/client/lib/cn'
|
|
9
9
|
import { DEFAULT_PRIMARY_COLOR, deriveThemeColors, resolveThemeColorOverrides } from '@/lib/themes'
|
|
10
|
-
import type {
|
|
11
|
-
WorkspaceIcon as WorkspaceIconValue,
|
|
12
|
-
WorkspaceLayout,
|
|
13
|
-
WorkspaceType
|
|
14
|
-
} from '@/lib/types'
|
|
10
|
+
import type { WorkspaceIcon as WorkspaceIconValue, WorkspaceLayout, HarnessType } from '@/lib/types'
|
|
15
11
|
|
|
16
|
-
export const
|
|
12
|
+
export const harnessIcon: Record<HarnessType, string> = {
|
|
17
13
|
'claude-code': claudeIcon,
|
|
18
14
|
openclaw: openclawIcon,
|
|
19
15
|
codex: openaiIcon,
|
|
@@ -23,14 +19,14 @@ export const workspaceProviderIcon: Record<WorkspaceType, string> = {
|
|
|
23
19
|
type WorkspaceIconProps = {
|
|
24
20
|
className?: string
|
|
25
21
|
icon?: WorkspaceIconValue
|
|
26
|
-
|
|
22
|
+
harness?: HarnessType | null
|
|
27
23
|
workspaceTheme?: WorkspaceLayout['theme']
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
function renderIconContent(
|
|
31
27
|
icon: WorkspaceIconValue | undefined,
|
|
32
28
|
themed: boolean,
|
|
33
|
-
|
|
29
|
+
fallbackIcon: string
|
|
34
30
|
) {
|
|
35
31
|
switch (icon?.type) {
|
|
36
32
|
case 'emoji':
|
|
@@ -59,21 +55,16 @@ function renderIconContent(
|
|
|
59
55
|
// Fall through to the default provider icon.
|
|
60
56
|
}
|
|
61
57
|
default:
|
|
62
|
-
return <img src={
|
|
58
|
+
return <img src={fallbackIcon} alt="" className="size-[95%]" />
|
|
63
59
|
}
|
|
64
60
|
}
|
|
65
61
|
|
|
66
|
-
export function WorkspaceIcon({
|
|
67
|
-
className,
|
|
68
|
-
icon,
|
|
69
|
-
workspaceType,
|
|
70
|
-
workspaceTheme
|
|
71
|
-
}: WorkspaceIconProps) {
|
|
62
|
+
export function WorkspaceIcon({ className, icon, harness, workspaceTheme }: WorkspaceIconProps) {
|
|
72
63
|
const themed = icon?.type !== 'upload' && icon?.background === 'theme'
|
|
73
64
|
const colors = themed
|
|
74
65
|
? (resolveThemeColorOverrides(workspaceTheme) ?? deriveThemeColors(DEFAULT_PRIMARY_COLOR))
|
|
75
66
|
: undefined
|
|
76
|
-
const
|
|
67
|
+
const fallbackIcon = harnessIcon[harness ?? 'claude-code']
|
|
77
68
|
|
|
78
69
|
return (
|
|
79
70
|
<span
|
|
@@ -86,7 +77,7 @@ export function WorkspaceIcon({
|
|
|
86
77
|
colors ? { backgroundColor: colors.primary, color: colors.primaryForeground } : undefined
|
|
87
78
|
}
|
|
88
79
|
>
|
|
89
|
-
{renderIconContent(icon, themed,
|
|
80
|
+
{renderIconContent(icon, themed, fallbackIcon)}
|
|
90
81
|
</span>
|
|
91
82
|
)
|
|
92
83
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { seedWorkspaceInfo } from '@/client/features/workspace/workspace-test-utils'
|
|
1
2
|
import { expect, spyOn } from 'bun:test'
|
|
2
3
|
import { act, useLayoutEffect } from 'react'
|
|
3
4
|
import type { ReactNode } from 'react'
|
|
@@ -9,7 +10,8 @@ import { QueryClientProvider, notifyManager } from '@tanstack/react-query'
|
|
|
9
10
|
import * as config from '@/client/api/app-config'
|
|
10
11
|
import { AccountProvider, useAccount } from './account-provider'
|
|
11
12
|
import { queryClient } from '@/client/api/query-client'
|
|
12
|
-
import type { WorkspaceMembers } from '../
|
|
13
|
+
import type { WorkspaceMembers } from '../collab/members/types'
|
|
14
|
+
import { setAllWorkspaceMembers, setWorkspaceMembers } from '../collab/members/store'
|
|
13
15
|
import { setIdentity } from '../identity/store'
|
|
14
16
|
import type { Identity } from '../identity/types'
|
|
15
17
|
|
|
@@ -32,6 +34,7 @@ export type AccountFixtureOptions = {
|
|
|
32
34
|
environment?: 'local' | 'cloud'
|
|
33
35
|
failSession?: boolean
|
|
34
36
|
loadingSession?: boolean
|
|
37
|
+
pendingMembership?: boolean
|
|
35
38
|
pendingMutation?: boolean
|
|
36
39
|
pendingMutationPaths?: string[]
|
|
37
40
|
injected?: boolean
|
|
@@ -44,6 +47,7 @@ export async function mountAccount({
|
|
|
44
47
|
environment = 'cloud',
|
|
45
48
|
failSession = false,
|
|
46
49
|
loadingSession = false,
|
|
50
|
+
pendingMembership = false,
|
|
47
51
|
pendingMutation = false,
|
|
48
52
|
pendingMutationPaths = [],
|
|
49
53
|
injected = true
|
|
@@ -54,6 +58,7 @@ export async function mountAccount({
|
|
|
54
58
|
Object.defineProperty(window, 'location', {
|
|
55
59
|
configurable: true,
|
|
56
60
|
value: {
|
|
61
|
+
pathname: '/settings',
|
|
57
62
|
assign: (href: string) => navigations.push(href),
|
|
58
63
|
replace: (href: string) => navigations.push(href)
|
|
59
64
|
}
|
|
@@ -87,7 +92,6 @@ export async function mountAccount({
|
|
|
87
92
|
const configSpy = spyOn(config, 'useAppConfig').mockReturnValue({
|
|
88
93
|
environment,
|
|
89
94
|
demo,
|
|
90
|
-
collab: false,
|
|
91
95
|
demoInstallUrl: '/'
|
|
92
96
|
})
|
|
93
97
|
let cloudSession: Identity | null = signedOut
|
|
@@ -123,8 +127,6 @@ export async function mountAccount({
|
|
|
123
127
|
? Response.json(cloudSession)
|
|
124
128
|
: Response.json({ error: 'No session' }, { status: 401 })
|
|
125
129
|
}
|
|
126
|
-
if (path.endsWith('/members') && (!init?.method || init.method === 'GET'))
|
|
127
|
-
return Response.json(membership)
|
|
128
130
|
if (path.endsWith('/sign-out')) {
|
|
129
131
|
if (failures.signOut)
|
|
130
132
|
return Response.json({ error: 'Try signing out again.' }, { status: 503 })
|
|
@@ -191,10 +193,21 @@ export async function mountAccount({
|
|
|
191
193
|
)
|
|
192
194
|
const qc = queryClient
|
|
193
195
|
qc.clear()
|
|
196
|
+
for (const id of ['one', 'two']) seedWorkspaceInfo(id, undefined, qc)
|
|
194
197
|
qc.setDefaultOptions({ queries: { retry: false }, mutations: { retry: false } })
|
|
195
198
|
setIdentity(null)
|
|
196
199
|
if (!loadingSession && !failSession && environment === 'cloud') setIdentity(cloudSession)
|
|
197
200
|
if (injected && environment === 'local') setIdentity(session)
|
|
201
|
+
// The cloud host publishes members before React starts; Moi never requests them.
|
|
202
|
+
const publishMembership = () => {
|
|
203
|
+
for (const id of ['one', 'two']) setWorkspaceMembers(id, membership)
|
|
204
|
+
}
|
|
205
|
+
if (environment === 'cloud' && cloudSession && !anonymous && !loadingSession && !failSession) {
|
|
206
|
+
if (!pendingMembership) {
|
|
207
|
+
setAllWorkspaceMembers([])
|
|
208
|
+
publishMembership()
|
|
209
|
+
}
|
|
210
|
+
}
|
|
198
211
|
const { createRoot } = await import('react-dom/client')
|
|
199
212
|
const root = createRoot(document.getElementById('root')!)
|
|
200
213
|
notifyManager.setNotifyFunction(callback => {
|
|
@@ -241,6 +254,7 @@ export async function mountAccount({
|
|
|
241
254
|
qc,
|
|
242
255
|
setMembership: (next: WorkspaceMembers) => {
|
|
243
256
|
membership = next
|
|
257
|
+
publishMembership()
|
|
244
258
|
},
|
|
245
259
|
navigations,
|
|
246
260
|
location,
|
|
@@ -12,13 +12,14 @@ export const accountKeys = {
|
|
|
12
12
|
export class CloudApiError extends Error {
|
|
13
13
|
constructor(
|
|
14
14
|
message: string,
|
|
15
|
-
readonly status: number
|
|
15
|
+
readonly status: number,
|
|
16
|
+
readonly code?: string
|
|
16
17
|
) {
|
|
17
18
|
super(message)
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
export async function cloudRequest(path: string, init?: RequestInit): Promise<Response> {
|
|
21
|
-
const response = await fetch(`/cloud
|
|
22
|
+
const response = await fetch(`/cloud${path}`, { ...init, credentials: 'same-origin' })
|
|
22
23
|
if (!response.ok) {
|
|
23
24
|
const body: unknown = await response.json().catch(() => undefined)
|
|
24
25
|
const message = isRecord(body)
|
|
@@ -28,7 +29,8 @@ export async function cloudRequest(path: string, init?: RequestInit): Promise<Re
|
|
|
28
29
|
: undefined
|
|
29
30
|
throw new CloudApiError(
|
|
30
31
|
message ?? 'Couldn’t complete this request. Try again.',
|
|
31
|
-
response.status
|
|
32
|
+
response.status,
|
|
33
|
+
isRecord(body) && typeof body.code === 'string' ? body.code : undefined
|
|
32
34
|
)
|
|
33
35
|
}
|
|
34
36
|
return response
|
|
@@ -40,7 +42,7 @@ export const identityRefreshQuery = queryOptions({
|
|
|
40
42
|
const identityRevision = getIdentityRevision()
|
|
41
43
|
let identity: Identity | null
|
|
42
44
|
try {
|
|
43
|
-
identity = parseIdentity(await (await cloudRequest('me', { signal })).json())
|
|
45
|
+
identity = parseIdentity(await (await cloudRequest('/api/me', { signal })).json())
|
|
44
46
|
} catch (error) {
|
|
45
47
|
if (!(error instanceof CloudApiError) || error.status !== 401) throw error
|
|
46
48
|
identity = null
|
|
@@ -54,12 +56,12 @@ export const identityRefreshQuery = queryOptions({
|
|
|
54
56
|
})
|
|
55
57
|
type ProfilePatch = { name: string }
|
|
56
58
|
export const updateCloudProfile = async (patch: ProfilePatch) =>
|
|
57
|
-
parseIdentity(await (await cloudRequest('me', jsonRequest('PATCH', patch))).json())
|
|
59
|
+
parseIdentity(await (await cloudRequest('/api/me', jsonRequest('PATCH', patch))).json())
|
|
58
60
|
export async function uploadCloudAvatar(file: File) {
|
|
59
61
|
const body = new FormData()
|
|
60
62
|
body.set('file', file)
|
|
61
|
-
return parseIdentity(await (await cloudRequest('me/avatar', { method: 'PUT', body })).json())
|
|
63
|
+
return parseIdentity(await (await cloudRequest('/api/me/avatar', { method: 'PUT', body })).json())
|
|
62
64
|
}
|
|
63
65
|
export const removeCloudAvatar = async () =>
|
|
64
|
-
parseIdentity(await (await cloudRequest('me/avatar', { method: 'DELETE' })).json())
|
|
65
|
-
export const signOutCloud = () => cloudRequest('auth/sign-out', jsonRequest('POST'))
|
|
66
|
+
parseIdentity(await (await cloudRequest('/api/me/avatar', { method: 'DELETE' })).json())
|
|
67
|
+
export const signOutCloud = () => cloudRequest('/api/auth/sign-out', jsonRequest('POST'))
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { queryClient } from '@/client/api/query-client'
|
|
2
1
|
import { getIdentity, setIdentity, getAccountGeneration } from '../identity/store'
|
|
3
|
-
import { identityKey } from '../identity/types'
|
|
4
2
|
import type { Identity } from '../identity/types'
|
|
5
|
-
import {
|
|
3
|
+
import { refreshMemberProfile } from '../collab/members/store'
|
|
6
4
|
|
|
7
5
|
export async function saveCloudProfile(field: 'name' | 'avatar', update: () => Promise<Identity>) {
|
|
8
6
|
const before = getIdentity()
|
|
@@ -24,8 +22,8 @@ export async function saveCloudProfile(field: 'name' | 'avatar', update: () => P
|
|
|
24
22
|
...(field === 'name' && current.name === before.name ? { name: saved.name } : {}),
|
|
25
23
|
...(field === 'avatar' && current.avatar === before.avatar ? { avatar: saved.avatar } : {})
|
|
26
24
|
})
|
|
27
|
-
// Our identity write can supersede the event bridge's in-flight snapshot
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
// Our identity write can supersede the event bridge's in-flight snapshot, so
|
|
26
|
+
// put the saved profile into the member lists without waiting for the next one.
|
|
27
|
+
const profile = getIdentity()
|
|
28
|
+
if (accountGeneration === getAccountGeneration() && profile) refreshMemberProfile(profile)
|
|
31
29
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useRef, type ReactNode } from 'react'
|
|
2
|
+
import { useMutation } from '@tanstack/react-query'
|
|
3
|
+
import { IconCamera, IconLoader } from '@tabler/icons-react'
|
|
4
|
+
import { Button } from '@/client/components/ui/button'
|
|
5
|
+
import { cn } from '@/client/lib/cn'
|
|
6
|
+
import { toast } from '@/client/components/ui/toast'
|
|
7
|
+
import { useAccount } from '../account/account-provider'
|
|
8
|
+
|
|
9
|
+
type AvatarUploadProps = { children: ReactNode }
|
|
10
|
+
|
|
11
|
+
export function AvatarUpload({ children }: AvatarUploadProps) {
|
|
12
|
+
const account = useAccount()
|
|
13
|
+
const input = useRef<HTMLInputElement>(null)
|
|
14
|
+
const upload = useMutation({
|
|
15
|
+
mutationFn: (file: File) => account.saveAvatar(file),
|
|
16
|
+
onSuccess: () => toast.add({ title: 'Avatar updated', type: 'success' }),
|
|
17
|
+
onError: error =>
|
|
18
|
+
toast.add({ title: 'Couldn’t update avatar', description: error.message, type: 'error' })
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div className="flex items-start">
|
|
23
|
+
<input
|
|
24
|
+
ref={input}
|
|
25
|
+
type="file"
|
|
26
|
+
accept="image/*"
|
|
27
|
+
aria-label="Choose an avatar file"
|
|
28
|
+
className="hidden"
|
|
29
|
+
disabled={upload.isPending}
|
|
30
|
+
onChange={event => {
|
|
31
|
+
const file = event.currentTarget.files?.[0]
|
|
32
|
+
event.currentTarget.value = ''
|
|
33
|
+
if (file) upload.mutate(file)
|
|
34
|
+
}}
|
|
35
|
+
/>
|
|
36
|
+
<Button
|
|
37
|
+
variant="ghost"
|
|
38
|
+
size="icon"
|
|
39
|
+
className="group/avatar relative size-16 overflow-hidden rounded-full p-0"
|
|
40
|
+
aria-label="Change your avatar"
|
|
41
|
+
aria-busy={upload.isPending}
|
|
42
|
+
disabled={upload.isPending || !account.registered}
|
|
43
|
+
onClick={() => input.current?.click()}
|
|
44
|
+
>
|
|
45
|
+
{children}
|
|
46
|
+
<span
|
|
47
|
+
aria-hidden="true"
|
|
48
|
+
className={cn(
|
|
49
|
+
'pointer-events-none absolute inset-0 flex items-center justify-center rounded-full bg-background/70 opacity-0 transition-opacity group-hover/avatar:opacity-100 group-focus-visible/avatar:opacity-100',
|
|
50
|
+
upload.isPending && 'opacity-100'
|
|
51
|
+
)}
|
|
52
|
+
>
|
|
53
|
+
{upload.isPending ? (
|
|
54
|
+
<IconLoader size={20} className="animate-spin" stroke={1.5} />
|
|
55
|
+
) : (
|
|
56
|
+
<IconCamera size={20} stroke={1.5} />
|
|
57
|
+
)}
|
|
58
|
+
</span>
|
|
59
|
+
</Button>
|
|
60
|
+
</div>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
@@ -4,6 +4,7 @@ import { Field, FieldGroup, FieldLabel } from '@/ui-components/field'
|
|
|
4
4
|
import { Input } from '@/client/components/ui/input'
|
|
5
5
|
import { toast } from '@/client/components/ui/toast'
|
|
6
6
|
import { useAccount } from '../account/account-provider'
|
|
7
|
+
import { UserAvatar } from '../collab/components/user-avatar'
|
|
7
8
|
import { SettingsSection } from './settings-section'
|
|
8
9
|
|
|
9
10
|
export function ProfileSettings() {
|
|
@@ -12,6 +13,15 @@ export function ProfileSettings() {
|
|
|
12
13
|
return (
|
|
13
14
|
<SettingsSection title="Profile">
|
|
14
15
|
<FieldGroup>
|
|
16
|
+
{account.registered && (
|
|
17
|
+
<Field>
|
|
18
|
+
<FieldLabel>Avatar</FieldLabel>
|
|
19
|
+
{/* Restore AvatarUpload once the cloud API stores uploaded images. */}
|
|
20
|
+
<div>
|
|
21
|
+
<UserAvatar profile={account.profile} className="size-16!" />
|
|
22
|
+
</div>
|
|
23
|
+
</Field>
|
|
24
|
+
)}
|
|
15
25
|
<NameField
|
|
16
26
|
key={account.profile.id}
|
|
17
27
|
name={account.profile.name ?? ''}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect } from 'react'
|
|
2
2
|
import { Redirect } from 'wouter'
|
|
3
|
+
import { homePath } from '@/client/api/app-config'
|
|
3
4
|
import { Button } from '@/client/components/ui/button'
|
|
4
5
|
import { Skeleton } from '@/client/components/ui/skeleton'
|
|
5
6
|
import { useAccount } from '../account/account-provider'
|
|
@@ -13,7 +14,7 @@ export function SettingsPage() {
|
|
|
13
14
|
window.location.replace('/cloud/login')
|
|
14
15
|
}
|
|
15
16
|
}, [account.cloud, account.demo, account.status, account.registered])
|
|
16
|
-
if (account.demo) return <Redirect to=
|
|
17
|
+
if (account.demo) return <Redirect to={homePath()} replace />
|
|
17
18
|
if (account.status === 'signed-out') return null
|
|
18
19
|
return (
|
|
19
20
|
<div className="min-h-0 flex-1 overflow-y-auto">
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-layout-context'
|
|
1
2
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
2
3
|
|
|
3
4
|
import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
@@ -8,25 +9,24 @@ import type { AppletThumbnail, AppletThumbnailBatch } from '@/lib/types'
|
|
|
8
9
|
// Freshness records only — image bytes stay server-side (`.moi/.cache`) and
|
|
9
10
|
// reach the UI as plain <img> URLs.
|
|
10
11
|
export function useAppletThumbnailRecords(workspaceId: string) {
|
|
12
|
+
const { apiBase } = useWorkspaceLayoutCtx()
|
|
11
13
|
return useQuery<AppletThumbnail[]>({
|
|
12
14
|
queryKey: workspaceKeys.appletThumbnails(workspaceId),
|
|
13
15
|
queryFn: async () =>
|
|
14
|
-
(
|
|
15
|
-
|
|
16
|
-
`/api/workspaces/${workspaceId}/applet-thumbnails`
|
|
17
|
-
)
|
|
18
|
-
).thumbnails,
|
|
16
|
+
(await requestJson<{ thumbnails: AppletThumbnail[] }>(`${apiBase}/applet-thumbnails`))
|
|
17
|
+
.thumbnails,
|
|
19
18
|
...WORKSPACE_RESOURCE_OPTIONS
|
|
20
19
|
})
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
export function useSaveAppletThumbnails(workspaceId: string) {
|
|
23
|
+
const { apiBase } = useWorkspaceLayoutCtx()
|
|
24
24
|
const queryClient = useQueryClient()
|
|
25
25
|
|
|
26
26
|
return useMutation<void, Error, AppletThumbnailBatch>({
|
|
27
27
|
mutationFn: input =>
|
|
28
28
|
requestVoid(
|
|
29
|
-
|
|
29
|
+
`${apiBase}/applet-thumbnails`,
|
|
30
30
|
jsonRequest('PUT', input),
|
|
31
31
|
'Failed to save applet thumbnails'
|
|
32
32
|
),
|