From fe0d7fcfce24705798187ef42809b9cb4f68be17 Mon Sep 17 00:00:00 2001 From: jiwangyihao Date: Sat, 18 Apr 2026 17:51:18 +0800 Subject: [PATCH] fix(tui): request root sessions in switch session dialog Only fetching the latest mixed session list lets recent child sessions crowd root sessions out of Switch Session. Querying root sessions directly keeps recent root sessions visible and makes dialog refetches stay in sync after delete or workspace recovery. --- .../cli/cmd/tui/component/dialog-session-list.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/component/dialog-session-list.tsx b/packages/opencode/src/cli/cmd/tui/component/dialog-session-list.tsx index 32342e77247d..a9c70a8edb32 100644 --- a/packages/opencode/src/cli/cmd/tui/component/dialog-session-list.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/dialog-session-list.tsx @@ -33,13 +33,16 @@ export function DialogSessionList() { const [search, setSearch] = createDebouncedSignal("", 150) const [searchResults, { refetch }] = createResource(search, async (query) => { - if (!query) return undefined - const result = await sdk.client.session.list({ search: query, limit: 30 }) + const result = await sdk.client.session.list({ + roots: true, + limit: query ? 30 : 100, + ...(query ? { search: query } : { start: Date.now() - 30 * 24 * 60 * 60 * 1000 }), + }) return result.data ?? [] }) const currentSessionID = createMemo(() => (route.data.type === "session" ? route.data.sessionID : undefined)) - const sessions = createMemo(() => searchResults() ?? sync.data.session) + const sessions = createMemo(() => searchResults() ?? sync.data.session.filter((x) => x.parentID === undefined)) function createWorkspace() { dialog.replace(() => ( @@ -80,7 +83,7 @@ export function DialogSessionList() { } await project.workspace.sync() await sync.session.refresh() - if (search()) await refetch() + await refetch() if (info?.workspaceID === session.workspaceID) { route.navigate({ type: "home" }) } @@ -233,7 +236,7 @@ export function DialogSessionList() { if (status && status !== "connected") { await sync.session.refresh() } - if (search()) await refetch() + await refetch() setToDelete(undefined) return }