moi-computer 0.3.0-next.1 → 0.3.0-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/bunfig.toml +5 -1
- package/client/AGENTS.md +15 -0
- package/client/accept-hmr-dependencies.ts +22 -0
- package/client/api/http.ts +31 -0
- package/client/api/query-options.ts +6 -0
- package/client/api/workspace-keys.ts +17 -0
- package/client/app/AppRouter.tsx +35 -0
- package/client/app/routes/HomeRoute.tsx +13 -0
- package/client/app/routes/WorkspaceRoute.tsx +89 -0
- package/client/app/shell/SidebarLayout.tsx +191 -0
- package/client/assets.d.ts +9 -0
- package/client/components/playground/PixelPainter.tsx +10 -21
- package/client/components/playground/PlaygroundPage.tsx +9 -11
- package/client/components/playground/ToolCallsPage.tsx +9 -11
- package/client/components/{BottomPanel.tsx → shared/BottomPanel.tsx} +1 -1
- package/client/components/shared/PanelHeader.tsx +9 -0
- package/client/components/shared/ReorderableList.tsx +199 -0
- package/client/components/ui/button.tsx +10 -7
- package/client/components/ui/collapsible.tsx +15 -0
- package/client/components/ui/dialog.tsx +2 -2
- package/client/components/ui/dropdown-menu.tsx +5 -5
- package/client/components/ui/hover-card.tsx +1 -1
- package/client/components/ui/popover.tsx +1 -1
- package/client/components/ui/skeleton.tsx +13 -0
- package/client/components/ui/tooltip.tsx +1 -1
- package/client/externalize-react.ts +7 -1
- package/client/{components → features/applets}/WidgetErrorBoundary.tsx +1 -1
- package/client/{components → features/applets}/WidgetShell.tsx +1 -1
- package/client/{hooks → features/applets}/useApplet.ts +6 -7
- package/client/{components/ChatInput.tsx → features/chat/ChatComposer.tsx} +29 -23
- package/client/features/chat/ChatPanel.tsx +188 -0
- package/client/{components → features/chat}/ChatPopup.tsx +23 -12
- package/client/{components → features/chat}/MarkdownContent.tsx +1 -1
- package/client/{components → features/chat}/ModelPicker.tsx +68 -17
- package/client/{components → features/chat}/ThreadSelector.tsx +11 -9
- package/client/{components → features/chat}/TurnView.tsx +16 -9
- package/client/features/chat/api.ts +78 -0
- package/client/features/chat/chat-connection.ts +107 -0
- package/client/features/chat/chat-frames.ts +131 -0
- package/client/{lib → features/chat}/preview-turn.ts +1 -1
- package/client/{components → features/chat}/tool-group/ReadImagePreview.tsx +1 -1
- package/client/{components → features/chat}/tool-group/SubagentCard.tsx +12 -10
- package/client/{components → features/chat}/tool-group/TimelineRow.tsx +5 -5
- package/client/{components → features/chat}/tool-group/ToolCallGroup.tsx +12 -4
- package/client/{components → features/chat}/tool-group/ToolOutput.tsx +12 -18
- package/client/{hooks → features/chat}/useChat.ts +7 -11
- package/client/features/connectors/ConnectorsPage.tsx +92 -0
- package/client/features/connectors/McpMenu.tsx +162 -0
- package/client/features/connectors/api.ts +28 -0
- package/client/features/home/CreateWorkspaceDialog.tsx +224 -0
- package/client/features/home/HomePage.tsx +220 -0
- package/client/{components → features/home}/WorkspacePreview.tsx +2 -2
- package/client/features/home/api.ts +148 -0
- package/client/features/home/workspace-presentation.tsx +44 -0
- package/client/features/scratchpad/Scratchpad.tsx +312 -0
- package/client/features/scratchpad/ScratchpadControls.tsx +503 -0
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +115 -0
- package/client/features/settings/EnvironmentSettings.tsx +149 -0
- package/client/features/settings/GeneralSettings.tsx +90 -0
- package/client/{components → features}/settings/IconPicker.tsx +73 -222
- package/client/features/settings/SettingsLayout.tsx +53 -0
- package/client/{components → features}/settings/WorkspaceSettings.tsx +12 -16
- package/client/features/settings/api.ts +88 -0
- package/client/features/settings/icon-picker-options.ts +161 -0
- package/client/{hooks → features/settings}/useEnvVars.ts +4 -4
- package/client/{components → features/widgets}/HiddenPanel.tsx +3 -3
- package/client/{components → features/widgets}/WidgetFrame.tsx +3 -8
- package/client/{components → features/widgets}/WidgetGrid.tsx +2 -9
- package/client/features/widgets/Widgets.tsx +215 -0
- package/client/{lib/grid-pack.ts → features/widgets/grid.ts} +7 -1
- package/client/{hooks → features/widgets}/useGridReconcile.ts +1 -1
- package/client/{components → features/workspace}/CustomizePanel.tsx +5 -6
- package/client/{lib → features/workspace}/WorkspaceLayoutContext.tsx +15 -8
- package/client/features/workspace/WorkspaceScreen.tsx +536 -0
- package/client/features/workspace/WorkspaceTabs.tsx +205 -0
- package/client/features/workspace/api.ts +56 -0
- package/client/features/workspace/useFitsSplitLayout.ts +37 -0
- package/client/global.d.ts +5 -0
- package/client/index.css +6 -10
- package/client/index.html +1 -1
- package/client/index.tsx +14 -31
- package/client/main.tsx +2 -2
- package/client/runtime/hmr-watchdog.ts +39 -0
- package/client/{hooks/useMeiEvents.ts → runtime/useWorkspaceEvents.ts} +9 -6
- package/client/store/ui.ts +5 -1
- package/client/theme.css +0 -2
- package/dist/chunk-11cab5dq.css +1 -0
- package/dist/chunk-23cgr1tz.css +1 -0
- package/dist/chunk-3hy3qy6d.js +10 -0
- package/dist/chunk-c4j722at.js +546 -0
- package/dist/chunk-dyfaffyz.js +119 -0
- package/dist/chunk-kpe40hm8.js +1 -0
- package/dist/chunk-p68fnz3q.js +2 -0
- package/dist/chunk-pcnahct1.js +5 -0
- package/dist/chunk-tqd3pkg8.css +1 -0
- package/dist/chunk-ty6dvda0.js +1 -0
- package/dist/index.html +2 -2
- package/lib/types.ts +18 -7
- package/lib/workspace-name.ts +14 -0
- package/package.json +3 -2
- package/server/api.ts +119 -14
- package/server/cli.ts +11 -5
- package/server/layout.ts +38 -7
- package/server/mcp.ts +72 -15
- package/server/moi-scaffold.ts +55 -10
- package/server/registry.ts +16 -0
- package/server/web.ts +1 -0
- package/server/workspace-init.ts +5 -19
- package/tsconfig.json +1 -1
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +1 -1
- package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +1 -1
- package/client/api/workspaces.ts +0 -427
- package/client/components/App.tsx +0 -41
- package/client/components/ChatPanel.tsx +0 -275
- package/client/components/HomePage.tsx +0 -17
- package/client/components/McpMenu.tsx +0 -125
- package/client/components/Scratchpad.tsx +0 -935
- package/client/components/Widgets.tsx +0 -132
- package/client/components/WorkspacesPage.tsx +0 -245
- package/client/components/layout/SidebarLayout.tsx +0 -258
- package/client/components/routes/workspace/[id].tsx +0 -675
- package/client/components/routes/workspace/create.tsx +0 -155
- package/client/components/settings/SettingsPages.tsx +0 -255
- package/client/hooks/useFitsSidebar.ts +0 -34
- package/client/lib/connection.ts +0 -238
- package/dist/chunk-07qf2tv1.css +0 -1
- package/dist/chunk-w18801vn.js +0 -672
- /package/client/components/{playground → shared}/LedLogo.tsx +0 -0
- /package/client/{lib → features/applets}/applet-cache.ts +0 -0
- /package/client/{components → features/chat}/ShimmerText.tsx +0 -0
- /package/client/{store/live.ts → features/chat/chat-store.ts} +0 -0
- /package/client/{lib → features/chat}/group-turns.ts +0 -0
- /package/client/{components → features/chat}/tool-group/CodeBlock.tsx +0 -0
- /package/client/{components → features/chat}/tool-group/Collapse.tsx +0 -0
- /package/client/{components → features/chat}/tool-group/detect.ts +0 -0
- /package/client/{components → features/chat}/tool-group/fixtures.ts +0 -0
- /package/client/{components → features/chat}/tool-group/format.ts +0 -0
- /package/client/{components → features/chat}/tool-group/index.ts +0 -0
- /package/client/{lib → features/chat}/uploads.ts +0 -0
- /package/client/{hooks → features/chat}/useStickToBottom.ts +0 -0
- /package/client/{components → features/connectors}/IconMcp.tsx +0 -0
- /package/client/{lib → features/connectors}/mcp-icons.ts +0 -0
- /package/client/{lib → features/scratchpad}/scratch-executor.ts +0 -0
- /package/client/{lib → features/settings}/render-icon.ts +0 -0
- /package/client/{lib → features/workspace}/WorkspaceContext.tsx +0 -0
- /package/client/{hooks → features/workspace}/useWorkspaceTheme.ts +0 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { QueryClient } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
|
+
import { wsUrl } from '@/client/lib/ws-url'
|
|
4
|
+
import { liveStore } from '@/client/features/chat/chat-store'
|
|
5
|
+
import { reduceChatFrame } from '@/client/features/chat/chat-frames'
|
|
6
|
+
import type { ClientMessage } from '@/lib/types'
|
|
7
|
+
|
|
8
|
+
// App-wide chat connection: ONE WebSocket for the whole client, opened once at
|
|
9
|
+
// startup and never torn down on navigation. Every server frame is tagged with
|
|
10
|
+
// `workspaceId`, so a single socket serves every workspace and the client routes
|
|
11
|
+
// each frame to the right `(workspaceId, sessionId)` slice — live transcript
|
|
12
|
+
// deltas into the React Query cache, status/error/rename into the live store.
|
|
13
|
+
//
|
|
14
|
+
// Socket identity is tracked by a monotonic `generation`: each socket captures
|
|
15
|
+
// the generation at creation and every callback bails if it's no longer current,
|
|
16
|
+
// so a delayed close/open from a superseded socket can't corrupt live state.
|
|
17
|
+
|
|
18
|
+
let qc: QueryClient | null = null
|
|
19
|
+
let socket: WebSocket | null = null
|
|
20
|
+
let generation = 0
|
|
21
|
+
let reconnectTimer: ReturnType<typeof setTimeout> | null = null
|
|
22
|
+
const queue: ClientMessage[] = []
|
|
23
|
+
let onWorkspaceSwitch: ((workspaceId: string) => void) | null = null
|
|
24
|
+
let sweepTimer: ReturnType<typeof setInterval> | null = null
|
|
25
|
+
|
|
26
|
+
// TTL backstop for live previews. Every clear path (turn arrival, run end,
|
|
27
|
+
// reconnect) is exact and should fire first; this only reaps a preview whose
|
|
28
|
+
// clear was somehow missed, so it can be generous.
|
|
29
|
+
const PREVIEW_TTL_MS = 15_000
|
|
30
|
+
|
|
31
|
+
export function initConnection(queryClient: QueryClient) {
|
|
32
|
+
qc = queryClient
|
|
33
|
+
if (!sweepTimer) {
|
|
34
|
+
sweepTimer = setInterval(
|
|
35
|
+
() => liveStore.getState().sweepPreviews(PREVIEW_TTL_MS, Date.now()),
|
|
36
|
+
5_000
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
if (socket) return // already connected (mount/StrictMode re-invoke safety)
|
|
40
|
+
connect()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function connect() {
|
|
44
|
+
const myGen = ++generation
|
|
45
|
+
if (reconnectTimer) {
|
|
46
|
+
clearTimeout(reconnectTimer)
|
|
47
|
+
reconnectTimer = null
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const s = new WebSocket(wsUrl('/ws'))
|
|
51
|
+
socket = s
|
|
52
|
+
|
|
53
|
+
s.onopen = () => {
|
|
54
|
+
if (generation !== myGen) {
|
|
55
|
+
s.close()
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
for (const m of queue) s.send(JSON.stringify(m))
|
|
59
|
+
queue.length = 0
|
|
60
|
+
// Heal any deltas missed while disconnected: refetch every live transcript.
|
|
61
|
+
// No-op on the first connect (nothing cached yet).
|
|
62
|
+
qc?.invalidateQueries({ queryKey: ['workspaces', 'events'] })
|
|
63
|
+
// Any in-flight preview from before the drop is superseded by that refetch
|
|
64
|
+
// (which returns the authoritative disk state) — drop them all so a frozen
|
|
65
|
+
// half-streamed preview can't linger over the healed transcript.
|
|
66
|
+
liveStore.getState().clearAllPreviews()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
s.onmessage = e => {
|
|
70
|
+
if (generation !== myGen) return
|
|
71
|
+
let data: unknown
|
|
72
|
+
try {
|
|
73
|
+
data = JSON.parse(e.data)
|
|
74
|
+
} catch {
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
handleFrame(data as Record<string, unknown>)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
s.onclose = () => {
|
|
81
|
+
if (generation !== myGen) return
|
|
82
|
+
socket = null
|
|
83
|
+
reconnectTimer = setTimeout(connect, 1000)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
s.onerror = () => s.close()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function handleFrame(data: Record<string, unknown>) {
|
|
90
|
+
reduceChatFrame(data, { queryClient: qc, sendMessage, onWorkspaceSwitch })
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function sendMessage(msg: ClientMessage) {
|
|
94
|
+
if (socket && socket.readyState === WebSocket.OPEN) socket.send(JSON.stringify(msg))
|
|
95
|
+
else queue.push(msg)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function setWorkspaceSwitchHandler(fn: ((workspaceId: string) => void) | null) {
|
|
99
|
+
onWorkspaceSwitch = fn
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Test seam: inject the QueryClient the frame handler reads, without opening a
|
|
103
|
+
// socket (the browser-only `connect()` path). Production always goes through
|
|
104
|
+
// `initConnection`.
|
|
105
|
+
export function __setQueryClientForTests(client: QueryClient | null) {
|
|
106
|
+
qc = client
|
|
107
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { QueryClient } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
4
|
+
import { getScratchExecutor } from '@/client/features/scratchpad/scratch-executor'
|
|
5
|
+
import { liveStore } from '@/client/features/chat/chat-store'
|
|
6
|
+
import { applyEvent } from '@/lib/format'
|
|
7
|
+
import type {
|
|
8
|
+
ClientMessage,
|
|
9
|
+
PreviewFrame,
|
|
10
|
+
ScratchOp,
|
|
11
|
+
StreamEvent,
|
|
12
|
+
ThreadConfig,
|
|
13
|
+
ViewState
|
|
14
|
+
} from '@/lib/types'
|
|
15
|
+
|
|
16
|
+
type ChatFrameContext = {
|
|
17
|
+
queryClient: QueryClient | null
|
|
18
|
+
sendMessage: (message: ClientMessage) => void
|
|
19
|
+
onWorkspaceSwitch: ((workspaceId: string) => void) | null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function reduceChatFrame(data: Record<string, unknown>, context: ChatFrameContext) {
|
|
23
|
+
const { queryClient, sendMessage, onWorkspaceSwitch } = context
|
|
24
|
+
const store = liveStore.getState()
|
|
25
|
+
|
|
26
|
+
if (data.type === 'status_snapshot') {
|
|
27
|
+
store.reconcileProcessing(
|
|
28
|
+
(data.running as { workspaceId: string; sessionId: string }[] | undefined) ?? []
|
|
29
|
+
)
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
if (data.type === 'status') {
|
|
33
|
+
const workspaceId = data.workspaceId as string
|
|
34
|
+
const sessionId = data.sessionId as string
|
|
35
|
+
const processing = data.processing as boolean
|
|
36
|
+
store.setProcessing(workspaceId, sessionId, processing)
|
|
37
|
+
if (!processing) store.clearPreviewsForSession(workspaceId, sessionId)
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
if (data.type === 'preview') {
|
|
41
|
+
const frame = data as unknown as PreviewFrame
|
|
42
|
+
const key = workspaceKeys.events(frame.workspaceId, frame.sessionId)
|
|
43
|
+
if (queryClient?.getQueryData(key) === undefined) return
|
|
44
|
+
store.setPreview({
|
|
45
|
+
workspaceId: frame.workspaceId,
|
|
46
|
+
sessionId: frame.sessionId,
|
|
47
|
+
messageId: frame.messageId,
|
|
48
|
+
parentToolUseId: frame.parentToolUseId,
|
|
49
|
+
blocks: frame.blocks
|
|
50
|
+
})
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
if (data.type === 'session_renamed') {
|
|
54
|
+
const workspaceId = data.workspaceId as string
|
|
55
|
+
const from = data.from as string
|
|
56
|
+
const to = data.to as string
|
|
57
|
+
store.renameSession(workspaceId, from, to)
|
|
58
|
+
|
|
59
|
+
const previousView = queryClient?.getQueryData<ViewState>(
|
|
60
|
+
workspaceKeys.events(workspaceId, from)
|
|
61
|
+
)
|
|
62
|
+
if (previousView !== undefined) {
|
|
63
|
+
queryClient?.setQueryData(workspaceKeys.events(workspaceId, to), previousView)
|
|
64
|
+
queryClient?.removeQueries({ queryKey: workspaceKeys.events(workspaceId, from) })
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const previousConfig = queryClient?.getQueryData<ThreadConfig>(
|
|
68
|
+
workspaceKeys.threadConfig(workspaceId, from)
|
|
69
|
+
)
|
|
70
|
+
if (previousConfig !== undefined) {
|
|
71
|
+
queryClient?.setQueryData(workspaceKeys.threadConfig(workspaceId, to), previousConfig)
|
|
72
|
+
queryClient?.removeQueries({ queryKey: workspaceKeys.threadConfig(workspaceId, from) })
|
|
73
|
+
}
|
|
74
|
+
queryClient?.invalidateQueries({ queryKey: workspaceKeys.sessions(workspaceId) })
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
if (data.type === 'workspace:switch') {
|
|
78
|
+
onWorkspaceSwitch?.(data.workspaceId as string)
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
if (data.type === 'scratchpad:op') {
|
|
82
|
+
const run = getScratchExecutor(data.workspaceId as string)
|
|
83
|
+
if (!run) return
|
|
84
|
+
const opId = data.opId as string
|
|
85
|
+
run(data.op as ScratchOp).then(
|
|
86
|
+
result => sendMessage({ type: 'scratchpad:op-result', opId, result }),
|
|
87
|
+
error =>
|
|
88
|
+
sendMessage({
|
|
89
|
+
type: 'scratchpad:op-result',
|
|
90
|
+
opId,
|
|
91
|
+
error: error instanceof Error ? error.message : String(error)
|
|
92
|
+
})
|
|
93
|
+
)
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const workspaceId = data.workspaceId as string | undefined
|
|
98
|
+
const sessionId = data.sessionId as string | undefined
|
|
99
|
+
if (!workspaceId || !sessionId) return
|
|
100
|
+
const kind = data.kind
|
|
101
|
+
|
|
102
|
+
if (kind === 'snapshot' || kind === 'turn' || kind === 'notice' || kind === 'result') {
|
|
103
|
+
patchView(queryClient, workspaceId, sessionId, data as unknown as StreamEvent)
|
|
104
|
+
if (kind === 'turn') {
|
|
105
|
+
const messageId = (data as unknown as { turn?: { meta?: { apiMessageId?: string } } }).turn
|
|
106
|
+
?.meta?.apiMessageId
|
|
107
|
+
if (messageId) store.clearPreview(messageId)
|
|
108
|
+
}
|
|
109
|
+
if (kind === 'result') store.clearPreviewsForSession(workspaceId, sessionId)
|
|
110
|
+
}
|
|
111
|
+
if (kind === 'error' && typeof data.content === 'string') {
|
|
112
|
+
store.setError(workspaceId, sessionId, data.content)
|
|
113
|
+
store.clearPreviewsForSession(workspaceId, sessionId)
|
|
114
|
+
}
|
|
115
|
+
if (kind === 'stopped') {
|
|
116
|
+
store.setProcessing(workspaceId, sessionId, false)
|
|
117
|
+
store.clearPreviewsForSession(workspaceId, sessionId)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function patchView(
|
|
122
|
+
queryClient: QueryClient | null,
|
|
123
|
+
workspaceId: string,
|
|
124
|
+
sessionId: string,
|
|
125
|
+
event: StreamEvent
|
|
126
|
+
) {
|
|
127
|
+
const queryKey = workspaceKeys.events(workspaceId, sessionId)
|
|
128
|
+
const existing = queryClient?.getQueryData<ViewState>(queryKey)
|
|
129
|
+
if (existing === undefined) return
|
|
130
|
+
queryClient?.setQueryData<ViewState>(queryKey, applyEvent(existing, event))
|
|
131
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// its finalized form groups); a preview with text stands alone as its own turn.
|
|
6
6
|
// The moment the real turn lands, the preview is cleared and the real turn takes
|
|
7
7
|
// its place in the same pipeline, so the swap is seamless.
|
|
8
|
-
import type { LivePreview } from '@/client/store
|
|
8
|
+
import type { LivePreview } from '@/client/features/chat/chat-store'
|
|
9
9
|
import type { Part, PreviewBlock, Turn } from '@/lib/types'
|
|
10
10
|
|
|
11
11
|
// Stable id for the synthetic live turn — keeps React's key steady across deltas
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
|
|
3
|
-
import { useWorkspaceId } from '@/client/
|
|
3
|
+
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
4
4
|
import type { ToolCall } from '@/lib/types'
|
|
5
5
|
|
|
6
6
|
// Image extensions the server's preview route can render (see server/preview.ts).
|
|
@@ -6,17 +6,16 @@
|
|
|
6
6
|
// sub-timeline, then its final summary. The `subagent` record
|
|
7
7
|
// (progress/status/usage/transcript) is built live from `task_*` events and isn't
|
|
8
8
|
// persisted, so a finished/replayed call shows only the header.
|
|
9
|
-
import { useEffect, useState } from 'react'
|
|
9
|
+
import { type ReactNode, useEffect, useState } from 'react'
|
|
10
10
|
|
|
11
11
|
import { IconPlayBasketball, IconPlayFootball, IconPlayVolleyball } from '@tabler/icons-react'
|
|
12
12
|
|
|
13
|
-
import { ShimmerText } from '@/client/
|
|
13
|
+
import { ShimmerText } from '@/client/features/chat/ShimmerText'
|
|
14
14
|
import { cn } from '@/client/lib/cn'
|
|
15
|
-
import type { ToolCall } from '@/lib/types'
|
|
15
|
+
import type { Part, ToolCall } from '@/lib/types'
|
|
16
16
|
|
|
17
17
|
import { Collapse } from './Collapse'
|
|
18
18
|
import { NodeBox, type RowPosition, RowChevron, TimelineRow } from './TimelineRow'
|
|
19
|
-
import { ToolCallGroup } from './ToolCallGroup'
|
|
20
19
|
import { formatDuration } from './format'
|
|
21
20
|
|
|
22
21
|
// While a subagent runs, its node cycles through "playing sport" glyphs — a
|
|
@@ -36,8 +35,13 @@ function RunningSportNode() {
|
|
|
36
35
|
)
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
type SubagentCardProps = RowPosition & {
|
|
40
|
-
|
|
38
|
+
type SubagentCardProps = RowPosition & {
|
|
39
|
+
call: ToolCall
|
|
40
|
+
cwd: string | null
|
|
41
|
+
renderNestedParts: (parts: Part[], cwd: string | null) => ReactNode
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function SubagentCard({ call, cwd, isFirst, isLast, renderNestedParts }: SubagentCardProps) {
|
|
41
45
|
const [open, setOpen] = useState(false)
|
|
42
46
|
const sub = call.subagent
|
|
43
47
|
const input = (call.input ?? {}) as { description?: string }
|
|
@@ -94,7 +98,7 @@ export function SubagentCard({ call, cwd, isFirst, isLast }: SubagentCardProps)
|
|
|
94
98
|
{formatDuration(durationMs)}
|
|
95
99
|
</span>
|
|
96
100
|
)}
|
|
97
|
-
{status === 'failed' && <span className="shrink-0 text-xs text-
|
|
101
|
+
{status === 'failed' && <span className="shrink-0 text-xs text-destructive">✗</span>}
|
|
98
102
|
{status === 'stopped' && (
|
|
99
103
|
<span className="shrink-0 text-xs text-muted-foreground">✗</span>
|
|
100
104
|
)}
|
|
@@ -112,9 +116,7 @@ export function SubagentCard({ call, cwd, isFirst, isLast }: SubagentCardProps)
|
|
|
112
116
|
summary, so a steps-only card has no trailing border. */}
|
|
113
117
|
<div className="mt-1 mb-1 overflow-hidden rounded-md border border-border">
|
|
114
118
|
{nestedParts.length > 0 && (
|
|
115
|
-
<div className="py-1.5 pr-2 pl-3">
|
|
116
|
-
<ToolCallGroup parts={nestedParts} cwd={cwd} />
|
|
117
|
-
</div>
|
|
119
|
+
<div className="py-1.5 pr-2 pl-3">{renderNestedParts(nestedParts, cwd)}</div>
|
|
118
120
|
)}
|
|
119
121
|
{summary && (
|
|
120
122
|
<div
|
|
@@ -8,7 +8,7 @@ import type { ReactNode } from 'react'
|
|
|
8
8
|
import { IconChevronRight, IconLoader2, IconPackage } from '@tabler/icons-react'
|
|
9
9
|
import { motion } from 'motion/react'
|
|
10
10
|
|
|
11
|
-
import { IconMcp } from '@/client/
|
|
11
|
+
import { IconMcp } from '@/client/features/connectors/IconMcp'
|
|
12
12
|
import { cn } from '@/client/lib/cn'
|
|
13
13
|
|
|
14
14
|
// Where a row sits in the group — drives which rail segments to draw so the rule
|
|
@@ -59,14 +59,14 @@ export function TimelineRow({
|
|
|
59
59
|
) : loading ? (
|
|
60
60
|
// A spinner node stands in for the dot; bg-background carves the rule.
|
|
61
61
|
<span className="absolute top-[15px] left-1/2 z-10 flex -translate-x-1/2 -translate-y-1/2 rounded-full bg-background p-0.5">
|
|
62
|
-
<IconLoader2 size={
|
|
62
|
+
<IconLoader2 size={12} stroke={1.75} className="animate-spin text-ring" />
|
|
63
63
|
</span>
|
|
64
64
|
) : (
|
|
65
65
|
// Background-colored ring carves a gap in the rule around the dot.
|
|
66
66
|
<span
|
|
67
67
|
className={cn(
|
|
68
68
|
'absolute top-[15px] left-1/2 z-10 size-[5px] -translate-x-1/2 -translate-y-1/2 rounded-full ring-3 ring-background',
|
|
69
|
-
isError ? 'bg-
|
|
69
|
+
isError ? 'bg-destructive' : 'bg-border'
|
|
70
70
|
)}
|
|
71
71
|
/>
|
|
72
72
|
)}
|
|
@@ -90,7 +90,7 @@ export function RowChevron({ open }: { open: boolean }) {
|
|
|
90
90
|
open ? 'opacity-100' : 'opacity-0 group-hover/row:opacity-100'
|
|
91
91
|
)}
|
|
92
92
|
>
|
|
93
|
-
<IconChevronRight size={12} stroke={
|
|
93
|
+
<IconChevronRight size={12} stroke={1.75} />
|
|
94
94
|
</motion.span>
|
|
95
95
|
)
|
|
96
96
|
}
|
|
@@ -117,7 +117,7 @@ export function NodeBox({ children, className }: { children: ReactNode; classNam
|
|
|
117
117
|
export function IconMarker({
|
|
118
118
|
icon: Icon,
|
|
119
119
|
size = 12,
|
|
120
|
-
stroke = 1.
|
|
120
|
+
stroke = 1.75
|
|
121
121
|
}: {
|
|
122
122
|
icon: typeof IconPackage
|
|
123
123
|
size?: number
|
|
@@ -15,7 +15,7 @@ import { type ReactNode, useState } from 'react'
|
|
|
15
15
|
import { IconLoader2, IconPackage } from '@tabler/icons-react'
|
|
16
16
|
|
|
17
17
|
import { cn } from '@/client/lib/cn'
|
|
18
|
-
import { formatMcpServerName, getMcpIcon } from '@/client/
|
|
18
|
+
import { formatMcpServerName, getMcpIcon } from '@/client/features/connectors/mcp-icons'
|
|
19
19
|
import type { Part, ToolCall } from '@/lib/types'
|
|
20
20
|
|
|
21
21
|
import { Collapse } from './Collapse'
|
|
@@ -113,7 +113,7 @@ function ToolRow({ isFirst, isLast, call, leading, marker, name, brief, preview
|
|
|
113
113
|
{/* Dotted rows spin at the node instead; only icon (MCP) rows, whose
|
|
114
114
|
node can't spin, keep a header spinner. */}
|
|
115
115
|
{isRunning && marker && (
|
|
116
|
-
<IconLoader2 size={12} stroke={1.
|
|
116
|
+
<IconLoader2 size={12} stroke={1.75} className="shrink-0 animate-spin text-ring" />
|
|
117
117
|
)}
|
|
118
118
|
{hasBody && <RowChevron open={open} />}
|
|
119
119
|
</button>
|
|
@@ -170,7 +170,15 @@ function ReasoningRow({ isFirst, isLast, text, inProgress = false }: ReasoningRo
|
|
|
170
170
|
type ToolCallCardProps = RowPosition & { call: ToolCall; cwd: string | null }
|
|
171
171
|
function ToolCallCard({ call, cwd, isFirst, isLast }: ToolCallCardProps) {
|
|
172
172
|
if (call.caller === 'subagent') {
|
|
173
|
-
return
|
|
173
|
+
return (
|
|
174
|
+
<SubagentCard
|
|
175
|
+
call={call}
|
|
176
|
+
cwd={cwd}
|
|
177
|
+
isFirst={isFirst}
|
|
178
|
+
isLast={isLast}
|
|
179
|
+
renderNestedParts={(parts, nestedCwd) => <ToolCallGroup parts={parts} cwd={nestedCwd} />}
|
|
180
|
+
/>
|
|
181
|
+
)
|
|
174
182
|
}
|
|
175
183
|
if (call.name === 'Skill' && call.skill) {
|
|
176
184
|
// On success, swap the timeline dot for a package icon node (same box as the
|
|
@@ -181,7 +189,7 @@ function ToolCallCard({ call, cwd, isFirst, isLast }: ToolCallCardProps) {
|
|
|
181
189
|
isFirst={isFirst}
|
|
182
190
|
isLast={isLast}
|
|
183
191
|
call={call}
|
|
184
|
-
marker={succeeded ? <IconMarker icon={IconPackage} size={
|
|
192
|
+
marker={succeeded ? <IconMarker icon={IconPackage} size={16} stroke={1.75} /> : undefined}
|
|
185
193
|
name="Loading Skill"
|
|
186
194
|
brief={call.skill.skillName}
|
|
187
195
|
/>
|
|
@@ -5,6 +5,7 @@ import { IconCheck, IconCopy } from '@tabler/icons-react'
|
|
|
5
5
|
import { cn } from '@/client/lib/cn'
|
|
6
6
|
import type { ToolCall } from '@/lib/types'
|
|
7
7
|
|
|
8
|
+
import { Button } from '@/client/components/ui/button'
|
|
8
9
|
import { CodeBlock } from './CodeBlock'
|
|
9
10
|
import { detectOutput } from './detect'
|
|
10
11
|
import { formatBytes } from './format'
|
|
@@ -29,14 +30,14 @@ export function ToolOutput({ call, output, isError }: ToolOutputProps) {
|
|
|
29
30
|
<div
|
|
30
31
|
className={cn(
|
|
31
32
|
'rounded-md border',
|
|
32
|
-
isError ? 'border-
|
|
33
|
+
isError ? 'border-destructive/30 bg-destructive/10' : 'border-border bg-muted'
|
|
33
34
|
)}
|
|
34
35
|
>
|
|
35
36
|
<pre
|
|
36
37
|
className={cn(
|
|
37
38
|
PRE,
|
|
38
39
|
'break-all whitespace-pre-wrap',
|
|
39
|
-
isError ? 'text-
|
|
40
|
+
isError ? 'text-destructive' : 'text-muted-foreground'
|
|
40
41
|
)}
|
|
41
42
|
>
|
|
42
43
|
{output || '(empty)'}
|
|
@@ -84,19 +85,15 @@ function Header({ raw, onRaw, label, size, copyText }: HeaderProps) {
|
|
|
84
85
|
return (
|
|
85
86
|
<div className="flex items-center gap-1 border-b border-border px-2 py-1">
|
|
86
87
|
{options.map(([value, text]) => (
|
|
87
|
-
<
|
|
88
|
+
<Button
|
|
88
89
|
key={text}
|
|
89
90
|
type="button"
|
|
91
|
+
variant={raw === value ? 'outline' : 'ghost'}
|
|
92
|
+
size="sm"
|
|
90
93
|
onClick={() => onRaw(value)}
|
|
91
|
-
className={cn(
|
|
92
|
-
'rounded-md px-1.5 py-0.5 text-[10px] font-medium tracking-wide uppercase transition-colors',
|
|
93
|
-
raw === value
|
|
94
|
-
? 'bg-background text-foreground shadow-[inset_0_0_0_1px_var(--border)]'
|
|
95
|
-
: 'text-muted-foreground hover:text-foreground'
|
|
96
|
-
)}
|
|
97
94
|
>
|
|
98
95
|
{text}
|
|
99
|
-
</
|
|
96
|
+
</Button>
|
|
100
97
|
))}
|
|
101
98
|
<div className="flex-1" />
|
|
102
99
|
<span className="text-[10px] font-medium text-muted-foreground tabular-nums">{size}</span>
|
|
@@ -123,17 +120,14 @@ function CopyButton({ text }: { text: string }) {
|
|
|
123
120
|
}
|
|
124
121
|
|
|
125
122
|
return (
|
|
126
|
-
<
|
|
123
|
+
<Button
|
|
127
124
|
type="button"
|
|
125
|
+
variant="ghost"
|
|
126
|
+
size="icon-sm"
|
|
128
127
|
onClick={copy}
|
|
129
128
|
aria-label={copied ? 'Copied' : 'Copy'}
|
|
130
|
-
className="flex size-5 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground"
|
|
131
129
|
>
|
|
132
|
-
{copied ?
|
|
133
|
-
|
|
134
|
-
) : (
|
|
135
|
-
<IconCopy size={13} stroke={1.5} />
|
|
136
|
-
)}
|
|
137
|
-
</button>
|
|
130
|
+
{copied ? <IconCheck stroke={1.75} /> : <IconCopy stroke={1.75} />}
|
|
131
|
+
</Button>
|
|
138
132
|
)
|
|
139
133
|
}
|
|
@@ -2,18 +2,14 @@ import { useCallback, useMemo } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { useQueryClient } from '@tanstack/react-query'
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from '@/client/api/workspaces'
|
|
11
|
-
import { useWorkspaceId } from '@/client/lib/WorkspaceContext'
|
|
12
|
-
import { useWorkspaceLayoutCtx } from '@/client/lib/WorkspaceLayoutContext'
|
|
13
|
-
import { sendMessage } from '@/client/lib/connection'
|
|
5
|
+
import { useSessionView, useThreadConfig, useWorkspaceModels } from '@/client/features/chat/api'
|
|
6
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
7
|
+
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
8
|
+
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
9
|
+
import { sendMessage } from '@/client/features/chat/chat-connection'
|
|
14
10
|
import { STREAM_RESPONSES } from '@/client/lib/flags'
|
|
15
|
-
import { buildPreviewTurn } from '@/client/
|
|
16
|
-
import { draftKey, liveStore, selectPreviews, useLive } from '@/client/store
|
|
11
|
+
import { buildPreviewTurn } from '@/client/features/chat/preview-turn'
|
|
12
|
+
import { draftKey, liveStore, selectPreviews, useLive } from '@/client/features/chat/chat-store'
|
|
17
13
|
import { applyEvent, emptyViewState } from '@/lib/format'
|
|
18
14
|
import type { Part, ViewState } from '@/lib/types'
|
|
19
15
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { IconPlugConnected } from '@tabler/icons-react'
|
|
2
|
+
|
|
3
|
+
import { useUserMcp } from './api'
|
|
4
|
+
import { McpServerCard, sortMcpServers } from '@/client/features/connectors/McpMenu'
|
|
5
|
+
import { SidebarLayout } from '@/client/app/shell/SidebarLayout'
|
|
6
|
+
import { Button } from '@/client/components/ui/button'
|
|
7
|
+
import { Skeleton } from '@/client/components/ui/skeleton'
|
|
8
|
+
|
|
9
|
+
const CONNECTOR_SKELETONS = Array.from({ length: 6 }, (_, index) => index)
|
|
10
|
+
|
|
11
|
+
export function ConnectorsPage() {
|
|
12
|
+
return (
|
|
13
|
+
<SidebarLayout panel="flat">
|
|
14
|
+
<div className="min-h-0 flex-1 overflow-y-auto">
|
|
15
|
+
<UserConnectorsPage />
|
|
16
|
+
</div>
|
|
17
|
+
</SidebarLayout>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function UserConnectorsPage() {
|
|
22
|
+
const connectorsQuery = useUserMcp()
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className="mx-auto w-full max-w-3xl px-8 pt-14 pb-16">
|
|
26
|
+
<div className="mb-4 flex items-center justify-between gap-2">
|
|
27
|
+
<h1 className="text-sm font-medium text-foreground">Connectors</h1>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<ConnectorsContent connectorsQuery={connectorsQuery} />
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type ConnectorsContentProps = {
|
|
36
|
+
connectorsQuery: ReturnType<typeof useUserMcp>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function ConnectorsContent({ connectorsQuery }: ConnectorsContentProps) {
|
|
40
|
+
if (connectorsQuery.isPending) {
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
role="status"
|
|
44
|
+
aria-label="Loading connectors"
|
|
45
|
+
className="grid grid-cols-1 gap-3 sm:grid-cols-2"
|
|
46
|
+
>
|
|
47
|
+
{CONNECTOR_SKELETONS.map(index => (
|
|
48
|
+
<div
|
|
49
|
+
key={index}
|
|
50
|
+
className="flex min-h-20 items-center gap-3 rounded-xl border border-border bg-card px-4 py-3"
|
|
51
|
+
>
|
|
52
|
+
<Skeleton className="size-10 shrink-0 rounded-sm" />
|
|
53
|
+
<div className="flex min-w-0 flex-1 flex-col gap-2">
|
|
54
|
+
<Skeleton className="h-4 w-36" />
|
|
55
|
+
<Skeleton className="h-3 w-20" />
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
))}
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (connectorsQuery.isError) {
|
|
64
|
+
return (
|
|
65
|
+
<div className="flex min-h-48 flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-border px-8 py-12 text-center">
|
|
66
|
+
<p className="text-sm text-muted-foreground">Could not load connectors.</p>
|
|
67
|
+
<Button variant="outline" size="sm" onClick={() => connectorsQuery.refetch()}>
|
|
68
|
+
Retry
|
|
69
|
+
</Button>
|
|
70
|
+
</div>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const connectors = sortMcpServers(connectorsQuery.data)
|
|
75
|
+
|
|
76
|
+
if (connectors.length === 0) {
|
|
77
|
+
return (
|
|
78
|
+
<div className="flex min-h-48 flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-border px-8 py-12 text-center">
|
|
79
|
+
<IconPlugConnected size={24} stroke={1.5} className="text-muted-foreground" />
|
|
80
|
+
<p className="mx-auto max-w-md text-sm text-foreground">No user connectors configured.</p>
|
|
81
|
+
</div>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
|
87
|
+
{connectors.map(connector => (
|
|
88
|
+
<McpServerCard key={connector.name} server={connector} />
|
|
89
|
+
))}
|
|
90
|
+
</div>
|
|
91
|
+
)
|
|
92
|
+
}
|