diff --git a/packages/tui/src/feature-plugins/sidebar/mcp.tsx b/packages/tui/src/feature-plugins/sidebar/mcp.tsx index 456061bb934..6018ff0ccb4 100644 --- a/packages/tui/src/feature-plugins/sidebar/mcp.tsx +++ b/packages/tui/src/feature-plugins/sidebar/mcp.tsx @@ -1,9 +1,9 @@ import { Plugin } from "@opencode/plugin/tui" -import { createMemo, For, Match, Show, Switch, createSignal } from "solid-js" +import { createMemo, For, Match, Show, Switch } from "solid-js" import { DialogMcp } from "../../component/dialog-mcp" -function View(props: { context: Plugin.Context; sessionID: string }) { - const [open, setOpen] = createSignal(true) +export function SidebarMcp(props: { context: Plugin.Context; sessionID: string }) { + const [view, updateView] = props.context.storage.store("view", { initial: { open: true } }) const theme = props.context.theme const session = createMemo(() => props.context.data.session.get(props.sessionID)) const list = createMemo(() => props.context.data.location.mcp.server.list(session()?.location) ?? []) @@ -23,13 +23,22 @@ function View(props: { context: Plugin.Context; sessionID: string }) { return ( 0}> - list().length > 2 && setOpen((x) => !x)}> + { + if (list().length <= 2) return + void updateView((draft) => { + draft.open = !draft.open + }).catch((error) => console.error("Failed to persist MCP sidebar state", error)) + }} + > 2}> - {open() ? "▼" : "▶"} + {view.open ? "▼" : "▶"} MCP - + {" "} ({on()} active{bad() > 0 ? `, ${bad()} error${bad() > 1 ? "s" : ""}` : ""}) @@ -37,7 +46,7 @@ function View(props: { context: Plugin.Context; sessionID: string }) { - + {(item) => ( , + render: (props) => , }) }, })