Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
feat(ui): galaxy orientation triad — halos, view marker, framed camera
Martin Vogelc36a9b81ffb4
diff --git a/graph-ui/src/components/GraphScene.tsx b/graph-ui/src/components/GraphScene.tsxindex 0785c394d..2b89758dc 100644--- a/graph-ui/src/components/GraphScene.tsx+++ b/graph-ui/src/components/GraphScene.tsx@@ -5,6 +5,7 @@ import type { OrbitControls as OrbitControlsImpl } from "three-stdlib";import { EffectComposer, Bloom } from "@react-three/postprocessing";import * as THREE from "three";import { NodeCloud } from "./NodeCloud";+import { HaloLayer } from "./HaloLayer";import { EdgeLines } from "./EdgeLines";import { NodeLabels } from "./NodeLabels";import { NodeTooltip } from "./NodeTooltip";@@ -108,6 +109,34 @@ function IdleAutoRotate({return null;}+/* ── Orbit-target reporter (throttled) ───────────────────── */++function ViewTargetReporter({+ controlsRef,+ onViewTarget,+}: {+ controlsRef: React.RefObject<OrbitControlsImpl | null>;+ onViewTarget: (x: number, y: number) => void;+}) {+ const last = useRef({ x: NaN, y: NaN, at: 0 });+ useFrame(() => {+ const controls = controlsRef.current;+ if (!controls) return;+ const now = performance.now();+ if (now - last.current.at < 200) return;+ const { x, y } = controls.target;+ if (+ Math.abs(x - last.current.x) < 1 &&+ Math.abs(y - last.current.y) < 1 &&+ !Number.isNaN(last.current.x)+ )+ return;+ last.current = { x, y, at: now };+ onViewTarget(x, y);+ });+ return null;+}+/* ── Main scene ─────────────────────────────────────────── */interface GraphSceneProps {@@ -128,6 +157,12 @@ interface GraphSceneProps {onBackgroundClick?: () => void;/* Custom hover card (the region scene shows region facts, not node ones). */renderTooltip?: (node: GraphNode) => React.ReactNode;+ /* Landmark halos on the top hubs (off in the region scene, where every+ * body is already a landmark). */+ landmarks?: boolean;+ /* Reports the orbit target (throttled) so the 2D minimap can show where+ * the camera is looking. */+ onViewTarget?: (x: number, y: number) => void;}export type { CameraTarget };@@ -143,6 +178,8 @@ export function GraphScene({onNodeClick,onBackgroundClick,renderTooltip,+ landmarks = false,+ onViewTarget,}: GraphSceneProps) {const [hovered, setHovered] = useState<GraphNode | null>(null);const controlsRef = useRef<OrbitControlsImpl | null>(null);@@ -152,6 +189,17 @@ export function GraphScene({* NodeCloud applies `nodeBoost` directly (no internal density scaling),* whereas EdgeLines scales by edge density itself — so it receives only the* user edge-brightness multiplier to avoid double-applying. */+ /* Constrained camera: orbit bounds follow the scene's actual extent so+ * you can neither clip through the cloud nor zoom out into the void. */+ const sceneRadius = (() => {+ let max = 100;+ for (const node of data.nodes) {+ const r = Math.sqrt(node.x * node.x + node.y * node.y + node.z * node.z);+ if (r > max) max = r;+ }+ return max;+ })();+const nodeBoost = nodeBoostScale(data.nodes.length) * display.nodeGlow;const bloomIntensity =BASE_BLOOM_INTENSITY * bloomIntensityScale(data.nodes.length) * display.bloom;@@ -192,6 +240,7 @@ export function GraphScene({boost={nodeBoost}/>{showLabels && <NodeLabels nodes={data.nodes} highlightedIds={highlightedIds} />}+ {landmarks && <HaloLayer nodes={data.nodes} />}{/* Missed skeleton (#963): white ghost of the not-fully-indexed files.* Clicks route through the same handler — GraphTab re-centers the@@ -262,6 +311,9 @@ export function GraphScene({(renderTooltip ? renderTooltip(hovered) : <NodeTooltip node={hovered} />)}<CameraAnimator target={cameraTarget} controlsRef={controlsRef} />+ {onViewTarget && (+ <ViewTargetReporter controlsRef={controlsRef} onViewTarget={onViewTarget} />+ )}<IdleAutoRotate controlsRef={controlsRef} /><EffectComposer multisampling={GRAPH_COMPOSER_MULTISAMPLING}>@@ -280,8 +332,8 @@ export function GraphScene({dampingFactor={0.08}rotateSpeed={0.5}zoomSpeed={1.5}- minDistance={10}- maxDistance={50000}+ minDistance={Math.max(5, sceneRadius * 0.02)}+ maxDistance={sceneRadius * 4}autoRotateSpeed={0.4}/></Canvas>diff --git a/graph-ui/src/components/GraphTab.tsx b/graph-ui/src/components/GraphTab.tsxindex a89dac553..2bdde10aa 100644--- a/graph-ui/src/components/GraphTab.tsx+++ b/graph-ui/src/components/GraphTab.tsx@@ -137,6 +137,7 @@ export function GraphTab({const [selectedPath, setSelectedPath] = useState<string | null>(null);const [selectedNode, setSelectedNode] = useState<GraphNode | null>(null);const [cameraTarget, setCameraTarget] = useState<CameraTarget | null>(null);+ const [viewTarget, setViewTarget] = useState<{ x: number; y: number } | null>(null);const [repoInfo, setRepoInfo] = useState<RepoInfo | null>(null);const [showLabels, setShowLabels] = useState(true);const [display, setDisplay] = useState<DisplaySettings>(() =>@@ -337,13 +338,15 @@ export function GraphTab({return computeCameraTarget(all, new Set(all.map((n) => n.id)));}, [data, missedSkeleton]);- /* With a skeleton beside the galaxy, auto-frame BOTH clusters on load so- * the side-by-side composition is visible without manual zooming. */+ /* Auto-frame the scene on load (skeleton or not): the fixed default+ * camera lands inside larger clouds. Deep-linked nodes keep their own+ * focus fly-to instead. */useEffect(() => {- if (missedSkeleton && overviewTarget) {+ if (overviewTarget && !routeNode) {setCameraTarget(overviewTarget);}- }, [missedSkeleton, overviewTarget]);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [overviewTarget]);/* Clicking empty space while the skeleton has focus flies back to the* overview (the galaxy may be entirely off-screen at that point, so there@@ -676,6 +679,7 @@ export function GraphTab({<NodeTooltip node={node} />);}}+ onViewTarget={(x, y) => setViewTarget({ x, y })}/></ErrorBoundary>@@ -683,6 +687,7 @@ export function GraphTab({regions={displayRegions}openRegionId={null}scentCounts={scent?.counts ?? null}+ viewTarget={viewTarget}onOpen={openRegion}onHome={() =>setCameraTarget(@@ -836,7 +841,7 @@ export function GraphTab({<><ErrorBoundary><GraphScene- active={active}+ active={active}data={filteredData}missed={showMissedSkeleton ? missedSkeleton : null}highlightedIds={highlightedIds}@@ -845,6 +850,8 @@ export function GraphTab({display={display}onNodeClick={handleNodeClick}onBackgroundClick={handleBackgroundClick}+ landmarks+ onViewTarget={(x, y) => setViewTarget({ x, y })}/></ErrorBoundary>@@ -852,6 +859,7 @@ export function GraphTab({regions={displayRegions}openRegionId={view.kind === "region" ? view.region.id : null}scentCounts={null}+ viewTarget={viewTarget}onOpen={openRegion}onHome={() =>setCameraTarget(diff --git a/graph-ui/src/components/HaloLayer.tsx b/graph-ui/src/components/HaloLayer.tsxnew file mode 100644index 000000000..c5adc513b--- /dev/null+++ b/graph-ui/src/components/HaloLayer.tsx@@ -0,0 +1,73 @@+import { useMemo } from "react";+import * as THREE from "three";+import type { GraphNode } from "../lib/types";++/* Landmark halos: the top hubs get a soft additive corona so the scene has+ * stable visual anchors while panning — the CodeCity landmark idea. Kept to+ * a handful so the halo stays a landmark, not decoration. */++const HALO_COUNT = 12;++let haloSprite: THREE.CanvasTexture | null = null;+function getHaloSprite(): THREE.CanvasTexture {+ if (haloSprite) return haloSprite;+ const size = 128;+ const canvas = document.createElement("canvas");+ canvas.width = size;+ canvas.height = size;+ const ctx = canvas.getContext("2d")!;+ const gradient = ctx.createRadialGradient(+ size / 2,+ size / 2,+ 0,+ size / 2,+ size / 2,+ size / 2,+ );+ gradient.addColorStop(0, "rgba(255,255,255,0.9)");+ gradient.addColorStop(0.35, "rgba(255,255,255,0.25)");+ gradient.addColorStop(1, "rgba(255,255,255,0)");+ ctx.fillStyle = gradient;+ ctx.fillRect(0, 0, size, size);+ haloSprite = new THREE.CanvasTexture(canvas);+ return haloSprite;+}++export function HaloLayer({ nodes }: { nodes: GraphNode[] }) {+ const { geometry, material } = useMemo(() => {+ const landmarks = [...nodes]+ .sort((a, b) => b.size - a.size)+ .slice(0, Math.min(HALO_COUNT, nodes.length));+ const positions = new Float32Array(landmarks.length * 3);+ const colors = new Float32Array(landmarks.length * 3);+ const temp = new THREE.Color();+ landmarks.forEach((node, index) => {+ positions[index * 3] = node.x;+ positions[index * 3 + 1] = node.y;+ positions[index * 3 + 2] = node.z;+ temp.set(node.color);+ colors[index * 3] = temp.r;+ colors[index * 3 + 1] = temp.g;+ colors[index * 3 + 2] = temp.b;+ });+ const geometry = new THREE.BufferGeometry();+ geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));+ geometry.setAttribute("color", new THREE.BufferAttribute(colors, 3));+ const sizes = landmarks.map((node) => node.size);+ const haloSize = Math.max(...sizes, 1) * 6;+ const material = new THREE.PointsMaterial({+ size: haloSize,+ map: getHaloSprite(),+ vertexColors: true,+ transparent: true,+ opacity: 0.28,+ depthWrite: false,+ blending: THREE.AdditiveBlending,+ sizeAttenuation: true,+ });+ return { geometry, material };+ }, [nodes]);++ if (nodes.length === 0) return null;+ return <points geometry={geometry} material={material} />;+}diff --git a/graph-ui/src/components/Minimap.tsx b/graph-ui/src/components/Minimap.tsxindex 9e5b87f9b..94f4e6807 100644--- a/graph-ui/src/components/Minimap.tsx+++ b/graph-ui/src/components/Minimap.tsx@@ -14,6 +14,33 @@ export interface MinimapDot {name: string;}+/* Project one world-space point with the same bounds the dots use. */+export function minimapProject(+ regions: Region[],+ width: number,+ height: number,+ point: { x: number; y: number },+ pad = 12,+): { cx: number; cy: number } | null {+ if (regions.length === 0) return null;+ let minX = Infinity,+ maxX = -Infinity,+ minY = Infinity,+ maxY = -Infinity;+ for (const region of regions) {+ minX = Math.min(minX, region.x);+ maxX = Math.max(maxX, region.x);+ minY = Math.min(minY, region.y);+ maxY = Math.max(maxY, region.y);+ }+ const spanX = maxX - minX || 1;+ const spanY = maxY - minY || 1;+ const cx = pad + ((point.x - minX) / spanX) * (width - pad * 2);+ const cy = pad + ((point.y - minY) / spanY) * (height - pad * 2);+ if (cx < -pad || cx > width + pad || cy < -pad || cy > height + pad) return null;+ return { cx, cy };+}+export function minimapLayout(regions: Region[],width: number,@@ -51,12 +78,15 @@ export function Minimap({regions,openRegionId,scentCounts,+ viewTarget,onOpen,onHome,}: {regions: Region[];openRegionId: number | null;scentCounts: Map<number, number> | null;+ /* Where the camera is looking (world x/y) — drawn as a ring. */+ viewTarget?: { x: number; y: number } | null;onOpen: (region: Region) => void;onHome: () => void;}) {@@ -68,6 +98,10 @@ export function Minimap({}});const dots = useMemo(() => minimapLayout(regions, W, H), [regions]);+ const marker = useMemo(+ () => (viewTarget ? minimapProject(regions, W, H, viewTarget) : null),+ [regions, viewTarget],+ );const byId = useMemo(() => new Map(regions.map((r) => [r.id, r])), [regions]);const toggle = () => {@@ -83,7 +117,7 @@ export function Minimap({if (regions.length === 0) return null;return (- <div className="absolute bottom-4 right-4 bg-card/85 backdrop-blur border border-border/50 rounded-md shadow-lg overflow-hidden">+ <div className="absolute bottom-16 right-4 bg-card/85 backdrop-blur border border-border/50 rounded-md shadow-lg overflow-hidden"><div className="flex items-center gap-1 px-2 py-1 border-b border-border/30"><span className="text-[12px] uppercase tracking-widest text-foreground/40">map@@ -105,6 +139,17 @@ export function Minimap({</div>{!collapsed && (<svg width={W} height={H} role="img" aria-label="Region minimap">+ {marker && (+ <circle+ cx={marker.cx}+ cy={marker.cy}+ r={7}+ fill="none"+ stroke="#4FA8E0"+ strokeWidth={1.5}+ strokeOpacity={0.8}+ />+ )}{dots.map((dot) => {const isOpen = dot.id === openRegionId;const hits = scentCounts?.get(dot.id) ?? 0;diff --git a/graph-ui/src/lib/regions.test.ts b/graph-ui/src/lib/regions.test.tsindex b4233b507..94da6b22e 100644--- a/graph-ui/src/lib/regions.test.ts+++ b/graph-ui/src/lib/regions.test.ts@@ -6,7 +6,7 @@ import {REGIONS_MIN_TOTAL_NODES,cohesionWord,} from "./regions";-import { minimapLayout } from "../components/Minimap";+import { minimapLayout, minimapProject } from "../components/Minimap";import type { Region, RegionsPayload } from "./types";function region(partial: Partial<Region> & { id: number; name: string }): Region {@@ -111,3 +111,27 @@ describe("minimapLayout", () => {expect(Number.isFinite(dots[0].cx)).toBe(true);});});++describe("minimapProject", () => {+ const region = (id: number, x: number, y: number): Region => ({+ id,+ name: `r${id}`,+ files: 1,+ members: 10,+ cohesion: 0.5,+ top_nodes: [],+ x,+ y,+ z: 0,+ size: 10,+ color: "#123456",+ });+ const regions = [region(0, -100, 0), region(1, 100, 50)];+ it("maps a world point with the same bounds as the dots", () => {+ const point = minimapProject(regions, 200, 150, { x: -100, y: 0 });+ expect(point).toEqual({ cx: 12, cy: 12 });+ });+ it("returns null for points far outside the map", () => {+ expect(minimapProject(regions, 200, 150, { x: 100000, y: 0 })).toBeNull();+ });+});