Skip to content

Commit afc649f

Browse files
committed
feat(ui): missed skeleton beside the code galaxy with click-to-focus
Render the miss graph side by side with the code graph instead of swapping layouts: - /api/layout (code graph) now also attaches "missed_graph": {nodes, edges, offset} — the shadow-project layout placed below the primary cluster (same satellite pattern as linked_projects; -Y slot so cross-repo satellites collide last). graph=missed stays the isolated view for API users - the UI paints the skeleton white and ghostly beside the galaxy, auto-frames BOTH clusters on load, and navigates naturally: clicking the skeleton flies the camera into it (file labels + detail panel), clicking a code node flies back to the code side, and clicking empty space while the skeleton has focus returns to the overview (the galaxy can be entirely off-screen at that point) - the sidebar toggle now shows/hides the skeleton (with a missed-file count) rather than swapping the layout Verified in the browser: overview composition, skeleton focus with split.c labeled, and the empty-space return flight; ui/httpd suites and frontend build + tests green. Refs DeusData#963 Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 664313e commit afc649f

5 files changed

Lines changed: 195 additions & 22 deletions

File tree

‎graph-ui/src/components/FilterPanel.tsx‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ interface FilterPanelProps {
2222
onToggleShowOnlyDead: () => void;
2323
onToggleHideEntryPoints: () => void;
2424
onToggleHideTests: () => void;
25-
/* Missed graph (#963): file structure of not-fully-indexed files */
25+
/* Missed skeleton (#963): white satellite of not-fully-indexed files */
2626
missedView: boolean;
27+
missedCount: number;
2728
onToggleMissedView: () => void;
2829
}
2930

@@ -80,6 +81,7 @@ export function FilterPanel({
8081
onToggleHideEntryPoints,
8182
onToggleHideTests,
8283
missedView,
84+
missedCount,
8385
onToggleMissedView,
8486
}: FilterPanelProps) {
8587
const { labelCounts, edgeTypeCounts, statusCounts } = useMemo(() => {
@@ -168,25 +170,30 @@ export function FilterPanel({
168170
</div>
169171
</ScrollArea>
170172

171-
{/* Missed graph (#963): swaps the layout to the file structure of files
172-
the indexer could not fully cover (best-effort signal). */}
173+
{/* Missed skeleton (#963): white satellite cluster of files the indexer
174+
could not fully cover, shown beside the code galaxy. Click it to
175+
focus; click the code galaxy to come back. */}
173176
<div className="px-4 pt-2 border-t border-border/30 space-y-2 shrink-0">
174177
<div className="flex items-center justify-between">
175178
<span className="text-[10px] text-foreground/30 uppercase tracking-widest">
176-
Graph
179+
Missed files
177180
</span>
181+
{missedCount > 0 && (
182+
<span className="text-[10px] text-foreground/50 tabular-nums">
183+
{missedCount.toLocaleString()} files
184+
</span>
185+
)}
178186
</div>
179187
<CheckRow
180188
checked={missedView}
181189
onToggle={onToggleMissedView}
182-
label="Missed files (not fully indexed)"
190+
label="Show missed skeleton"
183191
/>
184-
{missedView && (
185-
<p className="text-[9px] leading-snug text-foreground/30">
186-
Best-effort: files with unparseable regions or skips. Empty = no
187-
known misses (not a completeness guarantee).
188-
</p>
189-
)}
192+
<p className="text-[9px] leading-snug text-foreground/30">
193+
{missedCount > 0
194+
? "White satellite = files not fully indexed (best-effort). Click it to focus, click the galaxy to return."
195+
: "No known misses (best-effort — not a completeness guarantee)."}
196+
</p>
190197
</div>
191198

192199
{/* Dead-code view */}

‎graph-ui/src/components/GraphScene.tsx‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,31 @@ function IdleAutoRotate({
112112

113113
interface GraphSceneProps {
114114
data: GraphData;
115+
/* Missed skeleton (#963): pre-offset, pre-painted white nodes + edges of
116+
* the not-fully-indexed files, rendered as a ghost cluster beside the
117+
* galaxy. null hides it. */
118+
missed?: { nodes: GraphNode[]; edges: GraphData["edges"] } | null;
115119
highlightedIds: Set<number> | null;
116120
cameraTarget: CameraTarget | null;
117121
showLabels: boolean;
118122
display?: DisplaySettings;
119123
onNodeClick: (node: GraphNode) => void;
124+
/* Fired when a click hits empty space (no node). Used to fly back to the
125+
* overview after focusing the missed skeleton. */
126+
onBackgroundClick?: () => void;
120127
}
121128

122129
export type { CameraTarget };
123130

124131
export function GraphScene({
125132
data,
133+
missed = null,
126134
highlightedIds,
127135
cameraTarget,
128136
showLabels,
129137
display = DEFAULT_DISPLAY_SETTINGS,
130138
onNodeClick,
139+
onBackgroundClick,
131140
}: GraphSceneProps) {
132141
const [hovered, setHovered] = useState<GraphNode | null>(null);
133142
const controlsRef = useRef<OrbitControlsImpl | null>(null);
@@ -151,6 +160,7 @@ export function GraphScene({
151160
alpha: false,
152161
powerPreference: "high-performance",
153162
}}
163+
onPointerMissed={onBackgroundClick}
154164
>
155165
<color attach="background" args={["#06090f"]} />
156166
<ambientLight intensity={0.5} />
@@ -176,6 +186,30 @@ export function GraphScene({
176186
/>
177187
{showLabels && <NodeLabels nodes={data.nodes} highlightedIds={highlightedIds} />}
178188

189+
{/* Missed skeleton (#963): white ghost of the not-fully-indexed files.
190+
* Clicks route through the same handler — GraphTab re-centers the
191+
* camera on the whole skeleton cluster. */}
192+
{missed && missed.nodes.length > 0 && (
193+
<group>
194+
<EdgeLines
195+
nodes={missed.nodes}
196+
edges={missed.edges}
197+
highlightedIds={null}
198+
opacity={0.28}
199+
brightness={display.edgeBrightness}
200+
/>
201+
<NodeCloud
202+
nodes={missed.nodes}
203+
highlightedIds={null}
204+
onHover={setHovered}
205+
onClick={onNodeClick}
206+
opacity={0.6}
207+
boost={nodeBoost * 0.75}
208+
/>
209+
{showLabels && <NodeLabels nodes={missed.nodes} highlightedIds={null} />}
210+
</group>
211+
)}
212+
179213
{/* Satellite galaxies for cross-repo linked projects */}
180214
{data.linked_projects?.map((lp: LinkedProject) => {
181215
const offsetNodes = lp.nodes.map((n) => ({

‎graph-ui/src/components/GraphTab.tsx‎

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ export function GraphTab({ project }: GraphTabProps) {
102102
const [enabledLabels, setEnabledLabels] = useState<Set<string>>(new Set());
103103
const [enabledEdgeTypes, setEnabledEdgeTypes] = useState<Set<string>>(new Set());
104104

105-
/* Missed graph (#963): render the file structure of files the indexer
106-
* could not fully cover instead of the code graph. Server-side option
107-
* (`graph=missed` on /api/layout) — toggling refetches. */
108-
const [missedView, setMissedView] = useState(false);
105+
/* Missed skeleton (#963): the file structure of files the indexer could
106+
* not fully cover, shown as a white satellite cluster beside the code
107+
* galaxy. Toggle only hides/shows it — the data rides along with every
108+
* code-graph layout. */
109+
const [showMissedSkeleton, setShowMissedSkeleton] = useState(true);
109110

110111
/* Dead-code view: recolor by status + status-based filters */
111112
const [deadCodeView, setDeadCodeView] = useState(false);
@@ -189,11 +190,53 @@ export function GraphTab({ project }: GraphTabProps) {
189190
/* …and fetch only once budget and project agree (one fetch per change). */
190191
useEffect(() => {
191192
if (project && budget.project === project) {
192-
fetchOverview(project, budget.value, missedView ? "missed" : "code");
193+
fetchOverview(project, budget.value);
193194
setHighlightedIds(null);
194195
setSelectedPath(null);
195196
}
196-
}, [project, budget, missedView, fetchOverview]);
197+
}, [project, budget, fetchOverview]);
198+
199+
/* Missed skeleton: offset into place and paint white — a ghost of the
200+
* files the graph could not fully cover, sitting beside the galaxy. */
201+
const missedSkeleton = useMemo(() => {
202+
const mg = data?.missed_graph;
203+
if (!mg || mg.nodes.length === 0) return null;
204+
const nodes = mg.nodes.map((n) => ({
205+
...n,
206+
x: n.x + mg.offset.x,
207+
y: n.y + mg.offset.y,
208+
z: n.z + mg.offset.z,
209+
color: "#e9eef5",
210+
}));
211+
return { nodes, edges: mg.edges, ids: new Set(nodes.map((n) => n.id)) };
212+
}, [data]);
213+
214+
/* Overview framing: both clusters (galaxy + skeleton) in one shot. */
215+
const overviewTarget = useMemo(() => {
216+
if (!data) return null;
217+
const all = missedSkeleton ? [...data.nodes, ...missedSkeleton.nodes] : data.nodes;
218+
return computeCameraTarget(all, new Set(all.map((n) => n.id)));
219+
}, [data, missedSkeleton]);
220+
221+
/* With a skeleton beside the galaxy, auto-frame BOTH clusters on load so
222+
* the side-by-side composition is visible without manual zooming. */
223+
useEffect(() => {
224+
if (missedSkeleton && overviewTarget) {
225+
setCameraTarget(overviewTarget);
226+
}
227+
}, [missedSkeleton, overviewTarget]);
228+
229+
/* Clicking empty space while the skeleton has focus flies back to the
230+
* overview (the galaxy may be entirely off-screen at that point, so there
231+
* is no code node to click). No-op during normal galaxy exploration. */
232+
const handleBackgroundClick = useCallback(() => {
233+
if (selectedNode && missedSkeleton?.ids.has(selectedNode.id) && overviewTarget) {
234+
setSelectedNode(null);
235+
setHighlightedIds(null);
236+
setSelectedPath(null);
237+
setCameraTarget(overviewTarget);
238+
}
239+
}, [selectedNode, missedSkeleton, overviewTarget]);
197240

198241
/* Fetch git remote metadata for GitHub deep-links */
199242
useEffect(() => {
@@ -231,6 +274,19 @@ export function GraphTab({ project }: GraphTabProps) {
231274
const handleNodeClick = useCallback(
232275
(node: GraphNode) => {
233276
if (!filteredData) return;
277+
278+
/* Clicking the missed skeleton re-centers the camera on that whole
279+
* cluster (it's small — the natural focus unit is the skeleton, not a
280+
* single node); clicking any code node flies back to the code galaxy
281+
* via the normal per-node focus below. */
282+
if (missedSkeleton?.ids.has(node.id)) {
283+
setSelectedNode(node);
284+
setHighlightedIds(null);
285+
setSelectedPath(node.file_path ?? null);
286+
setCameraTarget(computeCameraTarget(missedSkeleton.nodes, missedSkeleton.ids));
287+
return;
288+
}
289+
234290
setSelectedNode(node);
235291

236292
/* Highlight the node and its direct connections */
@@ -243,7 +299,7 @@ export function GraphTab({ project }: GraphTabProps) {
243299
setSelectedPath(node.file_path ?? null);
244300
setCameraTarget(computeCameraTarget(filteredData.nodes, connectedIds));
245301
},
246-
[filteredData],
302+
[filteredData, missedSkeleton],
247303
);
248304

249305
const handleNavigateToNode = useCallback(
@@ -356,8 +412,9 @@ export function GraphTab({ project }: GraphTabProps) {
356412
onToggleShowOnlyDead={() => setShowOnlyDead((v) => !v)}
357413
onToggleHideEntryPoints={() => setHideEntryPoints((v) => !v)}
358414
onToggleHideTests={() => setHideTests((v) => !v)}
359-
missedView={missedView}
360-
onToggleMissedView={() => setMissedView((v) => !v)}
415+
missedView={showMissedSkeleton}
416+
missedCount={data?.missed_graph?.nodes.filter((n) => n.label === "File").length ?? 0}
417+
onToggleMissedView={() => setShowMissedSkeleton((v) => !v)}
361418
/>
362419
<Sidebar
363420
nodes={filteredData.nodes}
@@ -392,11 +449,13 @@ export function GraphTab({ project }: GraphTabProps) {
392449
<ErrorBoundary>
393450
<GraphScene
394451
data={filteredData}
452+
missed={showMissedSkeleton ? missedSkeleton : null}
395453
highlightedIds={highlightedIds}
396454
cameraTarget={cameraTarget}
397455
showLabels={showLabels}
398456
display={display}
399457
onNodeClick={handleNodeClick}
458+
onBackgroundClick={handleBackgroundClick}
400459
/>
401460
</ErrorBoundary>
402461

‎graph-ui/src/lib/types.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,21 @@ export interface LinkedProject {
5050
cross_edges: GraphEdge[];
5151
}
5252

53+
/* Missed-graph skeleton (#963): the file structure of files the indexer
54+
* could not fully cover, laid out as a satellite cluster beside the code
55+
* galaxy (server-computed offset, same shape as LinkedProject's). */
56+
export interface MissedGraph {
57+
nodes: GraphNode[];
58+
edges: GraphEdge[];
59+
offset: { x: number; y: number; z: number };
60+
}
61+
5362
export interface GraphData {
5463
nodes: GraphNode[];
5564
edges: GraphEdge[];
5665
total_nodes: number;
5766
linked_projects?: LinkedProject[];
67+
missed_graph?: MissedGraph;
5868
}
5969

6070
export interface Project {

‎src/ui/http_server.c‎

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,63 @@ static double layout_radius(const cbm_layout_result_t *r) {
13661366
return sqrt(max_r2);
13671367
}
13681368

1369+
/* Attach the missed-graph skeleton (#963) to the primary layout doc as
1370+
* "missed_graph": {"nodes":[...], "edges":[...], "offset":{x,y,z}}
1371+
* — the file structure of files the indexer could not fully cover, laid out
1372+
* as a satellite cluster beside the code galaxy (the UI renders it as a white
1373+
* skeleton; clicking it re-centers the camera there). The offset sits on the
1374+
* -Y side: linked-project satellites spread counter-clockwise from +X, so
1375+
* this slot collides last. Returns true when a non-empty skeleton was
1376+
* attached; no-op when the project has no missed files. */
1377+
static bool attach_missed_graph(yyjson_mut_doc *mdoc, yyjson_mut_val *mroot, cbm_store_t *store,
1378+
const char *project, double primary_radius) {
1379+
char covproj[512];
1380+
cbm_store_coverage_shadow_project(covproj, sizeof(covproj), project);
1381+
cbm_layout_result_t *ml = cbm_layout_compute(store, covproj, CBM_LAYOUT_OVERVIEW, NULL, 0, 0);
1382+
if (!ml) {
1383+
return false;
1384+
}
1385+
if (ml->node_count == 0) {
1386+
cbm_layout_free(ml);
1387+
return false;
1388+
}
1389+
double miss_radius = layout_radius(ml);
1390+
char *mjson = cbm_layout_to_json(ml);
1391+
cbm_layout_free(ml);
1392+
if (!mjson) {
1393+
return false;
1394+
}
1395+
yyjson_doc *mldoc = yyjson_read(mjson, strlen(mjson), 0);
1396+
free(mjson);
1397+
if (!mldoc) {
1398+
return false;
1399+
}
1400+
yyjson_mut_val *entry = yyjson_mut_obj(mdoc);
1401+
yyjson_val *mlroot = yyjson_doc_get_root(mldoc);
1402+
yyjson_val *mn = yyjson_obj_get(mlroot, "nodes");
1403+
yyjson_val *me = yyjson_obj_get(mlroot, "edges");
1404+
if (mn) {
1405+
yyjson_mut_obj_add_val(mdoc, entry, "nodes", yyjson_val_mut_copy(mdoc, mn));
1406+
}
1407+
if (me) {
1408+
yyjson_mut_obj_add_val(mdoc, entry, "edges", yyjson_val_mut_copy(mdoc, me));
1409+
}
1410+
yyjson_doc_free(mldoc);
1411+
1412+
double dist = primary_radius + miss_radius + LAYOUT_GALAXY_PAD;
1413+
if (dist < LAYOUT_GALAXY_SPACING) {
1414+
dist = LAYOUT_GALAXY_SPACING;
1415+
}
1416+
yyjson_mut_val *offset = yyjson_mut_obj(mdoc);
1417+
yyjson_mut_obj_add_real(mdoc, offset, "x", 0.0);
1418+
yyjson_mut_obj_add_real(mdoc, offset, "y", -dist);
1419+
yyjson_mut_obj_add_real(mdoc, offset, "z", 0.0);
1420+
yyjson_mut_obj_add_val(mdoc, entry, "offset", offset);
1421+
1422+
yyjson_mut_obj_add_val(mdoc, mroot, "missed_graph", entry);
1423+
return true;
1424+
}
1425+
13691426
static void handle_layout(cbm_http_conn_t *c, const cbm_http_req_t *req) {
13701427
char project[256] = {0};
13711428
char max_str[32] = {0};
@@ -1440,14 +1497,16 @@ static void handle_layout(cbm_http_conn_t *c, const cbm_http_req_t *req) {
14401497
return;
14411498
}
14421499

1443-
if (linked_count == 0) {
1500+
/* Fast path: no satellites to attach. The missed skeleton only decorates
1501+
* the CODE graph — a graph=missed request already IS the miss graph. */
1502+
if (linked_count == 0 && missed_graph) {
14441503
cbm_store_close(store);
14451504
cbm_http_replyf(c, 200, g_cors_json, "%s", primary_json);
14461505
free(primary_json);
14471506
return;
14481507
}
14491508

1450-
/* Parse primary JSON and append linked_projects array */
1509+
/* Parse primary JSON and append missed_graph + linked_projects */
14511510
yyjson_doc *pdoc = yyjson_read(primary_json, strlen(primary_json), 0);
14521511
free(primary_json);
14531512
if (!pdoc) {
@@ -1460,6 +1519,10 @@ static void handle_layout(cbm_http_conn_t *c, const cbm_http_req_t *req) {
14601519
yyjson_doc_free(pdoc);
14611520
yyjson_mut_val *mroot = yyjson_mut_doc_get_root(mdoc);
14621521

1522+
if (!missed_graph) {
1523+
(void)attach_missed_graph(mdoc, mroot, store, project, primary_radius);
1524+
}
1525+
14631526
yyjson_mut_val *lp_arr = yyjson_mut_arr(mdoc);
14641527

14651528
for (int li = 0; li < linked_count; li++) {

0 commit comments

Comments
 (0)