From 7b61a274e52531eec99801d37215a398f8a8bad5 Mon Sep 17 00:00:00 2001 From: Kacper Date: Tue, 23 Dec 2025 23:28:02 +0100 Subject: [PATCH] fix: Prevent race condition in unviewed validations count update - Added a guard to ensure the unviewed count is only updated if the current project matches the reference, preventing potential race conditions during state updates. --- .../layout/sidebar/hooks/use-unviewed-validations.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/ui/src/components/layout/sidebar/hooks/use-unviewed-validations.ts b/apps/ui/src/components/layout/sidebar/hooks/use-unviewed-validations.ts index da73ad15..ac5add46 100644 --- a/apps/ui/src/components/layout/sidebar/hooks/use-unviewed-validations.ts +++ b/apps/ui/src/components/layout/sidebar/hooks/use-unviewed-validations.ts @@ -31,7 +31,10 @@ export function useUnviewedValidations(currentProject: Project | null) { const hoursSince = (Date.now() - new Date(v.validatedAt).getTime()) / (1000 * 60 * 60); return hoursSince <= 24; }); - setCount(unviewed.length); + // Only update count if we're still on the same project (guard against race condition) + if (projectPathRef.current === projectPath) { + setCount(unviewed.length); + } } } } catch (err) {