Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

merge(explorer-visual-refresh): resolve conflict in GraphWorkspace.tsx

KaifAhmad1c86570b9963a
diff --cc explorer/src/workspaces/GraphWorkspace/GraphWorkspace.tsx
index 4e3e7e18,34a2918e..40e4e257
--- a/explorer/src/workspaces/GraphWorkspace/GraphWorkspace.tsx
+++ b/explorer/src/workspaces/GraphWorkspace/GraphWorkspace.tsx
@@@ -2069,140 -1972,24 +2230,193 @@@ export function GraphWorkspace()
canActivateFocusedMode,
displayState.groupedViewAvailable,
displayState.groupedViewReason,
- distanceMode,
- egoModeEnabled,
- egoMaxHops,
+ focusedSelectionResolution.reason,
- handlePluginAction,
hasGraphContent,
- heatmapEnabled,
- isLayoutRunning,
- pluginToolbarItems,
- reload,
requestViewMode,
- focusedSelectionResolution.reason,
- searchQuery,
- selectedNodeId,
- selectedNodeState,
- showLoadingOverlay,
viewMode,
]);
+ const cameraToolbarItems = useMemo<GraphToolbarItem[]>(() => [
+ {
+ id: "zoom-in",
+ label: "Zoom In",
+ title: "Zoom in (or scroll up on the canvas)",
+ ariaLabel: "Zoom in",
+ icon: ZoomIn,
+ compact: true,
+ onClick: () => sceneRef.current?.zoomIn(),
+ },
+ {
+ id: "zoom-out",
+ label: "Zoom Out",
+ title: "Zoom out (or scroll down on the canvas)",
+ ariaLabel: "Zoom out",
+ icon: ZoomOut,
+ compact: true,
+ onClick: () => sceneRef.current?.zoomOut(),
+ },
+ {
+ id: "fit-view",
+ label: "Fit",
+ title: "Reset the camera to fit the whole graph",
+ ariaLabel: "Fit view",
+ icon: Maximize2,
+ compact: true,
+ onClick: () => sceneRef.current?.fitView(),
+ },
+ ], []);
+
+ const layoutToolbarItems = useMemo<GraphToolbarItem[]>(() => [
+ {
+ id: "layout-toggle",
+ label: isLayoutRunning ? "Pause" : "Run",
+ title: "Toggle the layout worker",
+ icon: isLayoutRunning ? Pause : Play,
+ active: isLayoutRunning,
+ disabled: showLoadingOverlay,
+ onClick: () => setIsLayoutRunning((value) => !value),
+ },
+ ], [isLayoutRunning, showLoadingOverlay]);
+
+ const localToolbarItems = useMemo<GraphToolbarItem[]>(() => {
+ if (!selectedNodeState) {
+ return [];
+ }
+
+ return [
+ {
+ id: "collapse-neighborhood",
+ label: "Collapse",
+ title: "Hide lower-priority fanout around the selected node",
+ icon: Eye,
+ disabled: !selectedNodeState.canCollapseNeighborhood || selectedNodeState.isNeighborhoodCollapsed,
+ onClick: () => handlePluginAction({ type: "collapseNeighborhood" }),
+ },
+ {
+ id: "expand-neighborhood",
+ label: "Expand",
+ title: "Restore the collapsed local neighborhood",
+ icon: Users,
+ disabled: !selectedNodeState.isNeighborhoodCollapsed,
+ onClick: () => handlePluginAction({ type: "expandNeighborhood" }),
+ },
+ ];
+ }, [handlePluginAction, selectedNodeState]);
+
+ const analysisToolbarItems = useMemo<GraphToolbarItem[]>(
+ () => pluginToolbarItems.map((item) => ({
+ id: item.id,
+ label: item.label,
+ title: item.title,
+ icon: iconForPluginToolbarItem(item),
+ active: item.active,
+ onClick: item.onClick,
+ })),
+ [pluginToolbarItems],
+ );
+
+ const utilityToolbarItems = useMemo<GraphToolbarItem[]>(() => [
+ {
+ id: "reload",
+ label: "Reload",
+ title: "Reload the graph data",
+ ariaLabel: "Reload graph data",
+ icon: RefreshCw,
+ compact: true,
+ disabled: showLoadingOverlay,
+ onClick: reload,
+ },
+ ], [reload, showLoadingOverlay]);
+
+ const searchDisabled = showLoadingOverlay || !searchQuery.trim();
+
++ const distanceToolbarItems = useMemo<GraphToolbarItem[]>(() => {
++ if (!hasGraphContent || !selectedNodeId) {
++ return [];
++ }
++
++ return [
++ {
++ id: "ego-mode",
++ label: egoModeEnabled ? `Ego (${egoMaxHops}h)` : "Ego Mode",
++ title: egoModeEnabled
++ ? `Egocentric view: ${egoMaxHops} hops depth (click to toggle off)`
++ : "Show depth-of-field fading around the selected node",
++ active: egoModeEnabled,
++ onClick: () => {
++ setEgoModeEnabled((v) => !v);
++ if (heatmapEnabled) setHeatmapEnabled(false);
++ },
++ },
++ {
++ id: "heatmap",
++ label: "Heatmap",
++ title: heatmapEnabled
++ ? "Distance heatmap active (click to toggle off)"
++ : "Color nodes by hop distance from selected node",
++ active: heatmapEnabled,
++ onClick: () => {
++ setHeatmapEnabled((v) => !v);
++ if (egoModeEnabled) setEgoModeEnabled(false);
++ },
++ },
++ {
++ id: "dist-structural",
++ label: "Structural",
++ title: "Color edges by structural (hop) distance",
++ active: distanceMode === "structural",
++ onClick: () => setDistanceMode((m) => (m === "structural" ? "off" : "structural")),
++ },
++ {
++ id: "dist-semantic",
++ label: "Semantic",
++ title: "Color edges by semantic similarity to selected node",
++ active: distanceMode === "semantic",
++ onClick: () => setDistanceMode((m) => (m === "semantic" ? "off" : "semantic")),
++ },
++ ];
++ }, [distanceMode, egoMaxHops, egoModeEnabled, hasGraphContent, heatmapEnabled, selectedNodeId]);
++
+ const toolbarClusters = useMemo<GraphToolbarGroup[]>(() => [
+ {
+ id: "camera",
+ label: "Camera",
+ items: cameraToolbarItems,
+ },
+ {
+ id: "layout",
+ label: "Layout",
+ items: layoutToolbarItems,
+ },
+ {
+ id: "local-structure",
+ label: "Local",
+ items: localToolbarItems,
+ },
++ {
++ id: "distance",
++ label: "Distance",
++ items: distanceToolbarItems,
++ },
+ {
+ id: "analysis",
+ label: "Analysis",
+ items: analysisToolbarItems,
+ },
+ {
+ id: "utility",
+ label: "Utility",
+ items: utilityToolbarItems,
+ },
+ ].filter((group) => group.items.length > 0), [
+ analysisToolbarItems,
+ cameraToolbarItems,
++ distanceToolbarItems,
+ layoutToolbarItems,
+ localToolbarItems,
+ utilityToolbarItems,
+ ]);
+
const sceneAdapterProps = {
onNodeSelect: focusNode,
onEdgeSelect: handleEdgeSelect,
@@@ -2252,28 -2039,69 +2466,44 @@@
) : null}
{focusedSummary ? <MetricChip tone="warm">{focusedSummary}</MetricChip> : null}
</div>
- <div className="explore-toolbar-groups">
- <div style={{ minWidth: 280, flex: "1 1 320px" }}>
- <input
- value={searchQuery}
- onChange={(event) => setSearchQuery(event.target.value)}
- onKeyDown={(event) => {
- if (event.key === "Enter") {
- void handleSearch();
- }
- }}
- placeholder="Search a node, e.g. Metformin"
- style={{ ...inputStyle, margin: 0, minHeight: 38 }}
- />
+ <div className="explore-workflow-bar">
+ <SearchCommandBar
+ value={searchQuery}
+ disabled={searchDisabled}
+ onChange={setSearchQuery}
+ onSubmit={() => void handleSearch()}
+ />
+ <SegmentedModeControl items={viewModeItems} />
+ <div className="explore-toolbelt">
+ {toolbarClusters.map((group) => (
+ <ToolbarCluster
+ key={group.id}
+ label={group.label ?? group.id}
+ items={group.items}
+ compact={COMPACT_TOOLBAR_CLUSTER_IDS.has(group.id)}
+ />
+ ))}
</div>
- {coreToolbarGroups.map((group) => (
- <div key={group.id} className="explore-toolbar-group">
- {group.items.map((item) => {
- const baseStyle = item.tone === "primary" ? actionButtonStyle : secondaryActionButtonStyle;
- return (
- <button
- key={item.id}
- onClick={item.onClick}
- title={item.title}
- disabled={item.disabled}
- style={{
- ...baseStyle,
- minHeight: 36,
- padding: "8px 12px",
- background: item.active
- ? "rgba(31, 111, 235, 0.28)"
- : baseStyle.background,
- border: item.active
- ? "1px solid rgba(127, 208, 255, 0.35)"
- : baseStyle.border,
- color: item.active ? "#e6f2ff" : baseStyle.color,
- boxShadow: item.active ? `0 0 0 1px rgba(127, 208, 255, 0.12)` : baseStyle.boxShadow,
- }}
- >
- {item.label}
- </button>
- );
- })}
- </div>
- ))}
</div>
+ <EntityVisualKey />
</div>
+ {egoModeEnabled && (
+ <div style={{ display: "flex", alignItems: "center", gap: 10, fontSize: 12, color: "#a0b4cc" }}>
+ <span style={{ fontWeight: 600, color: "#79c0ff" }}>Ego depth:</span>
+ <input
+ type="range"
+ min={1}
+ max={8}
+ value={egoMaxHops}
+ onChange={(e) => setEgoMaxHops(Number(e.target.value))}
+ style={{ width: 90, accentColor: "#79c0ff" }}
+ title={`Ego depth: ${egoMaxHops} hops`}
+ />
+ <span style={{ fontFamily: "monospace", color: "#e6f2ff" }}>{egoMaxHops} hop{egoMaxHops !== 1 ? "s" : ""}</span>
+ </div>
+ )}
+
{searchError ? <div style={{ color: "#ff7b72", fontSize: 12 }}>{searchError}</div> : null}
{searchResults.length ? (