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.
This commit is contained in:
committed by
Dennis V
parent
d3d60f55ab
commit
ce598e2a52
@@ -73,15 +73,22 @@ export const useSessions = create<SessionsState>((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 })
|
||||
|
||||
Reference in New Issue
Block a user