Skip to content

Commit 7d06a8c

Browse files
adamruzickaclaude
andcommitted
Fix host table staleness on id change and redundant fetches for finished invocations
When React Router reuses JobInvocationDetailPage for a different job via breadcrumb navigation, the host table guard effect was not checking for id changes, leaving the table stale. Add a prevId ref so an id change triggers a re-fetch alongside the existing filter/status guards. TemplateInvocation was unconditionally calling dispatchFetch() on every expand, even for invocations that were already finished and had a full response in the Redux store. Guard dispatchFetch() behind response?.finished !== true to skip the extra HTTP request on collapse→expand cycles for completed invocations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 50d49af commit 7d06a8c

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

webpack/JobInvocationDetail/JobInvocationHostTable.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const JobInvocationHostTable = ({
6969
const [expandedHost, setExpandedHost] = useState(new Set());
7070
const prevJobFinished = useRef(jobFinished);
7171
const prevFilter = useRef(initialFilter);
72+
const prevId = useRef(id);
7273
const pollTimeoutId = useRef(null);
7374
const currentPollParams = useRef({});
7475
const jobFinishedRef = useRef(jobFinished);
@@ -257,10 +258,12 @@ const JobInvocationHostTable = ({
257258
useEffect(() => {
258259
const filterChanged = initialFilter !== prevFilter.current;
259260
const statusChanged = jobFinished !== prevJobFinished.current;
261+
const idChanged = id !== prevId.current;
260262

261-
if ((filterChanged || statusChanged) && initialFilter !== '') {
263+
if ((filterChanged || statusChanged || idChanged) && initialFilter !== '') {
262264
prevFilter.current = initialFilter;
263265
prevJobFinished.current = jobFinished;
266+
prevId.current = id;
264267
filterApiCall();
265268
}
266269
}, [initialFilter, jobFinished, id, filterApiCall]);

webpack/JobInvocationDetail/TemplateInvocation.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,16 @@ export const TemplateInvocation = ({
106106
}
107107

108108
if (isExpanded) {
109-
dispatchFetch();
109+
if (response?.finished !== true) {
110+
dispatchFetch();
111+
}
110112
}
111113

112114
return () => {
113115
cancelled = true;
114116
clearTimeout(timeoutRef.current);
115117
};
116-
}, [isExpanded, dispatch, templateURL, hostID]);
118+
}, [isExpanded, dispatch, templateURL, hostID, response]);
117119

118120
if (!response || (status === STATUS.PENDING && isEmpty(response))) {
119121
return <Skeleton data-testid="template-invocation-skeleton" />;

0 commit comments

Comments
 (0)