feat: improve session polling logic in BoardOnboardingChat component

This commit is contained in:
Abhimanyu Saharan
2026-02-16 01:46:12 +05:30
parent 6c3c9913db
commit 522761bc26
2 changed files with 130 additions and 3 deletions

View File

@@ -247,12 +247,17 @@ export function BoardOnboardingChat({
void startSession();
}, [startSession]);
const shouldPollSession =
isPageActive && (loading || isAwaitingAgent || (!question && !draft));
useEffect(() => {
if (!isPageActive) return;
if (!shouldPollSession) return;
void refreshSession();
const interval = setInterval(refreshSession, 2000);
const interval = setInterval(() => {
void refreshSession();
}, 2000);
return () => clearInterval(interval);
}, [isPageActive, refreshSession]);
}, [refreshSession, shouldPollSession]);
const handleAnswer = useCallback(
async (value: string, freeText?: string) => {