MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / SemanticMap

Function SemanticMap

dashboard/holographic/src/SemanticMap.tsx:86–822  ·  view source on GitHub ↗
({
  query,
  focus,
}: {
  query?: string;
  focus?: SemanticMapFocus | null;
})

Source from the content-addressed store, hash-verified

84}
85
86export default function SemanticMap({
87 query,
88 focus,
89}: {
90 query?: string;
91 focus?: SemanticMapFocus | null;
92}) {
93 const [data, setData] = useState<MemoryProjectionResponse | null>(null);
94 const [loading, setLoading] = useState(true);
95 const [error, setError] = useState("");
96 const [selected, setSelected] = useState<MemoryProjectionPoint | null>(null);
97 const [colorBy, setColorBy] = useState<"category" | "bank">("category");
98 const [sizeBy, setSizeBy] = useState<"retrievals" | "connections">("retrievals");
99 const [hiddenCats, setHiddenCats] = useState<ReadonlySet<string>>(new Set());
100 const [selection, setSelection] = useState<ReadonlySet<number> | null>(null);
101 const [transform, setTransform] = useState<MapTransform>(IDENTITY);
102 const [mode, setMode] = useState<"pan" | "select">("pan");
103 const [densityOverride, setDensityOverride] = useState<boolean | null>(null);
104 const [tip, setTip] = useState<TooltipState | null>(null);
105 const [hovered, setHovered] = useState<PlacedPoint | null>(null);
106 const [drag, setDragState] = useState<DragState | null>(null);
107 // Mirror drag state in a ref: pointerdown/up can land in the same task
108 // (fast clicks, synthetic events) before React commits the state update.
109 const dragRef = useRef<DragState | null>(null);
110 const setDrag = useCallback((next: DragState | null) => {
111 dragRef.current = next;
112 setDragState(next);
113 }, []);
114
115 const svgRef = useRef<SVGSVGElement>(null);
116 const zoomGroupRef = useRef<SVGGElement>(null);
117 const transformRef = useRef(transform);
118 const commitTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
119 const rafRef = useRef(0);
120
121 /**
122 * Gesture transforms are applied imperatively (one style write on the zoom
123 * group) and committed to React state only when the gesture settles. At a
124 * few thousand points, a per-tick state commit plus the `--hv-k` CSS-var
125 * invalidation (which recalcs every circle's calc() radius) produced
126 * multi-hundred-ms tasks; deferring both keeps wheel/drag at frame rate.
127 */
128 const applyTransform = useCallback((next: MapTransform, settle = false) => {
129 transformRef.current = next;
130 const g = zoomGroupRef.current;
131 if (g) {
132 g.style.transform = `translate(${next.tx}px, ${next.ty}px) scale(${next.k})`;
133 if (settle) g.style.setProperty("--hv-k", String(next.k));
134 }
135 if (commitTimerRef.current) clearTimeout(commitTimerRef.current);
136 if (settle) {
137 setTransform(next);
138 } else {
139 commitTimerRef.current = setTimeout(() => {
140 const g2 = zoomGroupRef.current;
141 if (g2) g2.style.setProperty("--hv-k", String(transformRef.current.k));
142 setTransform(transformRef.current);
143 }, 90);

Callers

nothing calls this directly

Calls 15

useMeasuredWidthFunction · 0.90
categoryColorMapFunction · 0.90
scaleLinearFunction · 0.90
padDomainFunction · 0.90
extentFunction · 0.90
buildGridFunction · 0.90
buildDensityFunction · 0.90
screenToBaseCoordsFunction · 0.90
zoomTransformAtFunction · 0.90
fitTransformToPlacedFunction · 0.90
findNearestFunction · 0.90
truncateFunction · 0.90

Tested by

no test coverage detected