moi-computer 0.13.1-next.1 → 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 -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 +18 -100
- 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 +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 +22 -20
- 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-th91xfnp.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 -49
- 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/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 -53
- 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 +3 -3
- package/server/collab/skill/index.ts +3 -3
- 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/update.ts +11 -11
- package/server/skills/version.ts +7 -7
- package/server/skills/workspace.ts +13 -11
- package/server/web.ts +11 -8
- 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/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/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
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { useLocation } from 'wouter'
|
|
2
|
+
import { parseRemoteWorkspaceTarget, workspaceAddress } from '@/lib/workspace-config'
|
|
3
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
4
|
+
import { useAppConfig } from '@/client/api/app-config'
|
|
5
|
+
import { jsonRequest } from '@/client/api/http'
|
|
6
|
+
import { Button } from '@/client/components/ui/button'
|
|
7
|
+
import { cloudRequest } from '@/client/features/account/api'
|
|
8
|
+
|
|
9
|
+
type WorkspaceInvitation = {
|
|
10
|
+
id: string
|
|
11
|
+
workspaceName: string
|
|
12
|
+
inviter: { name: string }
|
|
13
|
+
}
|
|
14
|
+
const invitationsKey = ['workspace-invitations']
|
|
15
|
+
|
|
16
|
+
export function WorkspaceInvitations() {
|
|
17
|
+
const cloud = useAppConfig().environment === 'cloud'
|
|
18
|
+
const query = useQuery({
|
|
19
|
+
queryKey: invitationsKey,
|
|
20
|
+
enabled: cloud,
|
|
21
|
+
queryFn: async () =>
|
|
22
|
+
(await (await cloudRequest('/api/workspaces/invitations')).json()) as {
|
|
23
|
+
invitations: WorkspaceInvitation[]
|
|
24
|
+
},
|
|
25
|
+
staleTime: 60_000,
|
|
26
|
+
refetchOnWindowFocus: true,
|
|
27
|
+
retry: false
|
|
28
|
+
})
|
|
29
|
+
if (!cloud || query.data?.invitations.length === 0) return null
|
|
30
|
+
return (
|
|
31
|
+
<section className="mb-8">
|
|
32
|
+
<h2 className="mb-4 text-sm font-medium">Invitations</h2>
|
|
33
|
+
{query.isPending ? (
|
|
34
|
+
<p className="text-sm text-muted-foreground">Loading invitations…</p>
|
|
35
|
+
) : query.isError ? (
|
|
36
|
+
<div role="alert">
|
|
37
|
+
<p className="text-sm text-muted-foreground">{query.error.message}</p>
|
|
38
|
+
<Button variant="ghost" onClick={() => void query.refetch()}>
|
|
39
|
+
Retry
|
|
40
|
+
</Button>
|
|
41
|
+
</div>
|
|
42
|
+
) : (
|
|
43
|
+
<ul className="border-t border-border">
|
|
44
|
+
{query.data.invitations.map(invitation => (
|
|
45
|
+
<InvitationRow key={invitation.id} invitation={invitation} />
|
|
46
|
+
))}
|
|
47
|
+
</ul>
|
|
48
|
+
)}
|
|
49
|
+
</section>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type InvitationRowProps = { invitation: WorkspaceInvitation }
|
|
54
|
+
function InvitationRow({ invitation }: InvitationRowProps) {
|
|
55
|
+
const client = useQueryClient()
|
|
56
|
+
const [, navigate] = useLocation()
|
|
57
|
+
const accept = useMutation({
|
|
58
|
+
mutationFn: async () => {
|
|
59
|
+
const response = await cloudRequest(
|
|
60
|
+
`/api/invitations/${encodeURIComponent(invitation.id)}/accept`,
|
|
61
|
+
jsonRequest('POST', {})
|
|
62
|
+
)
|
|
63
|
+
const { remote } = (await response.json()) as { remote: unknown }
|
|
64
|
+
return parseRemoteWorkspaceTarget(remote)
|
|
65
|
+
},
|
|
66
|
+
onSuccess: remote => {
|
|
67
|
+
void client.invalidateQueries({ queryKey: invitationsKey })
|
|
68
|
+
void client.invalidateQueries({ queryKey: ['shared-workspaces'] })
|
|
69
|
+
navigate(`/workspace/${workspaceAddress(remote.workspace_id, remote.user_id)}`)
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
return (
|
|
73
|
+
<li className="border-b border-border px-1 py-3">
|
|
74
|
+
<div className="flex items-center gap-2">
|
|
75
|
+
<div className="min-w-0 flex-1">
|
|
76
|
+
<p className="truncate text-sm font-medium">{invitation.workspaceName}</p>
|
|
77
|
+
<p className="text-xs text-muted-foreground">Invited by {invitation.inviter.name}</p>
|
|
78
|
+
</div>
|
|
79
|
+
<Button
|
|
80
|
+
variant="outline"
|
|
81
|
+
size="sm"
|
|
82
|
+
disabled={accept.isPending || accept.isSuccess}
|
|
83
|
+
onClick={() => accept.mutate()}
|
|
84
|
+
>
|
|
85
|
+
{accept.isPending
|
|
86
|
+
? 'Accepting…'
|
|
87
|
+
: accept.isSuccess
|
|
88
|
+
? 'Accepted'
|
|
89
|
+
: accept.isError
|
|
90
|
+
? 'Try again'
|
|
91
|
+
: 'Accept'}
|
|
92
|
+
</Button>
|
|
93
|
+
</div>
|
|
94
|
+
{accept.isError && (
|
|
95
|
+
<p role="alert" className="mt-2 text-sm text-destructive">
|
|
96
|
+
{accept.error.message}
|
|
97
|
+
</p>
|
|
98
|
+
)}
|
|
99
|
+
</li>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
@@ -12,9 +12,10 @@ import type { WorkspaceMembers, WorkspaceMembersSnapshot } from '../collab/membe
|
|
|
12
12
|
export type IdentityHostApi = {
|
|
13
13
|
identity: { set: (identity: Identity | null) => void; getRevision: () => number }
|
|
14
14
|
workspaceMembers: {
|
|
15
|
-
|
|
15
|
+
// Workspaces are named by address: `workspaceId`, or `ownerId:workspaceId` when shared.
|
|
16
|
+
set: (address: string, data: WorkspaceMembers) => void
|
|
16
17
|
setAll: (workspaces: WorkspaceMembersSnapshot[]) => void
|
|
17
|
-
remove: (
|
|
18
|
+
remove: (address: string) => void
|
|
18
19
|
clear: () => void
|
|
19
20
|
getRevision: () => number
|
|
20
21
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { queryClient } from '@/client/api/query-client'
|
|
2
|
-
import { memberKeys } from '../collab/members/keys'
|
|
3
1
|
import { identityKey, parseIdentity } from './types'
|
|
4
2
|
import type { Identity } from './types'
|
|
5
3
|
|
|
@@ -21,11 +19,7 @@ export function subscribeIdentity(listener: () => void) {
|
|
|
21
19
|
export function setIdentity(value: Identity | null): void {
|
|
22
20
|
const next = value === null ? null : parseIdentity(value)
|
|
23
21
|
const changedAccount = (current && identityKey(current)) !== (next && identityKey(next))
|
|
24
|
-
if (changedAccount)
|
|
25
|
-
accountGeneration++
|
|
26
|
-
void queryClient.cancelQueries({ queryKey: memberKeys.all })
|
|
27
|
-
queryClient.removeQueries({ queryKey: memberKeys.all })
|
|
28
|
-
}
|
|
22
|
+
if (changedAccount) accountGeneration++
|
|
29
23
|
identityRevision++
|
|
30
24
|
current = next
|
|
31
25
|
listeners.forEach(listener => listener())
|
|
@@ -15,7 +15,7 @@ export function AgentSetupStep({ onComplete }: AgentSetupStepProps) {
|
|
|
15
15
|
if (harness) onComplete(harness)
|
|
16
16
|
}, [harness, onComplete])
|
|
17
17
|
if (!harness) return <ChooseAgent onSelect={setHarness} />
|
|
18
|
-
return <HarnessLoginPanel
|
|
18
|
+
return <HarnessLoginPanel harness={harness} onConnected={onConnected} />
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
type ChooseAgentProps = { onSelect: (harness: OnboardingHarness) => void }
|
|
@@ -26,12 +26,12 @@ function ChooseAgent({ onSelect }: ChooseAgentProps) {
|
|
|
26
26
|
const retry = useRetryHarnessStatus()
|
|
27
27
|
if (installed.isPending || installed.error)
|
|
28
28
|
return <OnboardingStatus error={installed.error ?? undefined} onRetry={() => retry.mutate()} />
|
|
29
|
-
const options = (['claude-code', 'codex'] as const).map(
|
|
30
|
-
|
|
31
|
-
description: harnessDescription[
|
|
32
|
-
disabled: !canInstall && installed.data[
|
|
29
|
+
const options = (['claude-code', 'codex'] as const).map(harness => ({
|
|
30
|
+
harness,
|
|
31
|
+
description: harnessDescription[harness],
|
|
32
|
+
disabled: !canInstall && installed.data[harness].availability.status === 'unavailable',
|
|
33
33
|
disabledReason:
|
|
34
|
-
canInstall || installed.data[
|
|
34
|
+
canInstall || installed.data[harness].availability.status !== 'unavailable'
|
|
35
35
|
? undefined
|
|
36
36
|
: 'This agent is not installed on your computer'
|
|
37
37
|
}))
|
|
@@ -48,8 +48,8 @@ function ChooseAgent({ onSelect }: ChooseAgentProps) {
|
|
|
48
48
|
mode="action"
|
|
49
49
|
cardClassName="h-36"
|
|
50
50
|
disabled={false}
|
|
51
|
-
|
|
52
|
-
if (
|
|
51
|
+
onHarnessChange={harness => {
|
|
52
|
+
if (harness === 'claude-code' || harness === 'codex') onSelect(harness)
|
|
53
53
|
}}
|
|
54
54
|
/>
|
|
55
55
|
</OnboardingScreen>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
import { Redirect } from 'wouter'
|
|
3
|
+
import { homePath } from '@/client/api/app-config'
|
|
3
4
|
import { useSaveAppSettings } from '@/client/features/app-settings/api'
|
|
4
5
|
import type { OnboardingHarness } from '@/lib/onboarding'
|
|
5
6
|
import { useOnboardingSettings } from './api'
|
|
@@ -10,14 +11,14 @@ import { WorkspaceSetupStep } from './workspace-setup-step'
|
|
|
10
11
|
export function OnboardingPage() {
|
|
11
12
|
const onboarding = useOnboardingSettings()
|
|
12
13
|
const save = useSaveAppSettings()
|
|
13
|
-
const [destination, setDestination] = useState(
|
|
14
|
+
const [destination, setDestination] = useState(homePath)
|
|
14
15
|
const [harness, setHarness] = useState<OnboardingHarness>()
|
|
15
16
|
if (onboarding.loading || onboarding.error)
|
|
16
17
|
return <OnboardingStatus error={onboarding.error || undefined} onRetry={onboarding.retry} />
|
|
17
18
|
if (!onboarding.enabled || !onboarding.data?.showOnboarding) return <Redirect to={destination} />
|
|
18
19
|
|
|
19
20
|
function finish(workspaceId?: string) {
|
|
20
|
-
setDestination(workspaceId ? `/workspace/${workspaceId}/overview` :
|
|
21
|
+
setDestination(workspaceId ? `/workspace/${workspaceId}/overview` : homePath())
|
|
21
22
|
save.mutate({ showOnboarding: false })
|
|
22
23
|
}
|
|
23
24
|
if (!harness) return <AgentSetupStep onComplete={setHarness} />
|
|
@@ -57,7 +57,7 @@ export function WorkspaceSetupStep({
|
|
|
57
57
|
}
|
|
58
58
|
const workspaces = await requestJson<WorkspaceEntry[]>('/api/workspaces')
|
|
59
59
|
if (workspaces.length > 0) return
|
|
60
|
-
const entry = await createWorkspace.mutateAsync({
|
|
60
|
+
const entry = await createWorkspace.mutateAsync({ harness: harness })
|
|
61
61
|
return entry.id
|
|
62
62
|
},
|
|
63
63
|
onSuccess: id => onFinish(id)
|
|
@@ -11,13 +11,11 @@ import { withDefaultWidgets } from '@/lib/default-widgets'
|
|
|
11
11
|
import type { WidgetInfo } from '@/lib/types'
|
|
12
12
|
|
|
13
13
|
export function useWidgets(workspaceId: string) {
|
|
14
|
-
const { layout, setLayout } = useWorkspaceLayoutCtx()
|
|
14
|
+
const { layout, setLayout, apiBase } = useWorkspaceLayoutCtx()
|
|
15
15
|
const query = useQuery<WidgetInfo[]>({
|
|
16
16
|
queryKey: workspaceKeys.widgets(workspaceId),
|
|
17
17
|
queryFn: async () => {
|
|
18
|
-
const data = await requestJson<{ widgets: WidgetInfo[] }>(
|
|
19
|
-
`/api/workspaces/${workspaceId}/widgets`
|
|
20
|
-
)
|
|
18
|
+
const data = await requestJson<{ widgets: WidgetInfo[] }>(`${apiBase}/widgets`)
|
|
21
19
|
return data.widgets
|
|
22
20
|
},
|
|
23
21
|
...WORKSPACE_RESOURCE_OPTIONS
|
|
@@ -26,5 +24,5 @@ export function useWidgets(workspaceId: string) {
|
|
|
26
24
|
|
|
27
25
|
useGridReconcile(workspaceId, query.data ? widgets : undefined, layout, setLayout)
|
|
28
26
|
|
|
29
|
-
return { ...query, data: widgets }
|
|
27
|
+
return { ...query, data: widgets, hasData: query.data !== undefined }
|
|
30
28
|
}
|
|
@@ -208,7 +208,7 @@ function ViewItem({ view, Icon, onOpen }: ViewItemProps) {
|
|
|
208
208
|
type ViewsWidgetProps = {
|
|
209
209
|
views: ViewInfo[]
|
|
210
210
|
onOpenView: (viewId: string) => void
|
|
211
|
-
onCreateView
|
|
211
|
+
onCreateView?: () => void
|
|
212
212
|
showOnboarding: boolean
|
|
213
213
|
}
|
|
214
214
|
|
|
@@ -234,7 +234,7 @@ export function ViewsWidget({ views, onOpenView, onCreateView, showOnboarding }:
|
|
|
234
234
|
onOpen={() => onOpenView(view.id)}
|
|
235
235
|
/>
|
|
236
236
|
))}
|
|
237
|
-
<NewViewButton outlined={empty} onClick={onCreateView} />
|
|
237
|
+
{onCreateView && <NewViewButton outlined={empty} onClick={onCreateView} />}
|
|
238
238
|
</div>
|
|
239
239
|
{empty && showOnboarding && (
|
|
240
240
|
<p className="relative mr-8 ml-auto max-w-56 text-right text-sm text-muted-foreground">
|
|
@@ -46,7 +46,7 @@ const ROW_SPAN: Record<number, string> = {
|
|
|
46
46
|
type HiddenPanelProps = {
|
|
47
47
|
items: GridItem[]
|
|
48
48
|
renderItem: (id: string) => ReactNode
|
|
49
|
-
onCreateWidget
|
|
49
|
+
onCreateWidget?: () => void
|
|
50
50
|
onClose: () => void
|
|
51
51
|
onRestore: (id: string) => void
|
|
52
52
|
ref?: Ref<HTMLDivElement>
|
|
@@ -67,10 +67,12 @@ export function HiddenPanel({
|
|
|
67
67
|
ref={ref}
|
|
68
68
|
title="Widgets"
|
|
69
69
|
actions={
|
|
70
|
-
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
onCreateWidget && (
|
|
71
|
+
<Button type="button" variant="secondary" size="sm" onClick={onCreateWidget}>
|
|
72
|
+
<IconPlus data-icon="inline-start" stroke={1.75} />
|
|
73
|
+
New widget
|
|
74
|
+
</Button>
|
|
75
|
+
)
|
|
74
76
|
}
|
|
75
77
|
onClose={onClose}
|
|
76
78
|
className="max-h-[60vh]"
|
|
@@ -32,7 +32,7 @@ import { WorkspaceName } from './workspace-name'
|
|
|
32
32
|
import { WidgetCanvas } from './widget-canvas'
|
|
33
33
|
|
|
34
34
|
type NoWidgetsCreatedProps = {
|
|
35
|
-
onCreateWidget
|
|
35
|
+
onCreateWidget?: () => void
|
|
36
36
|
showOnboarding: boolean
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -53,18 +53,20 @@ function NoWidgetsCreated({ onCreateWidget, showOnboarding }: NoWidgetsCreatedPr
|
|
|
53
53
|
</div>
|
|
54
54
|
)}
|
|
55
55
|
</div>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
{onCreateWidget && (
|
|
57
|
+
<Button
|
|
58
|
+
type="button"
|
|
59
|
+
variant="outline"
|
|
60
|
+
className={cn(
|
|
61
|
+
'absolute inset-0 m-auto h-fit w-fit',
|
|
62
|
+
'flex-col gap-1 rounded-2xl border-0 py-4 pr-8 pl-8! text-xs shadow-sm transition-shadow duration-300 ease-out squircle hover:bg-background hover:shadow-lg [&_svg]:size-8'
|
|
63
|
+
)}
|
|
64
|
+
onClick={onCreateWidget}
|
|
65
|
+
>
|
|
66
|
+
<IconPlus data-icon="inline-start" stroke={1.5} />
|
|
67
|
+
New widget
|
|
68
|
+
</Button>
|
|
69
|
+
)}
|
|
68
70
|
</div>
|
|
69
71
|
)
|
|
70
72
|
}
|
|
@@ -166,8 +168,8 @@ function usePanelHeight() {
|
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
type OverviewProps = {
|
|
169
|
-
onCreateWidget
|
|
170
|
-
onCreateView
|
|
171
|
+
onCreateWidget?: () => void
|
|
172
|
+
onCreateView?: () => void
|
|
171
173
|
onOpenView: (viewId: string) => void
|
|
172
174
|
customizing: boolean
|
|
173
175
|
theming: boolean
|
|
@@ -231,7 +233,7 @@ export function Overview({
|
|
|
231
233
|
showOnboarding
|
|
232
234
|
})
|
|
233
235
|
if (defaultWidget) return defaultWidget
|
|
234
|
-
return <WidgetShell name={id} />
|
|
236
|
+
return <WidgetShell name={id} revision={widgetById.get(id)?.revision} />
|
|
235
237
|
}
|
|
236
238
|
|
|
237
239
|
function hide(id: string) {
|
|
@@ -7,7 +7,7 @@ import { WorkspaceIconPicker } from '@/client/features/workspace/settings/worksp
|
|
|
7
7
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-layout-context'
|
|
8
8
|
|
|
9
9
|
export function WorkspaceName() {
|
|
10
|
-
const { layout, name,
|
|
10
|
+
const { layout, name, harness, workspaceId } = useWorkspaceLayoutCtx()
|
|
11
11
|
const workspaceName = name ?? 'Workspace'
|
|
12
12
|
const saveName = useSaveWorkspaceName(workspaceId)
|
|
13
13
|
const [nameDraft, setNameDraft] = useState(workspaceName)
|
|
@@ -24,7 +24,7 @@ export function WorkspaceName() {
|
|
|
24
24
|
<WorkspaceIdentity
|
|
25
25
|
name={nameDraft}
|
|
26
26
|
icon={layout.icon}
|
|
27
|
-
|
|
27
|
+
harness={harness}
|
|
28
28
|
workspaceTheme={layout.theme}
|
|
29
29
|
onNameChange={setNameDraft}
|
|
30
30
|
onNameCommit={commitName}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-layout-context'
|
|
1
2
|
import { useCallback, useRef, useState } from 'react'
|
|
2
3
|
|
|
3
4
|
import {
|
|
@@ -71,8 +72,8 @@ function makeExecutor(editor: Editor) {
|
|
|
71
72
|
// the record; `resolve` maps it back to the serving URL at render time. Legacy
|
|
72
73
|
// snapshots still holding data URLs pass through `resolve` untouched (the
|
|
73
74
|
// server extracts them to files on the next save). See server/scratchpad/assets.ts.
|
|
74
|
-
function makeAssetStore(
|
|
75
|
-
const base =
|
|
75
|
+
function makeAssetStore(apiBase: string): TLAssetStore {
|
|
76
|
+
const base = `${apiBase}/scratchpad/assets`
|
|
76
77
|
return {
|
|
77
78
|
async upload(_asset, file) {
|
|
78
79
|
const res = await fetch(base, {
|
|
@@ -188,6 +189,7 @@ export function Scratchpad() {
|
|
|
188
189
|
}
|
|
189
190
|
|
|
190
191
|
function WorkspaceScratchpad({ workspaceId }: { workspaceId: string }) {
|
|
192
|
+
const { apiBase } = useWorkspaceLayoutCtx()
|
|
191
193
|
const editorRef = useRef<Editor | null>(null)
|
|
192
194
|
// The whole scratchpad region (canvas + tool bar + style bar). Focus is driven
|
|
193
195
|
// off whether a pointerdown lands inside this, so clicking a tool keeps the
|
|
@@ -201,10 +203,10 @@ function WorkspaceScratchpad({ workspaceId }: { workspaceId: string }) {
|
|
|
201
203
|
const applyingRemote = useRef(false)
|
|
202
204
|
// Reactive handle to the mounted editor, used to render the custom tool bar.
|
|
203
205
|
const [editor, setEditor] = useState<Editor | null>(null)
|
|
204
|
-
const { loaded, snapshot, skew, flagSkew } = useScratchpadSnapshot(
|
|
206
|
+
const { loaded, snapshot, skew, flagSkew } = useScratchpadSnapshot()
|
|
205
207
|
// This keyed component gives each workspace one stable asset store. A fresh
|
|
206
208
|
// identity makes <Tldraw> remount the editor and drop unsaved edits.
|
|
207
|
-
const [assetStore] = useState<TLAssetStore>(() => makeAssetStore(
|
|
209
|
+
const [assetStore] = useState<TLAssetStore>(() => makeAssetStore(apiBase))
|
|
208
210
|
|
|
209
211
|
const save = useCallback(() => {
|
|
210
212
|
const editor = editorRef.current
|
|
@@ -215,12 +217,12 @@ function WorkspaceScratchpad({ workspaceId }: { workspaceId: string }) {
|
|
|
215
217
|
} catch {
|
|
216
218
|
return
|
|
217
219
|
}
|
|
218
|
-
void fetch(
|
|
220
|
+
void fetch(`${apiBase}/scratchpad`, {
|
|
219
221
|
method: 'PUT',
|
|
220
222
|
headers: { 'Content-Type': 'application/json' },
|
|
221
223
|
body: JSON.stringify({ document, origin: BROWSER_TAB_ID })
|
|
222
224
|
}).catch(() => {})
|
|
223
|
-
}, [
|
|
225
|
+
}, [apiBase])
|
|
224
226
|
|
|
225
227
|
// A remote save (another tab, or an agent draw landing in another tab) — pull
|
|
226
228
|
// the new snapshot and load it into the live store. Skip our own echo. The
|
|
@@ -232,7 +234,7 @@ function WorkspaceScratchpad({ workspaceId }: { workspaceId: string }) {
|
|
|
232
234
|
if (e.type !== 'scratchpad:updated' || e.workspaceId !== workspaceId) return
|
|
233
235
|
if (e.origin && e.origin === BROWSER_TAB_ID) return
|
|
234
236
|
if (!editorRef.current) return
|
|
235
|
-
fetch(
|
|
237
|
+
fetch(`${apiBase}/scratchpad`)
|
|
236
238
|
.then(r => r.json())
|
|
237
239
|
.then((d: ScratchpadFetch) => {
|
|
238
240
|
const editor = editorRef.current
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-layout-context'
|
|
2
|
+
import { requestJson } from '@/client/api/http'
|
|
1
3
|
import { useCallback, useEffect, useState } from 'react'
|
|
2
4
|
|
|
3
5
|
import { IconVersions } from '@tabler/icons-react'
|
|
@@ -53,18 +55,18 @@ export function detectScratchpadSkew(
|
|
|
53
55
|
return { newer: false, writer, detail: 'The saved snapshot failed to load.' }
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
export function useScratchpadSnapshot(
|
|
58
|
+
export function useScratchpadSnapshot(): {
|
|
57
59
|
loaded: boolean
|
|
58
60
|
snapshot: TLEditorSnapshot['document'] | undefined
|
|
59
61
|
skew: ScratchpadSkew | null
|
|
60
62
|
flagSkew: (skew: ScratchpadSkew) => void
|
|
61
63
|
} {
|
|
64
|
+
const { apiBase } = useWorkspaceLayoutCtx()
|
|
62
65
|
const [result, setResult] = useState<SnapshotResult | null>(null)
|
|
63
66
|
|
|
64
67
|
useEffect(() => {
|
|
65
68
|
let cancelled = false
|
|
66
|
-
|
|
67
|
-
.then(response => response.json())
|
|
69
|
+
requestJson<ScratchpadFetch>(`${apiBase}/scratchpad`)
|
|
68
70
|
.then((data: ScratchpadFetch) => {
|
|
69
71
|
if (cancelled) return
|
|
70
72
|
let snapshot: TLEditorSnapshot['document'] | undefined
|
|
@@ -76,12 +78,18 @@ export function useScratchpadSnapshot(workspaceId: string): {
|
|
|
76
78
|
setResult({ snapshot, skew })
|
|
77
79
|
})
|
|
78
80
|
.catch(() => {
|
|
79
|
-
if (!cancelled)
|
|
81
|
+
if (!cancelled)
|
|
82
|
+
setResult({
|
|
83
|
+
skew: {
|
|
84
|
+
newer: false,
|
|
85
|
+
detail: 'Couldn’t load the canvas. Reopen Scratchpad to try again.'
|
|
86
|
+
}
|
|
87
|
+
})
|
|
80
88
|
})
|
|
81
89
|
return () => {
|
|
82
90
|
cancelled = true
|
|
83
91
|
}
|
|
84
|
-
}, [
|
|
92
|
+
}, [apiBase])
|
|
85
93
|
|
|
86
94
|
const flagSkew = useCallback((skew: ScratchpadSkew) => {
|
|
87
95
|
setResult(previous => ({ snapshot: previous?.snapshot, skew }))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/workspace-layout-context'
|
|
1
2
|
import type { SpeedMode } from '@/lib/types'
|
|
2
3
|
import type {
|
|
3
4
|
CompiledView,
|
|
4
5
|
MessageAttachment,
|
|
5
6
|
PendingView,
|
|
6
|
-
SelectedSessionScope,
|
|
7
7
|
ViewInfo,
|
|
8
8
|
WorkspaceState
|
|
9
9
|
} from '@/lib/types'
|
|
@@ -19,11 +19,10 @@ import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
|
|
|
19
19
|
|
|
20
20
|
// Compiled views from `.moi/views/`. Build and layout events refetch the list;
|
|
21
21
|
// mounts within 30 s reuse it.
|
|
22
|
-
export function compiledViewsOptions(workspaceId: string) {
|
|
22
|
+
export function compiledViewsOptions(workspaceId: string, apiBase: string) {
|
|
23
23
|
return {
|
|
24
24
|
queryKey: workspaceKeys.views(workspaceId),
|
|
25
|
-
queryFn: async () =>
|
|
26
|
-
(await requestJson<{ views: CompiledView[] }>(`/api/workspaces/${workspaceId}/views`)).views,
|
|
25
|
+
queryFn: async () => (await requestJson<{ views: CompiledView[] }>(`${apiBase}/views`)).views,
|
|
27
26
|
staleTime: 30_000,
|
|
28
27
|
gcTime: 5 * 60_000,
|
|
29
28
|
refetchOnMount: true,
|
|
@@ -58,6 +57,7 @@ export function getCachedViews(
|
|
|
58
57
|
const selectPendingViews = (state: WorkspaceState) => state.pendingViews
|
|
59
58
|
|
|
60
59
|
export function useViews(workspaceId: string) {
|
|
60
|
+
const { apiBase } = useWorkspaceLayoutCtx()
|
|
61
61
|
const queryClient = useQueryClient()
|
|
62
62
|
useWorkspaceEvent(event => {
|
|
63
63
|
if (event.type === 'view-layout:updated' && event.workspaceId === workspaceId) {
|
|
@@ -72,10 +72,16 @@ export function useViews(workspaceId: string) {
|
|
|
72
72
|
void queryClient.invalidateQueries({ queryKey: workspaceKeys.sessions(workspaceId) })
|
|
73
73
|
}
|
|
74
74
|
})
|
|
75
|
-
const compiled = useQuery(compiledViewsOptions(workspaceId))
|
|
75
|
+
const compiled = useQuery(compiledViewsOptions(workspaceId, apiBase))
|
|
76
76
|
const pending = useWorkspaceState(workspaceId, selectPendingViews)
|
|
77
77
|
const data = useMemo(() => mergeViews(compiled.data, pending.data), [compiled.data, pending.data])
|
|
78
|
-
return {
|
|
78
|
+
return {
|
|
79
|
+
data,
|
|
80
|
+
isLoading: compiled.isLoading || pending.isLoading,
|
|
81
|
+
isError: compiled.isError || pending.isError,
|
|
82
|
+
isFetching: compiled.isFetching || pending.isFetching,
|
|
83
|
+
refetch: () => Promise.all([compiled.refetch(), pending.refetch()])
|
|
84
|
+
}
|
|
79
85
|
}
|
|
80
86
|
function useViewMutation<T, Input>(workspaceId: string, mutationFn: (input: Input) => Promise<T>) {
|
|
81
87
|
const queryClient = useQueryClient()
|
|
@@ -84,39 +90,51 @@ function useViewMutation<T, Input>(workspaceId: string, mutationFn: (input: Inpu
|
|
|
84
90
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: workspaceKeys.views(workspaceId) })
|
|
85
91
|
})
|
|
86
92
|
}
|
|
93
|
+
// A view still being built lives in this Moi's state, next to the chat building
|
|
94
|
+
// it. A compiled view lives with the workspace's owner.
|
|
95
|
+
function useViewBase(workspaceId: string) {
|
|
96
|
+
const { apiBase } = useWorkspaceLayoutCtx()
|
|
97
|
+
const queryClient = useQueryClient()
|
|
98
|
+
const local = `/api/workspaces/${workspaceId}`
|
|
99
|
+
return {
|
|
100
|
+
local,
|
|
101
|
+
forView: (viewId: string) =>
|
|
102
|
+
getCachedWorkspaceState(queryClient, workspaceId)?.pendingViews[viewId] ? local : apiBase
|
|
103
|
+
}
|
|
104
|
+
}
|
|
87
105
|
export function useRenameView(workspaceId: string) {
|
|
106
|
+
const base = useViewBase(workspaceId)
|
|
88
107
|
return useViewMutation(workspaceId, ({ viewId, title }: { viewId: string; title: string }) =>
|
|
89
108
|
requestJson<ViewInfo>(
|
|
90
|
-
|
|
109
|
+
`${base.forView(viewId)}/views/${encodeURIComponent(viewId)}`,
|
|
91
110
|
jsonRequest('PATCH', { title }),
|
|
92
111
|
'Couldn’t rename view'
|
|
93
112
|
)
|
|
94
113
|
)
|
|
95
114
|
}
|
|
96
115
|
export function useDeleteView(workspaceId: string) {
|
|
116
|
+
const base = useViewBase(workspaceId)
|
|
97
117
|
return useViewMutation(workspaceId, (viewId: string) =>
|
|
98
118
|
requestVoid(
|
|
99
|
-
|
|
119
|
+
`${base.forView(viewId)}/views/${encodeURIComponent(viewId)}`,
|
|
100
120
|
{ method: 'DELETE' },
|
|
101
121
|
'Couldn’t delete view'
|
|
102
122
|
)
|
|
103
123
|
)
|
|
104
124
|
}
|
|
105
125
|
export function useCreateView(workspaceId: string) {
|
|
126
|
+
const { local } = useViewBase(workspaceId)
|
|
106
127
|
return useViewMutation(workspaceId, () =>
|
|
107
|
-
requestJson<PendingView>(
|
|
108
|
-
`/api/workspaces/${workspaceId}/views`,
|
|
109
|
-
jsonRequest('POST'),
|
|
110
|
-
'Couldn’t create view'
|
|
111
|
-
)
|
|
128
|
+
requestJson<PendingView>(`${local}/views`, jsonRequest('POST'), 'Couldn’t create view')
|
|
112
129
|
)
|
|
113
130
|
}
|
|
114
131
|
export function useSaveViewDraft(workspaceId: string) {
|
|
132
|
+
const { local } = useViewBase(workspaceId)
|
|
115
133
|
return useViewMutation(
|
|
116
134
|
workspaceId,
|
|
117
135
|
({ viewId, requirements }: { viewId: string; requirements: string }) =>
|
|
118
136
|
requestJson<PendingView>(
|
|
119
|
-
|
|
137
|
+
`${local}/views/${viewId}`,
|
|
120
138
|
jsonRequest('PATCH', { requirements }),
|
|
121
139
|
'Couldn’t save view requirements'
|
|
122
140
|
)
|
|
@@ -127,7 +145,6 @@ export type SubmitViewInput = {
|
|
|
127
145
|
requirements: string
|
|
128
146
|
sessionId: string
|
|
129
147
|
optimisticId: string
|
|
130
|
-
selectedSessionScope?: SelectedSessionScope
|
|
131
148
|
attachments?: MessageAttachment[]
|
|
132
149
|
model?: string
|
|
133
150
|
effort?: string
|
|
@@ -135,9 +152,10 @@ export type SubmitViewInput = {
|
|
|
135
152
|
stream?: boolean
|
|
136
153
|
}
|
|
137
154
|
export function useSubmitView(workspaceId: string) {
|
|
155
|
+
const { local } = useViewBase(workspaceId)
|
|
138
156
|
return useViewMutation(workspaceId, ({ viewId, ...input }: SubmitViewInput) =>
|
|
139
157
|
requestJson<{ viewId: string; sessionId: string }>(
|
|
140
|
-
|
|
158
|
+
`${local}/views/${viewId}/submit`,
|
|
141
159
|
jsonRequest('POST', input),
|
|
142
160
|
'Couldn’t start view chat'
|
|
143
161
|
)
|