moi-computer 0.3.1-next.1 → 0.4.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 +85 -12
- package/bin/moi.mjs +11 -0
- package/client/api/workspace-keys.ts +1 -0
- package/client/app/AppRouter.tsx +5 -1
- package/client/app/routes/WorkspaceRoute.tsx +9 -5
- package/client/app/shell/SidebarLayout.tsx +9 -7
- package/client/components/shared/BottomPanel.tsx +24 -5
- package/client/components/shared/Composer.tsx +1 -1
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/components/ui/button.tsx +5 -5
- package/client/components/ui/dropdown-menu.tsx +6 -6
- package/client/components/ui/hover-card.tsx +1 -1
- package/client/components/ui/input.tsx +1 -1
- package/client/components/ui/popover.tsx +1 -1
- package/client/components/ui/skeleton.tsx +1 -1
- package/client/components/ui/textarea.tsx +1 -1
- package/client/components/ui/tooltip.tsx +1 -1
- package/client/features/applets/applet-cache.ts +20 -1
- package/client/features/applets/applet-log.ts +10 -30
- package/client/features/applets/applet-runtime.ts +272 -0
- package/client/features/applets/useApplet.ts +36 -10
- package/client/features/chat/ChatComposer.tsx +1 -1
- package/client/features/chat/ChatEmptyState.tsx +186 -0
- package/client/features/chat/ChatPanel.tsx +95 -54
- package/client/features/chat/ChatPopup.tsx +3 -13
- package/client/features/chat/ChatPromptBubbles.tsx +74 -0
- package/client/features/chat/MarkdownContent.tsx +15 -3
- package/client/features/chat/ModelPicker.tsx +1 -1
- package/client/features/chat/TurnView.tsx +6 -17
- package/client/features/chat/chat-send.ts +26 -1
- package/client/features/chat/tool-group/CodeBlock.tsx +1 -1
- package/client/features/chat/tool-group/ReadImagePreview.tsx +1 -1
- package/client/features/chat/tool-group/SubagentCard.tsx +1 -1
- package/client/features/chat/tool-group/TimelineRow.tsx +4 -4
- package/client/features/chat/tool-group/ToolCallGroup.tsx +12 -5
- package/client/features/chat/tool-group/ToolOutput.tsx +2 -2
- package/client/features/chat/tool-group/format.ts +25 -4
- package/client/features/chat/useAppletChatMessage.ts +69 -0
- package/client/features/chat/useChat.ts +49 -14
- package/client/features/chat/useStickToBottom.ts +11 -1
- package/client/features/connectors/McpServerCards.tsx +3 -3
- package/client/features/dev/HarnessDebugPage.tsx +213 -77
- package/client/features/dev/PixelPainter.tsx +1 -1
- package/client/features/dev/PlaygroundPage.tsx +1 -1
- package/client/features/dev/ToolCallsPage.tsx +2 -2
- package/client/features/home/HomePage.tsx +17 -14
- package/client/features/home/WorkspacePreview.tsx +12 -13
- package/client/features/home/api.ts +8 -5
- package/client/features/home/workspace-presentation.tsx +1 -1
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +1 -1
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +21 -8
- package/client/features/scratchpad/Scratchpad.tsx +41 -2
- package/client/features/scratchpad/ScratchpadControls.tsx +13 -13
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +1 -1
- package/client/features/settings/EnvironmentSettings.tsx +1 -1
- package/client/features/settings/IconPicker.tsx +11 -11
- package/client/features/settings/SettingsLayout.tsx +1 -1
- package/client/features/settings/WorkspaceSettings.tsx +2 -2
- package/client/features/settings/api.ts +33 -1
- package/client/features/widgets/HiddenPanel.tsx +4 -3
- package/client/features/widgets/Widgets.tsx +1 -0
- package/client/features/workspace/CustomizePanel.tsx +96 -82
- package/client/features/workspace/WorkspaceScreen.tsx +129 -107
- package/client/features/workspace/WorkspaceSkillUpdateBanner.tsx +91 -0
- package/client/features/workspace/WorkspaceTabs.tsx +1 -1
- package/client/features/workspace/api.ts +52 -0
- package/client/features/workspace/moi-context.ts +63 -17
- package/client/features/workspace/tab-resolution.ts +75 -0
- package/client/features/workspace/useWorkspaceNavigation.ts +128 -0
- package/client/features/workspace/useWorkspaceSkillUpdates.ts +160 -0
- package/client/index.css +10 -15
- package/client/lib/app-icon-registry.ts +77 -70
- package/client/lib/rate-limit.ts +77 -0
- package/client/main.tsx +10 -2
- package/client/runtime/useWorkspaceEvents.ts +15 -2
- package/client/runtime/workspace-theme.ts +115 -0
- package/client/store/ui.ts +42 -17
- package/client/theme.css +20 -15
- package/dist/{chunk-1dfbr7n2.js → chunk-3m1xe1j3.js} +94 -94
- package/dist/chunk-5vaevt8z.js +2 -0
- package/dist/chunk-7bzpmtxp.js +50 -0
- package/dist/chunk-h0hk61pm.js +9 -0
- package/dist/{chunk-vkvb3hjm.js → chunk-h3evrtyp.js} +1 -1
- package/dist/chunk-k5sjx9s5.js +1 -0
- package/dist/{chunk-jen6xcm1.js → chunk-m9qja0nx.js} +1 -1
- package/dist/chunk-s7za1qsv.css +1 -0
- package/dist/{chunk-sxbfh73c.js → chunk-tcfa3vt3.js} +1 -1
- package/dist/chunk-v797g6ap.js +51 -0
- package/dist/chunk-xyrw8318.js +27 -0
- package/dist/index.html +1 -1
- package/lib/app-icons.ts +73 -0
- package/lib/moi-context.ts +104 -3
- package/lib/themes.ts +83 -45
- package/lib/types.ts +44 -9
- package/lib/workspace-tabs.ts +48 -0
- package/package.json +4 -1
- package/server/api.ts +57 -5
- package/server/app-settings.ts +65 -0
- package/server/applets.ts +132 -22
- package/server/bundler/build-applet.ts +74 -16
- package/server/cli.ts +144 -17
- package/server/control.ts +53 -7
- package/server/data-dir.ts +1 -1
- package/server/events.ts +1 -1
- package/server/functions-worker.ts +15 -1
- package/server/functions.ts +51 -6
- package/server/harness/claude-code/index.ts +2 -1
- package/server/harness/codex/adapter.ts +100 -9
- package/server/harness/codex/client.ts +34 -1
- package/server/harness/codex/index.ts +2 -1
- package/server/harness/codex/session.ts +32 -8
- package/server/layout.ts +9 -14
- package/server/moi-scaffold.ts +37 -3
- package/server/registry.ts +1 -1
- package/server/skill-update.ts +47 -0
- package/server/skill-version.ts +2 -11
- package/server/tabs.ts +59 -0
- package/server/theme.ts +8 -14
- package/server/view-builders.ts +6 -2
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +265 -107
- package/workspace/.claude/skills/moi-workspace/SKILL.md +85 -11
- package/client/features/workspace/useWorkspaceTheme.ts +0 -82
- package/dist/chunk-339jds4x.js +0 -15
- package/dist/chunk-3xsvsnhr.css +0 -1
- package/dist/chunk-6c8cwpzc.js +0 -1
- package/dist/chunk-anqmsbjt.js +0 -2
- package/dist/chunk-hbvfb6sk.js +0 -63
- package/dist/chunk-qwm5f6qk.js +0 -48
- package/dist/chunk-yp4srgqt.js +0 -10
- package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +0 -22
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { lazy, Suspense, useEffect,
|
|
1
|
+
import { lazy, Suspense, useEffect, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
import { AnimatePresence, motion } from 'motion/react'
|
|
4
4
|
|
|
@@ -8,13 +8,14 @@ import {
|
|
|
8
8
|
IconGhost,
|
|
9
9
|
IconLayout2,
|
|
10
10
|
IconLayoutSidebarRight,
|
|
11
|
-
|
|
11
|
+
IconLetterCase,
|
|
12
12
|
IconSketching
|
|
13
13
|
} from '@tabler/icons-react'
|
|
14
14
|
import { ChatPanel } from '@/client/features/chat/ChatPanel'
|
|
15
15
|
import { ChatPopup } from '@/client/features/chat/ChatPopup'
|
|
16
16
|
import { CustomizePanel } from '@/client/features/workspace/CustomizePanel'
|
|
17
17
|
import { AppletMount } from '@/client/features/applets/AppletMount'
|
|
18
|
+
import { useAppletEvent } from '@/client/features/applets/applet-runtime'
|
|
18
19
|
import { WidgetErrorBoundary } from '@/client/features/applets/WidgetErrorBoundary'
|
|
19
20
|
import { Widgets } from '@/client/features/widgets/Widgets'
|
|
20
21
|
import { PanelHeader } from '@/client/components/shared/PanelHeader'
|
|
@@ -22,32 +23,40 @@ import { workspaceProviderIcon } from '@/client/features/home/workspace-presenta
|
|
|
22
23
|
import { Button } from '@/client/components/ui/button'
|
|
23
24
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
24
25
|
import { WorkspaceSettings } from '@/client/features/settings/WorkspaceSettings'
|
|
26
|
+
import { useAppletChatMessage } from '@/client/features/chat/useAppletChatMessage'
|
|
25
27
|
import { useChat } from '@/client/features/chat/useChat'
|
|
26
28
|
import { useView } from '@/client/features/applets/useApplet'
|
|
27
29
|
import { ViewBuilderTab } from '@/client/features/views/ViewBuilderTab'
|
|
28
30
|
import { useViewBuilderActions } from '@/client/features/views/useViewBuilderActions'
|
|
29
31
|
import { useFitsSplitLayout } from '@/client/features/workspace/useFitsSplitLayout'
|
|
30
32
|
import { useWorkspaceAvailability } from '@/client/features/workspace/api'
|
|
31
|
-
import {
|
|
33
|
+
import { WorkspaceSkillUpdateBanner } from '@/client/features/workspace/WorkspaceSkillUpdateBanner'
|
|
34
|
+
import { useWorkspaceSkillUpdates } from '@/client/features/workspace/useWorkspaceSkillUpdates'
|
|
35
|
+
import { useWorkspaceTheme } from '@/client/runtime/workspace-theme'
|
|
32
36
|
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
33
37
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
38
|
+
import {
|
|
39
|
+
effectiveOpenTabs,
|
|
40
|
+
normalizeTabsState,
|
|
41
|
+
tabAvailable
|
|
42
|
+
} from '@/client/features/workspace/tab-resolution'
|
|
43
|
+
import { useWorkspaceNavigation } from '@/client/features/workspace/useWorkspaceNavigation'
|
|
34
44
|
import { resolveAppIcon } from '@/client/lib/app-icon-registry'
|
|
35
45
|
import { cn } from '@/client/lib/cn'
|
|
36
46
|
import { liveStore } from '@/client/features/chat/chat-store'
|
|
47
|
+
import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
|
|
37
48
|
import {
|
|
38
49
|
type CreateWorkspaceTabItem,
|
|
39
50
|
type WorkspaceTabItem,
|
|
40
51
|
WorkspaceTabs
|
|
41
52
|
} from '@/client/features/workspace/WorkspaceTabs'
|
|
42
|
-
import type {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
} from '@/lib/types'
|
|
50
|
-
import { createDefaultWorkspaceTabs } from '@/lib/workspace-layout'
|
|
53
|
+
import type { LayoutMode, ViewBuilder, ViewInfo, WidgetInfo, WorkspaceTabId } from '@/lib/types'
|
|
54
|
+
import {
|
|
55
|
+
viewBuilderIdFromTab,
|
|
56
|
+
viewBuilderTabId,
|
|
57
|
+
viewIdFromTab,
|
|
58
|
+
viewTabId
|
|
59
|
+
} from '@/lib/workspace-tabs'
|
|
51
60
|
|
|
52
61
|
const Scratchpad = lazy(() =>
|
|
53
62
|
import('@/client/features/scratchpad/Scratchpad').then(module => ({
|
|
@@ -65,14 +74,6 @@ function viewIcon(view: ViewInfo, builders: ViewBuilder[]) {
|
|
|
65
74
|
return resolveAppIcon(view.config.icon) ?? resolveAppIcon(builder?.icon) ?? IconArticle
|
|
66
75
|
}
|
|
67
76
|
|
|
68
|
-
const DEFAULT_TABS = createDefaultWorkspaceTabs()
|
|
69
|
-
|
|
70
|
-
const viewTabId = (id: string): WorkspaceTabId => `view:${id}`
|
|
71
|
-
const viewIdFromTab = (tab: WorkspaceTabId) => (tab.startsWith('view:') ? tab.slice(5) : null)
|
|
72
|
-
const viewBuilderTabId = (id: string): WorkspaceTabId => `view-builder:${id}`
|
|
73
|
-
const viewBuilderIdFromTab = (tab: WorkspaceTabId) =>
|
|
74
|
-
tab.startsWith('view-builder:') ? tab.slice('view-builder:'.length) : null
|
|
75
|
-
|
|
76
77
|
type SectionControlsProps = {
|
|
77
78
|
mode: LayoutMode
|
|
78
79
|
onToggleMode: () => void
|
|
@@ -95,12 +96,16 @@ function SectionControls({ mode, onToggleMode }: SectionControlsProps) {
|
|
|
95
96
|
|
|
96
97
|
type ViewAppProps = {
|
|
97
98
|
view: ViewInfo
|
|
99
|
+
// The view's addressable state, read from navigation state (focusTab /
|
|
100
|
+
// `moi tab focus`). `{}` on a fresh mount, a new browser tab, or a plain
|
|
101
|
+
// tab-bar click — the view must render sensibly with that.
|
|
102
|
+
params: Record<string, unknown>
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
// A view — an agent-defined app — mounted full-area. The bundle owns its own
|
|
101
106
|
// layout + scroll, so we give it a plain filled box and fade it in (mirroring
|
|
102
107
|
// WidgetShell, but full-area instead of a grid cell).
|
|
103
|
-
function ViewApp({ view }: ViewAppProps) {
|
|
108
|
+
function ViewApp({ view, params }: ViewAppProps) {
|
|
104
109
|
const workspaceId = useWorkspaceId()
|
|
105
110
|
const bundle = useView(view.id)
|
|
106
111
|
|
|
@@ -128,7 +133,7 @@ function ViewApp({ view }: ViewAppProps) {
|
|
|
128
133
|
workspaceId={workspaceId}
|
|
129
134
|
resetKey={bundle.version}
|
|
130
135
|
>
|
|
131
|
-
<bundle.Component />
|
|
136
|
+
<bundle.Component params={params} />
|
|
132
137
|
</WidgetErrorBoundary>
|
|
133
138
|
</motion.div>
|
|
134
139
|
</AppletMount>
|
|
@@ -167,7 +172,7 @@ function WorkspaceCustomizeAction({ active, onToggle }: WorkspaceCustomizeAction
|
|
|
167
172
|
aria-pressed={active}
|
|
168
173
|
onClick={onToggle}
|
|
169
174
|
>
|
|
170
|
-
<
|
|
175
|
+
<IconLetterCase stroke={1.75} />
|
|
171
176
|
</Button>
|
|
172
177
|
}
|
|
173
178
|
/>
|
|
@@ -184,21 +189,6 @@ type WorkspaceScreenProps = {
|
|
|
184
189
|
|
|
185
190
|
type WidgetMode = 'idle' | 'editing' | 'customizing'
|
|
186
191
|
|
|
187
|
-
function normalizeTabsState(tabs: WorkspaceTabsState | undefined): WorkspaceTabsState {
|
|
188
|
-
if (!tabs || !Array.isArray(tabs.open)) return DEFAULT_TABS
|
|
189
|
-
const open = tabs.open.filter((tab, index, all) => all.indexOf(tab) === index)
|
|
190
|
-
if (open.length === 0) return DEFAULT_TABS
|
|
191
|
-
return { open, active: open.includes(tabs.active) ? tabs.active : open[0] }
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function tabAvailable(tab: WorkspaceTabId, views: ViewInfo[], builders: ViewBuilder[]) {
|
|
195
|
-
if (tab === 'agent' || tab === 'widgets' || tab === 'scratchpad') return true
|
|
196
|
-
const builderId = viewBuilderIdFromTab(tab)
|
|
197
|
-
if (builderId) return builders.some(builder => builder.id === builderId)
|
|
198
|
-
const viewId = viewIdFromTab(tab)
|
|
199
|
-
return viewId ? views.some(v => v.id === viewId) : false
|
|
200
|
-
}
|
|
201
|
-
|
|
202
192
|
function tabItemFor(
|
|
203
193
|
tab: WorkspaceTabId,
|
|
204
194
|
views: ViewInfo[],
|
|
@@ -262,21 +252,11 @@ function applyVisibleTabOrder(
|
|
|
262
252
|
}
|
|
263
253
|
|
|
264
254
|
export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenProps) {
|
|
265
|
-
const {
|
|
266
|
-
view,
|
|
267
|
-
previewTurn,
|
|
268
|
-
sessionId,
|
|
269
|
-
processing,
|
|
270
|
-
error,
|
|
271
|
-
send,
|
|
272
|
-
stop,
|
|
273
|
-
switchThread,
|
|
274
|
-
dismissError
|
|
275
|
-
} = useChat()
|
|
276
255
|
const { layout, setLayout, name, icon, provider, workspaceId } = useWorkspaceLayoutCtx()
|
|
277
256
|
// Keep the composer read/write, but block sends when its agent executable is
|
|
278
257
|
// missing. The Send button explains how to install it.
|
|
279
258
|
const availability = useWorkspaceAvailability(workspaceId).data
|
|
259
|
+
const { bannerProps: skillUpdateBanner } = useWorkspaceSkillUpdates(workspaceId)
|
|
280
260
|
const unavailableReason =
|
|
281
261
|
availability === undefined ? undefined : availability.available ? null : availability.reason
|
|
282
262
|
const builderActions = useViewBuilderActions()
|
|
@@ -285,18 +265,13 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
285
265
|
const [floatingChatOpen, setFloatingChatOpen] = useState(false)
|
|
286
266
|
const [chatFocusRequest, setChatFocusRequest] = useState(0)
|
|
287
267
|
|
|
288
|
-
|
|
289
|
-
// tokens. The floating chat portals into the same element so it inherits them.
|
|
290
|
-
const themeRef = useRef<HTMLDivElement>(null)
|
|
291
|
-
useWorkspaceTheme(layout.theme, themeRef)
|
|
268
|
+
useWorkspaceTheme(layout.theme)
|
|
292
269
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
const
|
|
297
|
-
const
|
|
298
|
-
const openSet = new Set(tabsState.open)
|
|
299
|
-
const nonAgentOpenTabs = effectiveOpenTabs.filter(tab => tab !== 'agent')
|
|
270
|
+
// Split needs the open set to decide whether it's available at all, and the
|
|
271
|
+
// navigation hook needs split to resolve the active tab — so the open set is
|
|
272
|
+
// derived from the raw layout here, before either.
|
|
273
|
+
const openTabIds = effectiveOpenTabs(normalizeTabsState(layout.tabs), views, builders)
|
|
274
|
+
const nonAgentOpenTabs = openTabIds.filter(tab => tab !== 'agent')
|
|
300
275
|
const hasWorkspaceContent = nonAgentOpenTabs.length > 0
|
|
301
276
|
|
|
302
277
|
// Effective layout mode. Split is only visible with workspace content and
|
|
@@ -305,25 +280,41 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
305
280
|
const mode: LayoutMode = wantsSplit && canUseSplit ? 'split' : 'fullscreen'
|
|
306
281
|
const dockedSplit = mode === 'split'
|
|
307
282
|
|
|
283
|
+
// The tab address: URL in, active tab + applet params out, plus the persisted
|
|
284
|
+
// tab state it keeps in sync. See useWorkspaceNavigation for the invariants.
|
|
285
|
+
const { tabsState, activeTab, appletParams, navigateToTab, setTabs } = useWorkspaceNavigation({
|
|
286
|
+
views,
|
|
287
|
+
builders,
|
|
288
|
+
split: dockedSplit
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
// Chat comes after navigation, and takes the address: every message carries
|
|
292
|
+
// where the user is (active tab, and the params the view is rendering with)
|
|
293
|
+
// in its `<moi-context>` envelope.
|
|
294
|
+
const {
|
|
295
|
+
view,
|
|
296
|
+
chatLoaded,
|
|
297
|
+
previewTurn,
|
|
298
|
+
sessionId,
|
|
299
|
+
processing,
|
|
300
|
+
error,
|
|
301
|
+
send,
|
|
302
|
+
stop,
|
|
303
|
+
switchThread,
|
|
304
|
+
dismissError
|
|
305
|
+
} = useChat({ activeTab, appletParams })
|
|
306
|
+
|
|
307
|
+
const openSet = new Set(tabsState.open)
|
|
308
|
+
|
|
309
|
+
// Entering split with the agent tab on screen needs no special-casing
|
|
310
|
+
// anymore: the URL resolution below derives a visible tab and the redirect
|
|
311
|
+
// effect makes the URL follow it (replace).
|
|
308
312
|
const setMode = (m: LayoutMode) => {
|
|
309
|
-
if (m === 'split' && tabsState.active === 'agent') {
|
|
310
|
-
setLayout({
|
|
311
|
-
layoutMode: m,
|
|
312
|
-
tabs: {
|
|
313
|
-
open: tabsState.open,
|
|
314
|
-
active: nonAgentOpenTabs[0] ?? tabsState.active
|
|
315
|
-
}
|
|
316
|
-
})
|
|
317
|
-
return
|
|
318
|
-
}
|
|
319
313
|
setLayout({ layoutMode: m })
|
|
320
314
|
}
|
|
321
315
|
|
|
322
|
-
const visibleTabIds = dockedSplit ? nonAgentOpenTabs :
|
|
323
|
-
const
|
|
324
|
-
? tabsState.active
|
|
325
|
-
: (visibleTabIds[0] ?? 'agent')
|
|
326
|
-
const canCloseTabs = effectiveOpenTabs.length > 1
|
|
316
|
+
const visibleTabIds = dockedSplit ? nonAgentOpenTabs : openTabIds
|
|
317
|
+
const canCloseTabs = openTabIds.length > 1
|
|
327
318
|
const tabItems = visibleTabIds
|
|
328
319
|
.map(tab =>
|
|
329
320
|
tabItemFor(tab, views, builders, canCloseTabs || viewBuilderIdFromTab(tab) !== null)
|
|
@@ -339,14 +330,14 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
339
330
|
useEffect(() => {
|
|
340
331
|
const open = tabsState.open.filter(tab => tabAvailable(tab, views, builders))
|
|
341
332
|
if (open.length === tabsState.open.length) return
|
|
342
|
-
const nextOpen =
|
|
333
|
+
const nextOpen = effectiveOpenTabs(tabsState, views, builders)
|
|
343
334
|
setLayout({
|
|
344
335
|
tabs: {
|
|
345
336
|
open: nextOpen,
|
|
346
337
|
active: nextOpen.includes(tabsState.active) ? tabsState.active : nextOpen[0]
|
|
347
338
|
}
|
|
348
339
|
})
|
|
349
|
-
}, [builders, setLayout, tabsState
|
|
340
|
+
}, [builders, setLayout, tabsState, views])
|
|
350
341
|
|
|
351
342
|
useEffect(() => {
|
|
352
343
|
const replacements = new Map<WorkspaceTabId, WorkspaceTabId>()
|
|
@@ -357,6 +348,10 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
357
348
|
}
|
|
358
349
|
if (replacements.size === 0) return
|
|
359
350
|
|
|
351
|
+
// The URL follows a replaced builder tab to the view that took its place.
|
|
352
|
+
const urlReplacement = replacements.get(activeTab)
|
|
353
|
+
if (urlReplacement) navigateToTab(urlReplacement)
|
|
354
|
+
|
|
360
355
|
const replacementViews = new Set(replacements.values())
|
|
361
356
|
const sourceForView = new Map(
|
|
362
357
|
[...replacements].map(([builderTab, viewTab]) => [viewTab, builderTab])
|
|
@@ -377,7 +372,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
377
372
|
if (!changed) return
|
|
378
373
|
const active = replacements.get(tabsState.active) ?? tabsState.active
|
|
379
374
|
setLayout({ tabs: { open: open.length > 0 ? open : ['agent'], active } })
|
|
380
|
-
}, [builders,
|
|
375
|
+
}, [activeTab, builders, navigateToTab, setLayout, tabsState, views])
|
|
381
376
|
|
|
382
377
|
useEffect(() => {
|
|
383
378
|
const linked = activeBuilder ?? builders.find(builder => builder.viewId === activeViewId)
|
|
@@ -390,37 +385,49 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
390
385
|
}
|
|
391
386
|
}, [activeTab, mode])
|
|
392
387
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
const openTab = (tab: WorkspaceTabId) => {
|
|
399
|
-
const current = tabsStateRef.current
|
|
400
|
-
const open = current.open.includes(tab) ? current.open : [...current.open, tab]
|
|
401
|
-
setTabs({ open, active: tab })
|
|
388
|
+
// Tab switching is navigation; the saved default and the open set follow via
|
|
389
|
+
// the navigation hook. Only the chat side effects belong to the screen.
|
|
390
|
+
const openTab = (tab: WorkspaceTabId, params?: Record<string, unknown>) => {
|
|
391
|
+
navigateToTab(tab, params)
|
|
402
392
|
if (tab === 'agent') {
|
|
403
393
|
setFloatingChatOpen(false)
|
|
404
394
|
setChatFocusRequest(request => request + 1)
|
|
405
395
|
}
|
|
406
396
|
}
|
|
407
397
|
|
|
398
|
+
// Focus requests from applet bridges arrive here already validated — the
|
|
399
|
+
// applet runtime narrows the untrusted tab id and params shape at the trust
|
|
400
|
+
// boundary (applet-runtime.ts). A well-formed id for a missing view just
|
|
401
|
+
// resolves to the default like any dead URL.
|
|
402
|
+
useAppletEvent(workspaceId, 'focusTab', openTab)
|
|
403
|
+
|
|
404
|
+
// `moi tab focus` — a workspace event, not an applet call: the control
|
|
405
|
+
// server validated the target and params before publishing.
|
|
406
|
+
useWorkspaceEvent(event => {
|
|
407
|
+
if (event.type === 'tab:focus' && event.workspaceId === workspaceId) {
|
|
408
|
+
openTab(event.tab, event.params)
|
|
409
|
+
}
|
|
410
|
+
})
|
|
411
|
+
|
|
408
412
|
const closeTab = (tab: WorkspaceTabId) => {
|
|
409
413
|
const builderId = viewBuilderIdFromTab(tab)
|
|
410
414
|
const builder = builderId ? builders.find(candidate => candidate.id === builderId) : undefined
|
|
411
415
|
if ((!canCloseTabs && !builder) || !openSet.has(tab)) return
|
|
412
416
|
let open = tabsState.open.filter(t => t !== tab)
|
|
413
417
|
if (open.length === 0) open = ['agent']
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
418
|
+
// The neighbor that takes over when the tab on screen closes.
|
|
419
|
+
const visibleIndex = visibleTabIds.indexOf(tab)
|
|
420
|
+
const nextTab =
|
|
421
|
+
visibleTabIds[visibleIndex + 1] ??
|
|
422
|
+
visibleTabIds[visibleIndex - 1] ??
|
|
423
|
+
open.find(t => tabAvailable(t, views, builders)) ??
|
|
424
|
+
'agent'
|
|
425
|
+
const active =
|
|
426
|
+
tabsState.active === tab || !open.includes(tabsState.active) ? nextTab : tabsState.active
|
|
427
|
+
// Persist the open set BEFORE navigating so the sync effect (which reads
|
|
428
|
+
// tabsStateRef) can't resurrect the closed tab.
|
|
423
429
|
setTabs({ open, active })
|
|
430
|
+
if (activeTab === tab) navigateToTab(nextTab)
|
|
424
431
|
if (builder?.status === 'draft') void builderActions.discard(builder.id)
|
|
425
432
|
}
|
|
426
433
|
|
|
@@ -430,6 +437,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
430
437
|
let open = tabsState.open.filter(item => item !== tab)
|
|
431
438
|
if (open.length === 0) open = ['agent']
|
|
432
439
|
setTabs({ open, active: tabsState.active === tab ? open[0] : tabsState.active })
|
|
440
|
+
if (activeTab === tab) navigateToTab(open[0])
|
|
433
441
|
}
|
|
434
442
|
void builderActions.discard(builder.id)
|
|
435
443
|
}
|
|
@@ -454,6 +462,11 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
454
462
|
setChatFocusRequest(request => request + 1)
|
|
455
463
|
}
|
|
456
464
|
|
|
465
|
+
// Chat messages fired from applet UI. `openChat` is the reveal: on a view tab
|
|
466
|
+
// in full-screen mode the chat is a closed popover, and a run the user can't
|
|
467
|
+
// see is worse than a panel that opens itself.
|
|
468
|
+
useAppletChatMessage({ send, revealChat: openChat, unavailableReason })
|
|
469
|
+
|
|
457
470
|
const createItems: CreateWorkspaceTabItem[] = [
|
|
458
471
|
...(!dockedSplit && !openSet.has('agent')
|
|
459
472
|
? ([
|
|
@@ -523,12 +536,16 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
523
536
|
<ChatPanel
|
|
524
537
|
active={mode === 'split'}
|
|
525
538
|
focusRequest={chatFocusRequest}
|
|
539
|
+
chatLoaded={chatLoaded}
|
|
526
540
|
view={view}
|
|
527
541
|
previewTurn={previewTurn}
|
|
528
542
|
sessionId={sessionId}
|
|
529
543
|
processing={processing}
|
|
530
544
|
error={error}
|
|
531
545
|
onDismissError={dismissError}
|
|
546
|
+
composerBanner={
|
|
547
|
+
skillUpdateBanner ? <WorkspaceSkillUpdateBanner {...skillUpdateBanner} /> : undefined
|
|
548
|
+
}
|
|
532
549
|
unavailableReason={unavailableReason}
|
|
533
550
|
send={send}
|
|
534
551
|
stop={stop}
|
|
@@ -540,12 +557,16 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
540
557
|
<ChatPanel
|
|
541
558
|
active={mode === 'fullscreen' && activeTab === 'agent'}
|
|
542
559
|
focusRequest={chatFocusRequest}
|
|
560
|
+
chatLoaded={chatLoaded}
|
|
543
561
|
view={view}
|
|
544
562
|
previewTurn={previewTurn}
|
|
545
563
|
sessionId={sessionId}
|
|
546
564
|
processing={processing}
|
|
547
565
|
error={error}
|
|
548
566
|
onDismissError={dismissError}
|
|
567
|
+
composerBanner={
|
|
568
|
+
skillUpdateBanner ? <WorkspaceSkillUpdateBanner {...skillUpdateBanner} /> : undefined
|
|
569
|
+
}
|
|
549
570
|
unavailableReason={unavailableReason}
|
|
550
571
|
send={send}
|
|
551
572
|
stop={stop}
|
|
@@ -554,13 +575,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
554
575
|
)
|
|
555
576
|
|
|
556
577
|
return (
|
|
557
|
-
|
|
558
|
-
// the portaled floating chat — pick up the workspace theme, while the
|
|
559
|
-
// sidebar outside stays default.
|
|
560
|
-
<div
|
|
561
|
-
ref={themeRef}
|
|
562
|
-
className="relative flex h-full min-h-0 flex-col bg-background font-sans text-foreground"
|
|
563
|
-
>
|
|
578
|
+
<div className="relative flex h-full min-h-0 flex-col bg-background font-sans text-foreground">
|
|
564
579
|
<div ref={rowRef} className="flex min-h-0 flex-1">
|
|
565
580
|
{/* Full-screen: whole panel. Split: the left content column. */}
|
|
566
581
|
{(mode === 'fullscreen' || hasWorkspaceContent) && (
|
|
@@ -573,7 +588,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
573
588
|
<img
|
|
574
589
|
src={icon ?? workspaceProviderIcon[provider ?? 'claude-code']}
|
|
575
590
|
alt=""
|
|
576
|
-
className="size-5 shrink-0 rounded-
|
|
591
|
+
className="size-5 shrink-0 rounded-xs"
|
|
577
592
|
/>
|
|
578
593
|
{name && (
|
|
579
594
|
<span className="truncate text-sm font-medium text-foreground">{name}</span>
|
|
@@ -635,7 +650,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
635
650
|
onDiscard={() => discardBuilder(activeBuilder)}
|
|
636
651
|
/>
|
|
637
652
|
) : activeView ? (
|
|
638
|
-
<ViewApp view={activeView} />
|
|
653
|
+
<ViewApp view={activeView} params={appletParams} />
|
|
639
654
|
) : null}
|
|
640
655
|
</div>
|
|
641
656
|
)}
|
|
@@ -653,7 +668,9 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
653
668
|
)}
|
|
654
669
|
</div>
|
|
655
670
|
|
|
656
|
-
<AnimatePresence>
|
|
671
|
+
<AnimatePresence>
|
|
672
|
+
{widgetMode === 'customizing' && <CustomizePanel onClose={() => setWidgetMode('idle')} />}
|
|
673
|
+
</AnimatePresence>
|
|
657
674
|
|
|
658
675
|
{mode === 'fullscreen' && activeTab !== 'agent' && hasWorkspaceContent && (
|
|
659
676
|
<ChatPopup
|
|
@@ -664,18 +681,23 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
664
681
|
setChatFocusRequest(request => request + 1)
|
|
665
682
|
}
|
|
666
683
|
}}
|
|
667
|
-
container={themeRef}
|
|
668
684
|
>
|
|
669
685
|
{onClose => (
|
|
670
686
|
<ChatPanel
|
|
671
687
|
active={floatingChatOpen}
|
|
672
688
|
focusRequest={chatFocusRequest}
|
|
689
|
+
chatLoaded={chatLoaded}
|
|
673
690
|
view={view}
|
|
674
691
|
previewTurn={previewTurn}
|
|
675
692
|
sessionId={sessionId}
|
|
676
693
|
processing={processing}
|
|
677
694
|
error={error}
|
|
678
695
|
onDismissError={dismissError}
|
|
696
|
+
composerBanner={
|
|
697
|
+
skillUpdateBanner ? (
|
|
698
|
+
<WorkspaceSkillUpdateBanner {...skillUpdateBanner} />
|
|
699
|
+
) : undefined
|
|
700
|
+
}
|
|
679
701
|
unavailableReason={unavailableReason}
|
|
680
702
|
send={send}
|
|
681
703
|
stop={stop}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { IconFolderExclamation, IconLoader2, IconX } from '@tabler/icons-react'
|
|
2
|
+
|
|
3
|
+
import { Button } from '@/client/components/ui/button'
|
|
4
|
+
import { cn } from '@/client/lib/cn'
|
|
5
|
+
|
|
6
|
+
export type WorkspaceSkillUpdateAction = 'auto' | 'once'
|
|
7
|
+
|
|
8
|
+
export type WorkspaceSkillUpdateBannerProps = {
|
|
9
|
+
error: string | null
|
|
10
|
+
pendingAction: WorkspaceSkillUpdateAction | null
|
|
11
|
+
onUpdate: (action: WorkspaceSkillUpdateAction) => void
|
|
12
|
+
onDismiss: () => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function WorkspaceSkillUpdateBanner({
|
|
16
|
+
error,
|
|
17
|
+
pendingAction,
|
|
18
|
+
onUpdate,
|
|
19
|
+
onDismiss
|
|
20
|
+
}: WorkspaceSkillUpdateBannerProps) {
|
|
21
|
+
if (!error && pendingAction === 'auto') {
|
|
22
|
+
return (
|
|
23
|
+
<div
|
|
24
|
+
role="status"
|
|
25
|
+
className="flex w-full items-center gap-1.5 p-2 text-sm text-muted-foreground"
|
|
26
|
+
>
|
|
27
|
+
<IconLoader2 size={20} stroke={1.5} className="shrink-0 animate-spin" />
|
|
28
|
+
<span className="wrap-break-word">Updating moi skills…</span>
|
|
29
|
+
</div>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const pending = pendingAction !== null
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div
|
|
37
|
+
role={error ? 'alert' : 'status'}
|
|
38
|
+
className={cn(
|
|
39
|
+
'grid w-full grid-cols-[minmax(0,1fr)_auto] gap-x-2 gap-y-2 p-2 text-sm',
|
|
40
|
+
'@xl:flex @xl:items-center @xl:px-2 @xl:pl-3',
|
|
41
|
+
error && 'text-destructive'
|
|
42
|
+
)}
|
|
43
|
+
>
|
|
44
|
+
<div className="flex min-w-0 items-start gap-1.5 @xl:order-1 @xl:flex-1 @xl:items-center">
|
|
45
|
+
<IconFolderExclamation size={20} stroke={1.5} className="shrink-0" />
|
|
46
|
+
{error ? (
|
|
47
|
+
<span className="wrap-break-word">{`Update failed: ${error}`}</span>
|
|
48
|
+
) : (
|
|
49
|
+
<span className="wrap-break-word">This workspace is using old moi skills</span>
|
|
50
|
+
)}
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<Button
|
|
54
|
+
type="button"
|
|
55
|
+
variant="ghost"
|
|
56
|
+
size="icon-sm"
|
|
57
|
+
onClick={onDismiss}
|
|
58
|
+
className="col-start-2 row-start-1 -mt-1 -mr-1 text-muted-foreground hover:text-foreground @xl:order-4 @xl:m-0"
|
|
59
|
+
aria-label="Dismiss skill update"
|
|
60
|
+
>
|
|
61
|
+
<IconX stroke={1.75} />
|
|
62
|
+
</Button>
|
|
63
|
+
|
|
64
|
+
<div className="col-span-2 flex flex-wrap gap-1.5 @xl:contents">
|
|
65
|
+
<Button
|
|
66
|
+
type="button"
|
|
67
|
+
variant="default"
|
|
68
|
+
size="sm"
|
|
69
|
+
onClick={() => onUpdate('auto')}
|
|
70
|
+
disabled={pending}
|
|
71
|
+
className="@xl:order-2"
|
|
72
|
+
>
|
|
73
|
+
{pendingAction === 'auto' && <IconLoader2 stroke={1.75} className="animate-spin" />}
|
|
74
|
+
{pendingAction === 'auto' ? 'Updating…' : 'Auto-update'}
|
|
75
|
+
</Button>
|
|
76
|
+
|
|
77
|
+
<Button
|
|
78
|
+
type="button"
|
|
79
|
+
variant="secondary"
|
|
80
|
+
size="sm"
|
|
81
|
+
onClick={() => onUpdate('once')}
|
|
82
|
+
disabled={pending}
|
|
83
|
+
className="@xl:order-3"
|
|
84
|
+
>
|
|
85
|
+
{pendingAction === 'once' && <IconLoader2 stroke={1.75} className="animate-spin" />}
|
|
86
|
+
{pendingAction === 'once' ? 'Updating…' : 'Update once'}
|
|
87
|
+
</Button>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
@@ -183,7 +183,7 @@ export function WorkspaceTabs({
|
|
|
183
183
|
className="flex w-max items-center gap-1"
|
|
184
184
|
onReorder={ordered => onReorder(ordered as WorkspaceTabId[])}
|
|
185
185
|
renderPlaceholder={() => (
|
|
186
|
-
<div className="pointer-events-none absolute inset-0 rounded-
|
|
186
|
+
<div className="pointer-events-none absolute inset-0 rounded-md bg-muted" />
|
|
187
187
|
)}
|
|
188
188
|
renderOverlay={tab => <WorkspaceTab tab={tab} active={active === tab.key} preview />}
|
|
189
189
|
renderItem={(tab, state) => (
|
|
@@ -8,6 +8,8 @@ import type {
|
|
|
8
8
|
ViewInfo,
|
|
9
9
|
WidgetInfo,
|
|
10
10
|
WorkspaceLayout,
|
|
11
|
+
WorkspaceSkillsStatus,
|
|
12
|
+
WorkspaceSkillsUpdateFailure,
|
|
11
13
|
WorkspaceType
|
|
12
14
|
} from '@/lib/types'
|
|
13
15
|
|
|
@@ -38,6 +40,56 @@ export function useWorkspaceAvailability(workspaceId: string) {
|
|
|
38
40
|
})
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
export function useWorkspaceSkills(workspaceId: string) {
|
|
44
|
+
return useQuery<WorkspaceSkillsStatus>({
|
|
45
|
+
queryKey: workspaceKeys.skills(workspaceId),
|
|
46
|
+
queryFn: () => requestJson(`/api/workspaces/${workspaceId}/skills`),
|
|
47
|
+
...WORKSPACE_RESOURCE_OPTIONS
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type WorkspaceSkillUpdateError = Error & {
|
|
52
|
+
status?: WorkspaceSkillsStatus
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function updateWorkspaceSkills(workspaceId: string): Promise<WorkspaceSkillsStatus> {
|
|
56
|
+
const response = await fetch(`/api/workspaces/${workspaceId}/skills/update`, { method: 'POST' })
|
|
57
|
+
const text = await response.text()
|
|
58
|
+
let body: WorkspaceSkillsStatus | WorkspaceSkillsUpdateFailure | null = null
|
|
59
|
+
try {
|
|
60
|
+
body = JSON.parse(text) as WorkspaceSkillsStatus | WorkspaceSkillsUpdateFailure
|
|
61
|
+
} catch {}
|
|
62
|
+
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
const message = body && 'error' in body ? body.error : text
|
|
65
|
+
const error = new Error(message || 'Failed to update workspace skill')
|
|
66
|
+
if (body?.skills) {
|
|
67
|
+
;(error as WorkspaceSkillUpdateError).status = {
|
|
68
|
+
skills: body.skills,
|
|
69
|
+
updateAvailable: body.updateAvailable
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
throw error
|
|
73
|
+
}
|
|
74
|
+
if (!body) throw new Error('Invalid workspace skill update response')
|
|
75
|
+
return body
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function useUpdateWorkspaceSkills(workspaceId: string) {
|
|
79
|
+
const queryClient = useQueryClient()
|
|
80
|
+
return useMutation<WorkspaceSkillsStatus, WorkspaceSkillUpdateError>({
|
|
81
|
+
mutationFn: () => updateWorkspaceSkills(workspaceId),
|
|
82
|
+
onSuccess: status => {
|
|
83
|
+
queryClient.setQueryData(workspaceKeys.skills(workspaceId), status)
|
|
84
|
+
},
|
|
85
|
+
onError: error => {
|
|
86
|
+
if (error.status) {
|
|
87
|
+
queryClient.setQueryData(workspaceKeys.skills(workspaceId), error.status)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
41
93
|
export function useWorkspaceWidgets(workspaceId: string) {
|
|
42
94
|
return useQuery<WidgetInfo[]>({
|
|
43
95
|
queryKey: workspaceKeys.widgets(workspaceId),
|