Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): guard against stale triage counts

[._.]/ Adam Eivydc92d073712b
diff --git a/client/src/pages/Review.jsx b/client/src/pages/Review.jsx
index bbfcd6d819..74a2f82f4d 100644
--- a/client/src/pages/Review.jsx
+++ b/client/src/pages/Review.jsx
@@ -1,4 +1,4 @@
-import { useState, useEffect, useCallback, useMemo } from 'react';
+import { useState, useEffect, useCallback, useMemo, useRef } from 'react';
import { useNavigate } from 'react-router';
import {
ClipboardList,
@@ -95,6 +95,7 @@ export default function Review() {
const [filter, setFilter] = useState('pending');
const [briefingFullscreen, setBriefingFullscreen] = useState(false);
const [counts, setCounts] = useState(null);
+ const countsRequestId = useRef(0);
// Cross-domain live queue (M42 P5). These rows are derived live from each
// producer, not stored, so "dismiss" is a per-session client-side hide rather
@@ -114,7 +115,10 @@ export default function Review() {
}, [filter]);
const fetchCounts = useCallback(() => {
- api.getReviewCounts({ silent: true }).then(setCounts).catch(() => null);
+ const requestId = ++countsRequestId.current;
+ api.getReviewCounts({ silent: true }).then(data => {
+ if (requestId === countsRequestId.current) setCounts(data);
+ }).catch(() => null);
}, []);
const fetchBriefing = useCallback(async () => {
diff --git a/client/src/pages/Review.test.jsx b/client/src/pages/Review.test.jsx
index b4908e9f2a..3b2eb3ea0c 100644
--- a/client/src/pages/Review.test.jsx
+++ b/client/src/pages/Review.test.jsx
@@ -322,4 +322,34 @@ describe('Review Hub triage summary (#6926)', () => {
expect(summaryValue('Alerts')).toBe('2');
expect(api.getReviewCounts).toHaveBeenCalledTimes(2);
});
+
+ it('keeps the newest count response when refreshes resolve out of order', async () => {
+ let resolveInitial;
+ let resolveRefresh;
+ api.getReviewCounts
+ .mockReset()
+ .mockImplementationOnce(() => new Promise(resolve => { resolveInitial = resolve; }))
+ .mockImplementationOnce(() => new Promise(resolve => { resolveRefresh = resolve; }));
+
+ render(<Review />);
+ await waitFor(() => expect(resolveInitial).toBeTypeOf('function'));
+
+ const handler = socket.on.mock.calls.find(([name]) => name === 'review:item:updated')?.[1];
+ expect(handler).toBeTypeOf('function');
+ act(() => handler({ ...ITEM, status: 'completed' }));
+ await waitFor(() => expect(resolveRefresh).toBeTypeOf('function'));
+
+ await act(async () => {
+ resolveRefresh({ total: 7, alert: 2, todo: 1, briefing: 0, cos: 4 });
+ await Promise.resolve();
+ });
+ expect(summaryValue('Pending')).toBe('7');
+
+ await act(async () => {
+ resolveInitial(SUMMARY_COUNTS);
+ await Promise.resolve();
+ });
+ expect(summaryValue('Pending')).toBe('7');
+ expect(summaryValue('Alerts')).toBe('2');
+ });
});