import type { TuiPlugin, TuiPluginApi } from "@opencode-ai/plugin/tui" import type { BuiltinTuiPlugin } from "../builtins" import { createMemo, For, Match, Show, Switch, createSignal } from "solid-js" const id = "internal:sidebar-mcp" function View(props: { api: TuiPluginApi }) { const [open, setOpen] = createSignal(true) const theme = () => props.api.theme.current const list = createMemo(() => props.api.state.mcp()) const on = createMemo(() => list().filter((item) => item.status === "connected").length) const bad = createMemo( () => list().filter( (item) => item.status === "failed" || item.status === "needs_auth" || item.status === "needs_client_registration", ).length, ) const dot = (status: string) => { if (status === "connected") return theme().success if (status === "failed") return theme().error if (status === "disabled") return theme().textMuted if (status === "needs_auth") return theme().warning if (status === "needs_client_registration") return theme().error return theme().textMuted } return ( 0}> list().length > 2 && setOpen((x) => !x)}> 2}> {open() ? "▼" : "▶"} MCP {" "} ({on()} active{bad() > 0 ? `, ${bad()} error${bad() > 1 ? "s" : ""}` : ""}) {(item) => ( {item.name}{" "} Connected {item.error} Disabled Needs auth Needs client ID )} ) } const tui: TuiPlugin = async (api) => { api.slots.register({ order: 200, slots: { sidebar_content() { return }, }, }) } const plugin: BuiltinTuiPlugin = { id, tui, } export default plugin