diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index f635c17..4bc9a71 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -49,7 +49,10 @@ function SessionItem({ onDelete: () => void }) { const onPress = () => { - router.push(`/session/${session.id}`) + router.push({ + pathname: `/session/[id]`, + params: { id: session.id, ...(session.directory ? { directory: session.directory } : {}) }, + }) } const onLongPress = () => { diff --git a/src/stores/connections.ts b/src/stores/connections.ts index ef3b12d..606ee32 100644 --- a/src/stores/connections.ts +++ b/src/stores/connections.ts @@ -43,8 +43,9 @@ interface ConnectionsState { ) => Promise<{ ok: boolean; error?: string }> updateConnection: (id: string, updates: Partial) => Promise refreshProject: () => Promise - // 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 // Record a directory as recently used diff --git a/src/stores/sessions.ts b/src/stores/sessions.ts index 4f9b8dd..0f34c00 100644 --- a/src/stores/sessions.ts +++ b/src/stores/sessions.ts @@ -84,7 +84,9 @@ export const useSessions = create((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((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) {