mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(copilot): prevent infinite refetch loop when backend errors
- Only invalidate session queries on successful completion (status='ready') - Previously invalidated on both 'ready' and 'error' status - When backend returned 500, error status triggered refetch which caused infinite loop - Fixes spam of 'Let me check!' messages when backend is unavailable
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -203,8 +203,9 @@ export function useCopilotPage() {
|
||||
prevStatusRef.current = status;
|
||||
|
||||
const wasActive = prev === "streaming" || prev === "submitted";
|
||||
const isIdle = status === "ready" || status === "error";
|
||||
if (wasActive && isIdle && sessionId) {
|
||||
const isReady = status === "ready";
|
||||
// Only invalidate on successful completion, not on error to avoid infinite refetch loop
|
||||
if (wasActive && isReady && sessionId) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: getGetV2GetSessionQueryKey(sessionId),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user