moi-computer 0.13.1-next.1 → 0.13.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/api/app-config.ts +12 -1
- 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 +33 -6
- 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 +15 -9
- package/client/features/account/api.ts +6 -6
- package/client/features/account/profile-actions.ts +5 -7
- 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 +14 -109
- package/client/features/chat/use-chat.ts +8 -12
- package/client/features/collab/members/api.ts +4 -10
- package/client/features/collab/members/hooks.ts +32 -38
- package/client/features/collab/members/store.ts +96 -71
- package/client/features/collab/members/types.ts +5 -3
- package/client/features/collab/presence/client.ts +2 -3
- package/client/features/collab/presence/hooks.tsx +1 -1
- package/client/features/collab/proxy-user.ts +1 -3
- package/client/features/collab/sharing/workspace-members.tsx +0 -8
- package/client/features/dev/chat-states-page.tsx +3 -1
- package/client/features/dev/harness-debug-page.tsx +7 -7
- package/client/features/dev/workspace-setup-mocks.ts +1 -1
- 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 +3 -2
- 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 +66 -23
- package/client/features/views/use-view-actions.ts +10 -41
- 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 +1 -8
- package/client/features/workspace/use-workspace-navigation.ts +11 -7
- package/client/features/workspace/workspace-content.tsx +24 -31
- 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 +91 -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 +42 -16
- 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 +24 -9
- package/client/store/workspace-session.ts +30 -0
- package/dist/chunk-0h4zypgf.js +1 -0
- package/dist/chunk-1tksq43z.js +72 -0
- package/dist/chunk-6gxf0xr8.js +5 -0
- package/dist/chunk-a865c7x4.js +1 -0
- package/dist/chunk-f44cs6mw.js +2 -0
- package/dist/chunk-h3qag4a6.js +2 -0
- package/dist/chunk-kffcah9w.css +1 -0
- package/dist/chunk-q2tpy0h7.js +2 -0
- package/dist/chunk-r95acex1.js +546 -0
- package/dist/chunk-w5h9grdr.js +1 -0
- package/dist/{chunk-th91xfnp.js → chunk-xj1pjhng.js} +1 -1
- package/dist/index.html +1 -1
- package/lib/harness-instructions.ts +4 -4
- package/lib/harness-types.ts +13 -0
- package/lib/moi-context.ts +19 -5
- package/lib/types.ts +38 -54
- package/lib/workspace-config.ts +48 -0
- package/lib/workspace-layout.ts +5 -24
- package/package.json +5 -2
- package/server/AGENTS.md +1 -1
- package/server/README.md +36 -31
- package/server/api/harnesses.ts +5 -5
- package/server/api/index.ts +268 -162
- 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 +102 -54
- package/server/cli/commands/openclaw.ts +2 -2
- package/server/cli/commands/refresh.ts +10 -1
- package/server/cli/commands/remote.ts +330 -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 +73 -0
- package/server/cli/remote-operations.ts +247 -0
- package/server/collab/config.ts +3 -3
- package/server/collab/skill/index.ts +3 -3
- package/server/control.ts +47 -12
- 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 +2 -2
- 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/broker-client.ts +76 -0
- package/server/remote/broker.ts +81 -0
- package/server/remote/client.ts +725 -0
- package/server/remote/errors.ts +2 -0
- package/server/remote/routes.ts +121 -0
- package/server/remote/workspace.ts +34 -0
- package/server/scratchpad/document.ts +33 -12
- package/server/scratchpad/executor.ts +16 -7
- package/server/sessions/config.ts +8 -5
- package/server/sessions/pending-views.ts +17 -0
- package/server/sessions/send-message.ts +102 -0
- package/server/sessions/view-sessions.ts +9 -101
- package/server/skills/locations.ts +4 -4
- package/server/skills/update.ts +11 -11
- package/server/skills/version.ts +7 -7
- package/server/skills/workspace.ts +13 -11
- package/server/web.ts +13 -9
- package/server/workspace-state/file.ts +4 -0
- package/server/workspace-state/index.ts +0 -4
- package/server/workspaces/api.ts +24 -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/shared.ts +74 -0
- package/server/workspaces/tabs.ts +5 -12
- package/skill/SKILL.md +80 -19
- package/skill/references/SCRATCHPAD.md +4 -0
- package/skill/references/UI-COMPONENTS.md +1 -1
- package/client/api/app-ui-keys.ts +0 -6
- package/client/features/chat/sessions/browser-tab-state.ts +0 -43
- package/client/features/collab/members/keys.ts +0 -6
- package/client/features/workspace/browser-tab-state.ts +0 -51
- package/client/features/workspace/layout-save.ts +0 -13
- package/dist/chunk-3smkkcfw.js +0 -546
- package/dist/chunk-47h9c2qy.js +0 -2
- package/dist/chunk-8qed2gqp.js +0 -75
- package/dist/chunk-8zy3vesm.js +0 -1
- package/dist/chunk-a47zy276.js +0 -2
- package/dist/chunk-g4c1nte9.css +0 -1
- package/dist/chunk-kcactdr4.js +0 -2
- package/dist/chunk-m8bhx6tw.js +0 -1
- package/dist/chunk-pf19zcrn.js +0 -2
- package/dist/chunk-ygzxah0e.js +0 -1
- package/lib/workspace-types.ts +0 -13
- package/server/workspace-state/legacy-migration.ts +0 -79
package/client/api/app-config.ts
CHANGED
|
@@ -42,6 +42,17 @@ export async function loadAppConfig(): Promise<ClientAppConfig | undefined> {
|
|
|
42
42
|
return fetchAppConfig()
|
|
43
43
|
}
|
|
44
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
|
+
|
|
45
52
|
export function useAppConfig(): ClientAppConfig {
|
|
46
|
-
return useSyncExternalStore(
|
|
53
|
+
return useSyncExternalStore(
|
|
54
|
+
subscribe,
|
|
55
|
+
() => current,
|
|
56
|
+
() => current
|
|
57
|
+
)
|
|
47
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,3 +1,6 @@
|
|
|
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'
|
|
1
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'
|
|
@@ -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,9 +30,15 @@ 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
|
-
useWorkspaceMembers(id)
|
|
31
33
|
const { environment } = useAppConfig()
|
|
32
|
-
|
|
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}>
|
|
@@ -44,16 +53,17 @@ export function WorkspaceRoute({ id }: WorkspaceRouteProps) {
|
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
function WorkspaceContent({ id }: WorkspaceRouteProps) {
|
|
56
|
+
useWorkspaceMembers(id)
|
|
47
57
|
const queryClient = useQueryClient()
|
|
48
58
|
const [selectedSessionId] = useSelectedSession()
|
|
49
|
-
const { isLoading: layoutLoading, layout,
|
|
50
|
-
useWorkspaceHarnessChanges(id,
|
|
59
|
+
const { isLoading: layoutLoading, layout, harness } = useWorkspaceLayoutCtx()
|
|
60
|
+
useWorkspaceHarnessChanges(id, harness)
|
|
51
61
|
useWorkspaceTheme(layout.theme)
|
|
52
62
|
const widgets = useWidgets(id)
|
|
53
63
|
const views = useViews(id)
|
|
54
64
|
useAppletCacheInvalidation()
|
|
55
65
|
|
|
56
|
-
|
|
66
|
+
useWorkspaceScopedEvent(id, event => {
|
|
57
67
|
if (event.type === 'theme:updated' || event.type === 'workspace:updated') {
|
|
58
68
|
// Skip our own save: the cache already holds it, and the refetch could
|
|
59
69
|
// land an older value over a newer optimistic change.
|
|
@@ -73,6 +83,23 @@ function WorkspaceContent({ id }: WorkspaceRouteProps) {
|
|
|
73
83
|
const contentPending =
|
|
74
84
|
layoutLoading || selectedSessionId === undefined || widgets.isLoading || views.isLoading
|
|
75
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
|
+
|
|
76
103
|
return (
|
|
77
104
|
<WorkspaceScreen
|
|
78
105
|
contentPending={contentPending}
|
|
@@ -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'
|
|
@@ -10,6 +11,7 @@ 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
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
|
|
|
@@ -95,9 +97,8 @@ export async function mountAccount({
|
|
|
95
97
|
let cloudSession: Identity | null = signedOut
|
|
96
98
|
? null
|
|
97
99
|
: { ...session, type: 'user', email: 'alex@example.com', isAnonymous: anonymous }
|
|
98
|
-
const failures = { signOut: false, mutation: false, session: failSession
|
|
100
|
+
const failures = { signOut: false, mutation: false, session: failSession }
|
|
99
101
|
const mutationRequest = Promise.withResolvers<void>()
|
|
100
|
-
const membershipRequest = Promise.withResolvers<void>()
|
|
101
102
|
let membership: WorkspaceMembers = {
|
|
102
103
|
members: [{ ...session, membershipId: 'member-me' }],
|
|
103
104
|
invitations: []
|
|
@@ -126,12 +127,6 @@ export async function mountAccount({
|
|
|
126
127
|
? Response.json(cloudSession)
|
|
127
128
|
: Response.json({ error: 'No session' }, { status: 401 })
|
|
128
129
|
}
|
|
129
|
-
if (path.endsWith('/members') && (!init?.method || init.method === 'GET')) {
|
|
130
|
-
if (pendingMembership) await membershipRequest.promise
|
|
131
|
-
return failures.membership
|
|
132
|
-
? Response.json({ error: 'Members unavailable' }, { status: 503 })
|
|
133
|
-
: Response.json(membership)
|
|
134
|
-
}
|
|
135
130
|
if (path.endsWith('/sign-out')) {
|
|
136
131
|
if (failures.signOut)
|
|
137
132
|
return Response.json({ error: 'Try signing out again.' }, { status: 503 })
|
|
@@ -198,10 +193,21 @@ export async function mountAccount({
|
|
|
198
193
|
)
|
|
199
194
|
const qc = queryClient
|
|
200
195
|
qc.clear()
|
|
196
|
+
for (const id of ['one', 'two']) seedWorkspaceInfo(id, undefined, qc)
|
|
201
197
|
qc.setDefaultOptions({ queries: { retry: false }, mutations: { retry: false } })
|
|
202
198
|
setIdentity(null)
|
|
203
199
|
if (!loadingSession && !failSession && environment === 'cloud') setIdentity(cloudSession)
|
|
204
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
|
+
}
|
|
205
211
|
const { createRoot } = await import('react-dom/client')
|
|
206
212
|
const root = createRoot(document.getElementById('root')!)
|
|
207
213
|
notifyManager.setNotifyFunction(callback => {
|
|
@@ -245,10 +251,10 @@ export async function mountAccount({
|
|
|
245
251
|
calls,
|
|
246
252
|
failures,
|
|
247
253
|
mutationRequest,
|
|
248
|
-
membershipRequest,
|
|
249
254
|
qc,
|
|
250
255
|
setMembership: (next: WorkspaceMembers) => {
|
|
251
256
|
membership = next
|
|
257
|
+
publishMembership()
|
|
252
258
|
},
|
|
253
259
|
navigations,
|
|
254
260
|
location,
|
|
@@ -19,7 +19,7 @@ export class CloudApiError extends Error {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
export async function cloudRequest(path: string, init?: RequestInit): Promise<Response> {
|
|
22
|
-
const response = await fetch(`/cloud
|
|
22
|
+
const response = await fetch(`/cloud${path}`, { ...init, credentials: 'same-origin' })
|
|
23
23
|
if (!response.ok) {
|
|
24
24
|
const body: unknown = await response.json().catch(() => undefined)
|
|
25
25
|
const message = isRecord(body)
|
|
@@ -42,7 +42,7 @@ export const identityRefreshQuery = queryOptions({
|
|
|
42
42
|
const identityRevision = getIdentityRevision()
|
|
43
43
|
let identity: Identity | null
|
|
44
44
|
try {
|
|
45
|
-
identity = parseIdentity(await (await cloudRequest('me', { signal })).json())
|
|
45
|
+
identity = parseIdentity(await (await cloudRequest('/api/me', { signal })).json())
|
|
46
46
|
} catch (error) {
|
|
47
47
|
if (!(error instanceof CloudApiError) || error.status !== 401) throw error
|
|
48
48
|
identity = null
|
|
@@ -56,12 +56,12 @@ export const identityRefreshQuery = queryOptions({
|
|
|
56
56
|
})
|
|
57
57
|
type ProfilePatch = { name: string }
|
|
58
58
|
export const updateCloudProfile = async (patch: ProfilePatch) =>
|
|
59
|
-
parseIdentity(await (await cloudRequest('me', jsonRequest('PATCH', patch))).json())
|
|
59
|
+
parseIdentity(await (await cloudRequest('/api/me', jsonRequest('PATCH', patch))).json())
|
|
60
60
|
export async function uploadCloudAvatar(file: File) {
|
|
61
61
|
const body = new FormData()
|
|
62
62
|
body.set('file', file)
|
|
63
|
-
return parseIdentity(await (await cloudRequest('me/avatar', { method: 'PUT', body })).json())
|
|
63
|
+
return parseIdentity(await (await cloudRequest('/api/me/avatar', { method: 'PUT', body })).json())
|
|
64
64
|
}
|
|
65
65
|
export const removeCloudAvatar = async () =>
|
|
66
|
-
parseIdentity(await (await cloudRequest('me/avatar', { method: 'DELETE' })).json())
|
|
67
|
-
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
|
}
|
|
@@ -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
|
),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getWorkspaceApiBase } from '@/client/features/workspace/remote'
|
|
1
2
|
// Shared load cache for agent-authored applets (widgets / views).
|
|
2
3
|
//
|
|
3
4
|
// An applet is loaded as an ESM module via dynamic `import()`. The browser
|
|
@@ -43,7 +44,7 @@ const ENTRY_ROUTE = 'module'
|
|
|
43
44
|
// Assets + chunks resolve module-relative from the entry (via import.meta.url),
|
|
44
45
|
// so they don't inherit `?v` and aren't re-fetched needlessly.
|
|
45
46
|
export function appletUrl(segment: AppletSegment, workspaceId: string, name: string): string {
|
|
46
|
-
return
|
|
47
|
+
return `${getWorkspaceApiBase(workspaceId)}/${segment}/${name}/${ENTRY_ROUTE}?v=${appletVersion(segment, workspaceId, name)}`
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
// The key an applet bundle registers its CSS under (`window.__moiAppletCss`):
|
|
@@ -51,7 +52,7 @@ export function appletUrl(segment: AppletSegment, workspaceId: string, name: str
|
|
|
51
52
|
// (see injectCss in server/applets/build-applet.ts). Workspace-qualified so two
|
|
52
53
|
// workspaces sharing an applet name never read each other's styles.
|
|
53
54
|
export function appletStyleKey(segment: AppletSegment, workspaceId: string, name: string): string {
|
|
54
|
-
return
|
|
55
|
+
return `${getWorkspaceApiBase(workspaceId)}/${segment}/${name}`
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
// Stable applet identity used by scoped CSS, presence, and thumbnail capture.
|
|
@@ -79,12 +80,12 @@ export function invalidateApplet(segment: AppletSegment, workspaceId: string, na
|
|
|
79
80
|
disposeAppletBridge(key)
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
// Invalidate every applet of one kind
|
|
83
|
+
// Invalidate every applet of one kind in this workspace — the
|
|
83
84
|
// `applets:refresh` path, which names no specific applet. Only keys that have
|
|
84
85
|
// ever been loaded (or bumped) exist in the maps; anything else already loads
|
|
85
86
|
// fresh on first mount.
|
|
86
|
-
export function invalidateAppletSegment(segment: AppletSegment): void {
|
|
87
|
-
const prefix = `${segment}/`
|
|
87
|
+
export function invalidateAppletSegment(segment: AppletSegment, workspaceId?: string): void {
|
|
88
|
+
const prefix = workspaceId === undefined ? `${segment}/` : `${segment}/${workspaceId}/`
|
|
88
89
|
for (const key of new Set([...moduleCache.keys(), ...versions.keys()])) {
|
|
89
90
|
if (key.startsWith(prefix)) {
|
|
90
91
|
moduleCache.delete(key)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getWorkspaceApiBase } from '@/client/features/workspace/remote'
|
|
1
2
|
import { createRateLimiter } from '@/client/lib/rate-limit'
|
|
2
3
|
import type { AppletClientError, AppletKind } from '@/lib/types'
|
|
3
4
|
|
|
@@ -21,7 +22,7 @@ export function reportAppletError(workspaceId: string, event: AppletClientError)
|
|
|
21
22
|
const key = [workspaceId, event.source, event.kind, event.name, event.message].join('\0')
|
|
22
23
|
if (limiter.admit(key) !== 'ok') return
|
|
23
24
|
|
|
24
|
-
void fetch(
|
|
25
|
+
void fetch(`${getWorkspaceApiBase(workspaceId)}/applet-log`, {
|
|
25
26
|
method: 'POST',
|
|
26
27
|
headers: { 'Content-Type': 'application/json' },
|
|
27
28
|
body: JSON.stringify({ events: [event] })
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getWorkspaceApiBase } from '@/client/features/workspace/remote'
|
|
1
2
|
// The workspace applet runtime — the host side of the applet `moi` module.
|
|
2
3
|
//
|
|
3
4
|
// Every applet bundle inlines its own copy of the `moi` runtime module (see
|
|
@@ -152,7 +153,7 @@ function createRuntime(workspaceId: string) {
|
|
|
152
153
|
},
|
|
153
154
|
resolveUrl(url) {
|
|
154
155
|
if (!alive) return ''
|
|
155
|
-
return resolveUrl(url, { workspaceId, base })
|
|
156
|
+
return resolveUrl(url, { workspaceId, base, apiBase: getWorkspaceApiBase(workspaceId) })
|
|
156
157
|
},
|
|
157
158
|
sendChatMessage(input, legacyContext) {
|
|
158
159
|
if (!alive) return
|