From d7bf7f2f1656996b0294f208089e5a16c3134082 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 1 Oct 2026 16:54:28 +0200 Subject: [PATCH] fix(background-tasks): no state update after unmount when the features answer arrives late --- .../components/BackgroundTasks/BackgroundTasksWidget.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/components/BackgroundTasks/BackgroundTasksWidget.tsx b/client/src/components/BackgroundTasks/BackgroundTasksWidget.tsx index 087464442..c36cf2226 100644 --- a/client/src/components/BackgroundTasks/BackgroundTasksWidget.tsx +++ b/client/src/components/BackgroundTasks/BackgroundTasksWidget.tsx @@ -43,7 +43,12 @@ export default function BackgroundTasksWidget() { const [aiParsing, setAiParsing] = useState(false) useEffect(() => { - healthApi.features().then((f) => setAiParsing(!!f.aiParsing)).catch(() => setAiParsing(false)) + // Cancelled on unmount, so a late answer never sets state on a torn-down widget. + let cancelled = false + healthApi.features() + .then((f) => { if (!cancelled) setAiParsing(!!f.aiParsing) }) + .catch(() => { if (!cancelled) setAiParsing(false) }) + return () => { cancelled = true } }, []) // Re-runs the same files with force-ai: the LLM sees every file, kitinerary is skipped.