Skip to content

Commit 07b5b46

Browse files
committed
fix(security-agent): keep accepted poll through completion
1 parent 40c22d3 commit 07b5b46

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

apps/web/src/components/security-agent/SecurityAgentContext.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export function SecurityAgentProvider({ organizationId, children }: SecurityAgen
143143
const [gitHubError, setGitHubError] = useState<string | null>(null);
144144
const toggleEnabledInFlightRef = useRef(false);
145145
const acceptedQueuePollRef = useRef<{ intervalId: number; timeoutId: number } | null>(null);
146+
const acceptedQueuePollHasSeenActiveRef = useRef(false);
146147

147148
const clearAcceptedQueuePoll = useCallback(() => {
148149
const activePoll = acceptedQueuePollRef.current;
@@ -220,11 +221,17 @@ export function SecurityAgentProvider({ organizationId, children }: SecurityAgen
220221

221222
const pollAcceptedQueueMutation = useCallback(() => {
222223
clearAcceptedQueuePoll();
224+
acceptedQueuePollHasSeenActiveRef.current = false;
223225
invalidateAcceptedQueueQueries();
224226

225227
const intervalId = window.setInterval(() => {
226228
invalidateAcceptedQueueQueries();
227-
if (cachedListFindingsHasActiveAnalysis()) {
229+
const hasActiveAnalysis = cachedListFindingsHasActiveAnalysis();
230+
if (hasActiveAnalysis) {
231+
acceptedQueuePollHasSeenActiveRef.current = true;
232+
return;
233+
}
234+
if (acceptedQueuePollHasSeenActiveRef.current) {
228235
clearAcceptedQueuePoll();
229236
}
230237
}, ACCEPTED_QUEUE_POLL_INTERVAL_MS);

0 commit comments

Comments
 (0)