Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

fix(explorer): address PR #486 review blockers + resolve conflict with main

KaifAhmad1f516aef8fd7c
diff --cc explorer/src/workspaces/GraphWorkspace/GraphWorkspace.tsx
index b8e9c6b8,32daf9e2..06183c7d
--- a/explorer/src/workspaces/GraphWorkspace/GraphWorkspace.tsx
+++ b/explorer/src/workspaces/GraphWorkspace/GraphWorkspace.tsx
@@@ -12,7 -12,7 +12,8 @@@ import { useLoadGraph, useReloadGraph
import { GraphLoadingOverlay } from "./GraphLoadingOverlay";
import { createGraphLoadProgress, getGraphLoadTitle } from "./graphLoading";
import { GRAPH_THEME, withAlpha } from "./graphTheme";
-import { resolveDisplayGraph } from "./graphSceneState";
+import { resolveDisplayGraph, resolveDisplayStateSnapshot } from "./graphSceneState";
++import { computeGraphAnalyticsBase } from "./graphAnalytics";
import {
type GraphPlugin,
type GraphPluginActionRequest,
@@@ -1025,70 -1026,18 +1052,77 @@@ export function GraphWorkspace()
setCollapsedNeighborhoodNodeIds([]);
}, [summary?.edgeCount, summary?.nodeCount]);
- const showLoadingOverlay = isLoading || isFetching || loadingProgress?.phase === "stabilizing_layout";
+ const showLoadingOverlay = !graphReady && (isLoading || isFetching || Boolean(loadingProgress));
+ const showSettlingStatus = graphReady && loadingProgress?.phase === "stabilizing_layout";
const hasGraphContent = Boolean(summary?.nodeCount);
- const activePath = pathResult?.path ?? [];
- const activePathEdgeIds = pathResult?.edge_ids ?? [];
+ const activePath = pathResult?.path ?? EMPTY_PATH;
+ const activePathEdgeIds = pathResult?.edge_ids ?? EMPTY_PATH;
+ const structuralSelectedNodeId = useMemo(() => {
+ if (!selectedNodeId || !graph.hasNode(selectedNodeId)) {
+ return "";
+ }
+ if (viewMode === "focused") {
+ return selectedNodeId;
+ }
+ return collapsedNeighborhoodNodeIds.includes(selectedNodeId) ? selectedNodeId : "";
+ }, [collapsedNeighborhoodNodeIds, selectedNodeId, viewMode]);
+ const structuralActivePath = structuralSelectedNodeId ? activePath : EMPTY_PATH;
+ const structuralActivePathEdgeIds = structuralSelectedNodeId ? activePathEdgeIds : EMPTY_PATH;
++ const groupedViewAvailable = useMemo(
++ () => computeGraphAnalyticsBase(graph, { computeCommunities: true, computeCentrality: false }).communitiesByNode.size > 0,
++ [graphVersion],
++ );
const displayResult = useMemo(
- () => resolveDisplayGraph(selectedNodeId, activePath, activePathEdgeIds, viewMode, {
+ () => resolveDisplayGraph(structuralSelectedNodeId, structuralActivePath, structuralActivePathEdgeIds, viewMode, {
aggregationEnabled,
collapsedNeighborhoodNodeIds,
++ groupedViewAvailable,
}),
- [activePath, activePathEdgeIds, aggregationEnabled, collapsedNeighborhoodNodeIds, selectedNodeId, viewMode],
+ [
+ aggregationEnabled,
+ collapsedNeighborhoodNodeIds,
+ graphVersion,
++ groupedViewAvailable,
+ structuralActivePath,
+ structuralActivePathEdgeIds,
+ structuralSelectedNodeId,
+ viewMode,
+ ],
);
- const displayState = displayResult.state;
+ const displayState = useMemo(
+ () => resolveDisplayStateSnapshot(selectedNodeId, activePath, viewMode, {
+ aggregationEnabled,
+ collapsedNeighborhoodNodeIds,
++ groupedViewAvailable,
+ }),
- [activePath, aggregationEnabled, collapsedNeighborhoodNodeIds, graphVersion, selectedNodeId, viewMode],
++ [activePath, aggregationEnabled, collapsedNeighborhoodNodeIds, groupedViewAvailable, selectedNodeId, viewMode],
+ );
+ const displayMeta = displayResult.meta;
+ const previousDisplayGraphRef = useRef(displayResult.graph);
+ const previousDisplayStateRef = useRef(displayState);
+ useEffect(() => {
+ const graphRebuilt = previousDisplayGraphRef.current !== displayResult.graph;
+ const displayStateChanged = previousDisplayStateRef.current !== displayState;
+ debugGraphWorkspace("display-state-derived", {
+ selectedNodeId,
+ structuralSelectedNodeId,
+ viewMode,
+ graphRebuilt,
+ displayStateChanged,
+ aggregationEnabled,
+ collapsedNeighborhoodActive: Boolean(structuralSelectedNodeId && collapsedNeighborhoodNodeIds.includes(structuralSelectedNodeId)),
+ });
+ previousDisplayGraphRef.current = displayResult.graph;
+ previousDisplayStateRef.current = displayState;
+ }, [
+ aggregationEnabled,
+ collapsedNeighborhoodNodeIds,
+ displayResult.graph,
+ displayState,
+ selectedNodeId,
+ structuralSelectedNodeId,
+ viewMode,
+ ]);
const focusedSummary = useMemo(() => {
if (!selectedNodeId || !graph.hasNode(selectedNodeId)) {
if (viewMode === "grouped") {
diff --cc explorer/src/workspaces/GraphWorkspace/graphSceneState.ts
index bea7f64c,8a7bc15f..c70bb734
--- a/explorer/src/workspaces/GraphWorkspace/graphSceneState.ts
+++ b/explorer/src/workspaces/GraphWorkspace/graphSceneState.ts
@@@ -1235,46 -1212,6 +1235,47 @@@ function buildCommunityGroupedGraph():
};
}
+export function resolveDisplayStateSnapshot(
+ selectedNodeId: string,
+ activePath: string[],
+ viewMode: GraphViewMode,
+ options?: {
+ aggregationEnabled?: boolean;
+ collapsedNeighborhoodNodeIds?: Iterable<string>;
++ groupedViewAvailable?: boolean;
+ },
+): GraphDisplayStateSnapshot {
+ const aggregationEnabled = options?.aggregationEnabled ?? true;
+ const collapsedNeighborhoodNodeIds = new Set(
+ Array.from(options?.collapsedNeighborhoodNodeIds ?? []).filter((nodeId) => typeof nodeId === "string"),
+ );
+ const displayState = createEmptyDisplayState(selectedNodeId, aggregationEnabled);
- displayState.groupedViewAvailable = computeGraphAnalyticsBase(graph, {
++ displayState.groupedViewAvailable = options?.groupedViewAvailable ?? computeGraphAnalyticsBase(graph, {
+ computeCommunities: true,
+ computeCentrality: false,
+ }).communitiesByNode.size > 0;
+
+ if (!selectedNodeId || !graph.hasNode(selectedNodeId)) {
+ return displayState;
+ }
+
+ const shouldCollapseNeighborhood = Boolean(
+ viewMode !== "grouped"
+ && collapsedNeighborhoodNodeIds.has(selectedNodeId),
+ );
+ const collapsedState = shouldCollapseNeighborhood
+ ? buildCollapsedNeighborhoodState(selectedNodeId, activePath)
+ : {
+ selectedVisibleNeighborIds: rankNeighbors(selectedNodeId),
+ selectedCollapsedNeighborIds: [],
+ };
+
+ displayState.selectedRootNodeId = selectedNodeId;
+ displayState.selectedVisibleNeighborIds = collapsedState.selectedVisibleNeighborIds;
+ displayState.selectedCollapsedNeighborIds = collapsedState.selectedCollapsedNeighborIds;
+ return displayState;
+}
+
export function createFocusedGraph(
nodeId: string,
activePath: string[],
@@@ -1395,16 -1332,17 +1396,18 @@@ export function resolveDisplayGraph
options?: {
aggregationEnabled?: boolean;
collapsedNeighborhoodNodeIds?: Iterable<string>;
++ groupedViewAvailable?: boolean;
},
): GraphDisplayResult {
const aggregationEnabled = options?.aggregationEnabled ?? true;
const collapsedNeighborhoodNodeIds = new Set(
Array.from(options?.collapsedNeighborhoodNodeIds ?? []).filter((nodeId) => typeof nodeId === "string"),
);
- const displayState = createEmptyDisplayState(selectedNodeId, aggregationEnabled);
- displayState.groupedViewAvailable = computeGraphAnalyticsBase(graph, {
- computeCommunities: true,
- computeCentrality: false,
- }).communitiesByNode.size > 0;
+ const displayState = resolveDisplayStateSnapshot(selectedNodeId, activePath, viewMode, {
+ aggregationEnabled,
+ collapsedNeighborhoodNodeIds,
++ groupedViewAvailable: options?.groupedViewAvailable,
+ });
const isFocusedView = viewMode === "focused" && Boolean(selectedNodeId) && graph.hasNode(selectedNodeId);
const isGroupedView = viewMode === "grouped";
const shouldCollapseNeighborhood = Boolean(selectedNodeId && collapsedNeighborhoodNodeIds.has(selectedNodeId));
diff --cc plugins/.claude-plugin/plugin.json
index 2f21a77d,fa0feddd..fd5d35e7
--- a/plugins/.claude-plugin/plugin.json
+++ b/plugins/.claude-plugin/plugin.json
@@@ -24,7 -24,5 +24,6 @@@
"extraction",
"mcp"
],
- "skills": "./skills"
+ "skills": "./skills",
- "agents": "./agents",
- "hooks": "./hooks/hooks.json"
++ "agents": "./agents"
}