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

guard IssuesTab loads against a stale response landing after an app switch

[._.]/ Adam Eivyaf8fbef1b0f2
diff --git a/client/src/components/apps/tabs/IssuesTab.jsx b/client/src/components/apps/tabs/IssuesTab.jsx
index a33e11fcc7..73b8348278 100644
--- a/client/src/components/apps/tabs/IssuesTab.jsx
+++ b/client/src/components/apps/tabs/IssuesTab.jsx
@@ -1,4 +1,4 @@
-import { useState, useEffect, useCallback, useMemo, useId } from 'react';
+import { useState, useEffect, useCallback, useMemo, useId, useRef } from 'react';
import { Link } from 'react-router';
import {
AlertTriangle, ChevronDown, ChevronRight, CircleDot, ExternalLink,
@@ -68,15 +68,26 @@ export default function IssuesTab({ appId, appName }) {
// once the CoS task exists. Keyed by issue number so one claim can't disable
// every other row's button.
const [claims, setClaims] = useState({});
+ // Generation guard: a forge list can take seconds, so a Refresh (or a switch to
+ // a different app, which updates this component in place rather than
+ // remounting it) can leave an older request in flight. Without this, that older
+ // response lands last and shows one app's issues under another's Claim buttons.
+ const requestRef = useRef(0);
const load = useCallback(async () => {
+ const generation = requestRef.current + 1;
+ requestRef.current = generation;
+ const isCurrent = () => requestRef.current === generation;
+
setLoading(true);
setError('');
const result = await api.getAppIssues(appId).catch(err => {
- setError(err?.message || 'Failed to load issues');
+ if (isCurrent()) setError(err?.message || 'Failed to load issues');
return null;
});
+ if (!isCurrent()) return;
setLoading(false);
+ // A failed refresh keeps the last good list rather than blanking it.
if (result) setData(result);
}, [appId]);
diff --git a/client/src/components/apps/tabs/IssuesTab.test.jsx b/client/src/components/apps/tabs/IssuesTab.test.jsx
index a771bb8bd2..ac7f2732e9 100644
--- a/client/src/components/apps/tabs/IssuesTab.test.jsx
+++ b/client/src/components/apps/tabs/IssuesTab.test.jsx
@@ -109,6 +109,28 @@ describe('IssuesTab', () => {
expect(screen.queryByText('Crash on save')).not.toBeInTheDocument();
});
+ it('ignores a stale in-flight response when the app changes mid-request', async () => {
+ // Switching apps updates this component in place, so a slow first response
+ // must not land on top of the newer app's list.
+ let resolveFirst;
+ api.getAppIssues
+ .mockImplementationOnce(() => new Promise(res => { resolveFirst = res; }))
+ .mockResolvedValueOnce(okPayload([{ ...ISSUE, number: 99, title: 'Second app issue' }]));
+
+ const { rerender } = render(
+ <MemoryRouter><IssuesTab appId="app-1" appName="Widget" /></MemoryRouter>
+ );
+ rerender(
+ <MemoryRouter><IssuesTab appId="app-2" appName="Other" /></MemoryRouter>
+ );
+ expect(await screen.findByText('Second app issue')).toBeInTheDocument();
+
+ // The first app's response arrives late — it must be discarded.
+ resolveFirst(okPayload([ISSUE]));
+ await waitFor(() => expect(screen.getByText('Second app issue')).toBeInTheDocument());
+ expect(screen.queryByText('Crash on save')).not.toBeInTheDocument();
+ });
+
it('says "couldn\'t reach" for a transient failure — never "no open issues"', async () => {
api.getAppIssues.mockResolvedValue({
forge: 'github', fullName: 'acme/widget', issues: [],