{(r) => section("Reach", (
diff --git a/client/src/viz/deps/flow/FlowView.tsx b/client/src/viz/deps/flow/FlowView.tsx
index 5ba8ddf2..ff3f64f2 100644
--- a/client/src/viz/deps/flow/FlowView.tsx
+++ b/client/src/viz/deps/flow/FlowView.tsx
@@ -25,7 +25,7 @@ import { FlowLegend } from "./FlowLegend";
import { DepthControl, DirectionSwitch, FlowModeSwitch, ModelSwitch, ReachModeSwitch, REACH_OF_DIRECTION, RecentFlowMenu, RouteLensSwitch } from "./FlowTools";
import { createFetch } from "./fetchSignal";
import { FlowProgress } from "./FlowProgress";
-import { stopsOf } from "./inspectorModel";
+import { canAnchorBox, stopsOf } from "./inspectorModel";
import { PythonApps } from "./PythonApps";
import { reachFrom, REACH_MODES, type ReachMode } from "./reach";
import { RoutePicker } from "./RoutePicker";
@@ -142,7 +142,7 @@ export default function FlowView(props: {
const spec = parseAnchor(raw)!;
if ("exports" in spec) throw new Error("An exports anchor has no single graph");
return watchProgress(path, fetchAnchorGraph({ path, direction: direction as Direction, ...anchorFields(spec), ...(gen ? { expectedGeneration: Number(gen) } : {}) }));
- });
+ }, { keepPrevious: false });
const anchorGraph = anchorFetch.value;
// The other anchors (T20): each its own query, one at a time, kept by generation so a Return does not refetch.
type ExtraAnchor = { raw: string; graph: AnchorGraphResult | null; outcome: string; reason: string | null };
@@ -190,7 +190,7 @@ export default function FlowView(props: {
const addAnchorFrom = (id: string) => {
const box = model()?.byId.get(id);
const specs = anchorSpecs();
- if (!box || !specs.length || specs.length >= MAX_ANCHORS || exportsSpec()) return;
+ if (!box || !canAnchorBox(box) || !specs.length || specs.length >= MAX_ANCHORS || exportsSpec()) return;
// By element id: the engine anchors at the very element the box stands for, so the traces share ids by construction.
const next: Anchor = { file: box.file, element: id };
if (specs.some((a) => encodeAnchor(a) === encodeAnchor(next))) return;
@@ -200,7 +200,7 @@ export default function FlowView(props: {
/** Re-anchor on a drawn box by its element id, keeping the direction. */
const traceFrom = (id: string) => {
const box = model()?.byId.get(id);
- if (!box || !("side" in box) || box.kind === "scope") return;
+ if (!box || !canAnchorBox(box) || box.kind === "scope") return;
setSelected(null);
go({ anchor: encodeAnchor({ file: box.file, element: id }), open: undefined });
};
@@ -360,9 +360,9 @@ export default function FlowView(props: {
let token = 0;
createEffect(() => {
+ const mine = ++token;
const m = model();
if (!m) return setLayout(null);
- const mine = ++token;
const rect = host?.getBoundingClientRect();
const viewport = rect && rect.height > 0 ? { width: rect.width, height: rect.height } : undefined;
const aspectRatio = viewport ? viewport.width / viewport.height : 1.6;
diff --git a/client/src/viz/deps/flow/fetchSignal.test.ts b/client/src/viz/deps/flow/fetchSignal.test.ts
index 1eae648c..c763fa6d 100644
--- a/client/src/viz/deps/flow/fetchSignal.test.ts
+++ b/client/src/viz/deps/flow/fetchSignal.test.ts
@@ -22,3 +22,33 @@ describe("createFetch", () => {
dispose();
});
});
+
+it("clears an anchor's previous result while loading and after failure, ignoring late replies", async () => {
+ const pending = new Map void; reject: (error: Error) => void }>();
+ const { fetch, setKey, dispose } = createRoot((dispose) => {
+ const [key, setKey] = createSignal("first");
+ return { fetch: createFetch(key, (k) => new Promise((resolve, reject) => pending.set(k, { resolve, reject })), { keepPrevious: false }), setKey, dispose };
+ });
+ try {
+ pending.get("first")!.resolve("first graph");
+ await Promise.resolve();
+ expect(fetch.value()).toBe("first graph");
+ setKey("second");
+ expect(fetch.loading()).toBe(true);
+ expect(fetch.value()).toBeUndefined();
+ setKey("third");
+ pending.get("third")!.reject(new Error("No program element"));
+ await Promise.resolve();
+ expect(fetch.error()?.message).toBe("No program element");
+ expect(fetch.value()).toBeUndefined();
+ pending.get("second")!.resolve("late second graph");
+ await Promise.resolve();
+ expect(fetch.value()).toBeUndefined();
+ expect(fetch.error()?.message).toBe("No program element");
+ fetch.retry();
+ expect(fetch.error()).toBeNull();
+ pending.get("third")!.resolve("retried graph");
+ await Promise.resolve();
+ expect(fetch.value()).toBe("retried graph");
+ } finally { dispose(); }
+});
diff --git a/client/src/viz/deps/flow/fetchSignal.ts b/client/src/viz/deps/flow/fetchSignal.ts
index d232ae1c..dbf9c4e5 100644
--- a/client/src/viz/deps/flow/fetchSignal.ts
+++ b/client/src/viz/deps/flow/fetchSignal.ts
@@ -5,7 +5,7 @@ import { createEffect, createSignal, on } from "solid-js";
* reading it never suspends: the graph view sits under the treemap's
* Suspense, which would swap the whole view for its fallback.
*/
-export function createFetch(source: () => S | null | undefined, fetcher: (key: S) => Promise) {
+export function createFetch(source: () => S | null | undefined, fetcher: (key: S) => Promise, options: { keepPrevious?: boolean } = {}) {
const [value, setValue] = createSignal();
const [loading, setLoading] = createSignal(false);
const [error, setError] = createSignal(null);
@@ -16,6 +16,8 @@ export function createFetch(source: () => S | null | undefined, fetcher: (
on([source, attempt], ([key]) => {
const mine = ++token;
setError(null);
+ // Anchor requests must not present a previous graph as the new request.
+ if (options.keepPrevious === false) setValue(undefined);
if (key === null || key === undefined) {
setValue(undefined);
setLoading(false);
diff --git a/client/src/viz/deps/flow/inspectorModel.ts b/client/src/viz/deps/flow/inspectorModel.ts
index a6dfc98e..44e28936 100644
--- a/client/src/viz/deps/flow/inspectorModel.ts
+++ b/client/src/viz/deps/flow/inspectorModel.ts
@@ -6,6 +6,11 @@ import { isAssumedProof } from "../../../dataflow/outcome";
import type { FlowBox, FlowViewModel } from "./adapter";
import { humanizeDetail, MARK_OF_ANCHOR_KIND, MARK_OF_KIND, STOP_REASONS, stopWord, type FlowMark } from "./marks";
+/** Frontiers describe where a walk stopped; their display ids are not program elements. */
+export function canAnchorBox(box: FlowBox | undefined): boolean {
+ return !!box && "side" in box && box.kind !== "frontier";
+}
+
/** Route mode words for the render backbone; anchor mode names the engine's relation (`argument`, `return value`, …). */
export type EdgeKindWord = "renders" | "rendered by" | "handoff" | "field" | "structural" | (string & {});