mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-30 04:40:16 +00:00
Explorer was firing temporal requests before the graph even loaded. When the backend is down, /api/graph/nodes fails but the temporal bounds and snapshot effects didn't care , they fired anyway, off in their own corner, ignoring whether the graph actually came up. Every page load with no backend meant three failed requests instead of one, and a scrubber that had nothing to scrub. Added two small predicate functions and gated the temporal effects on them. Basically: don't ask for time-based data until you know the graph itself loaded. An empty graph still counts as loaded, so that case isn't broken. Confirmed with the backend down, before and after: three failing requests down to one. Fixes #982.
32 lines
772 B
TypeScript
32 lines
772 B
TypeScript
import type { GraphLoadSummary } from "./types";
|
|
|
|
/**
|
|
* Predicates for gating GraphWorkspace temporal API requests.
|
|
*
|
|
* Temporal bounds and snapshot requests must strictly not execute until the
|
|
* initial graph load has succeeded (summary !== undefined). An empty graph
|
|
* (nodeCount: 0) is still a successful load and must not be rejected.
|
|
*/
|
|
|
|
export function shouldFetchTemporalBounds(
|
|
summary: GraphLoadSummary | undefined,
|
|
): boolean {
|
|
return summary !== undefined;
|
|
}
|
|
|
|
export function shouldFetchTemporalSnapshot({
|
|
debouncedTime,
|
|
isLoading,
|
|
summary,
|
|
}: {
|
|
debouncedTime: Date | null;
|
|
isLoading: boolean;
|
|
summary: GraphLoadSummary | undefined;
|
|
}): boolean {
|
|
return (
|
|
summary !== undefined &&
|
|
debouncedTime !== null &&
|
|
!isLoading
|
|
);
|
|
}
|