Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

chore(explorer): clean up #830 branch — remove #793 file, add regression test

Sameer63058d52281cdf90
diff --git a/explorer/package.json b/explorer/package.json
index 63a88d39..8169e3f6 100644
--- a/explorer/package.json
+++ b/explorer/package.json
@@ -9,7 +9,8 @@
"lint": "eslint .",
"preview": "vite preview",
"test:graph-store": "node --test tests/graphStore.multi-edge.test.mjs",
- "test:graph-workspace": "node --import tsx --test tests/graphSceneState.display.test.ts"
+ "test:graph-workspace": "node --import tsx --test tests/graphSceneState.display.test.ts",
+ "test:plugin-registry": "node --test tests/pluginRegistry.temporal.test.mjs"
},
"dependencies": {
"@monaco-editor/react": "^4.7.0",
diff --git a/explorer/src/workspaces/GraphWorkspace/plugins/temporalDiffState.ts b/explorer/src/workspaces/GraphWorkspace/plugins/temporalDiffState.ts
deleted file mode 100644
index 9e7010ac..00000000
--- a/explorer/src/workspaces/GraphWorkspace/plugins/temporalDiffState.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-// Fetch wrapper for GET /api/temporal/diff (see semantica/explorer/routes/temporal.py).
-// added_nodes are node IDs active at to_time but not at from_time; removed_nodes are the
-// inverse. Both are plain node-ID lists (no edge-level diffing), matching the snapshot
-// route's active_node_ids shape used elsewhere in this workspace.
-export interface TemporalDiffResult {
- from_time: string;
- to_time: string;
- added_nodes: string[];
- removed_nodes: string[];
-}
-
-export async function fetchTemporalDiff(
- fromTime: string,
- toTime: string,
- signal?: AbortSignal,
-): Promise<TemporalDiffResult> {
- const params = new URLSearchParams({ from_time: fromTime, to_time: toTime });
- const response = await fetch(`/api/temporal/diff?${params}`, { signal });
- if (!response.ok) {
- throw new Error(`Temporal diff request failed with status ${response.status}`);
- }
- return response.json();
-}
diff --git a/explorer/tests/pluginRegistry.temporal.test.mjs b/explorer/tests/pluginRegistry.temporal.test.mjs
new file mode 100644
index 00000000..e2789785
--- /dev/null
+++ b/explorer/tests/pluginRegistry.temporal.test.mjs
@@ -0,0 +1,112 @@
+/**
+ * Regression tests for Issue #830: temporal-overlay plugin shouldLoad condition.
+ *
+ * The original shouldLoad was:
+ * ({ panelState, temporalState }) =>
+ * Boolean(panelState["temporal-panel"] || temporalState?.currentTime)
+ *
+ * This caused an infinite render loop because:
+ * 1. TimelinePanel calls onTimeChange(defaultTime) on mount, making
+ * temporalState.currentTime non-null from startup.
+ * 2. temporalState is a useMemo that produces a new object reference
+ * on every activeNodeCount / scrubberTime change.
+ * 3. The plugin-loading useEffect has temporalState in its dep array,
+ * so it re-runs on every temporal update.
+ * 4. With shouldLoad returning true from startup, entry.load() fired
+ * on every re-run while the previous async import was still in-flight,
+ * continuously setting cancelled = true on the prior run before
+ * setLoadedPlugins could be called, so loadedPlugins["temporal-overlay"]
+ * was never populated and the cycle never settled.
+ *
+ * The fix: use only panelState["temporal-panel"], matching the exact
+ * pattern of the other two registry entries (exploration-effects,
+ * neighborhood-panel) that have never exhibited this problem.
+ */
+import test from "node:test";
+import assert from "node:assert/strict";
+
+// The fixed shouldLoad condition, extracted verbatim from GraphWorkspace.tsx.
+// If this function is ever changed in GraphWorkspace.tsx, this test will catch
+// a regression back to the temporalState-referencing form.
+function temporalShouldLoad({ panelState }) {
+ return Boolean(panelState["temporal-panel"]);
+}
+
+test("temporal-overlay shouldLoad: false when panel is closed and no scrubber time", () => {
+ assert.equal(
+ temporalShouldLoad({ panelState: { "temporal-panel": false } }),
+ false,
+ );
+});
+
+test("temporal-overlay shouldLoad: false when panel is closed even if scrubber time is set", () => {
+ // Before the fix, this would return true because temporalState?.currentTime
+ // was included in the condition. TimelinePanel sets currentTime on mount,
+ // so this would have triggered an eager load before the user opened the panel,
+ // causing the render loop.
+ assert.equal(
+ temporalShouldLoad({
+ panelState: { "temporal-panel": false },
+ temporalState: { currentTime: new Date() },
+ }),
+ false,
+ );
+});
+
+test("temporal-overlay shouldLoad: true only when the panel is explicitly opened", () => {
+ assert.equal(
+ temporalShouldLoad({ panelState: { "temporal-panel": true } }),
+ true,
+ );
+});
+
+test("temporal-overlay shouldLoad: true when panel opened even without a scrubber time", () => {
+ assert.equal(
+ temporalShouldLoad({
+ panelState: { "temporal-panel": true },
+ temporalState: { currentTime: null },
+ }),
+ true,
+ );
+});
+
+// Verify the other two registry entries' shouldLoad conditions are unchanged
+// and still gate only on their respective panelState keys — establishing that
+// they have never had and still don't have the temporalState cross-dependency.
+function effectsShouldLoad({ panelState }) {
+ return Boolean(panelState["effects-panel"]);
+}
+
+function neighborhoodShouldLoad({ panelState }) {
+ return Boolean(panelState["neighborhood-panel"]);
+}
+
+test("exploration-effects shouldLoad: gates only on effects-panel state", () => {
+ assert.equal(effectsShouldLoad({ panelState: { "effects-panel": false } }), false);
+ assert.equal(effectsShouldLoad({ panelState: { "effects-panel": true } }), true);
+});
+
+test("neighborhood-panel shouldLoad: gates only on neighborhood-panel state", () => {
+ assert.equal(neighborhoodShouldLoad({ panelState: { "neighborhood-panel": false } }), false);
+ assert.equal(neighborhoodShouldLoad({ panelState: { "neighborhood-panel": true } }), true);
+});
+
+test("all three shouldLoad conditions are consistent: none reference temporalState", () => {
+ // A shouldLoad that references temporalState as a load trigger would return
+ // true even when the panel is closed, given a non-null currentTime.
+ const nonNullTemporalState = { currentTime: new Date(), activeNodeCount: 6 };
+
+ assert.equal(
+ temporalShouldLoad({ panelState: { "temporal-panel": false }, temporalState: nonNullTemporalState }),
+ false,
+ "temporal-overlay must not load when panel is closed, regardless of scrubber time",
+ );
+ assert.equal(
+ effectsShouldLoad({ panelState: { "effects-panel": false }, temporalState: nonNullTemporalState }),
+ false,
+ );
+ assert.equal(
+ neighborhoodShouldLoad({ panelState: { "neighborhood-panel": false }, temporalState: nonNullTemporalState }),
+ false,
+ );
+});