moi-computer 0.0.3 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bunfig.toml +4 -0
- package/client/api/workspaces.ts +277 -6
- package/client/assets/mcp/agentation.png +0 -0
- package/client/assets/mcp/airtable.png +0 -0
- package/client/assets/mcp/apollo.png +0 -0
- package/client/assets/mcp/asana.png +0 -0
- package/client/assets/mcp/box.png +0 -0
- package/client/assets/mcp/chrome.svg +33 -0
- package/client/assets/mcp/clickup.png +0 -0
- package/client/assets/mcp/cloudflare.png +0 -0
- package/client/assets/mcp/context7.png +0 -0
- package/client/assets/mcp/datadog.png +0 -0
- package/client/assets/mcp/dropbox.png +0 -0
- package/client/assets/mcp/elevenlabs.png +0 -0
- package/client/assets/mcp/exa.png +0 -0
- package/client/assets/mcp/firecrawl.png +0 -0
- package/client/assets/mcp/gmail.png +0 -0
- package/client/assets/mcp/googlecalendar.png +0 -0
- package/client/assets/mcp/googledrive.png +0 -0
- package/client/assets/mcp/grafana.png +0 -0
- package/client/assets/mcp/huggingface.png +0 -0
- package/client/assets/mcp/intercom.png +0 -0
- package/client/assets/mcp/monday.png +0 -0
- package/client/assets/mcp/mongodb.png +0 -0
- package/client/assets/mcp/paper.png +0 -0
- package/client/assets/mcp/paypal.png +0 -0
- package/client/assets/mcp/perplexity.png +0 -0
- package/client/assets/mcp/postgresql.png +0 -0
- package/client/assets/mcp/posthog.png +0 -0
- package/client/assets/mcp/puppeteer.png +0 -0
- package/client/assets/mcp/railway.png +0 -0
- package/client/assets/mcp/redis.png +0 -0
- package/client/assets/mcp/salesforce.png +0 -0
- package/client/assets/mcp/shopify.png +0 -0
- package/client/assets/mcp/snowflake.png +0 -0
- package/client/assets/mcp/telegram.png +0 -0
- package/client/assets/mcp/twilio.png +0 -0
- package/client/assets/mcp/zapier.png +0 -0
- package/client/components/App.tsx +7 -1
- package/client/components/ChatInput.tsx +194 -13
- package/client/components/ChatPanel.tsx +116 -47
- package/client/components/ChatPopup.tsx +1 -1
- package/client/components/IconMcp.tsx +21 -0
- package/client/components/McpMenu.tsx +125 -0
- package/client/components/ModelPicker.tsx +147 -0
- package/client/components/Scratchpad.tsx +775 -0
- package/client/components/ShimmerText.tsx +20 -0
- package/client/components/ThreadSelector.tsx +2 -2
- package/client/components/TurnView.tsx +111 -531
- package/client/components/WidgetShell.tsx +1 -1
- package/client/components/WorkspacesPage.tsx +12 -4
- package/client/components/layout/SidebarLayout.tsx +18 -9
- package/client/components/playground/ToolCallsPage.tsx +81 -0
- package/client/components/routes/workspace/[id].tsx +534 -141
- package/client/components/routes/workspace/create.tsx +155 -0
- package/client/components/settings/IconPicker.tsx +590 -0
- package/client/components/settings/SettingsPages.tsx +307 -0
- package/client/components/settings/WorkspaceSettings.tsx +92 -0
- package/client/components/tool-group/CodeBlock.tsx +41 -0
- package/client/components/tool-group/Collapse.tsx +28 -0
- package/client/components/tool-group/ReadImagePreview.tsx +46 -0
- package/client/components/tool-group/SubagentCard.tsx +135 -0
- package/client/components/tool-group/TimelineRow.tsx +147 -0
- package/client/components/tool-group/ToolCallGroup.tsx +231 -0
- package/client/components/tool-group/ToolOutput.tsx +139 -0
- package/client/components/tool-group/detect.ts +93 -0
- package/client/components/tool-group/fixtures.ts +315 -0
- package/client/components/tool-group/format.ts +211 -0
- package/client/components/tool-group/index.ts +9 -0
- package/client/components/ui/dialog.tsx +58 -0
- package/client/components/ui/hover-card.tsx +44 -0
- package/client/components/ui/switch.tsx +23 -0
- package/client/components/ui/tooltip.tsx +54 -0
- package/client/externalize-react.ts +6 -0
- package/client/hooks/useApplet.ts +117 -0
- package/client/hooks/useChat.ts +162 -62
- package/client/hooks/useMeiEvents.ts +9 -2
- package/client/hooks/useStickToBottom.ts +86 -0
- package/client/hooks/useWorkspaceTheme.ts +8 -2
- package/client/index.css +48 -2
- package/client/index.html +9 -5
- package/client/index.tsx +29 -2
- package/client/lib/WorkspaceContext.tsx +5 -8
- package/client/lib/WorkspaceLayoutContext.tsx +30 -10
- package/client/lib/applet-cache.ts +54 -0
- package/client/lib/connection.ts +237 -0
- package/client/lib/flags.ts +10 -0
- package/client/lib/mcp-icons.ts +142 -10
- package/client/lib/preview-turn.ts +37 -0
- package/client/lib/render-icon.ts +173 -0
- package/client/lib/scratch-executor.ts +20 -0
- package/client/lib/uploads.ts +18 -0
- package/client/main.tsx +5 -0
- package/client/store/live.ts +282 -0
- package/client/structured-clone-shim.ts +14 -0
- package/client/theme.css +2 -2
- package/client/vendor/emojibase/en/data.json +1 -0
- package/client/vendor/emojibase/en/messages.json +1 -0
- package/client/vendor/react/development/_impl/react-dom-client.js +15871 -0
- package/client/vendor/react/development/_impl/react-dom.js +223 -0
- package/client/vendor/react/development/_impl/react-jsx-dev-runtime.js +256 -0
- package/client/vendor/react/development/_impl/react-jsx-runtime.js +260 -0
- package/client/vendor/react/development/_impl/react.js +863 -0
- package/client/vendor/react/development/react-dom-client.js +6 -0
- package/client/vendor/react/development/react-dom.js +17 -0
- package/client/vendor/react/development/react-jsx-dev-runtime.js +5 -0
- package/client/vendor/react/development/react-jsx-runtime.js +6 -0
- package/client/vendor/react/development/react.js +47 -0
- package/client/vendor/react/production/_impl/react-dom-client.js +10361 -0
- package/client/vendor/react/production/_impl/react-dom.js +184 -0
- package/client/vendor/react/production/_impl/react-jsx-dev-runtime.js +37 -0
- package/client/vendor/react/production/_impl/react-jsx-runtime.js +60 -0
- package/client/vendor/react/production/_impl/react.js +428 -0
- package/client/vendor/react/production/react-dom-client.js +6 -0
- package/client/vendor/react/production/react-dom.js +17 -0
- package/client/vendor/react/production/react-jsx-dev-runtime.js +5 -0
- package/client/vendor/react/production/react-jsx-runtime.js +6 -0
- package/client/vendor/react/production/react.js +47 -0
- package/dist/agentation-4s0nn45p.png +0 -0
- package/dist/airtable-hsa66v6q.png +0 -0
- package/dist/apollo-2ed5dy2d.png +0 -0
- package/dist/asana-tvgtwbx2.png +0 -0
- package/dist/box-w3n36t5g.png +0 -0
- package/dist/chrome-tspm94rw.svg +33 -0
- package/dist/chunk-kc6e9nd4.css +1 -0
- package/dist/chunk-yf3p7qg7.js +673 -0
- package/dist/clickup-qqrqqvqb.png +0 -0
- package/dist/cloudflare-j9p931v6.png +0 -0
- package/dist/context7-8ht0xjfy.png +0 -0
- package/dist/datadog-70ne3yzt.png +0 -0
- package/dist/dropbox-4m5s9mgr.png +0 -0
- package/dist/elevenlabs-2nzzej1t.png +0 -0
- package/dist/exa-qqj3vr0x.png +0 -0
- package/dist/firecrawl-w2t8nehx.png +0 -0
- package/dist/gmail-sg6a5v3x.png +0 -0
- package/dist/googlecalendar-nqhh2v7r.png +0 -0
- package/dist/googledrive-6s8xyab7.png +0 -0
- package/dist/grafana-1yfsnwr6.png +0 -0
- package/dist/huggingface-kxzaxj83.png +0 -0
- package/dist/index.html +10 -6
- package/dist/intercom-td763jt8.png +0 -0
- package/dist/monday-jdbs4wwf.png +0 -0
- package/dist/mongodb-emzxvhd5.png +0 -0
- package/dist/paper-zbt34fab.png +0 -0
- package/dist/paypal-kwwf7xsc.png +0 -0
- package/dist/perplexity-4y63rxvj.png +0 -0
- package/dist/postgresql-qsspbsr1.png +0 -0
- package/dist/posthog-sphppc4w.png +0 -0
- package/dist/puppeteer-2xjt1a9b.png +0 -0
- package/dist/railway-834de8d2.png +0 -0
- package/dist/redis-spm6w2m1.png +0 -0
- package/dist/salesforce-1mk56v4z.png +0 -0
- package/dist/shopify-90dadaav.png +0 -0
- package/dist/snowflake-hfpykpgy.png +0 -0
- package/dist/telegram-v6tjyrs7.png +0 -0
- package/dist/twilio-dpyjdwpj.png +0 -0
- package/dist/zapier-p67qfch0.png +0 -0
- package/lib/attachment-note.ts +48 -0
- package/lib/claude-adapter.ts +219 -29
- package/lib/format.ts +32 -0
- package/lib/types.ts +314 -6
- package/package.json +11 -5
- package/server/CLAUDE.md +4 -1
- package/server/agent.ts +25 -118
- package/server/api.ts +593 -0
- package/server/applets.ts +396 -0
- package/server/build-applet.ts +580 -0
- package/server/cc-session.ts +611 -0
- package/server/cli-colors.ts +17 -0
- package/server/cli-ui.ts +52 -0
- package/server/cli.ts +965 -73
- package/server/constants.ts +1 -1
- package/server/control.ts +166 -19
- package/server/debug.ts +10 -0
- package/server/events.ts +24 -0
- package/server/functions-worker.ts +18 -2
- package/server/functions.ts +59 -12
- package/server/icon.ts +13 -0
- package/server/layout.ts +25 -3
- package/server/mcp.ts +125 -0
- package/server/moi-scaffold.ts +85 -0
- package/server/openclaw-session.ts +41 -10
- package/server/openclaw.ts +22 -0
- package/server/preview.ts +70 -0
- package/server/registry.ts +32 -2
- package/server/scratchpad-executor.ts +380 -0
- package/server/scratchpad-relay.ts +45 -0
- package/server/scratchpad.ts +171 -0
- package/server/skill-version.ts +146 -0
- package/server/skills-template.ts +6 -1
- package/server/state.ts +22 -36
- package/server/static.ts +23 -0
- package/server/status.ts +94 -0
- package/server/thread-config.ts +125 -0
- package/server/uploads.ts +0 -0
- package/server/vendor.ts +63 -0
- package/server/views.ts +0 -0
- package/server/web.ts +108 -253
- package/server/widgets.ts +52 -142
- package/server/workspace-config.ts +37 -0
- package/server/workspace-env.ts +407 -0
- package/server/workspace-init.ts +66 -0
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +109 -0
- package/workspace/.claude/skills/moi-workspace/SCRATCHPAD.md +57 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +252 -0
- package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +22 -0
- package/client/hooks/useWidget.ts +0 -72
- package/client/hooks/useWidgetList.ts +0 -30
- package/client/lib/ws.ts +0 -129
- package/client/store/chat.tsx +0 -162
- package/dist/chunk-4615fa69.js +0 -67
- package/dist/chunk-582xmy05.css +0 -1
- package/server/build-widget.ts +0 -343
- package/workspace/.claude/skills/widgets/DESIGN.md +0 -630
- package/workspace/.claude/skills/widgets/SKILL.md +0 -176
|
@@ -1,31 +1,70 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from
|
|
2
|
-
|
|
3
|
-
import { AnimatePresence, motion } from
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import {
|
|
24
|
-
import
|
|
1
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
IconAppWindow,
|
|
7
|
+
IconArtboard,
|
|
8
|
+
IconDots,
|
|
9
|
+
IconLayoutDashboard,
|
|
10
|
+
IconLayoutGrid,
|
|
11
|
+
IconMessageCircle,
|
|
12
|
+
IconPalette,
|
|
13
|
+
IconPlus,
|
|
14
|
+
} from "@tabler/icons-react";
|
|
15
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
useWorkspaceSessions,
|
|
19
|
+
useWorkspaceViews,
|
|
20
|
+
useWorkspaceWidgets,
|
|
21
|
+
workspaceKeys,
|
|
22
|
+
} from "@/client/api/workspaces";
|
|
23
|
+
import { ChatPanel } from "@/client/components/ChatPanel";
|
|
24
|
+
import { ChatPopup } from "@/client/components/ChatPopup";
|
|
25
|
+
import { McpMenu } from "@/client/components/McpMenu";
|
|
26
|
+
import { Scratchpad } from "@/client/components/Scratchpad";
|
|
27
|
+
import { WidgetErrorBoundary } from "@/client/components/WidgetErrorBoundary";
|
|
28
|
+
import { type WidgetMode, Widgets } from "@/client/components/Widgets";
|
|
29
|
+
import {
|
|
30
|
+
PanelHeader,
|
|
31
|
+
PROVIDER_ICON,
|
|
32
|
+
SidebarLayout,
|
|
33
|
+
SidebarToggle,
|
|
34
|
+
} from "@/client/components/layout/SidebarLayout";
|
|
35
|
+
import { LedLogo } from "@/client/components/playground/LedLogo";
|
|
36
|
+
import { Button } from "@/client/components/ui/button";
|
|
37
|
+
import {
|
|
38
|
+
DropdownMenu,
|
|
39
|
+
DropdownMenuCheckboxItem,
|
|
40
|
+
DropdownMenuContent,
|
|
41
|
+
DropdownMenuItem,
|
|
42
|
+
DropdownMenuSeparator,
|
|
43
|
+
DropdownMenuTrigger,
|
|
44
|
+
} from "@/client/components/ui/dropdown-menu";
|
|
45
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "@/client/components/ui/tooltip";
|
|
46
|
+
import { WorkspaceSettings } from "@/client/components/settings/WorkspaceSettings";
|
|
47
|
+
import { useChat } from "@/client/hooks/useChat";
|
|
48
|
+
import { useAppletCacheInvalidation, useView } from "@/client/hooks/useApplet";
|
|
49
|
+
import { useFitsSidebar } from "@/client/hooks/useFitsSidebar";
|
|
50
|
+
import { useGridReconcile } from "@/client/hooks/useGridReconcile";
|
|
51
|
+
import { useMeiEvent } from "@/client/hooks/useMeiEvents";
|
|
52
|
+
import { useWorkspaceTheme } from "@/client/hooks/useWorkspaceTheme";
|
|
53
|
+
import { Workspace } from "@/client/lib/WorkspaceContext";
|
|
54
|
+
import {
|
|
55
|
+
WorkspaceLayoutProvider,
|
|
56
|
+
useWorkspaceLayoutCtx,
|
|
57
|
+
} from "@/client/lib/WorkspaceLayoutContext";
|
|
58
|
+
import { cn } from "@/client/lib/cn";
|
|
59
|
+
import { liveStore } from "@/client/store/live";
|
|
60
|
+
import type { ChatDisplay, SessionInfo, ViewInfo, WidgetInfo } from "@/lib/types";
|
|
61
|
+
|
|
62
|
+
// Tab label for a view: its configured title, or the file-name id as fallback.
|
|
63
|
+
const viewLabel = (v: ViewInfo) => v.config.title || v.id;
|
|
25
64
|
|
|
26
65
|
type WorkspaceRouteProps = {
|
|
27
|
-
id: string
|
|
28
|
-
}
|
|
66
|
+
id: string;
|
|
67
|
+
};
|
|
29
68
|
|
|
30
69
|
// Route component for `/workspace/:id` — provides workspace id + layout context,
|
|
31
70
|
// then loads. Layout and widgets are React Query resources; chat (sessions,
|
|
@@ -38,97 +77,373 @@ export function WorkspaceRoute({ id }: WorkspaceRouteProps) {
|
|
|
38
77
|
<WorkspaceLoader id={id} />
|
|
39
78
|
</WorkspaceLayoutProvider>
|
|
40
79
|
</Workspace>
|
|
41
|
-
)
|
|
80
|
+
);
|
|
42
81
|
}
|
|
43
82
|
|
|
44
83
|
type WorkspaceLoaderProps = {
|
|
45
|
-
id: string
|
|
46
|
-
}
|
|
84
|
+
id: string;
|
|
85
|
+
};
|
|
47
86
|
|
|
48
87
|
function WorkspaceLoader({ id }: WorkspaceLoaderProps) {
|
|
49
|
-
const qc = useQueryClient()
|
|
50
|
-
const { layout, setLayout,
|
|
51
|
-
const widgets = useWorkspaceWidgets(id)
|
|
52
|
-
const
|
|
88
|
+
const qc = useQueryClient();
|
|
89
|
+
const { layout, setLayout, isLoading: layoutLoading } = useWorkspaceLayoutCtx();
|
|
90
|
+
const widgets = useWorkspaceWidgets(id);
|
|
91
|
+
const views = useWorkspaceViews(id);
|
|
92
|
+
const sessions = useWorkspaceSessions(id);
|
|
53
93
|
|
|
54
94
|
// Keep the grid balanced as widgets come and go. (Theme is applied inside
|
|
55
95
|
// WorkspaceView, scoped to the panel — see useWorkspaceTheme there.)
|
|
56
|
-
useGridReconcile(id, widgets.data, layout, setLayout)
|
|
96
|
+
useGridReconcile(id, widgets.data, layout, setLayout);
|
|
97
|
+
|
|
98
|
+
// Invalidate the shared applet module cache on every rebuild, even for views /
|
|
99
|
+
// widgets whose tab is currently backgrounded — so switching to them later
|
|
100
|
+
// loads the fresh bundle instead of a stale cached module.
|
|
101
|
+
useAppletCacheInvalidation();
|
|
57
102
|
|
|
58
103
|
// Server-pushed changes invalidate the matching query so the next render
|
|
59
104
|
// revalidates (theme re-applies; the grid reconcile places any new widget).
|
|
60
|
-
useMeiEvent(e => {
|
|
61
|
-
if (e.type ===
|
|
62
|
-
qc.invalidateQueries({ queryKey: workspaceKeys.layout(id) })
|
|
63
|
-
} else if (e.type ===
|
|
64
|
-
qc.invalidateQueries({ queryKey: workspaceKeys.widgets(id) })
|
|
105
|
+
useMeiEvent((e) => {
|
|
106
|
+
if (e.type === "theme:updated" || e.type === "workspace:updated") {
|
|
107
|
+
qc.invalidateQueries({ queryKey: workspaceKeys.layout(id) });
|
|
108
|
+
} else if (e.type === "widget-layout:updated") {
|
|
109
|
+
qc.invalidateQueries({ queryKey: workspaceKeys.widgets(id) });
|
|
110
|
+
} else if (e.type === "view-layout:updated") {
|
|
111
|
+
qc.invalidateQueries({ queryKey: workspaceKeys.views(id) });
|
|
65
112
|
}
|
|
66
|
-
})
|
|
113
|
+
});
|
|
67
114
|
|
|
68
115
|
// Fresh visit (nothing cached) → centered MOI logo in the panel. Switch-back
|
|
69
116
|
// shows cached data immediately while it revalidates, so no loader then.
|
|
70
|
-
const fresh = layoutLoading || widgets.isLoading
|
|
117
|
+
const fresh = layoutLoading || widgets.isLoading;
|
|
71
118
|
|
|
72
|
-
//
|
|
73
|
-
//
|
|
119
|
+
// Chat state lives in app-level stores (RQ cache + live store), not here, so
|
|
120
|
+
// navigation never discards an in-flight run — we just seed the active thread.
|
|
74
121
|
return (
|
|
75
|
-
|
|
76
|
-
<SeedActiveSession sessions={sessions.data} />
|
|
122
|
+
<>
|
|
123
|
+
<SeedActiveSession workspaceId={id} sessions={sessions.data} />
|
|
77
124
|
<SidebarLayout>
|
|
78
125
|
{fresh ? (
|
|
79
126
|
<div className="flex h-full items-center justify-center">
|
|
80
127
|
<LedLogo sprite="moi" effect="chaos" />
|
|
81
128
|
</div>
|
|
82
129
|
) : (
|
|
83
|
-
<WorkspaceView widgets={widgets.data ?? []} />
|
|
130
|
+
<WorkspaceView widgets={widgets.data ?? []} views={views.data ?? []} />
|
|
84
131
|
)}
|
|
85
132
|
</SidebarLayout>
|
|
86
|
-
|
|
87
|
-
)
|
|
133
|
+
</>
|
|
134
|
+
);
|
|
88
135
|
}
|
|
89
136
|
|
|
90
137
|
type SeedActiveSessionProps = {
|
|
91
|
-
|
|
92
|
-
|
|
138
|
+
workspaceId: string;
|
|
139
|
+
sessions: SessionInfo[] | undefined;
|
|
140
|
+
};
|
|
93
141
|
|
|
94
|
-
// Picks an active thread once the sessions query resolves. A
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
|
|
142
|
+
// Picks an active thread once the sessions query resolves. A workspace with no
|
|
143
|
+
// active selection yet gets the most recent thread; it also re-selects if the
|
|
144
|
+
// current one vanished from the list. Keyed per workspace in the live store, so
|
|
145
|
+
// the choice persists across navigation.
|
|
146
|
+
function SeedActiveSession({ workspaceId, sessions }: SeedActiveSessionProps) {
|
|
99
147
|
useEffect(() => {
|
|
100
|
-
if (!sessions) return
|
|
101
|
-
const active =
|
|
102
|
-
const stillValid = active && sessions.some(s => s.sessionId === active)
|
|
103
|
-
if (!stillValid)
|
|
104
|
-
}, [
|
|
105
|
-
return null
|
|
148
|
+
if (!sessions) return;
|
|
149
|
+
const active = liveStore.getState().activeByWorkspace[workspaceId] ?? null;
|
|
150
|
+
const stillValid = active && sessions.some((s) => s.sessionId === active);
|
|
151
|
+
if (!stillValid) liveStore.getState().setActive(workspaceId, sessions[0]?.sessionId ?? null);
|
|
152
|
+
}, [workspaceId, sessions]);
|
|
153
|
+
return null;
|
|
106
154
|
}
|
|
107
155
|
|
|
108
156
|
const ACTION_VARIANTS = {
|
|
109
|
-
from: { opacity: 0, scale: 0.8, filter:
|
|
110
|
-
to: { opacity: 1, scale: 1, filter:
|
|
157
|
+
from: { opacity: 0, scale: 0.8, filter: "blur(4px)" },
|
|
158
|
+
to: { opacity: 1, scale: 1, filter: "blur(0px)" },
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// A nav target: a fixed tab, or a view id. The `(string & {})` keeps editor
|
|
162
|
+
// autocomplete for the fixed keys while still accepting arbitrary view ids.
|
|
163
|
+
// Held in WorkspaceView's local state (transient — never persisted): "chat"
|
|
164
|
+
// shows the chat fullscreen; "widgets" / "canvas" / a view id fill the main area
|
|
165
|
+
// with the chat in its persisted position beside it.
|
|
166
|
+
type WorkspaceNav = "chat" | "widgets" | "canvas" | (string & {});
|
|
167
|
+
|
|
168
|
+
type WorkspaceTabsProps = {
|
|
169
|
+
active: WorkspaceNav;
|
|
170
|
+
onSelect: (nav: WorkspaceNav) => void;
|
|
171
|
+
views: ViewInfo[];
|
|
172
|
+
onCreateView: () => void;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// Shared geometry for every header tab. The active outline uses an inset shadow
|
|
176
|
+
// (not a border) so the box keeps the exact h-7 footprint — no 1px layout shift.
|
|
177
|
+
// Labels never wrap and the leading icon never shrinks, so a long view name keeps
|
|
178
|
+
// its full footprint. No color transition: switching tabs swaps the bg/border
|
|
179
|
+
// instantly.
|
|
180
|
+
const TAB_BASE =
|
|
181
|
+
"inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-md px-2.5 text-sm font-medium whitespace-nowrap [&_svg]:size-[18px] [&_svg]:shrink-0";
|
|
182
|
+
|
|
183
|
+
// Square (w = h) geometry modifier for icon-only triggers.
|
|
184
|
+
const ICON_TAB_SQUARE = "size-7 justify-center px-0";
|
|
185
|
+
|
|
186
|
+
// Labeled tabs (and the chat icon) keep a constant foreground text color; only
|
|
187
|
+
// the background and (when active) the inset-shadow border change between states.
|
|
188
|
+
const tabClass = (isActive: boolean) =>
|
|
189
|
+
cn(
|
|
190
|
+
TAB_BASE,
|
|
191
|
+
"text-foreground",
|
|
192
|
+
isActive ? "bg-muted shadow-[inset_0_0_0_1px_var(--border)]" : "hover:bg-muted/60",
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
// The "…" overflow trigger stays gray until active/hovered — it doesn't follow
|
|
196
|
+
// the always-foreground rule the labeled tabs use.
|
|
197
|
+
const iconTabClass = (isActive: boolean) =>
|
|
198
|
+
cn(
|
|
199
|
+
TAB_BASE,
|
|
200
|
+
ICON_TAB_SQUARE,
|
|
201
|
+
isActive
|
|
202
|
+
? "bg-muted text-foreground shadow-[inset_0_0_0_1px_var(--border)]"
|
|
203
|
+
: "text-muted-foreground hover:bg-muted/60 hover:text-foreground",
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
// A collapsible tab. `kind` groups the overflow menu: predefined tabs (widgets,
|
|
207
|
+
// canvas) sit above the custom views, separated by a divider.
|
|
208
|
+
type TabItem = {
|
|
209
|
+
key: WorkspaceNav;
|
|
210
|
+
Icon: typeof IconMessageCircle;
|
|
211
|
+
label: string;
|
|
212
|
+
kind: "fixed" | "view";
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
type OverflowTabsProps = {
|
|
216
|
+
tabs: TabItem[];
|
|
217
|
+
active: WorkspaceNav;
|
|
218
|
+
onSelect: (nav: WorkspaceNav) => void;
|
|
219
|
+
onCreateView: () => void;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// A horizontal strip of tabs that fills its available width and folds whatever
|
|
223
|
+
// doesn't fit into a trailing "…" menu, recomputing on resize. It measures each
|
|
224
|
+
// tab's natural width with a hidden mirror row (container queries can't see
|
|
225
|
+
// variable label widths), tracks its own width via a ResizeObserver, then shows
|
|
226
|
+
// as many tabs as fit and hides the rest — rightmost first — into the menu.
|
|
227
|
+
function OverflowTabs({ tabs, active, onSelect, onCreateView }: OverflowTabsProps) {
|
|
228
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
229
|
+
const mirrorRefs = useRef<(HTMLButtonElement | null)[]>([]);
|
|
230
|
+
const menuRef = useRef<HTMLButtonElement>(null);
|
|
231
|
+
const [avail, setAvail] = useState(0);
|
|
232
|
+
const [widths, setWidths] = useState<{ items: number[]; menu: number }>({ items: [], menu: 0 });
|
|
233
|
+
|
|
234
|
+
// Re-measure natural widths whenever the set of tabs (or their labels) changes.
|
|
235
|
+
const sig = tabs.map((t) => `${t.key}:${t.label}`).join("|");
|
|
236
|
+
useLayoutEffect(() => {
|
|
237
|
+
setWidths({
|
|
238
|
+
items: tabs.map((_, i) => mirrorRefs.current[i]?.offsetWidth ?? 0),
|
|
239
|
+
menu: menuRef.current?.offsetWidth ?? 0,
|
|
240
|
+
});
|
|
241
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
242
|
+
}, [sig]);
|
|
243
|
+
|
|
244
|
+
// Track the strip's available width (it grows to fill the header's slack).
|
|
245
|
+
useLayoutEffect(() => {
|
|
246
|
+
const el = rootRef.current;
|
|
247
|
+
if (!el) return;
|
|
248
|
+
const update = () => setAvail(el.clientWidth);
|
|
249
|
+
update();
|
|
250
|
+
const ro = new ResizeObserver(update);
|
|
251
|
+
ro.observe(el);
|
|
252
|
+
return () => ro.disconnect();
|
|
253
|
+
}, []);
|
|
254
|
+
|
|
255
|
+
// How many tabs fit: the "…" trigger is always reserved, then add tabs L→R
|
|
256
|
+
// while they fit. GAP mirrors the `gap-1` (4px) between buttons.
|
|
257
|
+
const visibleCount = useMemo(() => {
|
|
258
|
+
const GAP = 4;
|
|
259
|
+
if (!avail || widths.items.length !== tabs.length) return tabs.length;
|
|
260
|
+
let used = widths.menu;
|
|
261
|
+
let count = 0;
|
|
262
|
+
for (const w of widths.items) {
|
|
263
|
+
if (used + w + GAP <= avail) {
|
|
264
|
+
used += w + GAP;
|
|
265
|
+
count++;
|
|
266
|
+
} else break;
|
|
267
|
+
}
|
|
268
|
+
return count;
|
|
269
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
270
|
+
}, [avail, widths, tabs.length]);
|
|
271
|
+
|
|
272
|
+
const overflow = tabs.slice(visibleCount);
|
|
273
|
+
const overflowFixed = overflow.filter((t) => t.kind === "fixed");
|
|
274
|
+
const overflowViews = overflow.filter((t) => t.kind === "view");
|
|
275
|
+
// The "…" trigger lights up when one of the folded-away tabs is the active one.
|
|
276
|
+
const overflowActive = overflow.some((t) => t.key === active);
|
|
277
|
+
|
|
278
|
+
const menuItem = ({ key, Icon, label }: TabItem) => (
|
|
279
|
+
<DropdownMenuCheckboxItem
|
|
280
|
+
key={key}
|
|
281
|
+
checked={active === key}
|
|
282
|
+
closeOnClick
|
|
283
|
+
onClick={() => onSelect(key)}
|
|
284
|
+
>
|
|
285
|
+
<Icon stroke={1.75} />
|
|
286
|
+
{label}
|
|
287
|
+
</DropdownMenuCheckboxItem>
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
return (
|
|
291
|
+
<div ref={rootRef} className="relative flex min-w-0 flex-1 items-center gap-1">
|
|
292
|
+
{/* Hidden mirror: every tab + the menu trigger at natural width, laid out
|
|
293
|
+
but invisible and out of flow, read via the refs above. */}
|
|
294
|
+
<div
|
|
295
|
+
aria-hidden
|
|
296
|
+
className="pointer-events-none invisible absolute left-0 top-0 flex items-center gap-1"
|
|
297
|
+
>
|
|
298
|
+
{tabs.map(({ key, Icon, label }, i) => (
|
|
299
|
+
<button
|
|
300
|
+
key={key}
|
|
301
|
+
ref={(el) => {
|
|
302
|
+
mirrorRefs.current[i] = el;
|
|
303
|
+
}}
|
|
304
|
+
type="button"
|
|
305
|
+
className={tabClass(false)}
|
|
306
|
+
>
|
|
307
|
+
<Icon stroke={1.75} />
|
|
308
|
+
{label}
|
|
309
|
+
</button>
|
|
310
|
+
))}
|
|
311
|
+
<button ref={menuRef} type="button" className={iconTabClass(false)}>
|
|
312
|
+
<IconDots stroke={1.75} />
|
|
313
|
+
</button>
|
|
314
|
+
</div>
|
|
315
|
+
|
|
316
|
+
{tabs.slice(0, visibleCount).map(({ key, Icon, label }) => (
|
|
317
|
+
<button
|
|
318
|
+
key={key}
|
|
319
|
+
type="button"
|
|
320
|
+
className={tabClass(active === key)}
|
|
321
|
+
onClick={() => onSelect(key)}
|
|
322
|
+
>
|
|
323
|
+
<Icon stroke={1.75} />
|
|
324
|
+
{label}
|
|
325
|
+
</button>
|
|
326
|
+
))}
|
|
327
|
+
|
|
328
|
+
<DropdownMenu>
|
|
329
|
+
<DropdownMenuTrigger
|
|
330
|
+
render={
|
|
331
|
+
<button type="button" className={iconTabClass(overflowActive)} aria-label="More views">
|
|
332
|
+
<IconDots stroke={1.75} />
|
|
333
|
+
</button>
|
|
334
|
+
}
|
|
335
|
+
/>
|
|
336
|
+
<DropdownMenuContent align="start" className="min-w-48">
|
|
337
|
+
{overflowFixed.map(menuItem)}
|
|
338
|
+
{overflowFixed.length > 0 && overflowViews.length > 0 && <DropdownMenuSeparator />}
|
|
339
|
+
{overflowViews.map(menuItem)}
|
|
340
|
+
{overflow.length > 0 && <DropdownMenuSeparator />}
|
|
341
|
+
<DropdownMenuItem onClick={onCreateView}>
|
|
342
|
+
<IconPlus stroke={1.75} />
|
|
343
|
+
Create View
|
|
344
|
+
</DropdownMenuItem>
|
|
345
|
+
</DropdownMenuContent>
|
|
346
|
+
</DropdownMenu>
|
|
347
|
+
</div>
|
|
348
|
+
);
|
|
111
349
|
}
|
|
112
350
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
351
|
+
// The workspace nav: a pinned fullscreen-chat icon, then the collapsible strip of
|
|
352
|
+
// Widgets / Scratchpad / view tabs, which folds overflow into a "…" menu.
|
|
353
|
+
function WorkspaceTabs({ active, onSelect, views, onCreateView }: WorkspaceTabsProps) {
|
|
354
|
+
const tabs: TabItem[] = [
|
|
355
|
+
{ key: "widgets", Icon: IconLayoutGrid, label: "Widgets", kind: "fixed" },
|
|
356
|
+
{ key: "canvas", Icon: IconArtboard, label: "Scratchpad", kind: "fixed" },
|
|
357
|
+
...views.map(
|
|
358
|
+
(v): TabItem => ({ key: v.id, Icon: IconAppWindow, label: viewLabel(v), kind: "view" }),
|
|
359
|
+
),
|
|
360
|
+
];
|
|
361
|
+
|
|
362
|
+
return (
|
|
363
|
+
<div className="flex min-w-0 flex-1 items-center gap-1">
|
|
364
|
+
<Tooltip delay={50}>
|
|
365
|
+
<TooltipTrigger
|
|
366
|
+
render={
|
|
367
|
+
<button
|
|
368
|
+
type="button"
|
|
369
|
+
className={cn(tabClass(active === "chat"), ICON_TAB_SQUARE, "shrink-0")}
|
|
370
|
+
onClick={() => onSelect("chat")}
|
|
371
|
+
aria-label="Open fullscreen chat"
|
|
372
|
+
>
|
|
373
|
+
<IconMessageCircle stroke={1.75} />
|
|
374
|
+
</button>
|
|
375
|
+
}
|
|
376
|
+
/>
|
|
377
|
+
<TooltipContent>Open fullscreen chat</TooltipContent>
|
|
378
|
+
</Tooltip>
|
|
379
|
+
<OverflowTabs tabs={tabs} active={active} onSelect={onSelect} onCreateView={onCreateView} />
|
|
380
|
+
</div>
|
|
381
|
+
);
|
|
116
382
|
}
|
|
117
383
|
|
|
384
|
+
type ViewAppProps = {
|
|
385
|
+
view: ViewInfo;
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
// A view — an agent-defined app — mounted full-area. The bundle owns its own
|
|
389
|
+
// layout + scroll, so we give it a plain filled box and fade it in (mirroring
|
|
390
|
+
// WidgetShell, but full-area instead of a grid cell).
|
|
391
|
+
function ViewApp({ view }: ViewAppProps) {
|
|
392
|
+
const bundle = useView(view.id);
|
|
393
|
+
|
|
394
|
+
return (
|
|
395
|
+
<div className="relative min-h-0 flex-1 overflow-hidden">
|
|
396
|
+
<AnimatePresence mode="wait" initial={false}>
|
|
397
|
+
{bundle.status === "ready" && (
|
|
398
|
+
<motion.div
|
|
399
|
+
key={bundle.version}
|
|
400
|
+
className="absolute inset-0 overflow-auto"
|
|
401
|
+
initial={{ opacity: 0, filter: "blur(4px)" }}
|
|
402
|
+
animate={{ opacity: 1, filter: "blur(0px)" }}
|
|
403
|
+
exit={{ opacity: 0, filter: "blur(4px)" }}
|
|
404
|
+
transition={{ duration: 0.3, ease: "easeInOut" }}
|
|
405
|
+
>
|
|
406
|
+
<WidgetErrorBoundary name={view.id} resetKey={bundle.version}>
|
|
407
|
+
<bundle.Component />
|
|
408
|
+
</WidgetErrorBoundary>
|
|
409
|
+
</motion.div>
|
|
410
|
+
)}
|
|
411
|
+
{bundle.status === "error" && (
|
|
412
|
+
<motion.p
|
|
413
|
+
key={`err-${bundle.version}`}
|
|
414
|
+
className="text-destructive absolute inset-0 p-4 text-xs"
|
|
415
|
+
initial={{ opacity: 0 }}
|
|
416
|
+
animate={{ opacity: 1 }}
|
|
417
|
+
exit={{ opacity: 0 }}
|
|
418
|
+
transition={{ duration: 0.3, ease: "easeInOut" }}
|
|
419
|
+
>
|
|
420
|
+
{bundle.error}
|
|
421
|
+
</motion.p>
|
|
422
|
+
)}
|
|
423
|
+
</AnimatePresence>
|
|
424
|
+
</div>
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
type WidgetActionsProps = {
|
|
429
|
+
mode: WidgetMode;
|
|
430
|
+
onMode: (mode: WidgetMode) => void;
|
|
431
|
+
};
|
|
432
|
+
|
|
118
433
|
// Widget controls — live in the page header (right side), always visible.
|
|
119
434
|
function WidgetActions({ mode, onMode }: WidgetActionsProps) {
|
|
120
435
|
return (
|
|
121
436
|
<AnimatePresence mode="popLayout" initial={false}>
|
|
122
|
-
{mode !==
|
|
437
|
+
{mode !== "idle" ? (
|
|
123
438
|
<motion.div
|
|
124
439
|
key="done"
|
|
125
440
|
variants={ACTION_VARIANTS}
|
|
126
441
|
initial="from"
|
|
127
442
|
animate="to"
|
|
128
443
|
exit="from"
|
|
129
|
-
transition={{ type:
|
|
444
|
+
transition={{ type: "spring", duration: 0.3, bounce: 0 }}
|
|
130
445
|
>
|
|
131
|
-
<Button onClick={() => onMode(
|
|
446
|
+
<Button onClick={() => onMode("idle")}>Done</Button>
|
|
132
447
|
</motion.div>
|
|
133
448
|
) : (
|
|
134
449
|
<motion.div
|
|
@@ -138,75 +453,130 @@ function WidgetActions({ mode, onMode }: WidgetActionsProps) {
|
|
|
138
453
|
initial="from"
|
|
139
454
|
animate="to"
|
|
140
455
|
exit="from"
|
|
141
|
-
transition={{ type:
|
|
456
|
+
transition={{ type: "spring", duration: 0.3, bounce: 0 }}
|
|
142
457
|
>
|
|
143
458
|
<Button
|
|
144
459
|
variant="ghost"
|
|
145
|
-
className="text-muted-foreground [&_svg]:size-[18px]"
|
|
146
|
-
onClick={() => onMode(
|
|
460
|
+
className="h-7 text-muted-foreground @max-3xl:px-1.5! [&_svg]:size-[18px]"
|
|
461
|
+
onClick={() => onMode("customizing")}
|
|
147
462
|
>
|
|
148
463
|
<IconPalette stroke={1.75} />
|
|
149
|
-
Customize
|
|
464
|
+
<span className="@max-3xl:hidden">Customize</span>
|
|
150
465
|
</Button>
|
|
151
466
|
<Button
|
|
152
467
|
variant="ghost"
|
|
153
|
-
className="text-muted-foreground [&_svg]:size-[18px]"
|
|
154
|
-
onClick={() => onMode(
|
|
468
|
+
className="h-7 text-muted-foreground @max-3xl:px-1.5! [&_svg]:size-[18px]"
|
|
469
|
+
onClick={() => onMode("editing")}
|
|
155
470
|
>
|
|
156
471
|
<IconLayoutDashboard stroke={1.75} />
|
|
157
|
-
Edit widgets
|
|
472
|
+
<span className="@max-3xl:hidden">Edit widgets</span>
|
|
158
473
|
</Button>
|
|
159
474
|
</motion.div>
|
|
160
475
|
)}
|
|
161
476
|
</AnimatePresence>
|
|
162
|
-
)
|
|
477
|
+
);
|
|
163
478
|
}
|
|
164
479
|
|
|
165
480
|
type WorkspaceViewProps = {
|
|
166
|
-
widgets: WidgetInfo[]
|
|
167
|
-
|
|
481
|
+
widgets: WidgetInfo[];
|
|
482
|
+
views: ViewInfo[];
|
|
483
|
+
};
|
|
168
484
|
|
|
169
|
-
function WorkspaceView({ widgets }: WorkspaceViewProps) {
|
|
170
|
-
const {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
485
|
+
function WorkspaceView({ widgets, views }: WorkspaceViewProps) {
|
|
486
|
+
const {
|
|
487
|
+
view,
|
|
488
|
+
previewTurn,
|
|
489
|
+
sessionId,
|
|
490
|
+
processing,
|
|
491
|
+
error,
|
|
492
|
+
send,
|
|
493
|
+
stop,
|
|
494
|
+
switchThread,
|
|
495
|
+
dismissError,
|
|
496
|
+
} = useChat();
|
|
497
|
+
const { layout, setLayout, name, icon, provider } = useWorkspaceLayoutCtx();
|
|
498
|
+
const { ref: rowRef, fits: canFitSidebar } = useFitsSidebar<HTMLDivElement>();
|
|
499
|
+
const [widgetMode, setWidgetMode] = useState<WidgetMode>("idle");
|
|
500
|
+
// Two orthogonal, transient local bits: which body is selected (a fixed tab or
|
|
501
|
+
// a view id), and whether the chat is fullscreen. Fullscreen overrides (never
|
|
502
|
+
// persists) the chat's dock position, and toggling it keeps the body beneath.
|
|
503
|
+
const [bodyTab, setBodyTab] = useState<string>("widgets");
|
|
504
|
+
const [fullscreen, setFullscreen] = useState(false);
|
|
175
505
|
|
|
176
506
|
// Theme is scoped to this wrapper, not :root — the sidebar keeps the default
|
|
177
507
|
// tokens. The floating chat portals into the same element so it inherits them.
|
|
178
|
-
const themeRef = useRef<HTMLDivElement>(null)
|
|
179
|
-
useWorkspaceTheme(layout.theme, themeRef)
|
|
508
|
+
const themeRef = useRef<HTMLDivElement>(null);
|
|
509
|
+
useWorkspaceTheme(layout.theme, themeRef);
|
|
510
|
+
|
|
511
|
+
const hasWidgets = widgets.length > 0;
|
|
512
|
+
// The persisted position switch (sidebar ⇄ floating) only matters with widgets
|
|
513
|
+
// to dock beside; a solo chat is always fullscreen.
|
|
514
|
+
const canChangeChatMode = hasWidgets;
|
|
180
515
|
|
|
181
|
-
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
const
|
|
185
|
-
hasWidgets
|
|
516
|
+
// How the chat is shown: fullscreen (the chat view, or a solo chat), otherwise
|
|
517
|
+
// its persisted position — sidebar, or floating (also the fallback when a
|
|
518
|
+
// docked sidebar no longer fits). Fullscreen never touches the saved position.
|
|
519
|
+
const display: ChatDisplay =
|
|
520
|
+
!hasWidgets || fullscreen
|
|
521
|
+
? "fullscreen"
|
|
522
|
+
: layout.chatMode === "floating" || !canFitSidebar
|
|
523
|
+
? "floating"
|
|
524
|
+
: "sidebar";
|
|
186
525
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
526
|
+
// The nav highlights whatever fills the main area.
|
|
527
|
+
const activeNav: WorkspaceNav = display === "fullscreen" ? "chat" : bodyTab;
|
|
528
|
+
|
|
529
|
+
// Nav tabs: "chat" goes fullscreen; a body tab (widgets / canvas / view id)
|
|
530
|
+
// leaves fullscreen and shows it.
|
|
531
|
+
const selectNav = (v: WorkspaceNav) => {
|
|
532
|
+
if (v === "chat") setFullscreen(true);
|
|
533
|
+
else {
|
|
534
|
+
setBodyTab(v);
|
|
535
|
+
setFullscreen(false);
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
// "Create View" is a no-op for now — views are authored by the agent via the
|
|
540
|
+
// CLI (`.moi/views/<name>.tsx` + `moi bundle`), not from the UI.
|
|
541
|
+
const createView = () => {};
|
|
542
|
+
// The active view, when a view (not a fixed tab) fills the main area.
|
|
543
|
+
const activeView = views.find((v) => v.id === bodyTab);
|
|
544
|
+
|
|
545
|
+
// If the active view's file was deleted (its bundle vanished from the list),
|
|
546
|
+
// `bodyTab` dangles — fall back to the widget grid so nothing renders blank.
|
|
547
|
+
const isViewTab = bodyTab !== "widgets" && bodyTab !== "canvas";
|
|
548
|
+
useEffect(() => {
|
|
549
|
+
if (isViewTab && !activeView) setBodyTab("widgets");
|
|
550
|
+
}, [isViewTab, activeView]);
|
|
551
|
+
|
|
552
|
+
// The chat-mode picker switches the display: fullscreen is the transient view;
|
|
553
|
+
// sidebar/floating persist the dock position (and leave fullscreen).
|
|
554
|
+
const handleModeChange = canChangeChatMode
|
|
555
|
+
? (mode: ChatDisplay) => {
|
|
556
|
+
if (mode === "fullscreen") setFullscreen(true);
|
|
557
|
+
else {
|
|
558
|
+
setLayout({ chatMode: mode });
|
|
559
|
+
setFullscreen(false);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
: undefined;
|
|
190
563
|
|
|
191
564
|
const chatPanel = (
|
|
192
565
|
<ChatPanel
|
|
193
566
|
view={view}
|
|
194
|
-
|
|
195
|
-
|
|
567
|
+
previewTurn={previewTurn}
|
|
568
|
+
sessionId={sessionId}
|
|
196
569
|
processing={processing}
|
|
197
570
|
error={error}
|
|
198
571
|
onDismissError={dismissError}
|
|
199
572
|
send={send}
|
|
200
573
|
stop={stop}
|
|
201
|
-
chatMode={
|
|
574
|
+
chatMode={display}
|
|
202
575
|
onSwitchThread={switchThread}
|
|
203
576
|
onModeChange={handleModeChange}
|
|
204
|
-
onCollapse={() => setLayout({ chatMode:
|
|
205
|
-
// With no widgets there's no LHS header beside the chat, so host the
|
|
206
|
-
// sidebar toggle in the chat header instead.
|
|
207
|
-
leading={hasWidgets ? undefined : <SidebarToggle />}
|
|
577
|
+
onCollapse={() => setLayout({ chatMode: "floating" })}
|
|
208
578
|
/>
|
|
209
|
-
)
|
|
579
|
+
);
|
|
210
580
|
|
|
211
581
|
return (
|
|
212
582
|
// Themed wrapper: scoped CSS vars (bg/fg/font) live here so the panel — and
|
|
@@ -216,60 +586,83 @@ function WorkspaceView({ widgets }: WorkspaceViewProps) {
|
|
|
216
586
|
ref={themeRef}
|
|
217
587
|
className="bg-background text-foreground flex h-full min-h-0 flex-col font-sans"
|
|
218
588
|
>
|
|
219
|
-
{/*
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
589
|
+
{/* One shared header always sits atop the main content area, whose body is
|
|
590
|
+
the chat (fullscreen), the widget grid, or the scratchpad per the active
|
|
591
|
+
nav. A docked chat is an extra column beside it. rowRef stays mounted so
|
|
592
|
+
the sidebar-fit measurement (full panel width) survives mode switches. */}
|
|
593
|
+
<div ref={rowRef} className="flex min-h-0 flex-1">
|
|
594
|
+
<div
|
|
595
|
+
className={cn(
|
|
596
|
+
"flex min-h-0 flex-1 flex-col",
|
|
597
|
+
// Border + min width only while a chat docks beside the main area.
|
|
598
|
+
display !== "fullscreen" && "border-border min-w-[var(--column-w)] border-r",
|
|
599
|
+
)}
|
|
600
|
+
>
|
|
601
|
+
<PanelHeader>
|
|
602
|
+
<SidebarToggle />
|
|
603
|
+
<img
|
|
604
|
+
src={icon ?? PROVIDER_ICON[provider ?? "claude-code"]}
|
|
605
|
+
alt=""
|
|
606
|
+
className="size-5 shrink-0 rounded-[4px]"
|
|
607
|
+
/>
|
|
608
|
+
{name && <span className="text-foreground truncate text-sm font-medium">{name}</span>}
|
|
609
|
+
{hasWidgets ? (
|
|
610
|
+
<>
|
|
611
|
+
<span className="text-muted-foreground/40 select-none text-sm">/</span>
|
|
612
|
+
{/* The tabs strip grows to fill the header's slack and measures
|
|
613
|
+
its own width to fold overflow into the "…" menu, so it owns
|
|
614
|
+
the spacer role here. */}
|
|
615
|
+
<WorkspaceTabs
|
|
616
|
+
active={activeNav}
|
|
617
|
+
onSelect={selectNav}
|
|
618
|
+
views={views}
|
|
619
|
+
onCreateView={createView}
|
|
620
|
+
/>
|
|
621
|
+
</>
|
|
622
|
+
) : (
|
|
228
623
|
<div className="flex-1" />
|
|
229
|
-
|
|
230
|
-
|
|
624
|
+
)}
|
|
625
|
+
{activeNav === "widgets" && <WidgetActions mode={widgetMode} onMode={setWidgetMode} />}
|
|
626
|
+
<McpMenu />
|
|
627
|
+
<WorkspaceSettings />
|
|
628
|
+
</PanelHeader>
|
|
629
|
+
|
|
630
|
+
{activeNav === "chat" ? (
|
|
631
|
+
<div className="flex min-h-0 flex-1 flex-col overflow-hidden">{chatPanel}</div>
|
|
632
|
+
) : activeNav === "widgets" ? (
|
|
231
633
|
<Widgets mode={widgetMode} widgets={widgets} />
|
|
232
|
-
|
|
233
|
-
|
|
634
|
+
) : activeNav === "canvas" ? (
|
|
635
|
+
<Scratchpad />
|
|
636
|
+
) : activeView ? (
|
|
637
|
+
<ViewApp view={activeView} />
|
|
638
|
+
) : null}
|
|
639
|
+
</div>
|
|
234
640
|
|
|
235
|
-
{
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
// down to --chat-min before the fit check flips it to floating.
|
|
241
|
-
hasWidgets ? 'min-w-[var(--chat-min)] flex-[0_1_var(--chat-max)]' : 'flex-1'
|
|
242
|
-
)}
|
|
243
|
-
>
|
|
244
|
-
{/* No widgets → the chat fills the panel, so cap and center it. */}
|
|
245
|
-
<div
|
|
246
|
-
className={cn(
|
|
247
|
-
'flex min-h-0 w-full flex-1 flex-col',
|
|
248
|
-
!hasWidgets && 'mx-auto max-w-[var(--column-w)]'
|
|
249
|
-
)}
|
|
250
|
-
>
|
|
251
|
-
{chatPanel}
|
|
252
|
-
</div>
|
|
641
|
+
{display === "sidebar" && (
|
|
642
|
+
// Docked chat: caps at --chat-max on big screens (grow 0), shrinks down
|
|
643
|
+
// to --chat-min before the fit check flips it to floating.
|
|
644
|
+
<div className="flex min-h-0 min-w-[var(--chat-min)] flex-[0_1_var(--chat-max)] flex-col overflow-hidden">
|
|
645
|
+
<div className="flex min-h-0 w-full flex-1 flex-col">{chatPanel}</div>
|
|
253
646
|
</div>
|
|
254
647
|
)}
|
|
255
648
|
</div>
|
|
256
649
|
|
|
257
|
-
{
|
|
650
|
+
{display === "floating" && (
|
|
258
651
|
<ChatPopup
|
|
259
|
-
defaultOpen={layout.chatMode ===
|
|
652
|
+
defaultOpen={layout.chatMode === "floating" && canFitSidebar}
|
|
260
653
|
container={themeRef}
|
|
261
654
|
>
|
|
262
|
-
{onClose => (
|
|
655
|
+
{(onClose) => (
|
|
263
656
|
<ChatPanel
|
|
264
657
|
view={view}
|
|
265
|
-
|
|
266
|
-
|
|
658
|
+
previewTurn={previewTurn}
|
|
659
|
+
sessionId={sessionId}
|
|
267
660
|
processing={processing}
|
|
268
661
|
error={error}
|
|
269
662
|
onDismissError={dismissError}
|
|
270
663
|
send={send}
|
|
271
664
|
stop={stop}
|
|
272
|
-
chatMode={
|
|
665
|
+
chatMode={display}
|
|
273
666
|
onSwitchThread={switchThread}
|
|
274
667
|
onModeChange={handleModeChange}
|
|
275
668
|
onClose={onClose}
|
|
@@ -278,5 +671,5 @@ function WorkspaceView({ widgets }: WorkspaceViewProps) {
|
|
|
278
671
|
</ChatPopup>
|
|
279
672
|
)}
|
|
280
673
|
</div>
|
|
281
|
-
)
|
|
674
|
+
);
|
|
282
675
|
}
|