moi-computer 0.3.0 → 0.3.1-next.1
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/workspace-keys.ts +2 -2
- package/client/app/AppRouter.tsx +0 -2
- package/client/app/routes/WorkspaceRoute.tsx +3 -1
- package/client/app/shell/SidebarLayout.tsx +3 -16
- package/client/assets/openai.svg +1 -3
- package/client/components/shared/Composer.tsx +112 -0
- package/client/components/ui/button.tsx +1 -1
- package/client/components/ui/dropdown-menu.tsx +3 -3
- package/client/components/ui/tooltip.tsx +12 -15
- package/client/features/applets/WidgetErrorBoundary.tsx +19 -3
- package/client/features/applets/WidgetShell.tsx +8 -1
- package/client/features/applets/applet-log.ts +100 -0
- package/client/features/applets/useApplet.ts +21 -7
- package/client/features/chat/ChatComposer.tsx +33 -30
- package/client/features/chat/ChatPanel.tsx +5 -2
- package/client/features/chat/MarkdownContent.tsx +20 -2
- package/client/features/chat/ModelPicker.tsx +29 -41
- package/client/features/chat/TurnView.tsx +2 -2
- package/client/features/chat/chat-frames.ts +14 -6
- package/client/features/chat/chat-send.ts +1 -1
- package/client/features/chat/chat-store.ts +22 -17
- package/client/features/chat/model-order.ts +47 -0
- package/client/features/chat/tool-group/ToolOutput.tsx +4 -12
- package/client/features/chat/tool-group/format.ts +0 -6
- package/client/features/chat/useChat.ts +15 -2
- package/client/features/connectors/McpServerCards.tsx +95 -0
- package/client/features/connectors/api.ts +0 -11
- package/client/features/home/HomePage.tsx +45 -42
- package/client/features/home/WorkspacePreview.tsx +179 -38
- package/client/features/home/api.ts +24 -12
- package/client/features/home/workspace-presentation.tsx +17 -15
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +243 -0
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +95 -0
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +230 -0
- package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +35 -0
- package/client/features/home/workspace-setup/useWorkspaceImport.ts +61 -0
- package/client/features/settings/ConnectorsSettings.tsx +89 -0
- package/client/features/settings/GeneralSettings.tsx +12 -0
- package/client/features/settings/SettingsLayout.tsx +2 -2
- package/client/features/settings/WorkspaceSettings.tsx +8 -4
- package/client/features/views/ViewBuilderTab.tsx +28 -29
- package/client/features/views/useViewBuilderActions.ts +1 -1
- package/client/features/widgets/WidgetFrame.tsx +3 -0
- package/client/features/widgets/WidgetGrid.tsx +1 -0
- package/client/features/widgets/Widgets.tsx +12 -3
- package/client/features/widgets/api.ts +47 -0
- package/client/features/widgets/useWidgetThumbnails.ts +107 -0
- package/client/features/widgets/widget-snapshot.ts +71 -0
- package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -4
- package/client/features/workspace/WorkspaceScreen.tsx +19 -4
- package/client/features/workspace/api.ts +25 -3
- package/client/features/workspace/moi-context.ts +85 -0
- package/client/index.css +0 -5
- package/client/main.tsx +13 -4
- package/dist/{chunk-cs8vbert.js → chunk-1dfbr7n2.js} +2 -2
- package/dist/chunk-339jds4x.js +15 -0
- package/dist/chunk-3xsvsnhr.css +1 -0
- package/dist/{chunk-zpxrb1ce.js → chunk-anqmsbjt.js} +2 -2
- package/dist/chunk-hbvfb6sk.js +63 -0
- package/dist/chunk-jen6xcm1.js +14 -0
- package/dist/{chunk-kxmvv1ax.js → chunk-qwm5f6qk.js} +1 -1
- package/dist/{chunk-fjksw6xf.js → chunk-sxbfh73c.js} +1 -1
- package/dist/chunk-yp4srgqt.js +10 -0
- package/dist/index.html +1 -1
- package/dist/openai-ep9ht2pq.svg +1 -0
- package/lib/ids.ts +15 -0
- package/lib/moi-context.ts +170 -0
- package/lib/types.ts +95 -13
- package/lib/view-builder-directives.ts +16 -0
- package/lib/workspace-types.ts +12 -0
- package/package.json +4 -2
- package/server/api.ts +180 -34
- package/server/applet-log.ts +149 -0
- package/server/cli.ts +161 -7
- package/server/control.ts +81 -1
- package/server/functions.ts +44 -14
- package/server/harness/README.md +26 -9
- package/server/harness/claude-code/NOTES.md +20 -6
- package/server/harness/claude-code/adapter.ts +2 -2
- package/server/harness/claude-code/git-worktree.ts +32 -0
- package/server/harness/claude-code/index.ts +35 -13
- package/server/harness/claude-code/mcp.ts +16 -65
- package/server/harness/claude-code/models.ts +3 -0
- package/server/harness/claude-code/session.ts +196 -61
- package/server/harness/claude-code/sessions.ts +51 -0
- package/server/harness/codex/NOTES.md +41 -11
- package/server/harness/codex/adapter.ts +52 -6
- package/server/harness/codex/client.ts +69 -18
- package/server/harness/codex/discovery.ts +114 -0
- package/server/harness/codex/index.ts +12 -5
- package/server/harness/codex/probe.ts +4 -2
- package/server/harness/codex/session.ts +57 -5
- package/server/harness/executable.ts +82 -0
- package/server/harness/openclaw/adapter.ts +8 -1
- package/server/harness/openclaw/discovery.ts +139 -6
- package/server/harness/openclaw/gateway.ts +40 -18
- package/server/harness/openclaw/index.ts +12 -15
- package/server/harness/openclaw/session.ts +50 -10
- package/server/harness/openclaw/strip.ts +2 -2
- package/server/harness/shell-path.ts +79 -0
- package/server/harness/types.ts +37 -5
- package/server/layout.ts +81 -51
- package/server/registry.ts +57 -12
- package/server/scratchpad-assets.ts +41 -6
- package/server/scratchpad.ts +30 -0
- package/server/view-builders.ts +3 -2
- package/server/views.ts +5 -0
- package/server/web.ts +30 -8
- package/server/widgets.ts +23 -2
- package/server/workspace-import.ts +45 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +27 -3
- package/client/features/connectors/ConnectorsPage.tsx +0 -92
- package/client/features/connectors/McpMenu.tsx +0 -145
- package/client/features/home/CreateWorkspaceDialog.tsx +0 -130
- package/client/features/home/CreateWorkspaceDialogSteps.tsx +0 -234
- package/dist/chunk-4vf1t6v1.js +0 -10
- package/dist/chunk-4z52b2av.css +0 -1
- package/dist/chunk-b4b276wx.js +0 -15
- package/dist/chunk-y82s1jxm.js +0 -61
- package/dist/openai-h13pza4b.svg +0 -3
- package/lib/view-builder-meta.ts +0 -35
|
@@ -2,7 +2,9 @@ import { useCallback, useMemo } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { useQueryClient } from '@tanstack/react-query'
|
|
4
4
|
|
|
5
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
5
6
|
import { useSessionView, useThreadConfig, useWorkspaceModels } from '@/client/features/chat/api'
|
|
7
|
+
import { useMoiUserMessageContext } from '@/client/features/workspace/moi-context'
|
|
6
8
|
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
7
9
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
8
10
|
import { sendMessage } from '@/client/features/chat/chat-connection'
|
|
@@ -22,11 +24,17 @@ export function useChat() {
|
|
|
22
24
|
const qc = useQueryClient()
|
|
23
25
|
const { layout } = useWorkspaceLayoutCtx()
|
|
24
26
|
const modelsData = useWorkspaceModels(workspaceId).data
|
|
27
|
+
// Snapshot of the workspace's ambient UI state + queued one-shot
|
|
28
|
+
// directives, taken when the message actually goes out.
|
|
29
|
+
const buildMoiContext = useMoiUserMessageContext()
|
|
25
30
|
|
|
26
31
|
const activeSessionId = useLive(s => s.activeByWorkspace[workspaceId] ?? null)
|
|
27
|
-
const
|
|
28
|
-
activeSessionId ? (s.
|
|
32
|
+
const activity = useLive(s =>
|
|
33
|
+
activeSessionId ? (s.activity[`${workspaceId}:${activeSessionId}`] ?? 'idle') : 'idle'
|
|
29
34
|
)
|
|
35
|
+
// Only `running` shows the loader/Stop. `requires-action` (agent blocked on
|
|
36
|
+
// user input) deliberately renders like idle until it gets its own UI.
|
|
37
|
+
const processing = activity === 'running'
|
|
30
38
|
const error = useLive(s =>
|
|
31
39
|
activeSessionId ? (s.errors[`${workspaceId}:${activeSessionId}`] ?? null) : null
|
|
32
40
|
)
|
|
@@ -110,8 +118,12 @@ export function useChat() {
|
|
|
110
118
|
model,
|
|
111
119
|
effort,
|
|
112
120
|
stream,
|
|
121
|
+
context: buildMoiContext(),
|
|
113
122
|
...(ready.length > 0 ? { attachments: ready.map(a => a.upload!.id) } : {})
|
|
114
123
|
})
|
|
124
|
+
if (isNew) {
|
|
125
|
+
qc.invalidateQueries({ queryKey: workspaceKeys.preview(workspaceId) })
|
|
126
|
+
}
|
|
115
127
|
// Drop the thread's attachments now that they've been sent (revokes the
|
|
116
128
|
// preview object URLs). Keyed by the pre-mint id, matching where they were
|
|
117
129
|
// stored by the composer.
|
|
@@ -123,6 +135,7 @@ export function useChat() {
|
|
|
123
135
|
qc,
|
|
124
136
|
layout.selectedModel,
|
|
125
137
|
layout.selectedEffort,
|
|
138
|
+
buildMoiContext,
|
|
126
139
|
threadCfg?.model,
|
|
127
140
|
threadCfg?.effort,
|
|
128
141
|
modelsData
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import { IconAlertCircleFilled } from '@tabler/icons-react'
|
|
4
|
+
|
|
5
|
+
import { Skeleton } from '@/client/components/ui/skeleton'
|
|
6
|
+
import { IconMcp } from '@/client/features/connectors/IconMcp'
|
|
7
|
+
import { formatMcpServerName, getMcpIcon } from '@/client/features/connectors/mcp-icons'
|
|
8
|
+
import type { McpServer } from '@/lib/types'
|
|
9
|
+
|
|
10
|
+
function statusLabel(status: McpServer['status']): string {
|
|
11
|
+
if (status === 'needs-auth') return 'Needs auth'
|
|
12
|
+
return status[0].toUpperCase() + status.slice(1)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type McpServerIconProps = {
|
|
16
|
+
name: string
|
|
17
|
+
status: McpServer['status']
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function McpServerIcon({ name, status }: McpServerIconProps) {
|
|
21
|
+
const icon = getMcpIcon(name)
|
|
22
|
+
const className = 'size-full rounded-sm ring-2 ring-background'
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<span className="relative size-10 shrink-0">
|
|
26
|
+
{icon ? (
|
|
27
|
+
<img src={icon} alt="" className={className} />
|
|
28
|
+
) : (
|
|
29
|
+
<span className="flex size-full items-center justify-center rounded-sm bg-muted text-muted-foreground ring-2 ring-background">
|
|
30
|
+
<IconMcp className="size-5" />
|
|
31
|
+
</span>
|
|
32
|
+
)}
|
|
33
|
+
{status !== 'connected' && (
|
|
34
|
+
<IconAlertCircleFilled
|
|
35
|
+
aria-hidden="true"
|
|
36
|
+
size={16}
|
|
37
|
+
stroke={1.75}
|
|
38
|
+
className="absolute -top-1 -right-1 rounded-full bg-card text-amber-400"
|
|
39
|
+
/>
|
|
40
|
+
)}
|
|
41
|
+
</span>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function sortMcpServers(servers: McpServer[]): McpServer[] {
|
|
46
|
+
return [...servers].sort(
|
|
47
|
+
(a, b) => Number(b.status === 'connected') - Number(a.status === 'connected')
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type McpServerCardProps = {
|
|
52
|
+
server: McpServer
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type McpServerCardLayoutProps = {
|
|
56
|
+
icon: ReactNode
|
|
57
|
+
children: ReactNode
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function McpServerCardLayout({ icon, children }: McpServerCardLayoutProps) {
|
|
61
|
+
return (
|
|
62
|
+
<div className="flex items-center gap-3 text-card-foreground">
|
|
63
|
+
{icon}
|
|
64
|
+
<div className="flex min-w-0 flex-1 flex-col justify-center gap-0.5">{children}</div>
|
|
65
|
+
</div>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function McpServerCard({ server }: McpServerCardProps) {
|
|
70
|
+
return (
|
|
71
|
+
<McpServerCardLayout icon={<McpServerIcon name={server.name} status={server.status} />}>
|
|
72
|
+
<div className="truncate text-sm font-medium text-foreground">
|
|
73
|
+
{formatMcpServerName(server.name)}
|
|
74
|
+
</div>
|
|
75
|
+
<span className="text-sm text-muted-foreground">{statusLabel(server.status)}</span>
|
|
76
|
+
</McpServerCardLayout>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function McpServerCardSkeleton() {
|
|
81
|
+
return (
|
|
82
|
+
<McpServerCardLayout icon={<Skeleton className="size-10 shrink-0 rounded-sm" />}>
|
|
83
|
+
<Skeleton className="h-4 w-36 max-w-full" />
|
|
84
|
+
<Skeleton className="h-4 w-20" />
|
|
85
|
+
</McpServerCardLayout>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type McpServerGridProps = {
|
|
90
|
+
children: ReactNode
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function McpServerGrid({ children }: McpServerGridProps) {
|
|
94
|
+
return <div className="grid grid-cols-1 gap-6 sm:grid-cols-2">{children}</div>
|
|
95
|
+
}
|
|
@@ -15,14 +15,3 @@ export function useWorkspaceMcp(workspaceId: string, enabled: boolean) {
|
|
|
15
15
|
refetchOnWindowFocus: false
|
|
16
16
|
})
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
export function useUserMcp() {
|
|
20
|
-
return useQuery<McpServer[]>({
|
|
21
|
-
queryKey: workspaceKeys.userMcp,
|
|
22
|
-
queryFn: () => requestJson('/api/mcp'),
|
|
23
|
-
staleTime: 30_000,
|
|
24
|
-
gcTime: Infinity,
|
|
25
|
-
refetchOnMount: true,
|
|
26
|
-
refetchOnWindowFocus: true
|
|
27
|
-
})
|
|
28
|
-
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { IconChevronRight, IconEggCracked, IconLoader2, IconPlus } from '@tabler/icons-react'
|
|
2
2
|
import { Link, useLocation } from 'wouter'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
useDiscoveredWorkspaces,
|
|
6
|
+
useWorkspacePreview,
|
|
7
|
+
useWorkspaces,
|
|
8
|
+
useWorkspaceSetupInfo
|
|
9
|
+
} from './api'
|
|
10
|
+
import { CreateWorkspaceDialog } from './workspace-setup/CreateWorkspaceDialog'
|
|
11
|
+
import { ImportWorkspaceDialog } from './workspace-setup/ImportWorkspaceDialog'
|
|
12
|
+
import { useWorkspaceImport } from './workspace-setup/useWorkspaceImport'
|
|
5
13
|
import { HomeLogo } from './HomeLogo'
|
|
6
14
|
import { Button } from '@/client/components/ui/button'
|
|
7
15
|
import {
|
|
@@ -12,20 +20,22 @@ import {
|
|
|
12
20
|
import { cn } from '@/client/lib/cn'
|
|
13
21
|
import { useUiStore } from '@/client/store/ui'
|
|
14
22
|
import {
|
|
15
|
-
|
|
23
|
+
WorkspaceAgentIcons,
|
|
16
24
|
workspaceDisplayName,
|
|
17
25
|
workspaceProviderIcon
|
|
18
26
|
} from '@/client/features/home/workspace-presentation'
|
|
19
27
|
import type { DiscoveredWorkspace, WorkspaceEntry } from '@/lib/types'
|
|
20
28
|
|
|
21
|
-
import { CreateWorkspaceDialog } from './CreateWorkspaceDialog'
|
|
22
29
|
import { WorkspacePreview } from './WorkspacePreview'
|
|
23
30
|
|
|
24
31
|
export function HomePage() {
|
|
25
32
|
const [, navigate] = useLocation()
|
|
26
33
|
const workspacesQuery = useWorkspaces()
|
|
27
34
|
const discoveredQuery = useDiscoveredWorkspaces()
|
|
28
|
-
const
|
|
35
|
+
const setupInfo = useWorkspaceSetupInfo()
|
|
36
|
+
const importFlow = useWorkspaceImport({
|
|
37
|
+
onSuccess: entry => navigate(`/workspace/${entry.id}`)
|
|
38
|
+
})
|
|
29
39
|
const discoveredWorkspacesOpen = useUiStore(state => state.discoveredWorkspacesOpen)
|
|
30
40
|
const setDiscoveredWorkspacesOpen = useUiStore(state => state.setDiscoveredWorkspacesOpen)
|
|
31
41
|
|
|
@@ -48,13 +58,9 @@ export function HomePage() {
|
|
|
48
58
|
const workspaces = workspacesQuery.data
|
|
49
59
|
const discovered = discoveredQuery.data
|
|
50
60
|
const count = workspaces.length
|
|
51
|
-
const importingPath =
|
|
52
|
-
importMutation.isPending && importMutation.variables ? importMutation.variables.path : null
|
|
53
61
|
|
|
54
62
|
function handleAdd(suggestion: DiscoveredWorkspace) {
|
|
55
|
-
|
|
56
|
-
onSuccess: entry => navigate(`/workspace/${entry.id}`)
|
|
57
|
-
})
|
|
63
|
+
importFlow.startImport(suggestion)
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
return (
|
|
@@ -122,21 +128,25 @@ export function HomePage() {
|
|
|
122
128
|
<CollapsibleContent>
|
|
123
129
|
<ul className="border-t border-border">
|
|
124
130
|
{discovered.map(item => (
|
|
125
|
-
<SuggestedRow
|
|
126
|
-
key={item.path}
|
|
127
|
-
suggestion={item}
|
|
128
|
-
onAdd={handleAdd}
|
|
129
|
-
loading={importingPath === item.path}
|
|
130
|
-
/>
|
|
131
|
+
<SuggestedRow key={item.path} suggestion={item} onAdd={handleAdd} />
|
|
131
132
|
))}
|
|
132
133
|
</ul>
|
|
133
|
-
{importMutation.isError && (
|
|
134
|
-
<p className="mt-3 text-xs text-destructive">{importMutation.error.message}</p>
|
|
135
|
-
)}
|
|
136
134
|
</CollapsibleContent>
|
|
137
135
|
</Collapsible>
|
|
138
136
|
</section>
|
|
139
137
|
)}
|
|
138
|
+
|
|
139
|
+
{importFlow.choice && (
|
|
140
|
+
<ImportWorkspaceDialog
|
|
141
|
+
choice={importFlow.choice}
|
|
142
|
+
availability={setupInfo.data?.availability}
|
|
143
|
+
isPending={importFlow.isPending}
|
|
144
|
+
errorMessage={importFlow.error?.message}
|
|
145
|
+
onTypeChange={importFlow.selectType}
|
|
146
|
+
onSubmit={importFlow.submit}
|
|
147
|
+
onReset={importFlow.reset}
|
|
148
|
+
/>
|
|
149
|
+
)}
|
|
140
150
|
</div>
|
|
141
151
|
)
|
|
142
152
|
}
|
|
@@ -147,7 +157,8 @@ type WorkspaceCardProps = {
|
|
|
147
157
|
|
|
148
158
|
function WorkspaceCard({ workspace }: WorkspaceCardProps) {
|
|
149
159
|
const name = workspaceDisplayName(workspace)
|
|
150
|
-
const
|
|
160
|
+
const previewQuery = useWorkspacePreview(workspace.id)
|
|
161
|
+
const updatedAt = previewQuery.data?.updatedAt ?? new Date(workspace.addedAt).getTime()
|
|
151
162
|
|
|
152
163
|
return (
|
|
153
164
|
<Link
|
|
@@ -155,8 +166,8 @@ function WorkspaceCard({ workspace }: WorkspaceCardProps) {
|
|
|
155
166
|
className="group flex min-w-0 flex-col gap-4 rounded-xl bg-card p-2 shadow-xs transition-shadow hover:shadow-sm"
|
|
156
167
|
>
|
|
157
168
|
<WorkspacePreview workspaceId={workspace.id} />
|
|
158
|
-
<div className="flex min-w-0 flex-col px-2 pb-2">
|
|
159
|
-
<div className="flex min-w-0 items-center gap-
|
|
169
|
+
<div className="flex min-w-0 flex-col gap-2 px-2 pb-2">
|
|
170
|
+
<div className="flex min-w-0 items-center gap-1.5">
|
|
160
171
|
<img
|
|
161
172
|
src={workspace.icon ?? workspaceProviderIcon[workspace.type ?? 'claude-code']}
|
|
162
173
|
alt=""
|
|
@@ -164,10 +175,7 @@ function WorkspaceCard({ workspace }: WorkspaceCardProps) {
|
|
|
164
175
|
/>
|
|
165
176
|
<span className="truncate text-sm font-medium text-foreground">{name}</span>
|
|
166
177
|
</div>
|
|
167
|
-
<
|
|
168
|
-
{workspace.displayPath ?? workspace.path}
|
|
169
|
-
</div>
|
|
170
|
-
<div className="mt-2 text-xs text-muted-foreground">{meta}</div>
|
|
178
|
+
<span className="text-xs text-muted-foreground">{formatUpdatedAt(updatedAt)}</span>
|
|
171
179
|
</div>
|
|
172
180
|
</Link>
|
|
173
181
|
)
|
|
@@ -176,39 +184,34 @@ function WorkspaceCard({ workspace }: WorkspaceCardProps) {
|
|
|
176
184
|
type SuggestedRowProps = {
|
|
177
185
|
suggestion: DiscoveredWorkspace
|
|
178
186
|
onAdd: (suggestion: DiscoveredWorkspace) => void
|
|
179
|
-
loading: boolean
|
|
180
187
|
}
|
|
181
188
|
|
|
182
|
-
function SuggestedRow({ suggestion, onAdd
|
|
183
|
-
const { path,
|
|
189
|
+
function SuggestedRow({ suggestion, onAdd }: SuggestedRowProps) {
|
|
190
|
+
const { path, types } = suggestion
|
|
184
191
|
const name = workspaceDisplayName(suggestion)
|
|
185
192
|
return (
|
|
186
193
|
<li className="flex items-center gap-2 border-b border-border px-1 py-3">
|
|
187
|
-
<
|
|
194
|
+
<WorkspaceAgentIcons types={types} />
|
|
188
195
|
<span className="shrink-0 text-sm font-medium text-foreground">{name}</span>
|
|
189
196
|
<span title={path} className="min-w-0 flex-1 truncate text-xs text-muted-foreground">
|
|
190
197
|
{suggestion.displayPath ?? path}
|
|
191
198
|
</span>
|
|
192
|
-
<Button variant="outline" size="sm" onClick={() => onAdd(suggestion)}
|
|
193
|
-
{
|
|
194
|
-
<IconLoader2 stroke={1.75} className="animate-spin" />
|
|
195
|
-
) : (
|
|
196
|
-
<IconPlus stroke={1.75} />
|
|
197
|
-
)}
|
|
199
|
+
<Button variant="outline" size="sm" onClick={() => onAdd(suggestion)}>
|
|
200
|
+
<IconPlus stroke={1.75} />
|
|
198
201
|
Add
|
|
199
202
|
</Button>
|
|
200
203
|
</li>
|
|
201
204
|
)
|
|
202
205
|
}
|
|
203
206
|
|
|
204
|
-
function
|
|
205
|
-
const ms = Date.now() -
|
|
207
|
+
function formatUpdatedAt(timestamp: number): string {
|
|
208
|
+
const ms = Date.now() - timestamp
|
|
206
209
|
const mins = Math.floor(ms / 60000)
|
|
207
|
-
if (mins < 1) return '
|
|
208
|
-
if (mins < 60) return `
|
|
210
|
+
if (mins < 1) return 'Updated just now'
|
|
211
|
+
if (mins < 60) return `Updated ${mins} min${mins === 1 ? '' : 's'} ago`
|
|
209
212
|
const hours = Math.floor(mins / 60)
|
|
210
|
-
if (hours < 24) return `
|
|
213
|
+
if (hours < 24) return `Updated ${hours} hour${hours === 1 ? '' : 's'} ago`
|
|
211
214
|
const days = Math.floor(hours / 24)
|
|
212
|
-
if (days < 30) return `
|
|
213
|
-
return `
|
|
215
|
+
if (days < 30) return `Updated ${days} day${days === 1 ? '' : 's'} ago`
|
|
216
|
+
return `Updated ${new Date(timestamp).toLocaleDateString()}`
|
|
214
217
|
}
|
|
@@ -1,55 +1,196 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLayoutEffect, useRef, useState } from 'react'
|
|
2
2
|
|
|
3
|
-
import { useWorkspacePreview } from './api'
|
|
4
3
|
import { cn } from '@/client/lib/cn'
|
|
5
4
|
|
|
5
|
+
import { useWorkspacePreview } from './api'
|
|
6
|
+
|
|
6
7
|
type WorkspacePreviewProps = {
|
|
7
8
|
workspaceId: string
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const FOLDER = {
|
|
12
|
+
width: 320,
|
|
13
|
+
height: 160,
|
|
14
|
+
radius: 24,
|
|
15
|
+
topLeftRadius: 12,
|
|
16
|
+
bodyTop: 24,
|
|
17
|
+
tabEnd: 124,
|
|
18
|
+
shoulder: {
|
|
19
|
+
width: 48,
|
|
20
|
+
roundness: 20
|
|
21
|
+
}
|
|
22
|
+
} as const
|
|
23
|
+
|
|
24
|
+
function folderBackdropPath(horizontalRadiusScale: number): string {
|
|
25
|
+
const {
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
radius: radiusY,
|
|
29
|
+
topLeftRadius: topLeftRadiusY,
|
|
30
|
+
bodyTop,
|
|
31
|
+
tabEnd,
|
|
32
|
+
shoulder
|
|
33
|
+
} = FOLDER
|
|
34
|
+
const radiusX = Math.min(width / 2, radiusY * horizontalRadiusScale)
|
|
35
|
+
const topLeftRadiusX = Math.min(width / 2, topLeftRadiusY * horizontalRadiusScale)
|
|
36
|
+
const shoulderWidth = Math.max(0, shoulder.width)
|
|
37
|
+
const bodyStart = tabEnd + shoulderWidth
|
|
38
|
+
const roundness = Math.max(0, Math.min(shoulder.roundness, shoulderWidth / 2))
|
|
39
|
+
|
|
40
|
+
return [
|
|
41
|
+
`M ${topLeftRadiusX} 0`,
|
|
42
|
+
`H ${tabEnd}`,
|
|
43
|
+
`C ${tabEnd + roundness} 0 ${bodyStart - roundness} ${bodyTop} ${bodyStart} ${bodyTop}`,
|
|
44
|
+
`H ${width - radiusX}`,
|
|
45
|
+
`Q ${width} ${bodyTop} ${width} ${bodyTop + radiusY}`,
|
|
46
|
+
`V ${height - radiusY}`,
|
|
47
|
+
`Q ${width} ${height} ${width - radiusX} ${height}`,
|
|
48
|
+
`H ${radiusX}`,
|
|
49
|
+
`Q 0 ${height} 0 ${height - radiusY}`,
|
|
50
|
+
`V ${topLeftRadiusY}`,
|
|
51
|
+
`Q 0 0 ${topLeftRadiusX} 0`,
|
|
52
|
+
'Z'
|
|
53
|
+
].join(' ')
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function useFolderRadiusScale() {
|
|
57
|
+
const ref = useRef<HTMLDivElement>(null)
|
|
58
|
+
const [horizontalRadiusScale, setHorizontalRadiusScale] = useState(1)
|
|
59
|
+
|
|
60
|
+
useLayoutEffect(() => {
|
|
61
|
+
const element = ref.current
|
|
62
|
+
if (!element) return
|
|
63
|
+
|
|
64
|
+
const update = (width: number, height: number) => {
|
|
65
|
+
if (width <= 0 || height <= 0) return
|
|
66
|
+
const scaleX = width / FOLDER.width
|
|
67
|
+
const scaleY = height / FOLDER.height
|
|
68
|
+
const nextScale = scaleY / scaleX
|
|
69
|
+
setHorizontalRadiusScale(current =>
|
|
70
|
+
Math.abs(current - nextScale) < 0.001 ? current : nextScale
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const bounds = element.getBoundingClientRect()
|
|
75
|
+
update(bounds.width, bounds.height)
|
|
12
76
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
77
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
78
|
+
if (entry) update(entry.contentRect.width, entry.contentRect.height)
|
|
79
|
+
})
|
|
80
|
+
observer.observe(element)
|
|
81
|
+
return () => observer.disconnect()
|
|
82
|
+
}, [])
|
|
18
83
|
|
|
19
|
-
|
|
84
|
+
return { ref, horizontalRadiusScale }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Bottom-to-top placement for up to three widget screenshots. Each card peeks
|
|
88
|
+
// out of the folder at a slightly different angle and lifts on card hover.
|
|
89
|
+
const STACK = [
|
|
90
|
+
cn(
|
|
91
|
+
'opacity-40',
|
|
92
|
+
'-translate-x-3 translate-y-3 -rotate-6',
|
|
93
|
+
'group-hover:translate-y-2 group-focus-visible:translate-y-2'
|
|
94
|
+
),
|
|
95
|
+
cn(
|
|
96
|
+
'opacity-50',
|
|
97
|
+
'translate-x-3 translate-y-2 rotate-5',
|
|
98
|
+
'group-hover:translate-y-1 group-focus-visible:translate-y-1'
|
|
99
|
+
),
|
|
100
|
+
cn(
|
|
101
|
+
'opacity-100',
|
|
102
|
+
'-translate-x-1 translate-y-1 -rotate-2',
|
|
103
|
+
'group-hover:-translate-y-2 group-focus-visible:-translate-y-2'
|
|
104
|
+
)
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
export function WorkspacePreview({ workspaceId }: WorkspacePreviewProps) {
|
|
108
|
+
const query = useWorkspacePreview(workspaceId)
|
|
109
|
+
const thumbnails = query.data ? [...query.data.thumbnails].reverse() : []
|
|
110
|
+
const slots = STACK.slice(STACK.length - thumbnails.length)
|
|
111
|
+
const firstUserMessage = query.data?.firstUserMessage
|
|
112
|
+
const { ref, horizontalRadiusScale } = useFolderRadiusScale()
|
|
113
|
+
const backdropPath = folderBackdropPath(horizontalRadiusScale)
|
|
114
|
+
const noiseFilterId = `folder-noise-${workspaceId}`
|
|
20
115
|
|
|
21
116
|
return (
|
|
22
|
-
<div
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
117
|
+
<div ref={ref} className="relative h-40 w-full">
|
|
118
|
+
<svg
|
|
119
|
+
viewBox={`0 0 ${FOLDER.width} ${FOLDER.height}`}
|
|
120
|
+
preserveAspectRatio="none"
|
|
121
|
+
aria-hidden="true"
|
|
122
|
+
className="absolute inset-0 h-full w-full overflow-visible"
|
|
123
|
+
>
|
|
124
|
+
<defs>
|
|
125
|
+
<filter
|
|
126
|
+
id={noiseFilterId}
|
|
127
|
+
x="0%"
|
|
128
|
+
y="0%"
|
|
129
|
+
width="100%"
|
|
130
|
+
height="100%"
|
|
131
|
+
colorInterpolationFilters="sRGB"
|
|
132
|
+
>
|
|
133
|
+
<feTurbulence
|
|
134
|
+
type="fractalNoise"
|
|
135
|
+
baseFrequency="0.5"
|
|
136
|
+
numOctaves="3"
|
|
137
|
+
seed="7"
|
|
138
|
+
result="noise"
|
|
42
139
|
/>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
140
|
+
<feColorMatrix in="noise" type="saturate" values="0" result="monochromeNoise" />
|
|
141
|
+
<feComponentTransfer in="monochromeNoise" result="faintNoise">
|
|
142
|
+
<feFuncA type="linear" slope="0.24" />
|
|
143
|
+
</feComponentTransfer>
|
|
144
|
+
<feComposite in="faintNoise" in2="SourceAlpha" operator="in" result="clippedNoise" />
|
|
145
|
+
<feBlend in="SourceGraphic" in2="clippedNoise" mode="soft-light" />
|
|
146
|
+
</filter>
|
|
147
|
+
</defs>
|
|
148
|
+
<path
|
|
149
|
+
d={backdropPath}
|
|
150
|
+
filter={`url(#${noiseFilterId})`}
|
|
151
|
+
className="mask-[linear-gradient(to_bottom,rgba(0,0,0,0.5),black_40%)] fill-accent"
|
|
152
|
+
/>
|
|
153
|
+
</svg>
|
|
154
|
+
|
|
155
|
+
{thumbnails.map((src, index) => (
|
|
156
|
+
<img
|
|
157
|
+
key={index}
|
|
158
|
+
src={src}
|
|
159
|
+
alt=""
|
|
160
|
+
loading="lazy"
|
|
161
|
+
className={cn(
|
|
162
|
+
'absolute top-[12%] left-[14%] aspect-4/3 w-[72%] rounded-sm object-cover object-top shadow-xs',
|
|
163
|
+
'animate-in transition-transform duration-300 ease-out fade-in',
|
|
164
|
+
slots[index]
|
|
165
|
+
)}
|
|
51
166
|
/>
|
|
167
|
+
))}
|
|
168
|
+
|
|
169
|
+
{thumbnails.length === 0 && firstUserMessage && (
|
|
170
|
+
<div className="absolute inset-x-[12%] top-[20%] flex justify-end">
|
|
171
|
+
<div
|
|
172
|
+
aria-hidden="true"
|
|
173
|
+
className={cn(
|
|
174
|
+
'w-max max-w-40 origin-center rounded-sm bg-card px-3 py-2 shadow-xs',
|
|
175
|
+
'animate-in transition-transform duration-300 ease-out fade-in',
|
|
176
|
+
STACK[STACK.length - 1],
|
|
177
|
+
'group-hover:translate-y-0.5 group-focus-visible:translate-y-0.5'
|
|
178
|
+
)}
|
|
179
|
+
>
|
|
180
|
+
<p className="line-clamp-3 text-sm leading-normal whitespace-normal">
|
|
181
|
+
{firstUserMessage}
|
|
182
|
+
</p>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
52
185
|
)}
|
|
186
|
+
|
|
187
|
+
<div
|
|
188
|
+
className={cn(
|
|
189
|
+
'absolute inset-x-2 top-[40%] bottom-2 rounded-lg bg-accent',
|
|
190
|
+
'mask-[linear-gradient(to_bottom,rgba(0,0,0,0.9)_0%,black_50%)] backdrop-blur-lg',
|
|
191
|
+
'inset-shadow-[0_0_12px_color-mix(in_oklab,var(--background)_20%,transparent)]'
|
|
192
|
+
)}
|
|
193
|
+
/>
|
|
53
194
|
</div>
|
|
54
195
|
)
|
|
55
196
|
}
|
|
@@ -4,6 +4,7 @@ import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
|
4
4
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
5
5
|
import type {
|
|
6
6
|
DiscoveredWorkspace,
|
|
7
|
+
HarnessAvailability,
|
|
7
8
|
WorkspaceEntry,
|
|
8
9
|
WorkspacePreview,
|
|
9
10
|
WorkspaceType
|
|
@@ -43,37 +44,48 @@ export function useDiscoveredWorkspaces() {
|
|
|
43
44
|
})
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
export function
|
|
47
|
+
export function useImportWorkspace() {
|
|
47
48
|
const queryClient = useQueryClient()
|
|
48
|
-
return useMutation<WorkspaceEntry, Error,
|
|
49
|
-
mutationFn:
|
|
50
|
-
requestJson('/api/workspaces', jsonRequest('POST',
|
|
51
|
-
onSuccess: (entry,
|
|
49
|
+
return useMutation<WorkspaceEntry, Error, ImportWorkspaceInput>({
|
|
50
|
+
mutationFn: input =>
|
|
51
|
+
requestJson('/api/workspaces', jsonRequest('POST', input), 'Failed to add workspace'),
|
|
52
|
+
onSuccess: (entry, input) => {
|
|
52
53
|
queryClient.setQueryData<WorkspaceEntry[]>(workspaceKeys.all, previous =>
|
|
53
54
|
upsertWorkspaceEntry(previous, entry)
|
|
54
55
|
)
|
|
55
56
|
queryClient.setQueryData<DiscoveredWorkspace[]>(workspaceKeys.discover, previous =>
|
|
56
|
-
(previous ?? []).filter(item => item.path !==
|
|
57
|
+
(previous ?? []).filter(item => item.path !== input.path)
|
|
57
58
|
)
|
|
58
59
|
}
|
|
59
60
|
})
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
export type
|
|
63
|
+
export type ImportWorkspaceInput = {
|
|
64
|
+
path: string
|
|
65
|
+
type: WorkspaceType
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type WorkspaceSetupInfo = {
|
|
63
69
|
root: string
|
|
64
70
|
displayRoot: string
|
|
65
71
|
canChooseFolder: boolean
|
|
72
|
+
// Per-backend runtime availability (are the Claude/Codex CLIs installed?),
|
|
73
|
+
// keyed by workspace type. Missing entries mean available.
|
|
74
|
+
availability?: Partial<Record<WorkspaceType, HarnessAvailability>>
|
|
66
75
|
}
|
|
67
76
|
|
|
68
|
-
export function
|
|
69
|
-
return useQuery<
|
|
70
|
-
queryKey: workspaceKeys.
|
|
77
|
+
export function useWorkspaceSetupInfo() {
|
|
78
|
+
return useQuery<WorkspaceSetupInfo>({
|
|
79
|
+
queryKey: workspaceKeys.setupInfo,
|
|
80
|
+
// Availability can change while the app is open (the user installs the
|
|
81
|
+
// agent CLI) — refetch on mount instead of caching forever.
|
|
71
82
|
queryFn: () => requestJson('/api/workspaces/create'),
|
|
72
|
-
staleTime:
|
|
83
|
+
staleTime: 30_000,
|
|
84
|
+
refetchOnMount: 'always'
|
|
73
85
|
})
|
|
74
86
|
}
|
|
75
87
|
|
|
76
|
-
export type ChooseFolderResult =
|
|
88
|
+
export type ChooseFolderResult = DiscoveredWorkspace | { canceled: true }
|
|
77
89
|
|
|
78
90
|
export function useChooseFolder() {
|
|
79
91
|
return useMutation<ChooseFolderResult, Error, void>({
|