fix(background-tasks): no state update after unmount when the features answer arrives late

This commit is contained in:
Maurice
2026-10-01 16:54:28 +02:00
parent 5669f8b860
commit d7bf7f2f16
@@ -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.