moi-computer 0.12.0 → 0.12.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 +1 -1
- package/client/AGENTS.md +2 -2
- package/client/api/app-ui-keys.ts +1 -1
- package/client/api/workspace-keys.ts +1 -3
- package/client/app/routes/WorkspaceRoute.tsx +2 -8
- package/client/features/applets/applet-runtime.ts +11 -13
- package/client/features/chat/ChatPanel.tsx +70 -49
- package/client/features/chat/ChatPopup.tsx +81 -8
- package/client/features/chat/applet-chat-intents.ts +31 -12
- package/client/features/chat/chat-send.ts +33 -1
- package/client/features/chat/chat-store.ts +10 -0
- package/client/features/chat/composer/ChatComposer.tsx +24 -27
- package/client/features/chat/composer/ModelPicker.tsx +3 -3
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +3 -3
- package/client/features/chat/connection/chat-frames.ts +14 -7
- package/client/features/chat/messages/ChatEmptyState.tsx +33 -19
- package/client/features/chat/messages/MarkdownContent.tsx +3 -3
- package/client/features/chat/messages/fork-history.ts +14 -0
- package/client/features/chat/sessions/ChatSelector.tsx +138 -79
- package/client/features/chat/sessions/api.ts +109 -19
- package/client/features/chat/sessions/browser-tab-state.ts +30 -7
- package/client/features/chat/sessions/useSelectedSession.ts +217 -51
- package/client/features/chat/useChat.ts +43 -45
- package/client/features/collab/client.ts +10 -11
- package/client/features/collab/hooks.tsx +6 -11
- package/client/features/collab/host-state.ts +57 -128
- package/client/features/collab/provider.tsx +3 -3
- package/client/features/collab/testing/fake-engine.ts +6 -27
- package/client/features/collab/workspace-users-menu.tsx +3 -7
- package/client/features/drawings/{useViewBuilderSketch.ts → useViewSketch.ts} +7 -7
- package/client/features/home/HomePage.tsx +2 -2
- package/client/features/overview/Overview.tsx +3 -6
- package/client/features/overview/default/ViewsWidget.tsx +5 -12
- package/client/features/overview/default/registry.tsx +2 -4
- package/client/features/views/PendingViewScreen.tsx +279 -0
- package/client/features/views/ViewManager.tsx +10 -10
- package/client/features/views/api.ts +63 -130
- package/client/features/views/useViewActions.ts +151 -0
- package/client/features/views/useViewDrafts.ts +79 -0
- package/client/features/views/view-presentation.ts +4 -5
- package/client/features/views/view-submission.ts +88 -0
- package/client/features/workspace/WorkspaceMenu.tsx +63 -0
- package/client/features/workspace/WorkspaceScreen.tsx +180 -375
- package/client/features/workspace/browser-tab-state.ts +16 -9
- package/client/features/workspace/moi-context.ts +13 -15
- package/client/features/workspace/tab-resolution.ts +16 -29
- package/client/features/workspace/useWorkspaceNavigation.ts +146 -104
- package/client/index.tsx +5 -1
- package/client/runtime/useWorkspaceEvents.ts +7 -6
- package/client/store/ui.ts +25 -29
- package/dist/chunk-1zhnhy00.js +1 -0
- package/dist/chunk-27501vke.js +1 -0
- package/dist/{chunk-jf6czgrz.js → chunk-9xtv6djt.js} +2 -2
- package/dist/chunk-am1x230f.js +2 -0
- package/dist/{chunk-nez8sdta.js → chunk-darpsw65.js} +1 -1
- package/dist/{chunk-97eg9mjn.js → chunk-gps4qc38.js} +1 -1
- package/dist/{chunk-3a48fyf7.js → chunk-hzwr8dp8.js} +4 -4
- package/dist/{chunk-efdyz6xp.js → chunk-j905va8r.js} +1 -1
- package/dist/chunk-n33w9y38.js +10 -0
- package/dist/chunk-r63ks44z.js +68 -0
- package/dist/{chunk-vfpsc75k.js → chunk-vqpkqtdr.js} +1 -1
- package/dist/chunk-wd46nk26.css +1 -0
- package/dist/chunk-xgt7vxt9.js +1 -0
- package/dist/{chunk-z3byfve5.js → chunk-yvzhwtfa.js} +2 -2
- package/dist/index.html +1 -1
- package/lib/ids.ts +2 -5
- package/lib/moi-context.ts +100 -73
- package/lib/navigation.ts +48 -87
- package/lib/session-drafts.ts +10 -0
- package/lib/types.ts +64 -31
- package/lib/view-build-directives.ts +12 -0
- package/lib/workspace-layout.ts +1 -1
- package/lib/workspace-tabs.ts +12 -7
- package/package.json +3 -1
- package/server/agent-launcher.ts +27 -0
- package/server/api.ts +119 -209
- package/server/app-config.ts +21 -2
- package/server/applets/build-worker.ts +2 -1
- package/server/applets/view-source.ts +7 -1
- package/server/cli-env.ts +72 -50
- package/server/cli.ts +101 -64
- package/server/control.ts +82 -63
- package/server/data-dir.ts +13 -0
- package/server/functions.ts +2 -1
- package/server/harness/README.md +8 -0
- package/server/harness/acp/adapter.ts +2 -2
- package/server/harness/acp/client.ts +2 -1
- package/server/harness/acp/discovery.ts +3 -3
- package/server/harness/acp/session.ts +6 -9
- package/server/harness/claude-code/adapter.ts +13 -8
- package/server/harness/claude-code/auth.ts +3 -2
- package/server/harness/claude-code/cli.ts +3 -1
- package/server/harness/claude-code/git-worktree.ts +5 -2
- package/server/harness/claude-code/index.ts +5 -0
- package/server/harness/claude-code/mcp.ts +2 -0
- package/server/harness/claude-code/models.ts +2 -0
- package/server/harness/claude-code/session.ts +5 -34
- package/server/harness/claude-code/sessions.ts +8 -12
- package/server/harness/codex/NOTES.md +23 -4
- package/server/harness/codex/adapter.ts +5 -3
- package/server/harness/codex/client.ts +13 -21
- package/server/harness/codex/index.ts +18 -0
- package/server/harness/codex/session.ts +6 -14
- package/server/harness/codex/thread-list.ts +74 -0
- package/server/harness/fork.ts +12 -0
- package/server/harness/openclaw/adapter.ts +3 -3
- package/server/harness/openclaw/session.ts +2 -30
- package/server/harness/session-title.ts +12 -3
- package/server/harness/types.ts +8 -3
- package/server/moi-scaffold.ts +2 -1
- package/server/pending-views.ts +164 -0
- package/server/registry.ts +14 -4
- package/server/selected-session.ts +91 -44
- package/server/service.ts +16 -2
- package/server/session-archive.ts +32 -0
- package/server/session-config.ts +16 -111
- package/server/session-lifecycle.ts +17 -0
- package/server/session-store.ts +127 -0
- package/server/status.ts +3 -1
- package/server/tabs.ts +7 -10
- package/server/view-sessions.ts +267 -0
- package/server/views.ts +30 -41
- package/server/web.ts +47 -45
- package/server/workspace-env.ts +27 -0
- package/server/workspace-init.ts +6 -2
- package/workspace/.claude/skills/moi-workspace/SKILL.md +49 -20
- package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +2 -5
- package/client/features/views/ViewBuilder.tsx +0 -239
- package/client/features/views/useViewBuilderActions.ts +0 -103
- package/client/features/views/useViewBuilderDrafts.ts +0 -68
- package/dist/chunk-2jncyq65.js +0 -1
- package/dist/chunk-e2q5ken7.js +0 -68
- package/dist/chunk-h2kj1ysj.js +0 -1
- package/dist/chunk-nzwgm8vc.css +0 -1
- package/dist/chunk-ph0h6h86.js +0 -1
- package/dist/chunk-ryg9z3kn.js +0 -10
- package/dist/chunk-tpn177bt.js +0 -2
- package/lib/view-builder-directives.ts +0 -16
- package/server/chat-selection.ts +0 -22
- package/server/view-builders.ts +0 -453
|
@@ -3,13 +3,9 @@ import { lazy, Suspense, useCallback, useEffect, useRef, useState } from 'react'
|
|
|
3
3
|
import { AnimatePresence } from 'motion/react'
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
IconArticle,
|
|
7
6
|
IconBrowserPlus,
|
|
8
7
|
IconLayout2,
|
|
9
8
|
IconLayoutSidebarRight,
|
|
10
|
-
IconLetterCase,
|
|
11
|
-
IconMessages,
|
|
12
|
-
IconSettings,
|
|
13
9
|
IconSketching
|
|
14
10
|
} from '@tabler/icons-react'
|
|
15
11
|
|
|
@@ -23,30 +19,23 @@ import { ThemePanel } from '@/client/features/workspace/ThemePanel'
|
|
|
23
19
|
import { Overview } from '@/client/features/overview/Overview'
|
|
24
20
|
import { WorkspaceUsersMenu } from '@/client/features/collab'
|
|
25
21
|
import { PanelHeader } from '@/client/components/shared/PanelHeader'
|
|
26
|
-
import { WorkspaceIcon } from '@/client/components/shared/WorkspaceIcon'
|
|
27
22
|
import { Button } from '@/client/components/ui/button'
|
|
28
|
-
import {
|
|
29
|
-
DropdownMenu,
|
|
30
|
-
DropdownMenuContent,
|
|
31
|
-
DropdownMenuGroup,
|
|
32
|
-
DropdownMenuItem,
|
|
33
|
-
DropdownMenuTrigger
|
|
34
|
-
} from '@/client/components/ui/dropdown-menu'
|
|
35
23
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
24
|
+
import { toast } from '@/client/components/ui/toast'
|
|
36
25
|
import {
|
|
37
26
|
useAppletChatMessage,
|
|
38
27
|
useAppletChatAttachment
|
|
39
28
|
} from '@/client/features/chat/applet-chat-intents'
|
|
40
29
|
import { useChat } from '@/client/features/chat/useChat'
|
|
30
|
+
import { usePinnedSession } from '@/client/features/chat/sessions/useSelectedSession'
|
|
41
31
|
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} from '@/client/features/
|
|
45
|
-
import { ViewBuilder, type ViewBuilderHandle } from '@/client/features/views/ViewBuilder'
|
|
32
|
+
PendingViewScreen,
|
|
33
|
+
type PendingViewHandle
|
|
34
|
+
} from '@/client/features/views/PendingViewScreen'
|
|
46
35
|
import { ViewManager } from '@/client/features/views/ViewManager'
|
|
47
36
|
import { getViewIcon, getViewLabel } from '@/client/features/views/view-presentation'
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
37
|
+
import { useViewActions } from '@/client/features/views/useViewActions'
|
|
38
|
+
import { useViewDrafts } from '@/client/features/views/useViewDrafts'
|
|
50
39
|
import { useFitsSplitLayout } from '@/client/features/workspace/useFitsSplitLayout'
|
|
51
40
|
import { useWorkspaceComposerState } from '@/client/features/chat/composer/useWorkspaceComposerState'
|
|
52
41
|
import { useWorkspaceTheme } from '@/client/runtime/workspace-theme'
|
|
@@ -57,13 +46,9 @@ import {
|
|
|
57
46
|
useLive
|
|
58
47
|
} from '@/client/features/chat/chat-store'
|
|
59
48
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
60
|
-
import {
|
|
61
|
-
|
|
62
|
-
normalizeTabsState,
|
|
63
|
-
tabAvailable
|
|
64
|
-
} from '@/client/features/workspace/tab-resolution'
|
|
49
|
+
import { WorkspaceMenu } from '@/client/features/workspace/WorkspaceMenu'
|
|
50
|
+
import { effectiveOpenTabs, tabAvailable } from '@/client/features/workspace/tab-resolution'
|
|
65
51
|
import { useWorkspaceNavigation } from '@/client/features/workspace/useWorkspaceNavigation'
|
|
66
|
-
import { resolveAppIcon } from '@/client/lib/app-icon-registry'
|
|
67
52
|
import { cn } from '@/client/lib/cn'
|
|
68
53
|
import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
|
|
69
54
|
import { useUiStore } from '@/client/store/ui'
|
|
@@ -73,19 +58,16 @@ import {
|
|
|
73
58
|
WorkspaceTabs
|
|
74
59
|
} from '@/client/features/workspace/WorkspaceTabs'
|
|
75
60
|
import { isDefaultWidget } from '@/lib/default-widgets'
|
|
61
|
+
import { composerDraftKey, draftSessionId } from '@/lib/session-drafts'
|
|
76
62
|
import type {
|
|
63
|
+
CompiledView,
|
|
77
64
|
LayoutMode,
|
|
78
|
-
|
|
65
|
+
PendingView,
|
|
79
66
|
ViewInfo,
|
|
80
67
|
WidgetInfo,
|
|
81
68
|
WorkspaceTabId
|
|
82
69
|
} from '@/lib/types'
|
|
83
|
-
import {
|
|
84
|
-
viewBuilderIdFromTab,
|
|
85
|
-
viewBuilderTabId,
|
|
86
|
-
viewIdFromTab,
|
|
87
|
-
viewTabId
|
|
88
|
-
} from '@/lib/workspace-tabs'
|
|
70
|
+
import { viewIdFromTab, viewTabId } from '@/lib/workspace-tabs'
|
|
89
71
|
|
|
90
72
|
import { WorkspaceSplitLayout } from './WorkspaceSplitLayout'
|
|
91
73
|
import { UnavailablePage } from './UnavailablePage'
|
|
@@ -96,12 +78,9 @@ const Scratchpad = lazy(() =>
|
|
|
96
78
|
}))
|
|
97
79
|
)
|
|
98
80
|
|
|
99
|
-
const viewBuilderIcon = (builder: ViewBuilderData) => resolveAppIcon(builder.icon) ?? IconArticle
|
|
100
|
-
|
|
101
81
|
type WorkspaceScreenProps = {
|
|
102
82
|
widgets: WidgetInfo[]
|
|
103
83
|
views: ViewInfo[]
|
|
104
|
-
builders: ViewBuilderData[]
|
|
105
84
|
}
|
|
106
85
|
|
|
107
86
|
type WidgetMode = 'idle' | 'customizing' | 'theming'
|
|
@@ -109,20 +88,9 @@ type WidgetMode = 'idle' | 'customizing' | 'theming'
|
|
|
109
88
|
function tabItemFor(
|
|
110
89
|
tab: WorkspaceTabId,
|
|
111
90
|
views: ViewInfo[],
|
|
112
|
-
builders: ViewBuilderData[],
|
|
113
91
|
closable: boolean,
|
|
114
|
-
|
|
115
|
-
builderRunning: (sessionId: string) => boolean
|
|
92
|
+
viewRunning: (sessionId: string) => boolean
|
|
116
93
|
): WorkspaceTabItem | null {
|
|
117
|
-
if (tab === 'agent') {
|
|
118
|
-
return {
|
|
119
|
-
key: tab,
|
|
120
|
-
Icon: IconMessages,
|
|
121
|
-
label: 'Agent',
|
|
122
|
-
closable,
|
|
123
|
-
loading: agentRunning
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
94
|
if (tab === 'overview') {
|
|
127
95
|
return {
|
|
128
96
|
key: tab,
|
|
@@ -140,89 +108,26 @@ function tabItemFor(
|
|
|
140
108
|
closable
|
|
141
109
|
}
|
|
142
110
|
}
|
|
143
|
-
const builderId = viewBuilderIdFromTab(tab)
|
|
144
|
-
const builder = builderId ? builders.find(candidate => candidate.id === builderId) : null
|
|
145
|
-
if (builder) {
|
|
146
|
-
return {
|
|
147
|
-
key: tab,
|
|
148
|
-
Icon: viewBuilderIcon(builder),
|
|
149
|
-
label: builder.title || builder.viewId || 'New view',
|
|
150
|
-
closable,
|
|
151
|
-
loading: builderRunning(builder.sessionId)
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
111
|
const viewId = viewIdFromTab(tab)
|
|
155
112
|
const view = viewId ? views.find(v => v.id === viewId) : null
|
|
156
113
|
return view
|
|
157
114
|
? {
|
|
158
115
|
key: tab,
|
|
159
|
-
Icon: getViewIcon(view
|
|
116
|
+
Icon: getViewIcon(view),
|
|
160
117
|
label: getViewLabel(view),
|
|
161
|
-
closable
|
|
118
|
+
closable: closable || view.status !== 'compiled',
|
|
119
|
+
loading:
|
|
120
|
+
view.status !== 'compiled' &&
|
|
121
|
+
!!view.executionSessionId &&
|
|
122
|
+
viewRunning(view.executionSessionId)
|
|
162
123
|
}
|
|
163
124
|
: null
|
|
164
125
|
}
|
|
165
126
|
|
|
166
|
-
function
|
|
167
|
-
open: WorkspaceTabId[],
|
|
168
|
-
visible: WorkspaceTabId[],
|
|
169
|
-
orderedVisible: WorkspaceTabId[]
|
|
170
|
-
) {
|
|
171
|
-
const visibleSet = new Set(visible)
|
|
172
|
-
let cursor = 0
|
|
173
|
-
return open.map(tab => (visibleSet.has(tab) ? orderedVisible[cursor++] : tab))
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
type WorkspaceMenuProps = {
|
|
177
|
-
onOpenTheme: () => void
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function WorkspaceMenu({ onOpenTheme }: WorkspaceMenuProps) {
|
|
181
|
-
const { layout, name, provider } = useWorkspaceLayoutCtx()
|
|
182
|
-
const [iconHovered, setIconHovered] = useState(false)
|
|
183
|
-
|
|
184
|
-
return (
|
|
185
|
-
<WorkspaceSettingsDialog>
|
|
186
|
-
<DropdownMenu>
|
|
187
|
-
<DropdownMenuTrigger
|
|
188
|
-
className="flex min-w-0 cursor-pointer items-center gap-2 rounded-sm outline-none focus-visible:ring-3 focus-visible:ring-ring/50"
|
|
189
|
-
aria-label={`${name ?? 'Workspace'} menu`}
|
|
190
|
-
onPointerEnter={() => setIconHovered(true)}
|
|
191
|
-
onPointerLeave={() => setIconHovered(false)}
|
|
192
|
-
>
|
|
193
|
-
<WorkspaceIcon
|
|
194
|
-
icon={iconHovered ? { ...layout.icon, type: 'glyph', value: 'dots' } : layout.icon}
|
|
195
|
-
workspaceType={provider}
|
|
196
|
-
workspaceTheme={layout.theme}
|
|
197
|
-
className="size-5 rounded-sm"
|
|
198
|
-
/>
|
|
199
|
-
{name && <span className="truncate text-sm font-medium text-foreground">{name}</span>}
|
|
200
|
-
</DropdownMenuTrigger>
|
|
201
|
-
<DropdownMenuContent align="start" sideOffset={6} className="w-36">
|
|
202
|
-
<DropdownMenuGroup>
|
|
203
|
-
<DropdownMenuItem onClick={onOpenTheme}>
|
|
204
|
-
<IconLetterCase stroke={1.75} />
|
|
205
|
-
Theme
|
|
206
|
-
</DropdownMenuItem>
|
|
207
|
-
<DropdownMenuItem
|
|
208
|
-
nativeButton
|
|
209
|
-
render={<WorkspaceSettingsDialogTrigger />}
|
|
210
|
-
className="w-full"
|
|
211
|
-
>
|
|
212
|
-
<IconSettings stroke={1.75} />
|
|
213
|
-
Settings
|
|
214
|
-
</DropdownMenuItem>
|
|
215
|
-
</DropdownMenuGroup>
|
|
216
|
-
</DropdownMenuContent>
|
|
217
|
-
</DropdownMenu>
|
|
218
|
-
</WorkspaceSettingsDialog>
|
|
219
|
-
)
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenProps) {
|
|
127
|
+
export function WorkspaceScreen({ widgets, views: allViews }: WorkspaceScreenProps) {
|
|
223
128
|
const { layout, setLayout, workspaceId } = useWorkspaceLayoutCtx()
|
|
224
129
|
const theme = resolveWorkspaceTheme(layout.theme)
|
|
225
|
-
const
|
|
130
|
+
const viewActions = useViewActions()
|
|
226
131
|
const {
|
|
227
132
|
ref: rowRef,
|
|
228
133
|
fits: canUseSplit,
|
|
@@ -231,34 +136,31 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
231
136
|
const [widgetMode, setWidgetMode] = useState<WidgetMode>('idle')
|
|
232
137
|
const [floatingChatOpen, setFloatingChatOpen] = useState(false)
|
|
233
138
|
const [chatFocusRequest, setChatFocusRequest] = useState(0)
|
|
234
|
-
const
|
|
139
|
+
const pendingViewRefs = useRef(new Map<string, PendingViewHandle>())
|
|
235
140
|
const dockedChatWidth = useUiStore(state => state.dockedChatWidth)
|
|
236
141
|
const setDockedChatWidth = useUiStore(state => state.setDockedChatWidth)
|
|
237
142
|
const sessionActivity = useLive(state => state.activity)
|
|
143
|
+
const views = allViews.filter((view): view is CompiledView => view.status === 'compiled')
|
|
144
|
+
const pendingViews = allViews.filter((view): view is PendingView => view.status !== 'compiled')
|
|
238
145
|
const hasRunningSession = hasRunningWorkspaceActivity(sessionActivity, workspaceId)
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
146
|
+
const viewDrafts = useViewDrafts({
|
|
147
|
+
workspaceId,
|
|
148
|
+
pendingViews,
|
|
149
|
+
onSave: (viewId, requirements) => viewActions.save(viewId, requirements)
|
|
242
150
|
})
|
|
243
151
|
|
|
244
152
|
useWorkspaceTheme(layout.theme)
|
|
245
153
|
|
|
246
|
-
// Split needs the open set to decide whether it's available at all, and the
|
|
247
|
-
// navigation hook needs split to resolve the active tab — so the open set is
|
|
248
|
-
// derived from the raw layout here, before either.
|
|
249
|
-
const hasWorkspaceContent = effectiveOpenTabs(
|
|
250
|
-
normalizeTabsState(layout.tabs),
|
|
251
|
-
views,
|
|
252
|
-
builders
|
|
253
|
-
).some(tab => tab !== 'agent')
|
|
254
154
|
const hasAppletWidgets = widgets.some(widget => !isDefaultWidget(widget.id))
|
|
255
155
|
const hasWorkspaceApplets = hasAppletWidgets || views.length > 0
|
|
256
156
|
|
|
257
|
-
//
|
|
258
|
-
|
|
259
|
-
const wantsSplit = layout.layoutMode === 'split' && hasWorkspaceContent
|
|
157
|
+
// Split needs enough row width; the saved mode remains the user's intent.
|
|
158
|
+
const wantsSplit = layout.layoutMode === 'split'
|
|
260
159
|
const mode: LayoutMode = wantsSplit && canUseSplit ? 'split' : 'fullscreen'
|
|
261
|
-
const
|
|
160
|
+
const revealChat = useCallback(() => {
|
|
161
|
+
setFloatingChatOpen(true)
|
|
162
|
+
setChatFocusRequest(request => request + 1)
|
|
163
|
+
}, [])
|
|
262
164
|
|
|
263
165
|
// The tab address: URL in, active tab + applet params out, plus the persisted
|
|
264
166
|
// tab state it keeps in sync. See useWorkspaceNavigation for the invariants.
|
|
@@ -271,9 +173,8 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
271
173
|
isUnavailable,
|
|
272
174
|
onNavigationClick
|
|
273
175
|
} = useWorkspaceNavigation({
|
|
274
|
-
views,
|
|
275
|
-
|
|
276
|
-
split: dockedSplit
|
|
176
|
+
views: allViews,
|
|
177
|
+
onOpenChat: revealChat
|
|
277
178
|
})
|
|
278
179
|
|
|
279
180
|
// Chat comes after navigation, and takes the address: every message carries
|
|
@@ -281,9 +182,11 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
281
182
|
// in its `<moi-context>` envelope.
|
|
282
183
|
const {
|
|
283
184
|
view,
|
|
185
|
+
forkedFromSessionId,
|
|
284
186
|
chatLoaded,
|
|
285
187
|
previewTurn,
|
|
286
188
|
sessionId,
|
|
189
|
+
composerSessionId,
|
|
287
190
|
processing,
|
|
288
191
|
error,
|
|
289
192
|
loadError,
|
|
@@ -293,7 +196,8 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
293
196
|
selectSession,
|
|
294
197
|
dismissError
|
|
295
198
|
} = useChat({ activeTab, appletParams })
|
|
296
|
-
const {
|
|
199
|
+
const { pinnedSessionId } = usePinnedSession()
|
|
200
|
+
const { composerBanner, viewDraftComposerBanner, agentAvailability } = useWorkspaceComposerState(
|
|
297
201
|
workspaceId,
|
|
298
202
|
{
|
|
299
203
|
chatError: error,
|
|
@@ -303,43 +207,37 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
303
207
|
}
|
|
304
208
|
)
|
|
305
209
|
|
|
306
|
-
const openTabIds = effectiveOpenTabs(tabsState,
|
|
307
|
-
const nonAgentOpenTabs = openTabIds.filter(tab => tab !== 'agent')
|
|
210
|
+
const openTabIds = effectiveOpenTabs(tabsState, allViews)
|
|
308
211
|
const openSet = new Set(tabsState.open)
|
|
309
212
|
|
|
310
|
-
// Entering split with the agent tab on screen needs no special-casing
|
|
311
|
-
// anymore: the URL resolution below derives a visible tab and the redirect
|
|
312
|
-
// effect makes the URL follow it (replace).
|
|
313
213
|
const setMode = (m: LayoutMode) => {
|
|
314
214
|
setLayout({ layoutMode: m })
|
|
315
215
|
}
|
|
316
216
|
|
|
317
|
-
const visibleTabIds = dockedSplit ? nonAgentOpenTabs : openTabIds
|
|
318
217
|
const canCloseTabs = openTabIds.length > 1
|
|
319
|
-
const tabItems =
|
|
218
|
+
const tabItems = openTabIds
|
|
320
219
|
.map(tab =>
|
|
321
|
-
tabItemFor(
|
|
322
|
-
|
|
323
|
-
views,
|
|
324
|
-
builders,
|
|
325
|
-
canCloseTabs || viewBuilderIdFromTab(tab) !== null,
|
|
326
|
-
hasRunningSession,
|
|
327
|
-
sessionId => isSessionRunning(sessionActivity, workspaceId, sessionId)
|
|
220
|
+
tabItemFor(tab, allViews, canCloseTabs, sessionId =>
|
|
221
|
+
isSessionRunning(sessionActivity, workspaceId, sessionId)
|
|
328
222
|
)
|
|
329
223
|
)
|
|
330
224
|
.filter((tab): tab is WorkspaceTabItem => Boolean(tab))
|
|
331
225
|
const activeViewId = viewIdFromTab(activeTab)
|
|
332
226
|
const activeView = activeViewId ? views.find(v => v.id === activeViewId) : undefined
|
|
333
|
-
const
|
|
334
|
-
|
|
335
|
-
? builders.find(builder => builder.id === activeBuilderId)
|
|
227
|
+
const activePendingView = activeViewId
|
|
228
|
+
? pendingViews.find(pendingView => pendingView.id === activeViewId)
|
|
336
229
|
: undefined
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
230
|
+
const activeDraftView =
|
|
231
|
+
!pinnedSessionId &&
|
|
232
|
+
sessionId === null &&
|
|
233
|
+
activePendingView?.status === 'draft' &&
|
|
234
|
+
(!activePendingView.executionSessionId ||
|
|
235
|
+
!isSessionRunning(sessionActivity, workspaceId, activePendingView.executionSessionId))
|
|
236
|
+
? activePendingView
|
|
341
237
|
: undefined
|
|
342
|
-
const
|
|
238
|
+
const activeDraftViewId = activeDraftView?.id
|
|
239
|
+
const startupPending = !pinnedSessionId && activePendingView?.status === 'starting'
|
|
240
|
+
const visibleChatLoaded = chatLoaded && !startupPending
|
|
343
241
|
const canAnnotate =
|
|
344
242
|
widgetMode === 'idle' &&
|
|
345
243
|
((activeTab === 'overview' && hasAppletWidgets) || activeView !== undefined)
|
|
@@ -351,7 +249,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
351
249
|
targetRef: annotationTargetRef
|
|
352
250
|
} = useChatAnnotation({
|
|
353
251
|
workspaceId,
|
|
354
|
-
sessionId,
|
|
252
|
+
sessionId: composerSessionId,
|
|
355
253
|
activeTab,
|
|
356
254
|
mode,
|
|
357
255
|
available: canAnnotate,
|
|
@@ -360,76 +258,32 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
360
258
|
})
|
|
361
259
|
|
|
362
260
|
useEffect(() => {
|
|
363
|
-
const open = tabsState.open.filter(tab => tabAvailable(tab,
|
|
261
|
+
const open = tabsState.open.filter(tab => tabAvailable(tab, allViews))
|
|
364
262
|
if (open.length === tabsState.open.length) return
|
|
365
|
-
const nextOpen = effectiveOpenTabs(tabsState,
|
|
263
|
+
const nextOpen = effectiveOpenTabs(tabsState, allViews)
|
|
366
264
|
setTabs({
|
|
367
265
|
open: nextOpen,
|
|
368
266
|
active: nextOpen.includes(tabsState.active) ? tabsState.active : nextOpen[0]
|
|
369
267
|
})
|
|
370
|
-
}, [
|
|
371
|
-
|
|
372
|
-
useEffect(() => {
|
|
373
|
-
const replacements = new Map<WorkspaceTabId, WorkspaceTabId>()
|
|
374
|
-
for (const builder of builders) {
|
|
375
|
-
if (builder.status !== 'ready' || !builder.viewId) continue
|
|
376
|
-
if (!views.some(view => view.id === builder.viewId)) continue
|
|
377
|
-
replacements.set(viewBuilderTabId(builder.id), viewTabId(builder.viewId))
|
|
378
|
-
}
|
|
379
|
-
if (replacements.size === 0) return
|
|
380
|
-
|
|
381
|
-
// The URL follows a replaced builder tab to the view that took its place.
|
|
382
|
-
const urlReplacement = replacements.get(activeTab)
|
|
383
|
-
if (urlReplacement) navigateToTab(urlReplacement, { replace: true })
|
|
384
|
-
|
|
385
|
-
const replacementViews = new Set(replacements.values())
|
|
386
|
-
const sourceForView = new Map(
|
|
387
|
-
[...replacements].map(([builderTab, viewTab]) => [viewTab, builderTab])
|
|
388
|
-
)
|
|
389
|
-
const open: WorkspaceTabId[] = []
|
|
390
|
-
let changed = false
|
|
391
|
-
for (const tab of tabsState.open) {
|
|
392
|
-
const source = sourceForView.get(tab)
|
|
393
|
-
if (replacementViews.has(tab) && source && tabsState.open.includes(source)) {
|
|
394
|
-
changed = true
|
|
395
|
-
continue
|
|
396
|
-
}
|
|
397
|
-
const replacement = replacements.get(tab)
|
|
398
|
-
const next = replacement ?? tab
|
|
399
|
-
if (replacement) changed = true
|
|
400
|
-
if (!open.includes(next)) open.push(next)
|
|
401
|
-
}
|
|
402
|
-
if (!changed) return
|
|
403
|
-
const active = replacements.get(tabsState.active) ?? tabsState.active
|
|
404
|
-
setTabs({ open: open.length > 0 ? open : ['overview'], active })
|
|
405
|
-
}, [activeTab, builders, navigateToTab, setTabs, tabsState, views])
|
|
268
|
+
}, [allViews, setTabs, tabsState])
|
|
406
269
|
|
|
407
270
|
useEffect(() => {
|
|
408
|
-
if (mode !== 'fullscreen'
|
|
271
|
+
if (mode !== 'fullscreen') {
|
|
409
272
|
setFloatingChatOpen(false)
|
|
410
273
|
}
|
|
411
|
-
}, [
|
|
274
|
+
}, [mode])
|
|
412
275
|
|
|
413
276
|
useEffect(() => {
|
|
414
|
-
if (!
|
|
277
|
+
if (!activeDraftViewId) return
|
|
415
278
|
if (mode === 'fullscreen') setFloatingChatOpen(true)
|
|
416
279
|
setChatFocusRequest(request => request + 1)
|
|
417
|
-
}, [
|
|
280
|
+
}, [activeDraftViewId, mode])
|
|
418
281
|
|
|
419
|
-
|
|
420
|
-
// the navigation hook. Only the chat side effects belong to the screen.
|
|
421
|
-
const openTab = (tab: WorkspaceTabId) => {
|
|
422
|
-
navigateToTab(tab)
|
|
423
|
-
if (tab === 'agent') {
|
|
424
|
-
setFloatingChatOpen(false)
|
|
425
|
-
setChatFocusRequest(request => request + 1)
|
|
426
|
-
}
|
|
427
|
-
}
|
|
282
|
+
const openTab = navigateToTab
|
|
428
283
|
|
|
429
284
|
const createView = () => {
|
|
430
|
-
//
|
|
431
|
-
|
|
432
|
-
void builderActions.create().then(builder => openTab(viewBuilderTabId(builder.id)))
|
|
285
|
+
// A pending view has no chat until its first submission.
|
|
286
|
+
void viewActions.create().then(pendingView => openTab(viewTabId(pendingView.id)))
|
|
433
287
|
}
|
|
434
288
|
|
|
435
289
|
const navigateFromWelcome = (destination: WelcomeDestination) => {
|
|
@@ -453,19 +307,35 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
453
307
|
}
|
|
454
308
|
})
|
|
455
309
|
|
|
310
|
+
const deletePendingView = async (pendingView: PendingView) => {
|
|
311
|
+
const sketch = pendingViewRefs.current.get(pendingView.id)
|
|
312
|
+
try {
|
|
313
|
+
await viewActions.discard(pendingView.id)
|
|
314
|
+
} catch (error) {
|
|
315
|
+
toast.add({
|
|
316
|
+
title: error instanceof Error ? error.message : 'Couldn’t discard view',
|
|
317
|
+
type: 'error'
|
|
318
|
+
})
|
|
319
|
+
return false
|
|
320
|
+
}
|
|
321
|
+
await sketch?.resetSketch()
|
|
322
|
+
viewDrafts.clear(pendingView.id)
|
|
323
|
+
return true
|
|
324
|
+
}
|
|
325
|
+
|
|
456
326
|
const closeTab = (tab: WorkspaceTabId) => {
|
|
457
327
|
if (tab === 'overview') return
|
|
458
|
-
const
|
|
459
|
-
const
|
|
460
|
-
if ((!canCloseTabs && !
|
|
328
|
+
const viewId = viewIdFromTab(tab)
|
|
329
|
+
const pendingView = viewId ? pendingViews.find(candidate => candidate.id === viewId) : undefined
|
|
330
|
+
if ((!canCloseTabs && !pendingView) || !openSet.has(tab)) return
|
|
461
331
|
let open = tabsState.open.filter(t => t !== tab)
|
|
462
332
|
if (open.length === 0) open = ['overview']
|
|
463
333
|
// The neighbor that takes over when the tab on screen closes.
|
|
464
|
-
const visibleIndex =
|
|
334
|
+
const visibleIndex = openTabIds.indexOf(tab)
|
|
465
335
|
const nextTab =
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
open.find(t => tabAvailable(t,
|
|
336
|
+
openTabIds[visibleIndex + 1] ??
|
|
337
|
+
openTabIds[visibleIndex - 1] ??
|
|
338
|
+
open.find(t => tabAvailable(t, allViews)) ??
|
|
469
339
|
'overview'
|
|
470
340
|
const active =
|
|
471
341
|
tabsState.active === tab || !open.includes(tabsState.active) ? nextTab : tabsState.active
|
|
@@ -473,37 +343,33 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
473
343
|
// tabsStateRef) can't resurrect the closed tab.
|
|
474
344
|
setTabs({ open, active })
|
|
475
345
|
if (activeTab === tab) navigateToTab(nextTab)
|
|
476
|
-
if (
|
|
477
|
-
void builderRefs.current.get(builder.id)?.resetSketch()
|
|
478
|
-
builderDrafts.clear(builder.id)
|
|
479
|
-
void builderActions.discard(builder.id)
|
|
480
|
-
}
|
|
346
|
+
if (pendingView?.status === 'draft') void deletePendingView(pendingView)
|
|
481
347
|
}
|
|
482
348
|
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
349
|
+
const discardPendingView = async (pendingView: PendingView) => {
|
|
350
|
+
if (!(await deletePendingView(pendingView))) return
|
|
351
|
+
|
|
352
|
+
const tab = viewTabId(pendingView.id)
|
|
353
|
+
if (!openSet.has(tab)) return
|
|
354
|
+
let open = tabsState.open.filter(item => item !== tab)
|
|
355
|
+
if (open.length === 0) open = ['overview']
|
|
356
|
+
const nextTab = open.find(item => tabAvailable(item, allViews)) ?? 'overview'
|
|
357
|
+
const active = tabsState.active === tab ? nextTab : tabsState.active
|
|
358
|
+
setTabs({ open, active })
|
|
359
|
+
if (activeTab === tab) navigateToTab(nextTab, { replace: true })
|
|
494
360
|
}
|
|
495
361
|
|
|
496
|
-
const reorderTabs = (
|
|
497
|
-
const open = applyVisibleTabOrder(tabsState.open, visibleTabIds, orderedVisibleTabs)
|
|
498
|
-
if (open === tabsState.open) return
|
|
362
|
+
const reorderTabs = (open: WorkspaceTabId[]) => {
|
|
499
363
|
setTabs({ open, active: tabsState.active })
|
|
500
364
|
}
|
|
501
365
|
|
|
502
366
|
const openChat = (intent?: string) => {
|
|
503
367
|
if (intent !== undefined) {
|
|
504
|
-
useUiStore
|
|
368
|
+
useUiStore
|
|
369
|
+
.getState()
|
|
370
|
+
.setComposerDraft(composerDraftKey(workspaceId, composerSessionId), intent)
|
|
505
371
|
}
|
|
506
|
-
if (mode === 'fullscreen'
|
|
372
|
+
if (mode === 'fullscreen') {
|
|
507
373
|
setFloatingChatOpen(true)
|
|
508
374
|
if (floatingChatOpen) {
|
|
509
375
|
setChatFocusRequest(request => request + 1)
|
|
@@ -517,19 +383,9 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
517
383
|
// in full-screen mode the chat is a closed popover, and a run the user can't
|
|
518
384
|
// see is worse than a panel that opens itself.
|
|
519
385
|
useAppletChatMessage({ sessionId, send, revealChat: openChat, agentAvailability })
|
|
520
|
-
useAppletChatAttachment(
|
|
386
|
+
useAppletChatAttachment(composerSessionId, openChat)
|
|
521
387
|
|
|
522
388
|
const createItems: CreateWorkspaceTabItem[] = [
|
|
523
|
-
...(!dockedSplit && !openSet.has('agent')
|
|
524
|
-
? ([
|
|
525
|
-
{
|
|
526
|
-
key: 'agent',
|
|
527
|
-
Icon: IconMessages,
|
|
528
|
-
label: 'Agent',
|
|
529
|
-
onClick: () => openTab('agent')
|
|
530
|
-
}
|
|
531
|
-
] satisfies CreateWorkspaceTabItem[])
|
|
532
|
-
: []),
|
|
533
389
|
...(!openSet.has('scratchpad')
|
|
534
390
|
? ([
|
|
535
391
|
{
|
|
@@ -540,29 +396,17 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
540
396
|
}
|
|
541
397
|
] satisfies CreateWorkspaceTabItem[])
|
|
542
398
|
: []),
|
|
543
|
-
...
|
|
544
|
-
.map(
|
|
399
|
+
...allViews
|
|
400
|
+
.map(view => ({ view, tab: viewTabId(view.id) }))
|
|
545
401
|
.filter(({ tab }) => !openSet.has(tab))
|
|
546
402
|
.map(
|
|
547
403
|
({ view, tab }): CreateWorkspaceTabItem => ({
|
|
548
404
|
key: tab,
|
|
549
|
-
Icon: getViewIcon(view
|
|
405
|
+
Icon: getViewIcon(view),
|
|
550
406
|
label: getViewLabel(view),
|
|
551
407
|
onClick: () => openTab(tab)
|
|
552
408
|
})
|
|
553
409
|
),
|
|
554
|
-
...builders
|
|
555
|
-
.filter(builder => builder.status !== 'ready')
|
|
556
|
-
.map(builder => ({ builder, tab: viewBuilderTabId(builder.id) }))
|
|
557
|
-
.filter(({ tab }) => !openSet.has(tab))
|
|
558
|
-
.map(
|
|
559
|
-
({ builder, tab }): CreateWorkspaceTabItem => ({
|
|
560
|
-
key: tab,
|
|
561
|
-
Icon: viewBuilderIcon(builder),
|
|
562
|
-
label: builder.title || builder.viewId || 'New view',
|
|
563
|
-
onClick: () => openTab(tab)
|
|
564
|
-
})
|
|
565
|
-
),
|
|
566
410
|
{
|
|
567
411
|
key: 'create-view',
|
|
568
412
|
Icon: IconBrowserPlus,
|
|
@@ -571,82 +415,55 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
571
415
|
}
|
|
572
416
|
]
|
|
573
417
|
|
|
574
|
-
const
|
|
575
|
-
(
|
|
576
|
-
|
|
577
|
-
},
|
|
578
|
-
[activeDraftBuilder, builderDrafts]
|
|
579
|
-
)
|
|
580
|
-
const removeBuilderDrawing = useCallback(() => {
|
|
581
|
-
if (activeDraftBuilder) {
|
|
582
|
-
void builderRefs.current.get(activeDraftBuilder.id)?.resetSketch()
|
|
418
|
+
const removeViewDrawing = useCallback(() => {
|
|
419
|
+
if (activeDraftView) {
|
|
420
|
+
void pendingViewRefs.current.get(activeDraftView.id)?.resetSketch()
|
|
583
421
|
}
|
|
584
|
-
}, [
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
await builderView?.prepareSketchForSend()
|
|
590
|
-
await builderActions.submit(activeDraftBuilder, value)
|
|
422
|
+
}, [activeDraftView])
|
|
423
|
+
const sendChat = async (text: string, options?: Parameters<typeof send>[1]) => {
|
|
424
|
+
if (activePendingView?.status === 'draft') {
|
|
425
|
+
await pendingViewRefs.current.get(activePendingView.id)?.prepareSketchForSend()
|
|
426
|
+
await viewActions.submit(activePendingView, text)
|
|
591
427
|
// Submit clears the sent attachment. Keep the canvas until the built view replaces it.
|
|
592
|
-
|
|
593
|
-
},
|
|
594
|
-
|
|
595
|
-
)
|
|
428
|
+
viewDrafts.clear(activePendingView.id)
|
|
429
|
+
} else await send(text, options)
|
|
430
|
+
}
|
|
596
431
|
|
|
597
|
-
const
|
|
432
|
+
const viewChatDraft = activeDraftView
|
|
598
433
|
? {
|
|
599
|
-
sessionId:
|
|
600
|
-
|
|
601
|
-
initialValue: activeDraftBuilder.input.requirements,
|
|
602
|
-
onChange: changeBuilderDraft,
|
|
603
|
-
onRemoveDrawing: removeBuilderDrawing,
|
|
604
|
-
onSubmit: submitBuilderDraft
|
|
434
|
+
sessionId: draftSessionId(viewTabId(activeDraftView.id)),
|
|
435
|
+
onRemoveDrawing: removeViewDrawing
|
|
605
436
|
}
|
|
606
437
|
: undefined
|
|
607
438
|
|
|
608
|
-
|
|
439
|
+
const chatPanelProps = {
|
|
440
|
+
agent: theme.agent,
|
|
441
|
+
focusRequest: chatFocusRequest,
|
|
442
|
+
chatLoaded: visibleChatLoaded,
|
|
443
|
+
hasWorkspaceApplets,
|
|
444
|
+
view,
|
|
445
|
+
forkedFromSessionId,
|
|
446
|
+
previewTurn,
|
|
447
|
+
sessionId,
|
|
448
|
+
processing,
|
|
449
|
+
composerBanner: activeDraftView ? viewDraftComposerBanner : composerBanner,
|
|
450
|
+
agentAvailability,
|
|
451
|
+
send: sendChat,
|
|
452
|
+
stop,
|
|
453
|
+
onNavigateFromWelcome: navigateFromWelcome,
|
|
454
|
+
viewDraft: viewChatDraft
|
|
455
|
+
}
|
|
456
|
+
|
|
609
457
|
const dockedChat = (
|
|
610
458
|
<ChatPanel
|
|
611
|
-
|
|
459
|
+
{...chatPanelProps}
|
|
612
460
|
active={mode === 'split'}
|
|
613
|
-
focusRequest={chatFocusRequest}
|
|
614
|
-
chatLoaded={chatLoaded}
|
|
615
|
-
hasWorkspaceApplets={hasWorkspaceApplets}
|
|
616
|
-
view={view}
|
|
617
|
-
previewTurn={previewTurn}
|
|
618
|
-
sessionId={sessionId}
|
|
619
|
-
processing={processing}
|
|
620
|
-
composerBanner={activeDraftBuilder ? builderComposerBanner : composerBanner}
|
|
621
|
-
agentAvailability={agentAvailability}
|
|
622
|
-
send={send}
|
|
623
|
-
stop={stop}
|
|
624
|
-
onNavigateFromWelcome={navigateFromWelcome}
|
|
625
461
|
onClose={() => setMode('fullscreen')}
|
|
626
462
|
annotation={dockedAnnotation}
|
|
627
|
-
builderDraft={builderChatDraft}
|
|
628
463
|
docked
|
|
629
464
|
/>
|
|
630
465
|
)
|
|
631
466
|
|
|
632
|
-
const tabbedChat = (
|
|
633
|
-
<ChatPanel
|
|
634
|
-
agent={theme.agent}
|
|
635
|
-
active={mode === 'fullscreen' && activeTab === 'agent'}
|
|
636
|
-
focusRequest={chatFocusRequest}
|
|
637
|
-
chatLoaded={chatLoaded}
|
|
638
|
-
hasWorkspaceApplets={hasWorkspaceApplets}
|
|
639
|
-
view={view}
|
|
640
|
-
previewTurn={previewTurn}
|
|
641
|
-
sessionId={sessionId}
|
|
642
|
-
processing={processing}
|
|
643
|
-
composerBanner={composerBanner}
|
|
644
|
-
agentAvailability={agentAvailability}
|
|
645
|
-
send={send}
|
|
646
|
-
stop={stop}
|
|
647
|
-
onNavigateFromWelcome={navigateFromWelcome}
|
|
648
|
-
/>
|
|
649
|
-
)
|
|
650
467
|
const workspacePanel = (
|
|
651
468
|
<div
|
|
652
469
|
className={cn(
|
|
@@ -663,8 +480,6 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
663
480
|
>
|
|
664
481
|
{isUnavailable ? (
|
|
665
482
|
<UnavailablePage onOpenOverview={() => openTab('overview')} />
|
|
666
|
-
) : activeTab === 'agent' ? (
|
|
667
|
-
tabbedChat
|
|
668
483
|
) : activeTab === 'overview' ? (
|
|
669
484
|
<Overview
|
|
670
485
|
customizing={widgetMode === 'customizing'}
|
|
@@ -675,7 +490,6 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
675
490
|
}
|
|
676
491
|
widgets={widgets}
|
|
677
492
|
views={views}
|
|
678
|
-
builders={builders}
|
|
679
493
|
onOpenView={viewId => openTab(viewTabId(viewId))}
|
|
680
494
|
onCreateView={createView}
|
|
681
495
|
onCreateWidget={() => {
|
|
@@ -689,30 +503,34 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
689
503
|
</Suspense>
|
|
690
504
|
) : null}
|
|
691
505
|
|
|
692
|
-
{
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
506
|
+
{pendingViews.map(pendingView => (
|
|
507
|
+
<PendingViewScreen
|
|
508
|
+
key={pendingView.id}
|
|
509
|
+
ref={handle => {
|
|
510
|
+
if (handle) pendingViewRefs.current.set(pendingView.id, handle)
|
|
511
|
+
else pendingViewRefs.current.delete(pendingView.id)
|
|
512
|
+
}}
|
|
513
|
+
active={!isUnavailable && activePendingView?.id === pendingView.id}
|
|
514
|
+
pendingView={pendingView}
|
|
515
|
+
running={
|
|
516
|
+
!!pendingView.executionSessionId &&
|
|
517
|
+
isSessionRunning(sessionActivity, workspaceId, pendingView.executionSessionId)
|
|
518
|
+
}
|
|
519
|
+
sketchSessionId={
|
|
520
|
+
pendingView.status === 'draft'
|
|
521
|
+
? (pinnedSessionId ?? draftSessionId(viewTabId(pendingView.id)))
|
|
522
|
+
: undefined
|
|
523
|
+
}
|
|
524
|
+
chatDocked={mode === 'split'}
|
|
525
|
+
workspaceId={workspaceId}
|
|
526
|
+
onEditingStart={() => {
|
|
527
|
+
if (mode === 'fullscreen') setFloatingChatOpen(false)
|
|
528
|
+
}}
|
|
529
|
+
onContinueInChat={openChat}
|
|
530
|
+
onOpenChat={() => openChat()}
|
|
531
|
+
onDiscard={() => discardPendingView(pendingView)}
|
|
532
|
+
/>
|
|
533
|
+
))}
|
|
716
534
|
|
|
717
535
|
{/* Views are not part of the chain above: ViewManager keeps them
|
|
718
536
|
mounted across tab switches (and collapses to nothing while
|
|
@@ -753,10 +571,10 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
753
571
|
</div>
|
|
754
572
|
<WorkspaceUsersMenu
|
|
755
573
|
workspaceId={workspaceId}
|
|
756
|
-
describeTab={tab => tabItemFor(tab,
|
|
574
|
+
describeTab={tab => tabItemFor(tab, allViews, false, () => false)}
|
|
757
575
|
onOpenTab={openTab}
|
|
758
576
|
/>
|
|
759
|
-
{
|
|
577
|
+
{canUseSplit && mode === 'fullscreen' && (
|
|
760
578
|
<Tooltip>
|
|
761
579
|
<TooltipTrigger
|
|
762
580
|
render={
|
|
@@ -764,14 +582,14 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
764
582
|
variant="ghost"
|
|
765
583
|
size="icon-sm"
|
|
766
584
|
onClick={() => setMode('split')}
|
|
767
|
-
aria-label="Dock
|
|
585
|
+
aria-label="Dock chat"
|
|
768
586
|
className="text-muted-foreground"
|
|
769
587
|
>
|
|
770
588
|
<IconLayoutSidebarRight stroke={1.75} />
|
|
771
589
|
</Button>
|
|
772
590
|
}
|
|
773
591
|
/>
|
|
774
|
-
<TooltipContent>Dock
|
|
592
|
+
<TooltipContent>Dock chat</TooltipContent>
|
|
775
593
|
</Tooltip>
|
|
776
594
|
)}
|
|
777
595
|
</PanelHeader>
|
|
@@ -784,7 +602,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
784
602
|
className="relative flex h-full min-h-0 flex-col font-sans text-foreground"
|
|
785
603
|
>
|
|
786
604
|
<div ref={rowRef} className="flex min-h-0 flex-1">
|
|
787
|
-
{
|
|
605
|
+
{canUseSplit && splitLayoutConstraints ? (
|
|
788
606
|
<WorkspaceSplitLayout
|
|
789
607
|
{...splitLayoutConstraints}
|
|
790
608
|
workspace={workspacePanel}
|
|
@@ -799,7 +617,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
799
617
|
)}
|
|
800
618
|
</div>
|
|
801
619
|
|
|
802
|
-
{mode === 'fullscreen' &&
|
|
620
|
+
{mode === 'fullscreen' && (
|
|
803
621
|
<ChatPopup
|
|
804
622
|
agent={theme.agent}
|
|
805
623
|
loading={hasRunningSession}
|
|
@@ -813,23 +631,10 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
813
631
|
>
|
|
814
632
|
{onClose => (
|
|
815
633
|
<ChatPanel
|
|
816
|
-
|
|
634
|
+
{...chatPanelProps}
|
|
817
635
|
active={floatingChatOpen}
|
|
818
|
-
focusRequest={chatFocusRequest}
|
|
819
|
-
chatLoaded={chatLoaded}
|
|
820
|
-
hasWorkspaceApplets={hasWorkspaceApplets}
|
|
821
|
-
view={view}
|
|
822
|
-
previewTurn={previewTurn}
|
|
823
|
-
sessionId={sessionId}
|
|
824
|
-
processing={processing}
|
|
825
|
-
composerBanner={activeDraftBuilder ? builderComposerBanner : composerBanner}
|
|
826
|
-
agentAvailability={agentAvailability}
|
|
827
|
-
send={send}
|
|
828
|
-
stop={stop}
|
|
829
|
-
onNavigateFromWelcome={navigateFromWelcome}
|
|
830
636
|
onClose={onClose}
|
|
831
637
|
annotation={popupAnnotation}
|
|
832
|
-
builderDraft={builderChatDraft}
|
|
833
638
|
/>
|
|
834
639
|
)}
|
|
835
640
|
</ChatPopup>
|