* fix(sessions): load all sessions across projects, not just active directory Closes #48 Root cause: loadSessions() used connState.client which carries the active connection's directory as x-opencode-directory header. The server filters sessions by that directory, so only the current project's sessions were visible. Fix: call clientForDirectory(undefined) to get a no-header client. The server then returns sessions from all projects. The session row UI already showed a directory badge (shortDir from session.directory), so no UI change is needed — each session already displays its project folder name. * fix(sessions): preserve directory when opening rows Carry each listed session directory into the route so selection, messages, and follow-up operations use the matching project client. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -43,8 +43,9 @@ interface ConnectionsState {
|
||||
) => Promise<{ ok: boolean; error?: string }>
|
||||
updateConnection: (id: string, updates: Partial<ServerConnection>) => Promise<void>
|
||||
refreshProject: () => Promise<void>
|
||||
// Create a one-off client pointing at a specific directory (for cross-project operations)
|
||||
clientForDirectory: (directory: string) => Client | null
|
||||
// Create a one-off client pointing at a specific directory (for cross-project operations).
|
||||
// Pass undefined to get a directory-less client that queries the server without project scope.
|
||||
clientForDirectory: (directory?: string) => Client | null
|
||||
// Switch the active connection's directory and reload
|
||||
switchDirectory: (directory?: string) => Promise<void>
|
||||
// Record a directory as recently used
|
||||
|
||||
@@ -84,7 +84,9 @@ export const useSessions = create<SessionsState>((set, get) => ({
|
||||
|
||||
loadSessions: async () => {
|
||||
const connState = useConnections.getState()
|
||||
const client = connState.client
|
||||
// Use a directory-less client so the server returns sessions from ALL projects,
|
||||
// not just the one matching the active connection's directory header.
|
||||
const client = connState.clientForDirectory(undefined) || connState.client
|
||||
if (!client) {
|
||||
set({ error: "No active connection" })
|
||||
return
|
||||
@@ -92,11 +94,8 @@ export const useSessions = create<SessionsState>((set, get) => ({
|
||||
|
||||
try {
|
||||
set({ isLoading: true, error: null })
|
||||
// List with the connection's default client and send no directory scope:
|
||||
// opencode-server resolves the x-opencode-directory header to a project by
|
||||
// exact match, and $HOME maps to the empty "global" project, which hides the
|
||||
// user's real workspace sessions (bug #32). The default client already carries
|
||||
// the connection's explicit directory when one is configured.
|
||||
// A directory-less list includes sessions across projects. Each row carries
|
||||
// its own directory into the session route so subsequent operations stay scoped.
|
||||
const sessions = await client.session.list({ roots: true, limit: 50 })
|
||||
set({ sessions, isLoading: false })
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user