From ce598e2a52b6787a711c4a1e165805127f2a8ff5 Mon Sep 17 00:00:00 2001 From: Dzianis Vauchok <2119348+dzianisv@users.noreply.github.com> Date: Tue, 26 May 2026 07:53:13 +0000 Subject: [PATCH] fix: use server home path for session listing to show all projects When no project directory is explicitly selected, the session list was filtered to the server's CWD, hiding sessions from other projects. Fix by using the server's home path (fetched from /path) as the x-opencode-directory header when listing sessions without an explicit project directory. This ensures recent sessions across all projects appear in the list. --- src/stores/sessions.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/stores/sessions.ts b/src/stores/sessions.ts index 7db656b..cf6e162 100644 --- a/src/stores/sessions.ts +++ b/src/stores/sessions.ts @@ -73,15 +73,22 @@ export const useSessions = create((set, get) => ({ error: null, loadSessions: async () => { - const client = useConnections.getState().client - if (!client) { + const connState = useConnections.getState() + if (!connState.client) { set({ error: "No active connection" }) return } + // When no project directory is explicitly selected, use the server home path so the + // session list shows all recent sessions across all projects — not just the server's CWD. + const listClient = + !connState.activeConnection?.directory && connState.serverHome + ? connState.clientForDirectory(connState.serverHome) + : connState.client + try { set({ isLoading: true, error: null }) - const sessions = await client.session.list({ roots: true, limit: 50 }) + const sessions = await (listClient || connState.client).session.list({ roots: true, limit: 50 }) set({ sessions, isLoading: false }) } catch (error) { set({ error: "Failed to load sessions", isLoading: false })