From b3a1360ad9d29811e672ba714dd006ee732d5a7b Mon Sep 17 00:00:00 2001 From: OpeOginni <107570612+OpeOginni@users.noreply.github.com> Date: Mon, 12 Jan 2026 22:26:58 +0100 Subject: [PATCH] feat(dialog-select-server): add icon button for server removal (#8053) --- .../src/components/dialog-select-server.tsx | 44 +++++++++++++------ packages/ui/src/hooks/use-filtered-list.tsx | 15 +++++-- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/packages/app/src/components/dialog-select-server.tsx b/packages/app/src/components/dialog-select-server.tsx index 7e2bcc181..3e4ee8883 100644 --- a/packages/app/src/components/dialog-select-server.tsx +++ b/packages/app/src/components/dialog-select-server.tsx @@ -5,6 +5,7 @@ import { Dialog } from "@opencode-ai/ui/dialog" import { List } from "@opencode-ai/ui/list" import { TextField } from "@opencode-ai/ui/text-field" import { Button } from "@opencode-ai/ui/button" +import { IconButton } from "@opencode-ai/ui/icon-button" import { normalizeServerUrl, serverDisplayName, useServer } from "@/context/server" import { usePlatform } from "@/context/platform" import { createOpencodeClient } from "@opencode-ai/sdk/v2/client" @@ -116,6 +117,10 @@ export function DialogSelectServer() { select(value, true) } + async function handleRemove(url: string) { + server.remove(url) + } + return (
@@ -130,20 +135,33 @@ export function DialogSelectServer() { }} > {(i) => ( -
+
- {serverDisplayName(i)} - {store.status[i]?.version} + class="flex items-center gap-2 min-w-0 flex-1" + classList={{ "opacity-50": store.status[i]?.healthy === false }} + > +
+ {serverDisplayName(i)} + {store.status[i]?.version} +
+ + { + e.stopPropagation() + handleRemove(i) + }} + /> +
)} diff --git a/packages/ui/src/hooks/use-filtered-list.tsx b/packages/ui/src/hooks/use-filtered-list.tsx index 1b3be4b4c..11bc35548 100644 --- a/packages/ui/src/hooks/use-filtered-list.tsx +++ b/packages/ui/src/hooks/use-filtered-list.tsx @@ -22,10 +22,17 @@ export function useFilteredList(props: FilteredListProps) { const empty: Group[] = [] const [grouped, { refetch }] = createResource( - () => ({ - filter: store.filter, - items: typeof props.items === "function" ? undefined : props.items, - }), + () => { + // When items is a function (not async filter function), call it to track changes + const itemsValue = typeof props.items === "function" + ? (props.items as () => T[])() // Call synchronous function to track it + : props.items + + return { + filter: store.filter, + items: itemsValue, + } + }, async ({ filter, items }) => { const needle = filter?.toLowerCase() const all = (items ?? (await (props.items as (filter: string) => T[] | Promise)(needle))) || []