Skip to content

Commit f24e689

Browse files
Harden 3D graph cleanup and stop forcing a Django family chip.
Keep the WebGL canvas on its own mount so hover tooltips do not reconcile against the renderer DOM, dispose layer geometries and the GL context on unmount, and only show family chips for stacks that are actually present. Rebuild the bundled UI so the static assets match. Co-authored-by: zord.lack.net <zord.lack.net@gmail.com>
1 parent bcbc085 commit f24e689

9 files changed

Lines changed: 4205 additions & 75 deletions

File tree

‎src/loadpath/static/assets/LayeredGraph3D-D12B4Z17.js‎

Lines changed: 4116 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/loadpath/static/assets/index-Bh26i1BD.css‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/loadpath/static/assets/index-COu_6ith.js‎

Lines changed: 0 additions & 62 deletions
This file was deleted.

‎src/loadpath/static/assets/index-DNN4KyeU.css‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎src/loadpath/static/assets/index-DVQVwbDy.js‎

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/loadpath/static/index.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
<link rel="preconnect" href="https://fonts.googleapis.com" />
1818
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1919
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap" rel="stylesheet" />
20-
<script type="module" crossorigin src="./assets/index-COu_6ith.js"></script>
21-
<link rel="stylesheet" crossorigin href="./assets/index-DNN4KyeU.css">
20+
<script type="module" crossorigin src="./assets/index-DVQVwbDy.js"></script>
21+
<link rel="stylesheet" crossorigin href="./assets/index-Bh26i1BD.css">
2222
</head>
2323
<body>
2424
<div id="root"></div>

‎ui/src/ImpactGraph.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export function ImpactGraph({ nodes, edges }: { nodes: GraphNode[]; edges: Graph
221221
</div>
222222
<div className="seg" aria-label="Graph families">
223223
{(["django", "stitch", "react"] as const)
224-
.filter((family) => presentFamilies.has(family) || family === "django")
224+
.filter((family) => presentFamilies.has(family))
225225
.map((family) => (
226226
<button
227227
key={family}

‎ui/src/LayeredGraph3D.tsx‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function makeLayerLabel(text: string, color: string): THREE.Sprite {
4747
}
4848

4949
export function LayeredGraph3D({ nodes, edges, selectedId, neighborIds, onSelect }: Props) {
50+
const wrapRef = useRef<HTMLDivElement>(null);
5051
const hostRef = useRef<HTMLDivElement>(null);
5152
const [hover, setHover] = useState<{ node: GraphNode; x: number; y: number } | null>(null);
5253
const [webglError, setWebglError] = useState<string | null>(null);
@@ -75,6 +76,11 @@ export function LayeredGraph3D({ nodes, edges, selectedId, neighborIds, onSelect
7576
setWebglError("WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map.");
7677
return;
7778
}
79+
if (!renderer.getContext()) {
80+
renderer.dispose();
81+
setWebglError("WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map.");
82+
return;
83+
}
7884
setWebglError(null);
7985
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
8086
renderer.domElement.dataset.testid = "graph-3d-canvas";
@@ -145,8 +151,11 @@ export function LayeredGraph3D({ nodes, edges, selectedId, neighborIds, onSelect
145151
});
146152
const labelColor = cssColor("--muted", "#8b9bb0");
147153
const labels: THREE.Sprite[] = [];
154+
const discGeoms: THREE.BufferGeometry[] = [];
148155
for (const layer of layerCenters(nodes)) {
149-
const disc = new THREE.Mesh(new THREE.CircleGeometry(discRadius(layer.count), 48), planeMat);
156+
const discGeom = new THREE.CircleGeometry(discRadius(layer.count), 48);
157+
discGeoms.push(discGeom);
158+
const disc = new THREE.Mesh(discGeom, planeMat);
150159
disc.rotation.y = Math.PI / 2;
151160
disc.position.x = layer.x;
152161
group.add(disc);
@@ -207,7 +216,7 @@ export function LayeredGraph3D({ nodes, edges, selectedId, neighborIds, onSelect
207216
return;
208217
}
209218
renderer.domElement.style.cursor = "pointer";
210-
const rect = host.getBoundingClientRect();
219+
const rect = (wrapRef.current ?? host).getBoundingClientRect();
211220
setHover({ node, x: event.clientX - rect.left, y: event.clientY - rect.top });
212221
};
213222
const onClick = (event: MouseEvent) => {
@@ -250,6 +259,7 @@ export function LayeredGraph3D({ nodes, edges, selectedId, neighborIds, onSelect
250259
sphere.dispose();
251260
edgeGeom.dispose();
252261
planeMat.dispose();
262+
for (const geom of discGeoms) geom.dispose();
253263
(lines.material as THREE.Material).dispose();
254264
for (const label of labels) {
255265
const material = label.material as THREE.SpriteMaterial;
@@ -259,6 +269,11 @@ export function LayeredGraph3D({ nodes, edges, selectedId, neighborIds, onSelect
259269
for (const mesh of meshById.values()) {
260270
(mesh.material as THREE.Material).dispose();
261271
}
272+
try {
273+
renderer.forceContextLoss();
274+
} catch {
275+
/* already lost */
276+
}
262277
renderer.dispose();
263278
renderer.domElement.remove();
264279
setHover(null);
@@ -270,7 +285,8 @@ export function LayeredGraph3D({ nodes, edges, selectedId, neighborIds, onSelect
270285
}, [selectedId, neighborIds]);
271286

272287
return (
273-
<div className="graph-3d-host" ref={hostRef}>
288+
<div className="graph-3d-host" ref={wrapRef}>
289+
<div className="graph-3d-canvas-host" ref={hostRef} />
274290
{webglError ? (
275291
<p className="muted graph-3d-hint" data-testid="graph-3d-fallback">
276292
{webglError}

‎ui/src/styles.css‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ kbd {
647647
}
648648
.graph-stage .react-flow,
649649
.graph-3d,
650-
.graph-3d-host {
650+
.graph-3d-host,
651+
.graph-3d-canvas-host {
651652
flex: 1;
652653
width: 100%;
653654
height: 100%;
@@ -659,7 +660,8 @@ kbd {
659660
display: flex;
660661
flex-direction: column;
661662
}
662-
.graph-3d-host { position: relative; min-height: 0; }
663+
.graph-3d-host { position: relative; min-height: 0; display: flex; flex-direction: column; }
664+
.graph-3d-canvas-host { position: relative; min-height: 0; }
663665
.graph-3d canvas { display: block; width: 100%; height: 100%; }
664666
.graph-3d-tip {
665667
position: absolute;

0 commit comments

Comments
 (0)