GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Desktop: MCP UI (#6162) · ideabrian/opencode@2333af6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • app/src
      • components
        • dialog-select-mcp.tsx
        • session-lsp-indicator.tsx
        • session-mcp-indicator.tsx
        • status-bar.tsx
      • context
        • global-sync.tsx
      • pages
        • session.tsx
    • ui/src/components
      • icon.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/app/src/components/dialog-select-mcp.tsx‎

Copy file name to clipboard
+91Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { Component, createMemo, createSignal, Show } from "solid-js"
2+
import { useSync } from "@/context/sync"
3+
import { useSDK } from "@/context/sdk"
4+
import { Dialog } from "@opencode-ai/ui/dialog"
5+
import { List } from "@opencode-ai/ui/list"
6+
import { Switch } from "@opencode-ai/ui/switch"
7+
8+
export const DialogSelectMcp: Component = () => {
9+
const sync = useSync()
10+
const sdk = useSDK()
11+
const [loading, setLoading] = createSignal<string | null>(null)
12+
13+
const items = createMemo(() =>
14+
Object.entries(sync.data.mcp ?? {})
15+
.map(([name, status]) => ({ name, status: status.status }))
16+
.sort((a, b) => a.name.localeCompare(b.name)),
17+
)
18+
19+
const toggle = async (name: string) => {
20+
if (loading()) return
21+
setLoading(name)
22+
const status = sync.data.mcp[name]
23+
if (status?.status === "connected") {
24+
await sdk.client.mcp.disconnect({ name })
25+
} else {
26+
await sdk.client.mcp.connect({ name })
27+
}
28+
const result = await sdk.client.mcp.status()
29+
if (result.data) sync.set("mcp", result.data)
30+
setLoading(null)
31+
}
32+
33+
const enabledCount = createMemo(() => items().filter((i) => i.status === "connected").length)
34+
const totalCount = createMemo(() => items().length)
35+
36+
return (
37+
<Dialog title="MCPs" description={`${enabledCount()} of ${totalCount()} enabled`}>
38+
<List
39+
search={{ placeholder: "Search", autofocus: true }}
40+
emptyMessage="No MCPs configured"
41+
key={(x) => x?.name ?? ""}
42+
items={items}
43+
filterKeys={["name", "status"]}
44+
sortBy={(a, b) => a.name.localeCompare(b.name)}
45+
onSelect={(x) => {
46+
if (x) toggle(x.name)
47+
}}
48+
>
49+
{(i) => {
50+
const mcpStatus = () => sync.data.mcp[i.name]
51+
const status = () => mcpStatus()?.status
52+
const error = () => {
53+
const s = mcpStatus()
54+
return s?.status === "failed" ? s.error : undefined
55+
}
56+
const enabled = () => status() === "connected"
57+
return (
58+
<div class="w-full flex items-center justify-between gap-x-3">
59+
<div class="flex flex-col gap-0.5 min-w-0">
60+
<div class="flex items-center gap-2">
61+
<span class="truncate">{i.name}</span>
62+
<Show when={status() === "connected"}>
63+
<span class="text-11-regular text-text-weaker">connected</span>
64+
</Show>
65+
<Show when={status() === "failed"}>
66+
<span class="text-11-regular text-text-weaker">failed</span>
67+
</Show>
68+
<Show when={status() === "needs_auth"}>
69+
<span class="text-11-regular text-text-weaker">needs auth</span>
70+
</Show>
71+
<Show when={status() === "disabled"}>
72+
<span class="text-11-regular text-text-weaker">disabled</span>
73+
</Show>
74+
<Show when={loading() === i.name}>
75+
<span class="text-11-regular text-text-weak">...</span>
76+
</Show>
77+
</div>
78+
<Show when={error()}>
79+
<span class="text-11-regular text-text-weaker truncate">{error()}</span>
80+
</Show>
81+
</div>
82+
<div onClick={(e) => e.stopPropagation()}>
83+
<Switch checked={enabled()} disabled={loading() === i.name} onChange={() => toggle(i.name)} />
84+
</div>
85+
</div>
86+
)
87+
}}
88+
</List>
89+
</Dialog>
90+
)
91+
}
Collapse file

‎packages/app/src/components/session-lsp-indicator.tsx‎

Copy file name to clipboard
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { createMemo, Show } from "solid-js"
2+
import { Icon } from "@opencode-ai/ui/icon"
3+
import { useSync } from "@/context/sync"
4+
import { Tooltip } from "@opencode-ai/ui/tooltip"
5+
6+
export function SessionLspIndicator() {
7+
const sync = useSync()
8+
9+
const lspStats = createMemo(() => {
10+
const lsp = sync.data.lsp ?? []
11+
const connected = lsp.filter((s) => s.status === "connected").length
12+
const hasError = lsp.some((s) => s.status === "error")
13+
const total = lsp.length
14+
return { connected, hasError, total }
15+
})
16+
17+
const tooltipContent = createMemo(() => {
18+
const lsp = sync.data.lsp ?? []
19+
if (lsp.length === 0) return "No LSP servers"
20+
return lsp.map((s) => s.name).join(", ")
21+
})
22+
23+
return (
24+
<Show when={lspStats().total > 0}>
25+
<Tooltip placement="top" value={tooltipContent()}>
26+
<div class="flex items-center gap-1 px-2 cursor-default select-none">
27+
<Icon
28+
name="code"
29+
size="small"
30+
classList={{
31+
"text-icon-critical-base": lspStats().hasError,
32+
"text-icon-success-base": !lspStats().hasError && lspStats().connected > 0,
33+
}}
34+
/>
35+
<span class="text-12-regular text-text-weak">{lspStats().connected} LSP</span>
36+
</div>
37+
</Tooltip>
38+
</Show>
39+
)
40+
}
Collapse file

‎packages/app/src/components/session-mcp-indicator.tsx‎

Copy file name to clipboard
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { createMemo, Show } from "solid-js"
2+
import { Button } from "@opencode-ai/ui/button"
3+
import { Icon } from "@opencode-ai/ui/icon"
4+
import { useDialog } from "@opencode-ai/ui/context/dialog"
5+
import { useSync } from "@/context/sync"
6+
import { DialogSelectMcp } from "@/components/dialog-select-mcp"
7+
8+
export function SessionMcpIndicator() {
9+
const sync = useSync()
10+
const dialog = useDialog()
11+
12+
const mcpStats = createMemo(() => {
13+
const mcp = sync.data.mcp ?? {}
14+
const entries = Object.entries(mcp)
15+
const enabled = entries.filter(([, status]) => status.status === "connected").length
16+
const failed = entries.some(([, status]) => status.status === "failed")
17+
const total = entries.length
18+
return { enabled, failed, total }
19+
})
20+
21+
return (
22+
<Show when={mcpStats().total > 0}>
23+
<Button variant="ghost" onClick={() => dialog.show(() => <DialogSelectMcp />)}>
24+
<Icon
25+
name="mcp"
26+
size="small"
27+
classList={{
28+
"text-icon-critical-base": mcpStats().failed,
29+
"text-icon-success-base": !mcpStats().failed && mcpStats().enabled > 0,
30+
}}
31+
/>
32+
<span class="text-12-regular text-text-weak">{mcpStats().enabled} MCP</span>
33+
</Button>
34+
</Show>
35+
)
36+
}
Collapse file

‎packages/app/src/components/status-bar.tsx‎

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Show, type ParentProps } from "solid-js"
2+
import { usePlatform } from "@/context/platform"
3+
4+
export function StatusBar(props: ParentProps) {
5+
const platform = usePlatform()
6+
return (
7+
<div class="h-8 w-full shrink-0 flex items-center justify-between px-2 border-t border-border-weak-base bg-background-base">
8+
<Show when={platform.version}>
9+
<span class="text-12-regular text-text-weak">v{platform.version}</span>
10+
</Show>
11+
<div class="flex items-center">{props.children}</div>
12+
</div>
13+
)
14+
}
Collapse file

‎packages/app/src/context/global-sync.tsx‎

Copy file name to clipboardExpand all lines: packages/app/src/context/global-sync.tsx
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
type ProviderListResponse,
1313
type ProviderAuthResponse,
1414
type Command,
15+
type McpStatus,
16+
type LspStatus,
1517
createOpencodeClient,
1618
} from "@opencode-ai/sdk/v2/client"
1719
import { createStore, produce, reconcile } from "solid-js/store"
@@ -41,6 +43,10 @@ type State = {
4143
todo: {
4244
[sessionID: string]: Todo[]
4345
}
46+
mcp: {
47+
[name: string]: McpStatus
48+
}
49+
lsp: LspStatus[]
4450
limit: number
4551
message: {
4652
[sessionID: string]: Message[]
@@ -85,6 +91,8 @@ function createGlobalSync() {
8591
session_status: {},
8692
session_diff: {},
8793
todo: {},
94+
mcp: {},
95+
lsp: [],
8896
limit: 5,
8997
message: {},
9098
part: {},
@@ -149,6 +157,8 @@ function createGlobalSync() {
149157
session: () => loadSessions(directory),
150158
status: () => sdk.session.status().then((x) => setStore("session_status", x.data!)),
151159
config: () => sdk.config.get().then((x) => setStore("config", x.data!)),
160+
mcp: () => sdk.mcp.status().then((x) => setStore("mcp", x.data ?? {})),
161+
lsp: () => sdk.lsp.status().then((x) => setStore("lsp", x.data ?? [])),
152162
}
153163
await Promise.all(Object.values(load).map((p) => retry(p).catch((e) => setGlobalStore("error", e))))
154164
.then(() => setStore("ready", true))
Collapse file

‎packages/app/src/pages/session.tsx‎

Copy file name to clipboardExpand all lines: packages/app/src/pages/session.tsx
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,17 @@ import { checksum } from "@opencode-ai/util/encode"
4949
import { useDialog } from "@opencode-ai/ui/context/dialog"
5050
import { DialogSelectFile } from "@/components/dialog-select-file"
5151
import { DialogSelectModel } from "@/components/dialog-select-model"
52+
import { DialogSelectMcp } from "@/components/dialog-select-mcp"
5253
import { useCommand } from "@/context/command"
5354
import { useNavigate, useParams } from "@solidjs/router"
5455
import { UserMessage } from "@opencode-ai/sdk/v2"
5556
import { useSDK } from "@/context/sdk"
5657
import { usePrompt } from "@/context/prompt"
5758
import { extractPromptFromParts } from "@/utils/prompt"
5859
import { ConstrainDragYAxis, getDraggableId } from "@/utils/solid-dnd"
60+
import { StatusBar } from "@/components/status-bar"
61+
import { SessionMcpIndicator } from "@/components/session-mcp-indicator"
62+
import { SessionLspIndicator } from "@/components/session-lsp-indicator"
5963

6064
export default function Page() {
6165
const layout = useLayout()
@@ -274,6 +278,15 @@ export default function Page() {
274278
slash: "model",
275279
onSelect: () => dialog.show(() => <DialogSelectModel />),
276280
},
281+
{
282+
id: "mcp.toggle",
283+
title: "Toggle MCPs",
284+
description: "Toggle MCPs",
285+
category: "MCP",
286+
keybind: "mod+;",
287+
slash: "mcp",
288+
onSelect: () => dialog.show(() => <DialogSelectMcp />),
289+
},
277290
{
278291
id: "agent.cycle",
279292
title: "Cycle agent",
@@ -921,6 +934,10 @@ export default function Page() {
921934
</DragDropProvider>
922935
</div>
923936
</Show>
937+
<StatusBar>
938+
<SessionLspIndicator />
939+
<SessionMcpIndicator />
940+
</StatusBar>
924941
</div>
925942
)
926943
}
Collapse file

‎packages/ui/src/components/icon.tsx‎

Copy file name to clipboardExpand all lines: packages/ui/src/components/icon.tsx
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const icons = {
1818
console: `<path d="M3.75 5.4165L8.33333 9.99984L3.75 14.5832M10.4167 14.5832H16.25" stroke="currentColor" stroke-linecap="square"/>`,
1919
expand: `<path d="M4.58301 10.4163V15.4163H9.58301M10.4163 4.58301H15.4163V9.58301" stroke="currentColor" stroke-linecap="square"/>`,
2020
collapse: `<path d="M16.666 8.33398H11.666V3.33398" stroke="currentColor" stroke-linecap="square"/><path d="M8.33398 16.666V11.666H3.33398" stroke="currentColor" stroke-linecap="square"/>`,
21+
code: `<path d="M8.7513 7.5013L6.2513 10.0013L8.7513 12.5013M11.2513 7.5013L13.7513 10.0013L11.2513 12.5013M2.91797 2.91797H17.0846V17.0846H2.91797V2.91797Z" stroke="currentColor"/>`,
2122
"code-lines": `<path d="M2.08325 3.75H11.2499M14.5833 3.75H17.9166M2.08325 10L7.08325 10M10.4166 10L17.9166 10M2.08325 16.25L8.74992 16.25M12.0833 16.25L17.9166 16.25" stroke="currentColor" stroke-linecap="square" stroke-linejoin="round"/>`,
2223
"circle-ban-sign": `<path d="M15.3675 4.63087L4.55742 15.441M17.9163 9.9987C17.9163 14.371 14.3719 17.9154 9.99967 17.9154C7.81355 17.9154 5.83438 17.0293 4.40175 15.5966C2.96911 14.164 2.08301 12.1848 2.08301 9.9987C2.08301 5.62644 5.62742 2.08203 9.99967 2.08203C12.1858 2.08203 14.165 2.96813 15.5976 4.40077C17.0302 5.8334 17.9163 7.81257 17.9163 9.9987Z" stroke="currentColor" stroke-linecap="round"/>`,
2324
"edit-small-2": `<path d="M17.0834 17.0833V17.5833H17.5834V17.0833H17.0834ZM2.91675 17.0833H2.41675V17.5833H2.91675V17.0833ZM2.91675 2.91659V2.41659H2.41675V2.91659H2.91675ZM9.58341 3.41659H10.0834V2.41659H9.58341V2.91659V3.41659ZM17.5834 10.4166V9.91659H16.5834V10.4166H17.0834H17.5834ZM10.4167 7.08325L10.0632 6.7297L9.91675 6.87615V7.08325H10.4167ZM10.4167 9.58325H9.91675V10.0833H10.4167V9.58325ZM12.9167 9.58325V10.0833H13.1239L13.2703 9.93681L12.9167 9.58325ZM15.4167 2.08325L15.7703 1.7297L15.4167 1.37615L15.0632 1.7297L15.4167 2.08325ZM17.9167 4.58325L18.2703 4.93681L18.6239 4.58325L18.2703 4.2297L17.9167 4.58325ZM17.0834 17.0833V16.5833H2.91675V17.0833V17.5833H17.0834V17.0833ZM2.91675 17.0833H3.41675V2.91659H2.91675H2.41675V17.0833H2.91675ZM2.91675 2.91659V3.41659H9.58341V2.91659V2.41659H2.91675V2.91659ZM17.0834 10.4166H16.5834V17.0833H17.0834H17.5834V10.4166H17.0834ZM10.4167 7.08325H9.91675V9.58325H10.4167H10.9167V7.08325H10.4167ZM10.4167 9.58325V10.0833H12.9167V9.58325V9.08325H10.4167V9.58325ZM10.4167 7.08325L10.7703 7.43681L15.7703 2.43681L15.4167 2.08325L15.0632 1.7297L10.0632 6.7297L10.4167 7.08325ZM15.4167 2.08325L15.0632 2.43681L17.5632 4.93681L17.9167 4.58325L18.2703 4.2297L15.7703 1.7297L15.4167 2.08325ZM17.9167 4.58325L17.5632 4.2297L12.5632 9.2297L12.9167 9.58325L13.2703 9.93681L18.2703 4.93681L17.9167 4.58325Z" fill="currentColor"/>`,

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.