moi-computer 0.0.2 → 0.1.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/bin/moi.mjs +3 -1
- 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/BottomPanel.tsx +2 -2
- package/client/components/ChatInput.tsx +195 -14
- package/client/components/ChatPanel.tsx +118 -49
- package/client/components/ChatPopup.tsx +2 -2
- package/client/components/CustomizePanel.tsx +8 -8
- package/client/components/HiddenPanel.tsx +1 -1
- package/client/components/HomePage.tsx +1 -1
- package/client/components/IconMcp.tsx +21 -0
- package/client/components/MarkdownContent.tsx +2 -2
- 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 +114 -534
- package/client/components/WidgetErrorBoundary.tsx +2 -2
- package/client/components/WidgetFrame.tsx +1 -1
- package/client/components/WidgetShell.tsx +2 -2
- package/client/components/Widgets.tsx +2 -2
- package/client/components/WorkspacePreview.tsx +3 -3
- package/client/components/WorkspacesPage.tsx +28 -20
- package/client/components/layout/SidebarLayout.tsx +24 -15
- package/client/components/playground/PixelPainter.tsx +2 -2
- package/client/components/playground/PlaygroundPage.tsx +1 -1
- 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/button.tsx +4 -4
- package/client/components/ui/dialog.tsx +58 -0
- package/client/components/ui/dropdown-menu.tsx +9 -9
- package/client/components/ui/hover-card.tsx +44 -0
- package/client/components/ui/popover.tsx +1 -1
- package/client/components/ui/switch.tsx +23 -0
- package/client/components/ui/tooltip.tsx +54 -0
- package/client/externalize-react.ts +11 -5
- 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 +49 -3
- package/client/index.html +22 -18
- 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/atlassian-b3tq39hs.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/claude-z2xnay0d.svg +3 -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/discord-vejhptwx.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/favicon-nbmyjfjh.png +0 -0
- package/dist/figma-y9898rry.png +0 -0
- package/dist/firecrawl-w2t8nehx.png +0 -0
- package/dist/github-av5r5y3e.png +0 -0
- package/dist/gitlab-4pv5vm6b.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/granola-7j3b0nk2.png +0 -0
- package/dist/hermes-nous-pznd63x9.png +0 -0
- package/dist/hubspot-hghcmc2t.png +0 -0
- package/dist/huggingface-kxzaxj83.png +0 -0
- package/dist/index.html +47 -0
- package/dist/intercom-td763jt8.png +0 -0
- package/dist/linear-v9s3az2d.png +0 -0
- package/dist/monday-jdbs4wwf.png +0 -0
- package/dist/mongodb-emzxvhd5.png +0 -0
- package/dist/neon-zj4qar44.png +0 -0
- package/dist/notion-w034c0b8.png +0 -0
- package/dist/openclaw-a2pyfhpn.svg +22 -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/sentry-hdwpmvek.png +0 -0
- package/dist/shopify-90dadaav.png +0 -0
- package/dist/slack-1c1wj62s.png +0 -0
- package/dist/snowflake-hfpykpgy.png +0 -0
- package/dist/stripe-zrfaqbj3.png +0 -0
- package/dist/supabase-4vg33zf2.png +0 -0
- package/dist/telegram-v6tjyrs7.png +0 -0
- package/dist/twilio-dpyjdwpj.png +0 -0
- package/dist/vercel-7d0ssw28.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 +21 -31
- package/server/CLAUDE.md +3 -0
- 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 +970 -72
- 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 +113 -223
- 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/server/build-widget.ts +0 -343
- package/workspace/.claude/skills/widgets/DESIGN.md +0 -630
- package/workspace/.claude/skills/widgets/SKILL.md +0 -176
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { useWorkspaceMcp } from '@/client/api/workspaces'
|
|
2
|
+
import { IconMcp } from '@/client/components/IconMcp'
|
|
3
|
+
import { Button } from '@/client/components/ui/button'
|
|
4
|
+
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/client/components/ui/hover-card'
|
|
5
|
+
import { useScrollFade } from '@/client/hooks/useScrollFade'
|
|
6
|
+
import { formatMcpServerName, getMcpIcon } from '@/client/lib/mcp-icons'
|
|
7
|
+
import { useWorkspaceId } from '@/client/lib/WorkspaceContext'
|
|
8
|
+
import { useWorkspaceLayoutCtx } from '@/client/lib/WorkspaceLayoutContext'
|
|
9
|
+
import { cn } from '@/client/lib/cn'
|
|
10
|
+
import type { McpServer } from '@/lib/types'
|
|
11
|
+
|
|
12
|
+
function McpServerRow({ server }: { server: McpServer }) {
|
|
13
|
+
const icon = getMcpIcon(server.name)
|
|
14
|
+
const connected = server.status === 'connected'
|
|
15
|
+
return (
|
|
16
|
+
<div className="flex items-center gap-2.5 rounded-xs px-2 py-1 hover:bg-muted">
|
|
17
|
+
{icon ? (
|
|
18
|
+
<img src={icon} alt="" className="size-5 shrink-0 rounded ring-2 ring-background" />
|
|
19
|
+
) : (
|
|
20
|
+
<span className="flex size-5 shrink-0 items-center justify-center rounded bg-muted text-muted-foreground ring-2 ring-background">
|
|
21
|
+
<IconMcp className="size-4" />
|
|
22
|
+
</span>
|
|
23
|
+
)}
|
|
24
|
+
<span className="flex-1 truncate text-sm text-foreground">
|
|
25
|
+
{formatMcpServerName(server.name)}
|
|
26
|
+
</span>
|
|
27
|
+
<span
|
|
28
|
+
className={cn(
|
|
29
|
+
'size-[5px] shrink-0 rounded-full',
|
|
30
|
+
connected ? 'bg-emerald-500' : 'bg-yellow-500/75'
|
|
31
|
+
)}
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// The scrollable server list. Its own component so `useScrollFade`'s effect runs
|
|
38
|
+
// when the (portaled, mount-on-open) hover card opens — attaching the scroll ref.
|
|
39
|
+
// Overflow is signalled with top/bottom mask fades; the scrollbar is hidden.
|
|
40
|
+
function McpList({ servers }: { servers: McpServer[] }) {
|
|
41
|
+
const { ref, showTopFade, showBottomFade } = useScrollFade()
|
|
42
|
+
const fade =
|
|
43
|
+
showTopFade && showBottomFade
|
|
44
|
+
? 'mask-fade-y'
|
|
45
|
+
: showTopFade
|
|
46
|
+
? 'mask-fade-top'
|
|
47
|
+
: showBottomFade
|
|
48
|
+
? 'mask-fade-bottom'
|
|
49
|
+
: undefined
|
|
50
|
+
return (
|
|
51
|
+
<div
|
|
52
|
+
ref={ref}
|
|
53
|
+
className={cn(
|
|
54
|
+
'scrollbar-none flex max-h-72 flex-col overflow-y-auto overscroll-contain',
|
|
55
|
+
fade
|
|
56
|
+
)}
|
|
57
|
+
>
|
|
58
|
+
{servers.map(server => (
|
|
59
|
+
<McpServerRow key={server.name} server={server} />
|
|
60
|
+
))}
|
|
61
|
+
</div>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// MCP status hover card — Claude workspaces only (OpenClaw/Hermes use other
|
|
66
|
+
// backends). Lists each MCP server with a green/red dot. The (expensive, cached)
|
|
67
|
+
// status query: while it hasn't resolved the trigger is just a gray icon with no
|
|
68
|
+
// dot and no hover card; once loaded the card opens on hover and the icon goes
|
|
69
|
+
// dark + shows a dot badge when any server is connected.
|
|
70
|
+
export function McpMenu() {
|
|
71
|
+
const workspaceId = useWorkspaceId()
|
|
72
|
+
// Read provider from the shared layout context, not a second `useWorkspaceLayout`
|
|
73
|
+
// observer — a duplicate observer that remounts (e.g. when this menu moves
|
|
74
|
+
// between the fullscreen and two-pane headers) fires `refetchOnMount`, which
|
|
75
|
+
// overwrites an in-flight optimistic chat-mode change before it's persisted.
|
|
76
|
+
const { provider, isLoading } = useWorkspaceLayoutCtx()
|
|
77
|
+
const isClaude = !isLoading && provider !== 'openclaw' && provider !== 'hermes'
|
|
78
|
+
const { data: servers } = useWorkspaceMcp(workspaceId, isClaude)
|
|
79
|
+
|
|
80
|
+
if (!isClaude) return null
|
|
81
|
+
|
|
82
|
+
const anyConnected = servers?.some(s => s.status === 'connected') ?? false
|
|
83
|
+
|
|
84
|
+
const trigger = (
|
|
85
|
+
<Button
|
|
86
|
+
variant="ghost"
|
|
87
|
+
size="icon"
|
|
88
|
+
aria-label="MCP"
|
|
89
|
+
className={cn(
|
|
90
|
+
'relative size-7 [&_svg]:size-[20px]',
|
|
91
|
+
anyConnected ? 'text-foreground' : 'text-muted-foreground'
|
|
92
|
+
)}
|
|
93
|
+
>
|
|
94
|
+
<IconMcp />
|
|
95
|
+
{anyConnected && (
|
|
96
|
+
<span className="absolute right-[5px] bottom-1.5 size-[5px] rounded-full bg-foreground ring-1 ring-background" />
|
|
97
|
+
)}
|
|
98
|
+
</Button>
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
// Not loaded yet → plain gray icon, no hover card.
|
|
102
|
+
if (!servers) return trigger
|
|
103
|
+
|
|
104
|
+
// Active (connected) servers first, then disabled/errored/auth-pending. The
|
|
105
|
+
// sort is stable, so each group keeps the server list's original order.
|
|
106
|
+
const sorted = [...servers].sort(
|
|
107
|
+
(a, b) => Number(b.status === 'connected') - Number(a.status === 'connected')
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<HoverCard delay={0} closeDelay={100}>
|
|
112
|
+
<HoverCardTrigger render={trigger} />
|
|
113
|
+
<HoverCardContent align="end" sideOffset={6} className="w-56 p-1">
|
|
114
|
+
<div className="px-2 pt-1 pb-1.5 text-xs font-medium text-muted-foreground">
|
|
115
|
+
Connected MCPs
|
|
116
|
+
</div>
|
|
117
|
+
{servers.length === 0 ? (
|
|
118
|
+
<div className="px-2 py-1 text-sm text-muted-foreground">No MCP servers</div>
|
|
119
|
+
) : (
|
|
120
|
+
<McpList servers={sorted} />
|
|
121
|
+
)}
|
|
122
|
+
</HoverCardContent>
|
|
123
|
+
</HoverCard>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { memo, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { IconChevronDown } from '@tabler/icons-react'
|
|
4
|
+
|
|
5
|
+
import { useSaveThreadConfig, useThreadConfig, useWorkspaceModels } from '@/client/api/workspaces'
|
|
6
|
+
import { useWorkspaceLayoutCtx } from '@/client/lib/WorkspaceLayoutContext'
|
|
7
|
+
import { useLive } from '@/client/store/live'
|
|
8
|
+
|
|
9
|
+
import { Button } from './ui/button'
|
|
10
|
+
import {
|
|
11
|
+
DropdownMenu,
|
|
12
|
+
DropdownMenuContent,
|
|
13
|
+
DropdownMenuGroup,
|
|
14
|
+
DropdownMenuLabel,
|
|
15
|
+
DropdownMenuRadioGroup,
|
|
16
|
+
DropdownMenuRadioItem,
|
|
17
|
+
DropdownMenuSeparator,
|
|
18
|
+
DropdownMenuSub,
|
|
19
|
+
DropdownMenuSubContent,
|
|
20
|
+
DropdownMenuSubTrigger,
|
|
21
|
+
DropdownMenuTrigger
|
|
22
|
+
} from './ui/dropdown-menu'
|
|
23
|
+
import { Switch } from './ui/switch'
|
|
24
|
+
|
|
25
|
+
// Models describe themselves with a " · "-joined blurb; we show only the
|
|
26
|
+
// headline (e.g. "Opus 4.8 with 1M context · Most capable…" → "Opus 4.8 with 1M context").
|
|
27
|
+
function headline(description?: string): string {
|
|
28
|
+
return description?.split(/\s*·\s*/)[0] ?? ''
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function capitalize(s: string): string {
|
|
32
|
+
return s.charAt(0).toUpperCase() + s.slice(1)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Model selector for the chat composer. Renders the workspace's available
|
|
36
|
+
// models from `/api/workspaces/:id/models`. Model + reasoning effort are
|
|
37
|
+
// persisted PER THREAD (so a thread reopens with the settings it last ran with)
|
|
38
|
+
// once a thread exists; while no thread is open (a brand-new chat) the picker
|
|
39
|
+
// edits the workspace defaults, which seed the new thread. Both are sent with
|
|
40
|
+
// each chat frame (see useChat); leaving them untouched runs on the SDK default.
|
|
41
|
+
// Fast mode remains local-only for now.
|
|
42
|
+
// Memoized (no props): it lives inside ChatInput, which re-renders on every
|
|
43
|
+
// keystroke, so memo keeps the picker from re-rendering with it — it updates
|
|
44
|
+
// only on its own store/query changes (active thread, models, layout).
|
|
45
|
+
export const ModelPicker = memo(function ModelPicker() {
|
|
46
|
+
const { workspaceId, layout, setLayout } = useWorkspaceLayoutCtx()
|
|
47
|
+
const { data } = useWorkspaceModels(workspaceId)
|
|
48
|
+
const models = data?.models ?? []
|
|
49
|
+
|
|
50
|
+
// The active thread, if any. Its stored config is the source of truth; a new
|
|
51
|
+
// chat (no active thread) falls back to — and edits — the workspace defaults.
|
|
52
|
+
const activeSessionId = useLive(s => s.activeByWorkspace[workspaceId] ?? null)
|
|
53
|
+
const threadCfg = useThreadConfig(workspaceId, activeSessionId).data
|
|
54
|
+
const saveThreadCfg = useSaveThreadConfig(workspaceId)
|
|
55
|
+
const [fastMode, setFastMode] = useState(false)
|
|
56
|
+
|
|
57
|
+
const selected = (activeSessionId ? threadCfg?.model : undefined) ?? layout.selectedModel
|
|
58
|
+
const selectedEffort = (activeSessionId ? threadCfg?.effort : undefined) ?? layout.selectedEffort
|
|
59
|
+
const setSelected = (value: string) => {
|
|
60
|
+
if (activeSessionId)
|
|
61
|
+
saveThreadCfg.mutate({ sessionId: activeSessionId, patch: { model: value } })
|
|
62
|
+
else setLayout({ selectedModel: value })
|
|
63
|
+
}
|
|
64
|
+
const setEffort = (value: string) => {
|
|
65
|
+
if (activeSessionId)
|
|
66
|
+
saveThreadCfg.mutate({ sessionId: activeSessionId, patch: { effort: value } })
|
|
67
|
+
else setLayout({ selectedEffort: value })
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (models.length === 0) return null
|
|
71
|
+
|
|
72
|
+
// Show the persisted pick when it's still in the list; otherwise the first
|
|
73
|
+
// model. An unset pick sends no model id, so the run uses the SDK default.
|
|
74
|
+
const persisted = models.some(m => m.value === selected) ? selected : undefined
|
|
75
|
+
const current = persisted ?? models[0].value
|
|
76
|
+
const model = models.find(m => m.value === current) ?? models[0]
|
|
77
|
+
const effortLevels = model.supportsEffort ? (model.supportedEffortLevels ?? []) : []
|
|
78
|
+
const currentEffort =
|
|
79
|
+
selectedEffort && effortLevels.includes(selectedEffort) ? selectedEffort : effortLevels[0]
|
|
80
|
+
const showReasoning = effortLevels.length > 0
|
|
81
|
+
// Fast mode is Claude-only (Opus); OpenClaw models never report supportsFastMode.
|
|
82
|
+
const showFastMode = !!model.supportsFastMode
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<DropdownMenu>
|
|
86
|
+
<DropdownMenuTrigger
|
|
87
|
+
render={
|
|
88
|
+
<Button variant="ghost" size="default" className="gap-1.5 px-2.5 text-muted-foreground">
|
|
89
|
+
<span className="font-normal text-foreground">
|
|
90
|
+
{headline(model.description) || model.displayName}
|
|
91
|
+
</span>
|
|
92
|
+
{currentEffort && (
|
|
93
|
+
<span className="text-muted-foreground">{capitalize(currentEffort)}</span>
|
|
94
|
+
)}
|
|
95
|
+
<IconChevronDown className="size-3.5! text-muted-foreground/60" stroke={1.5} />
|
|
96
|
+
</Button>
|
|
97
|
+
}
|
|
98
|
+
/>
|
|
99
|
+
<DropdownMenuContent align="start" side="top" className="min-w-56">
|
|
100
|
+
<DropdownMenuGroup>
|
|
101
|
+
<DropdownMenuLabel>Models</DropdownMenuLabel>
|
|
102
|
+
<DropdownMenuRadioGroup value={current} onValueChange={setSelected}>
|
|
103
|
+
{models.map(m => (
|
|
104
|
+
<DropdownMenuRadioItem key={m.value} value={m.value} closeOnClick>
|
|
105
|
+
{headline(m.description) || m.displayName}
|
|
106
|
+
</DropdownMenuRadioItem>
|
|
107
|
+
))}
|
|
108
|
+
</DropdownMenuRadioGroup>
|
|
109
|
+
</DropdownMenuGroup>
|
|
110
|
+
|
|
111
|
+
{(showReasoning || showFastMode) && <DropdownMenuSeparator />}
|
|
112
|
+
|
|
113
|
+
{showReasoning && (
|
|
114
|
+
<DropdownMenuSub>
|
|
115
|
+
<DropdownMenuSubTrigger>
|
|
116
|
+
<div className="flex flex-1 items-center justify-between">
|
|
117
|
+
Reasoning
|
|
118
|
+
{currentEffort && (
|
|
119
|
+
<span className="ml-auto text-muted-foreground">{capitalize(currentEffort)}</span>
|
|
120
|
+
)}
|
|
121
|
+
</div>
|
|
122
|
+
</DropdownMenuSubTrigger>
|
|
123
|
+
<DropdownMenuSubContent>
|
|
124
|
+
<DropdownMenuRadioGroup value={currentEffort} onValueChange={setEffort}>
|
|
125
|
+
{effortLevels.map(level => (
|
|
126
|
+
<DropdownMenuRadioItem key={level} value={level} closeOnClick>
|
|
127
|
+
{capitalize(level)}
|
|
128
|
+
</DropdownMenuRadioItem>
|
|
129
|
+
))}
|
|
130
|
+
</DropdownMenuRadioGroup>
|
|
131
|
+
</DropdownMenuSubContent>
|
|
132
|
+
</DropdownMenuSub>
|
|
133
|
+
)}
|
|
134
|
+
|
|
135
|
+
{showFastMode && (
|
|
136
|
+
<DropdownMenuGroup className="mt-0.5">
|
|
137
|
+
<DropdownMenuLabel>Fast mode</DropdownMenuLabel>
|
|
138
|
+
<label className="flex cursor-pointer items-center justify-between gap-4 rounded-xs px-2 py-1 text-sm">
|
|
139
|
+
Enable fast mode
|
|
140
|
+
<Switch checked={fastMode} onCheckedChange={setFastMode} />
|
|
141
|
+
</label>
|
|
142
|
+
</DropdownMenuGroup>
|
|
143
|
+
)}
|
|
144
|
+
</DropdownMenuContent>
|
|
145
|
+
</DropdownMenu>
|
|
146
|
+
)
|
|
147
|
+
})
|