Skip to content

Commit 996622c

Browse files
committed
Prevent graph rearranging on node or
1 parent f3427c1 commit 996622c

2 files changed

Lines changed: 18 additions & 15 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Core loop:
2727
- Agent tooling to inspect errors, traverse graph context, read source, and output correction prompts (`python/agents/*`)
2828
- Live, non-blocking agent run indicators in the desktop UI (phase updates + progress bars while fix suggestions are generated, then auto-hidden when the run ends)
2929
- Three-column desktop workspace layout: errors (left), graph (center, primary), and a suggestion panel (right) that appears only after an agent workflow run starts
30+
- Graph force-layout simulation is intentionally reheated only on initial analyze and `Reset view`; selecting nodes or left-panel errors preserves the current arrangement
3031
- Error list cards emphasize severity, message, and entity label; internal rule codes are hidden from the left-panel card headers
3132
- Suggestion lifecycle management across agent runs with a single active suggestion panel: close hides the panel, and per-error `Open Suggestion` actions re-open the latest generated suggestion without re-running the agent
3233
- Settings page with a persisted dark mode toggle for the desktop UI

src/frontend/components/GraphView.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,6 @@ function GraphView({ graph, focusRequest, selectedNodeId, onNodeClick }: GraphVi
141141

142142
const graphData = useMemo(() => {
143143
const allNodesById = new Map(graph.nodes.map((node) => [node.id, node]));
144-
const keepNodeIds = new Set<string>();
145-
146-
if (selectedNodeId) {
147-
keepNodeIds.add(selectedNodeId);
148-
}
149-
if (focusRequest?.nodeId) {
150-
keepNodeIds.add(focusRequest.nodeId);
151-
}
152144

153145
const typeVisibleNodeIds = new Set(
154146
graph.nodes
@@ -203,7 +195,7 @@ function GraphView({ graph, focusRequest, selectedNodeId, onNodeClick }: GraphVi
203195
const shouldKeepForIsolation = !hideIsolatedNodes || degree > 0 || node.type === "Error";
204196
const shouldKeepForDegree = degree >= minVisibleDegree || node.type === "Error";
205197

206-
if (keepNodeIds.has(nodeId) || (shouldKeepForIsolation && shouldKeepForDegree)) {
198+
if (shouldKeepForIsolation && shouldKeepForDegree) {
207199
visibleNodeIds.add(nodeId);
208200
}
209201
}
@@ -233,11 +225,9 @@ function GraphView({ graph, focusRequest, selectedNodeId, onNodeClick }: GraphVi
233225

234226
return { nodes, links };
235227
}, [
236-
focusRequest?.nodeId,
237228
graph,
238229
hideIsolatedNodes,
239230
minVisibleDegree,
240-
selectedNodeId,
241231
showIssueNeighborhoodOnly,
242232
visibleNodeTypes
243233
]);
@@ -277,7 +267,7 @@ function GraphView({ graph, focusRequest, selectedNodeId, onNodeClick }: GraphVi
277267
[hoveredNodeId, importantNodeIds, labelDensityMode, selectedNodeId, zoomLevel]
278268
);
279269

280-
useEffect(() => {
270+
const configureGraphForces = useCallback(() => {
281271
const graphApi = graphRef.current;
282272
if (!graphApi) {
283273
return;
@@ -296,10 +286,17 @@ function GraphView({ graph, focusRequest, selectedNodeId, onNodeClick }: GraphVi
296286
chargeForce.distanceMax(GRAPH_CHARGE_DISTANCE_MAX);
297287
}
298288
}
289+
}, []);
299290

291+
useEffect(() => {
292+
const graphApi = graphRef.current;
293+
if (!graphApi) {
294+
return;
295+
}
296+
configureGraphForces();
300297
graphApi.d3ReheatSimulation();
301298
shouldAutoFitRef.current = true;
302-
}, [graphData]);
299+
}, [configureGraphForces, graph]);
303300

304301
useEffect(() => {
305302
if (!focusRequest) {
@@ -412,8 +409,13 @@ function GraphView({ graph, focusRequest, selectedNodeId, onNodeClick }: GraphVi
412409
type="button"
413410
className="reset-view-button"
414411
onClick={() => {
415-
shouldAutoFitRef.current = false;
416-
graphRef.current?.zoomToFit(420, 80);
412+
const graphApi = graphRef.current;
413+
if (!graphApi) {
414+
return;
415+
}
416+
configureGraphForces();
417+
shouldAutoFitRef.current = true;
418+
graphApi.d3ReheatSimulation();
417419
}}
418420
>
419421
Reset view

0 commit comments

Comments
 (0)