moi-computer 0.7.0 → 0.8.1-next.0
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/README.md +2 -2
- package/client/api/workspace-keys.ts +1 -2
- package/client/app/AppRouter.tsx +10 -3
- package/client/app/routes/HomeRoute.tsx +1 -1
- package/client/app/shell/SidebarLayout.tsx +2 -14
- package/client/components/shared/BottomPanel.tsx +2 -1
- package/client/components/shared/Composer.tsx +20 -7
- package/client/components/shared/PanelHeader.tsx +8 -1
- package/client/components/ui/button.tsx +3 -3
- package/client/components/ui/dialog.tsx +1 -1
- package/client/components/ui/dropdown-menu.tsx +2 -2
- package/client/components/ui/hover-card.tsx +1 -1
- package/client/components/ui/popover.tsx +1 -1
- package/client/components/ui/resizable.tsx +40 -0
- package/client/features/applets/AppletMount.tsx +9 -22
- package/client/features/applets/applet-cache.ts +7 -0
- package/client/features/applets/applet-styles.ts +21 -1
- package/client/features/applets/useApplet.ts +1 -1
- package/client/features/chat/ChatEmptyState.tsx +9 -11
- package/client/features/chat/ChatPanel.tsx +76 -48
- package/client/features/chat/ChatPopup.tsx +16 -2
- package/client/features/chat/ChatPromptBubbles.tsx +6 -8
- package/client/features/chat/ChatSelector.tsx +25 -8
- package/client/features/chat/ModelPicker.tsx +5 -4
- package/client/features/chat/TurnView.tsx +108 -13
- package/client/features/chat/api.ts +1 -18
- package/client/features/chat/chat-send.ts +2 -2
- package/client/features/chat/{ChatComposer.tsx → composer/ChatComposer.tsx} +24 -9
- package/client/features/chat/composer/banners/ChatErrorBanner.tsx +28 -0
- package/client/features/chat/composer/banners/ComposerBanner.tsx +30 -0
- package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +91 -0
- package/client/features/{workspace → chat/composer/banners}/WorkspaceSkillUpdateBanner.tsx +9 -7
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +74 -0
- package/client/features/{workspace → chat/composer}/useWorkspaceSkillUpdates.ts +1 -1
- package/client/features/chat/group-turns.ts +46 -28
- package/client/features/chat/interleave-notices.ts +84 -0
- package/client/features/chat/model-order.ts +9 -3
- package/client/features/chat/tool-group/TimelineRow.tsx +23 -11
- package/client/features/chat/tool-group/ToolCallGroup.tsx +38 -3
- package/client/features/chat/tool-group/format.ts +23 -7
- package/client/features/chat/useAppletChatMessage.ts +11 -16
- package/client/features/chat/useChat.ts +3 -7
- package/client/features/dev/ChatStatesPage.tsx +428 -0
- package/client/features/dev/DevIndexPage.tsx +52 -0
- package/client/features/dev/DevRoutes.tsx +6 -3
- package/client/features/dev/HarnessDebugPage.tsx +3 -3
- package/client/features/dev/chat-states-fixtures.ts +744 -0
- package/client/features/home/api.ts +0 -10
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +21 -64
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +1 -1
- package/client/features/scratchpad/Scratchpad.tsx +5 -3
- package/client/features/scratchpad/scratch-session.ts +71 -0
- package/client/features/views/ViewBuilderTab.tsx +5 -4
- package/client/features/views/ViewManager.tsx +258 -0
- package/client/features/views/useViewBuilderActions.ts +2 -2
- package/client/features/views/view-residency.ts +77 -0
- package/client/features/widgets/WidgetFrame.tsx +6 -2
- package/client/features/workspace/CustomizePanel.tsx +40 -24
- package/client/features/workspace/WorkspaceLayoutContext.tsx +12 -2
- package/client/features/workspace/WorkspaceScreen.tsx +131 -201
- package/client/features/workspace/WorkspaceSplitLayout.tsx +111 -0
- package/client/features/workspace/WorkspaceTabs.tsx +1 -1
- package/client/features/workspace/api.ts +33 -8
- package/client/features/workspace/useFitsSplitLayout.ts +31 -5
- package/client/index.css +5 -2
- package/client/lib/flags.ts +4 -3
- package/client/runtime/useWorkspaceEvents.ts +18 -1
- package/client/runtime/workspace-theme.ts +29 -10
- package/client/store/ui.ts +5 -1
- package/client/theme.css +96 -6
- package/dist/{chunk-0pcdwjkp.js → chunk-2vaafjp4.js} +1 -1
- package/dist/{chunk-9y2zbzqz.js → chunk-35fq49qa.js} +1 -1
- package/dist/chunk-gny990qx.css +1 -0
- package/dist/chunk-gt7n06ef.js +1 -0
- package/dist/{chunk-rxvx4ta9.js → chunk-kkj86722.js} +75 -75
- package/dist/chunk-n7pga5x3.js +80 -0
- package/dist/chunk-xeyxk7ep.js +10 -0
- package/dist/{chunk-w3tnv51j.js → chunk-xzx7c9hq.js} +1 -1
- package/dist/index.html +1 -1
- package/lib/format.ts +17 -1
- package/lib/themes.ts +123 -51
- package/lib/types.ts +40 -13
- package/lib/workspace-layout.ts +2 -2
- package/package.json +6 -4
- package/server/agent.ts +199 -0
- package/server/api.ts +38 -90
- package/server/bundler/build-applet.ts +7 -4
- package/server/cli.ts +46 -15
- package/server/control.ts +13 -6
- package/server/env-apply.ts +4 -0
- package/server/harness/README.md +28 -12
- package/server/harness/claude-code/auth.ts +54 -0
- package/server/harness/claude-code/index.ts +6 -1
- package/server/harness/codex/adapter.ts +9 -1
- package/server/harness/codex/auth.ts +50 -0
- package/server/harness/codex/index.ts +6 -1
- package/server/harness/codex/session.ts +33 -14
- package/server/harness/openclaw/NOTES.md +518 -187
- package/server/harness/openclaw/adapter.ts +125 -31
- package/server/harness/openclaw/compat.ts +99 -0
- package/server/harness/openclaw/cron-view.ts +78 -0
- package/server/harness/openclaw/discovery.ts +145 -52
- package/server/harness/openclaw/gateway.ts +224 -36
- package/server/harness/openclaw/index.ts +56 -21
- package/server/harness/openclaw/session.ts +971 -55
- package/server/harness/openclaw/strip.ts +87 -15
- package/server/harness/openclaw/thinking.ts +198 -0
- package/server/harness/types.ts +10 -5
- package/server/layout.ts +5 -2
- package/server/moi-scaffold.ts +1 -1
- package/server/registry.ts +0 -20
- package/server/theme.ts +24 -27
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +100 -53
- package/workspace/.claude/skills/moi-workspace/SKILL.md +10 -12
- package/client/features/dev/PixelPainter.tsx +0 -94
- package/client/features/dev/PlaygroundPage.tsx +0 -69
- package/dist/chunk-175bm057.js +0 -27
- package/dist/chunk-55sh4dty.js +0 -2
- package/dist/chunk-afgbg75t.js +0 -50
- package/dist/chunk-agtetn7n.css +0 -1
- package/dist/chunk-dfs36zgc.js +0 -1
- package/dist/chunk-exj6hr30.js +0 -9
- package/dist/chunk-m11ckkxd.js +0 -51
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { lazy, Suspense, useEffect, useState } from 'react'
|
|
2
2
|
|
|
3
|
-
import { AnimatePresence
|
|
3
|
+
import { AnimatePresence } from 'motion/react'
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
IconArticle,
|
|
@@ -15,9 +15,7 @@ import { IconGhost } from '@/client/components/shared/IconGhost'
|
|
|
15
15
|
import { ChatPanel } from '@/client/features/chat/ChatPanel'
|
|
16
16
|
import { ChatPopup } from '@/client/features/chat/ChatPopup'
|
|
17
17
|
import { CustomizePanel } from '@/client/features/workspace/CustomizePanel'
|
|
18
|
-
import { AppletMount } from '@/client/features/applets/AppletMount'
|
|
19
18
|
import { useAppletEvent } from '@/client/features/applets/applet-runtime'
|
|
20
|
-
import { WidgetErrorBoundary } from '@/client/features/applets/WidgetErrorBoundary'
|
|
21
19
|
import { Widgets } from '@/client/features/widgets/Widgets'
|
|
22
20
|
import { PanelHeader } from '@/client/components/shared/PanelHeader'
|
|
23
21
|
import { workspaceProviderIcon } from '@/client/features/home/workspace-presentation'
|
|
@@ -26,20 +24,17 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/
|
|
|
26
24
|
import { WorkspaceSettings } from '@/client/features/settings/WorkspaceSettings'
|
|
27
25
|
import { useAppletChatMessage } from '@/client/features/chat/useAppletChatMessage'
|
|
28
26
|
import { useChat } from '@/client/features/chat/useChat'
|
|
29
|
-
import { useView } from '@/client/features/applets/useApplet'
|
|
30
27
|
import { ViewBuilderTab } from '@/client/features/views/ViewBuilderTab'
|
|
28
|
+
import { ViewManager } from '@/client/features/views/ViewManager'
|
|
31
29
|
import { useViewBuilderActions } from '@/client/features/views/useViewBuilderActions'
|
|
32
30
|
import { useFitsSplitLayout } from '@/client/features/workspace/useFitsSplitLayout'
|
|
33
|
-
import {
|
|
34
|
-
import { WorkspaceSkillUpdateBanner } from '@/client/features/workspace/WorkspaceSkillUpdateBanner'
|
|
35
|
-
import { useWorkspaceSkillUpdates } from '@/client/features/workspace/useWorkspaceSkillUpdates'
|
|
31
|
+
import { useWorkspaceComposerState } from '@/client/features/chat/composer/useWorkspaceComposerState'
|
|
36
32
|
import { useWorkspaceTheme } from '@/client/runtime/workspace-theme'
|
|
37
33
|
import {
|
|
38
34
|
hasRunningWorkspaceActivity,
|
|
39
35
|
isSessionRunning,
|
|
40
36
|
useLive
|
|
41
37
|
} from '@/client/features/chat/chat-store'
|
|
42
|
-
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
43
38
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
44
39
|
import {
|
|
45
40
|
effectiveOpenTabs,
|
|
@@ -64,6 +59,8 @@ import {
|
|
|
64
59
|
viewTabId
|
|
65
60
|
} from '@/lib/workspace-tabs'
|
|
66
61
|
|
|
62
|
+
import { WorkspaceSplitLayout } from './WorkspaceSplitLayout'
|
|
63
|
+
|
|
67
64
|
const Scratchpad = lazy(() =>
|
|
68
65
|
import('@/client/features/scratchpad/Scratchpad').then(module => ({
|
|
69
66
|
default: module.Scratchpad
|
|
@@ -81,83 +78,22 @@ function viewIcon(view: ViewInfo, builders: ViewBuilder[]) {
|
|
|
81
78
|
}
|
|
82
79
|
|
|
83
80
|
type SectionControlsProps = {
|
|
84
|
-
mode: LayoutMode
|
|
85
81
|
onToggleMode: () => void
|
|
86
82
|
}
|
|
87
83
|
|
|
88
|
-
//
|
|
89
|
-
function SectionControls({
|
|
90
|
-
const fullscreen = mode === 'fullscreen'
|
|
84
|
+
// Full-screen workspace action: open the chat as a docked split column.
|
|
85
|
+
function SectionControls({ onToggleMode }: SectionControlsProps) {
|
|
91
86
|
return (
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
type ViewAppProps = {
|
|
104
|
-
view: ViewInfo
|
|
105
|
-
// The view's addressable state, read from navigation state (focusTab /
|
|
106
|
-
// `moi tab focus`). `{}` on a fresh mount, a new browser tab, or a plain
|
|
107
|
-
// tab-bar click — the view must render sensibly with that.
|
|
108
|
-
params: Record<string, unknown>
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// A view — an agent-defined app — mounted full-area. The bundle owns its own
|
|
112
|
-
// layout + scroll, so we give it a plain filled box and fade it in (mirroring
|
|
113
|
-
// WidgetShell, but full-area instead of a grid cell).
|
|
114
|
-
function ViewApp({ view, params }: ViewAppProps) {
|
|
115
|
-
const workspaceId = useWorkspaceId()
|
|
116
|
-
const bundle = useView(view.id)
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<div className="relative min-h-0 flex-1 overflow-hidden">
|
|
120
|
-
<AnimatePresence mode="wait" initial={false}>
|
|
121
|
-
{bundle.status === 'ready' && (
|
|
122
|
-
<AppletMount
|
|
123
|
-
asChild
|
|
124
|
-
segment="views"
|
|
125
|
-
name={view.id}
|
|
126
|
-
version={bundle.version}
|
|
127
|
-
key={bundle.version}
|
|
128
|
-
>
|
|
129
|
-
<motion.div
|
|
130
|
-
className="absolute inset-0 overflow-auto"
|
|
131
|
-
initial={{ opacity: 0, filter: 'blur(4px)' }}
|
|
132
|
-
animate={{ opacity: 1, filter: 'blur(0px)' }}
|
|
133
|
-
exit={{ opacity: 0, filter: 'blur(4px)' }}
|
|
134
|
-
transition={{ duration: 0.3, ease: 'easeInOut' }}
|
|
135
|
-
>
|
|
136
|
-
<WidgetErrorBoundary
|
|
137
|
-
name={view.id}
|
|
138
|
-
kind="view"
|
|
139
|
-
workspaceId={workspaceId}
|
|
140
|
-
resetKey={bundle.version}
|
|
141
|
-
>
|
|
142
|
-
<bundle.Component params={params} />
|
|
143
|
-
</WidgetErrorBoundary>
|
|
144
|
-
</motion.div>
|
|
145
|
-
</AppletMount>
|
|
146
|
-
)}
|
|
147
|
-
{bundle.status === 'error' && (
|
|
148
|
-
<motion.p
|
|
149
|
-
key={`err-${bundle.version}`}
|
|
150
|
-
className="absolute inset-0 p-4 text-xs text-destructive"
|
|
151
|
-
initial={{ opacity: 0 }}
|
|
152
|
-
animate={{ opacity: 1 }}
|
|
153
|
-
exit={{ opacity: 0 }}
|
|
154
|
-
transition={{ duration: 0.3, ease: 'easeInOut' }}
|
|
155
|
-
>
|
|
156
|
-
{bundle.error}
|
|
157
|
-
</motion.p>
|
|
158
|
-
)}
|
|
159
|
-
</AnimatePresence>
|
|
160
|
-
</div>
|
|
87
|
+
<Tooltip>
|
|
88
|
+
<TooltipTrigger
|
|
89
|
+
render={
|
|
90
|
+
<Button variant="ghost" size="icon-sm" onClick={onToggleMode} aria-label="Dock agent">
|
|
91
|
+
<IconLayoutSidebarRight stroke={1.75} />
|
|
92
|
+
</Button>
|
|
93
|
+
}
|
|
94
|
+
/>
|
|
95
|
+
<TooltipContent>Dock agent</TooltipContent>
|
|
96
|
+
</Tooltip>
|
|
161
97
|
)
|
|
162
98
|
}
|
|
163
99
|
|
|
@@ -263,17 +199,17 @@ function applyVisibleTabOrder(
|
|
|
263
199
|
|
|
264
200
|
export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenProps) {
|
|
265
201
|
const { layout, setLayout, name, icon, provider, workspaceId } = useWorkspaceLayoutCtx()
|
|
266
|
-
// Keep the composer read/write, but block sends when its agent executable is
|
|
267
|
-
// missing. The Send button explains how to install it.
|
|
268
|
-
const availability = useWorkspaceAvailability(workspaceId).data
|
|
269
|
-
const { bannerProps: skillUpdateBanner } = useWorkspaceSkillUpdates(workspaceId)
|
|
270
|
-
const unavailableReason =
|
|
271
|
-
availability === undefined ? undefined : availability.available ? null : availability.reason
|
|
272
202
|
const builderActions = useViewBuilderActions()
|
|
273
|
-
const {
|
|
203
|
+
const {
|
|
204
|
+
ref: rowRef,
|
|
205
|
+
fits: canUseSplit,
|
|
206
|
+
constraints: splitLayoutConstraints
|
|
207
|
+
} = useFitsSplitLayout<HTMLDivElement>()
|
|
274
208
|
const [widgetMode, setWidgetMode] = useState<WidgetMode>('idle')
|
|
275
209
|
const [floatingChatOpen, setFloatingChatOpen] = useState(false)
|
|
276
210
|
const [chatFocusRequest, setChatFocusRequest] = useState(0)
|
|
211
|
+
const dockedChatWidth = useUiStore(state => state.dockedChatWidth)
|
|
212
|
+
const setDockedChatWidth = useUiStore(state => state.setDockedChatWidth)
|
|
277
213
|
const sessionActivity = useLive(state => state.activity)
|
|
278
214
|
const hasRunningSession = hasRunningWorkspaceActivity(sessionActivity, workspaceId)
|
|
279
215
|
|
|
@@ -315,6 +251,10 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
315
251
|
selectSession,
|
|
316
252
|
dismissError
|
|
317
253
|
} = useChat({ activeTab, appletParams })
|
|
254
|
+
const { composerBanner, composerAvailability } = useWorkspaceComposerState(workspaceId, {
|
|
255
|
+
chatError: error,
|
|
256
|
+
onDismissChatError: dismissError
|
|
257
|
+
})
|
|
318
258
|
|
|
319
259
|
const openSet = new Set(tabsState.open)
|
|
320
260
|
|
|
@@ -479,7 +419,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
479
419
|
// Chat messages fired from applet UI. `openChat` is the reveal: on a view tab
|
|
480
420
|
// in full-screen mode the chat is a closed popover, and a run the user can't
|
|
481
421
|
// see is worse than a panel that opens itself.
|
|
482
|
-
useAppletChatMessage({ send, revealChat: openChat,
|
|
422
|
+
useAppletChatMessage({ send, revealChat: openChat, composerAvailability })
|
|
483
423
|
|
|
484
424
|
const createItems: CreateWorkspaceTabItem[] = [
|
|
485
425
|
...(!dockedSplit && !openSet.has('agent')
|
|
@@ -559,15 +499,13 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
559
499
|
previewTurn={previewTurn}
|
|
560
500
|
sessionId={sessionId}
|
|
561
501
|
processing={processing}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
composerBanner={
|
|
565
|
-
skillUpdateBanner ? <WorkspaceSkillUpdateBanner {...skillUpdateBanner} /> : undefined
|
|
566
|
-
}
|
|
567
|
-
unavailableReason={unavailableReason}
|
|
502
|
+
composerBanner={composerBanner}
|
|
503
|
+
composerAvailability={composerAvailability}
|
|
568
504
|
send={send}
|
|
569
505
|
stop={stop}
|
|
570
506
|
onSelectSession={selectSession}
|
|
507
|
+
onClose={() => setMode('fullscreen')}
|
|
508
|
+
docked
|
|
571
509
|
/>
|
|
572
510
|
)
|
|
573
511
|
|
|
@@ -580,112 +518,110 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
580
518
|
previewTurn={previewTurn}
|
|
581
519
|
sessionId={sessionId}
|
|
582
520
|
processing={processing}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
composerBanner={
|
|
586
|
-
skillUpdateBanner ? <WorkspaceSkillUpdateBanner {...skillUpdateBanner} /> : undefined
|
|
587
|
-
}
|
|
588
|
-
unavailableReason={unavailableReason}
|
|
521
|
+
composerBanner={composerBanner}
|
|
522
|
+
composerAvailability={composerAvailability}
|
|
589
523
|
send={send}
|
|
590
524
|
stop={stop}
|
|
591
525
|
onSelectSession={selectSession}
|
|
592
526
|
/>
|
|
593
527
|
)
|
|
594
528
|
|
|
595
|
-
|
|
596
|
-
<div
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
/>
|
|
653
|
-
) : activeTab === 'scratchpad' ? (
|
|
654
|
-
<Suspense fallback={null}>
|
|
655
|
-
<Scratchpad />
|
|
656
|
-
</Suspense>
|
|
657
|
-
) : activeBuilder ? (
|
|
658
|
-
<ViewBuilderTab
|
|
659
|
-
key={activeBuilder.id}
|
|
660
|
-
builder={activeBuilder}
|
|
661
|
-
unavailableReason={unavailableReason}
|
|
662
|
-
onSave={requirements => builderActions.save(activeBuilder.id, requirements)}
|
|
663
|
-
onSubmit={requirements => {
|
|
664
|
-
if (mode === 'fullscreen') setFloatingChatOpen(true)
|
|
665
|
-
return builderActions.submit(activeBuilder, requirements)
|
|
666
|
-
}}
|
|
667
|
-
onOpenChat={() => {
|
|
668
|
-
selectSession(activeBuilder.sessionId)
|
|
669
|
-
openChat()
|
|
670
|
-
}}
|
|
671
|
-
onDiscard={() => discardBuilder(activeBuilder)}
|
|
672
|
-
/>
|
|
673
|
-
) : activeView ? (
|
|
674
|
-
<ViewApp view={activeView} params={appletParams} />
|
|
675
|
-
) : null}
|
|
529
|
+
const workspacePanel = (
|
|
530
|
+
<div
|
|
531
|
+
className={cn(
|
|
532
|
+
'flex h-full min-h-0 min-w-0 flex-1 flex-col-reverse overflow-hidden bg-background shadow-xs transition-[border-radius]',
|
|
533
|
+
mode === 'split' && 'rounded-xl'
|
|
534
|
+
)}
|
|
535
|
+
>
|
|
536
|
+
{activeTab === 'agent' ? (
|
|
537
|
+
tabbedChat
|
|
538
|
+
) : activeTab === 'widgets' ? (
|
|
539
|
+
<Widgets
|
|
540
|
+
editing={widgetMode === 'editing'}
|
|
541
|
+
onEditingChange={editing => setWidgetMode(editing ? 'editing' : 'idle')}
|
|
542
|
+
widgets={widgets}
|
|
543
|
+
onCreateWidget={() => {
|
|
544
|
+
selectSession(null)
|
|
545
|
+
openChat('Create widget')
|
|
546
|
+
}}
|
|
547
|
+
/>
|
|
548
|
+
) : activeTab === 'scratchpad' ? (
|
|
549
|
+
<Suspense fallback={null}>
|
|
550
|
+
<Scratchpad />
|
|
551
|
+
</Suspense>
|
|
552
|
+
) : activeBuilder ? (
|
|
553
|
+
<ViewBuilderTab
|
|
554
|
+
key={activeBuilder.id}
|
|
555
|
+
builder={activeBuilder}
|
|
556
|
+
composerAvailability={composerAvailability}
|
|
557
|
+
onSave={requirements => builderActions.save(activeBuilder.id, requirements)}
|
|
558
|
+
onSubmit={requirements => {
|
|
559
|
+
if (mode === 'fullscreen') setFloatingChatOpen(true)
|
|
560
|
+
return builderActions.submit(activeBuilder, requirements)
|
|
561
|
+
}}
|
|
562
|
+
onOpenChat={() => {
|
|
563
|
+
selectSession(activeBuilder.sessionId)
|
|
564
|
+
openChat()
|
|
565
|
+
}}
|
|
566
|
+
onDiscard={() => discardBuilder(activeBuilder)}
|
|
567
|
+
/>
|
|
568
|
+
) : null}
|
|
569
|
+
|
|
570
|
+
{/* Views are not part of the chain above: ViewManager keeps them
|
|
571
|
+
mounted across tab switches (and collapses to nothing while
|
|
572
|
+
another tab is on screen), which is what makes a switch back
|
|
573
|
+
instant. It stays with the content, so the header below it in
|
|
574
|
+
the DOM keeps painting over both. */}
|
|
575
|
+
<ViewManager views={views} activeViewId={activeView?.id ?? null} params={appletParams} />
|
|
576
|
+
|
|
577
|
+
<PanelHeader>
|
|
578
|
+
<div className="flex min-w-0 flex-1 items-center gap-4">
|
|
579
|
+
<div className="flex items-center gap-2">
|
|
580
|
+
<img
|
|
581
|
+
src={icon ?? workspaceProviderIcon[provider ?? 'claude-code']}
|
|
582
|
+
alt=""
|
|
583
|
+
className="size-5 shrink-0 rounded-xs"
|
|
584
|
+
/>
|
|
585
|
+
{name && <span className="truncate text-sm font-medium text-foreground">{name}</span>}
|
|
676
586
|
</div>
|
|
677
|
-
|
|
587
|
+
<WorkspaceTabs
|
|
588
|
+
tabs={tabItems}
|
|
589
|
+
active={activeTab}
|
|
590
|
+
createItems={createItems}
|
|
591
|
+
onSelect={openTab}
|
|
592
|
+
onClose={closeTab}
|
|
593
|
+
onReorder={reorderTabs}
|
|
594
|
+
/>
|
|
595
|
+
</div>
|
|
596
|
+
<div className="flex shrink-0 items-center gap-1">
|
|
597
|
+
<WorkspaceCustomizeAction
|
|
598
|
+
active={widgetMode === 'customizing'}
|
|
599
|
+
onToggle={() => setWidgetMode(widgetMode === 'customizing' ? 'idle' : 'customizing')}
|
|
600
|
+
/>
|
|
601
|
+
<WorkspaceSettings />
|
|
602
|
+
{hasWorkspaceContent && canUseSplit && mode === 'fullscreen' && (
|
|
603
|
+
<SectionControls onToggleMode={() => setMode('split')} />
|
|
604
|
+
)}
|
|
605
|
+
</div>
|
|
606
|
+
</PanelHeader>
|
|
607
|
+
</div>
|
|
608
|
+
)
|
|
678
609
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
{
|
|
688
|
-
|
|
610
|
+
return (
|
|
611
|
+
<div className="relative flex h-full min-h-0 flex-col font-sans text-foreground">
|
|
612
|
+
<div ref={rowRef} className="flex min-h-0 flex-1">
|
|
613
|
+
{hasWorkspaceContent && canUseSplit && splitLayoutConstraints ? (
|
|
614
|
+
<WorkspaceSplitLayout
|
|
615
|
+
{...splitLayoutConstraints}
|
|
616
|
+
workspace={workspacePanel}
|
|
617
|
+
chat={dockedChat}
|
|
618
|
+
open={mode === 'split'}
|
|
619
|
+
chatWidth={dockedChatWidth}
|
|
620
|
+
onCollapse={() => setMode('fullscreen')}
|
|
621
|
+
onChatWidthChange={setDockedChatWidth}
|
|
622
|
+
/>
|
|
623
|
+
) : (
|
|
624
|
+
workspacePanel
|
|
689
625
|
)}
|
|
690
626
|
</div>
|
|
691
627
|
|
|
@@ -713,14 +649,8 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
713
649
|
previewTurn={previewTurn}
|
|
714
650
|
sessionId={sessionId}
|
|
715
651
|
processing={processing}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
composerBanner={
|
|
719
|
-
skillUpdateBanner ? (
|
|
720
|
-
<WorkspaceSkillUpdateBanner {...skillUpdateBanner} />
|
|
721
|
-
) : undefined
|
|
722
|
-
}
|
|
723
|
-
unavailableReason={unavailableReason}
|
|
652
|
+
composerBanner={composerBanner}
|
|
653
|
+
composerAvailability={composerAvailability}
|
|
724
654
|
send={send}
|
|
725
655
|
stop={stop}
|
|
726
656
|
onSelectSession={selectSession}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { useLayoutEffect, useRef, useState } from 'react'
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
3
|
+
import type { PanelImperativeHandle } from 'react-resizable-panels'
|
|
4
|
+
|
|
5
|
+
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '../../components/ui/resizable'
|
|
6
|
+
import { cn } from '../../lib/cn'
|
|
7
|
+
|
|
8
|
+
import type { WorkspaceSplitLayoutConstraints } from './useFitsSplitLayout'
|
|
9
|
+
|
|
10
|
+
type WorkspaceSplitLayoutProps = WorkspaceSplitLayoutConstraints & {
|
|
11
|
+
workspace: ReactNode
|
|
12
|
+
chat: ReactNode
|
|
13
|
+
open: boolean
|
|
14
|
+
chatWidth: number
|
|
15
|
+
onCollapse: () => void
|
|
16
|
+
onChatWidthChange: (width: number) => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function WorkspaceSplitLayout({
|
|
20
|
+
workspace,
|
|
21
|
+
chat,
|
|
22
|
+
open,
|
|
23
|
+
workspaceMinWidth,
|
|
24
|
+
chatMinWidth,
|
|
25
|
+
chatMaxWidth,
|
|
26
|
+
chatWidth,
|
|
27
|
+
onCollapse,
|
|
28
|
+
onChatWidthChange
|
|
29
|
+
}: WorkspaceSplitLayoutProps) {
|
|
30
|
+
const chatPanelRef = useRef<PanelImperativeHandle>(null)
|
|
31
|
+
const transitionFrameRef = useRef<number | null>(null)
|
|
32
|
+
const [transitionsEnabled, setTransitionsEnabled] = useState(false)
|
|
33
|
+
const openChatWidth = Math.min(Math.max(chatWidth, chatMinWidth), chatMaxWidth)
|
|
34
|
+
const defaultChatSize = useRef(open ? openChatWidth : 0).current
|
|
35
|
+
|
|
36
|
+
useLayoutEffect(() => {
|
|
37
|
+
const chatPanel = chatPanelRef.current
|
|
38
|
+
if (!chatPanel) return
|
|
39
|
+
|
|
40
|
+
if (open) {
|
|
41
|
+
chatPanel.resize(openChatWidth)
|
|
42
|
+
} else {
|
|
43
|
+
chatPanel.collapse()
|
|
44
|
+
}
|
|
45
|
+
}, [openChatWidth, open])
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<ResizablePanelGroup
|
|
49
|
+
orientation="horizontal"
|
|
50
|
+
className={cn(
|
|
51
|
+
'overflow-visible!',
|
|
52
|
+
transitionsEnabled &&
|
|
53
|
+
'[&>#chat]:transition-[flex-grow] [&>#chat]:duration-200 [&>#chat]:ease-in-out motion-reduce:[&>#chat]:transition-none!',
|
|
54
|
+
transitionsEnabled && 'has-[[data-separator=active]]:[&>#chat]:transition-none!'
|
|
55
|
+
)}
|
|
56
|
+
onLayoutChanged={(_layout, meta) => {
|
|
57
|
+
if (!transitionsEnabled && transitionFrameRef.current === null) {
|
|
58
|
+
transitionFrameRef.current = requestAnimationFrame(() => {
|
|
59
|
+
setTransitionsEnabled(true)
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (meta.isUserInteraction) {
|
|
64
|
+
requestAnimationFrame(() => {
|
|
65
|
+
const chatPanel = chatPanelRef.current
|
|
66
|
+
if (!chatPanel) return
|
|
67
|
+
const size = chatPanel.getSize()
|
|
68
|
+
if (size.inPixels > 0) onChatWidthChange(Math.round(size.inPixels))
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
<ResizablePanel id="workspace" className="overflow-visible!" minSize={workspaceMinWidth}>
|
|
74
|
+
<div data-slot="workspace-split-workspace" className="flex h-full min-h-0 min-w-0 flex-col">
|
|
75
|
+
{workspace}
|
|
76
|
+
</div>
|
|
77
|
+
</ResizablePanel>
|
|
78
|
+
<ResizableHandle aria-label="Resize chat" hidden={!open} disabled={!open} />
|
|
79
|
+
<ResizablePanel
|
|
80
|
+
id="chat"
|
|
81
|
+
aria-hidden={!open}
|
|
82
|
+
inert={!open}
|
|
83
|
+
collapsible
|
|
84
|
+
collapsedSize={0}
|
|
85
|
+
defaultSize={defaultChatSize}
|
|
86
|
+
minSize={chatMinWidth}
|
|
87
|
+
maxSize={chatMaxWidth}
|
|
88
|
+
groupResizeBehavior="preserve-pixel-size"
|
|
89
|
+
panelRef={chatPanelRef}
|
|
90
|
+
onResize={(size, _id, previousSize) => {
|
|
91
|
+
if (open && size.inPixels === 0 && previousSize && previousSize.inPixels > 0) {
|
|
92
|
+
onCollapse()
|
|
93
|
+
}
|
|
94
|
+
}}
|
|
95
|
+
className={cn(
|
|
96
|
+
'overflow-hidden!',
|
|
97
|
+
transitionsEnabled &&
|
|
98
|
+
'transition-opacity duration-200 ease-in-out motion-reduce:transition-none',
|
|
99
|
+
open ? 'opacity-100' : 'opacity-0'
|
|
100
|
+
)}
|
|
101
|
+
>
|
|
102
|
+
<div
|
|
103
|
+
data-slot="workspace-split-chat"
|
|
104
|
+
className="flex h-full min-h-0 min-w-(--chat-min) flex-col"
|
|
105
|
+
>
|
|
106
|
+
{chat}
|
|
107
|
+
</div>
|
|
108
|
+
</ResizablePanel>
|
|
109
|
+
</ResizablePanelGroup>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
@@ -3,10 +3,12 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
|
3
3
|
import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
4
4
|
import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
|
|
5
5
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
6
|
+
import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
|
|
6
7
|
import type {
|
|
7
|
-
|
|
8
|
+
HarnessLogin,
|
|
8
9
|
ViewInfo,
|
|
9
10
|
WidgetInfo,
|
|
11
|
+
WorkspaceAgent,
|
|
10
12
|
WorkspaceLayout,
|
|
11
13
|
WorkspaceSkillsStatus,
|
|
12
14
|
WorkspaceSkillsUpdateFailure,
|
|
@@ -28,18 +30,41 @@ export function useWorkspaceLayout(workspaceId: string) {
|
|
|
28
30
|
})
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
// The workspace's agent backend in one snapshot: availability (runtime
|
|
34
|
+
// presence + auth), any in-flight login ceremony, the model catalog, and
|
|
35
|
+
// capabilities. Fetched once at workspace open; afterwards the volatile parts
|
|
36
|
+
// (`availability`, `login`) are patched in place by `agent:updated` events —
|
|
37
|
+
// the server owns the login watch loop, so the client never polls. Focus
|
|
38
|
+
// refetch stays as a cheap safety net (the server serves its cache).
|
|
39
|
+
export function useWorkspaceAgent(workspaceId: string) {
|
|
40
|
+
const queryClient = useQueryClient()
|
|
41
|
+
useWorkspaceEvent(event => {
|
|
42
|
+
if (event.type === 'agent:updated' && event.workspaceId === workspaceId) {
|
|
43
|
+
queryClient.setQueryData<WorkspaceAgent>(workspaceKeys.agent(workspaceId), prev =>
|
|
44
|
+
prev ? { ...prev, availability: event.availability, login: event.login } : prev
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
// Env can swap credentials; the server dropped its cache — refetch.
|
|
48
|
+
if (event.type === 'env:updated' && event.workspaceId === workspaceId) {
|
|
49
|
+
queryClient.invalidateQueries({ queryKey: workspaceKeys.agent(workspaceId) })
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
return useQuery<WorkspaceAgent>({
|
|
53
|
+
queryKey: workspaceKeys.agent(workspaceId),
|
|
54
|
+
queryFn: () => requestJson(`/api/workspaces/${workspaceId}/agent`),
|
|
38
55
|
staleTime: 30_000,
|
|
39
56
|
refetchOnWindowFocus: true
|
|
40
57
|
})
|
|
41
58
|
}
|
|
42
59
|
|
|
60
|
+
export function startWorkspaceLogin(workspaceId: string): Promise<HarnessLogin> {
|
|
61
|
+
return requestJson(
|
|
62
|
+
`/api/workspaces/${workspaceId}/auth/login`,
|
|
63
|
+
{ method: 'POST' },
|
|
64
|
+
'Could not start sign-in'
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
43
68
|
export function useWorkspaceSkills(workspaceId: string) {
|
|
44
69
|
return useQuery<WorkspaceSkillsStatus>({
|
|
45
70
|
queryKey: workspaceKeys.skills(workspaceId),
|