fix(ui): align telemetry and laboratory navigation

This commit is contained in:
DCCONSTRUCTIONS
2026-07-28 03:18:27 +03:00
parent 6db5ac05ef
commit e35f81ac34
13 changed files with 195 additions and 55 deletions
@@ -23,6 +23,7 @@ interface ComputeContourContextValue {
selectedContour: ComputeContour | null;
loading: boolean;
error: string | null;
telemetryRefreshGeneration: number;
selectContour: (contourId: string) => void;
createContour: (draft: ComputeContourDraft) => Promise<ComputeContour>;
updateContour: (
@@ -30,6 +31,7 @@ interface ComputeContourContextValue {
draft: ComputeContourDraft,
) => Promise<ComputeContour>;
refresh: () => void;
refreshTelemetry: () => void;
}
const ComputeContourContext = createContext<ComputeContourContextValue | null>(null);
@@ -42,7 +44,12 @@ export function ComputeContourProvider({ children }: { children: ReactNode }) {
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const [generation, setGeneration] = useState(0);
const [telemetryRefreshGeneration, setTelemetryRefreshGeneration] = useState(0);
const refresh = useCallback(() => setGeneration((value) => value + 1), []);
const refreshTelemetry = useCallback(
() => setTelemetryRefreshGeneration((value) => value + 1),
[],
);
useEffect(() => {
const controller = new AbortController();
@@ -103,19 +110,23 @@ export function ComputeContourProvider({ children }: { children: ReactNode }) {
selectedContour,
loading,
error,
telemetryRefreshGeneration,
selectContour,
createContour,
updateContour,
refresh,
refreshTelemetry,
}), [
contours,
selectedContour,
loading,
error,
telemetryRefreshGeneration,
selectContour,
createContour,
updateContour,
refresh,
refreshTelemetry,
]);
return (
@@ -18,6 +18,7 @@ export interface WorkerTelemetryState {
export function useWorkerTelemetry(
pollMilliseconds = DEFAULT_WORKER_TELEMETRY_POLL_MILLISECONDS,
enabled = true,
externalRefreshGeneration = 0,
): WorkerTelemetryState {
const normalizedPollMilliseconds = normalizeWorkerTelemetryPollMilliseconds(
pollMilliseconds,
@@ -51,7 +52,7 @@ export function useWorkerTelemetry(
if (!controller.signal.aborted) setLoading(false);
});
return () => controller.abort();
}, [enabled, generation]);
}, [enabled, externalRefreshGeneration, generation]);
useEffect(() => {
if (!enabled || loading) return;