Fix session caching - enable refetch on focus and reconnect

This commit is contained in:
Chris Scott committed 2025-12-07 14:34:35 -05:00
1 parent 08e3414677
commit ec1d96a77d
3 files changed
+11 -6

No files matched your search

+2 -2
View File
@@ -85,7 +85,7 @@ A full-stack web application for running [OpenCode](https://github.com/sst/openc
```bash
# Clone the repository
git clone https://github.com/yourusername/opencode-webui.git
git clone https://github.com/cstech-dev/opencode-webui.git
cd opencode-webui
# Start with Docker Compose (single container)
@@ -125,7 +125,7 @@ docker exec -it opencode-web sh
```bash
# Clone the repository
git clone https://github.com/yourusername/opencode-webui.git
git clone https://github.com/cstech-dev/opencode-webui.git
cd opencode-webui
# Install dependencies (uses Bun workspaces)
+9 -2
View File
@@ -28,6 +28,9 @@ export const useSessions = (opcodeUrl: string | null | undefined, directory?: st
queryKey: ["opencode", "sessions", opcodeUrl, directory],
queryFn: () => client!.listSessions(),
enabled: !!client,
refetchOnWindowFocus: true,
refetchOnReconnect: true,
staleTime: 10000,
});
};
@@ -38,6 +41,9 @@ export const useSession = (opcodeUrl: string | null | undefined, sessionID: stri
queryKey: ["opencode", "session", opcodeUrl, sessionID, directory],
queryFn: () => client!.getSession(sessionID!),
enabled: !!client && !!sessionID,
refetchOnWindowFocus: true,
refetchOnReconnect: true,
staleTime: 15000,
});
};
@@ -49,8 +55,9 @@ export const useMessages = (opcodeUrl: string | null | undefined, sessionID: str
queryFn: () => client!.listMessages(sessionID!),
enabled: !!client && !!sessionID,
refetchOnMount: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnWindowFocus: true,
refetchOnReconnect: true,
staleTime: 30000,
gcTime: 10 * 60 * 1000,
placeholderData: (previousData) => previousData,
});
-2
View File
@@ -333,8 +333,6 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string)
setIsConnected(true)
setError(null)
resetReconnectDelay()
queryClient.invalidateQueries({ queryKey: ['opencode', 'sessions', opcodeUrl, directory] })
queryClient.invalidateQueries({ queryKey: ['opencode', 'messages', opcodeUrl] })
}
eventSource.onerror = () => {