Skip to content

UI Fix: Topology View Centering & Edge Label Overlap#110

Open
antoncxx wants to merge 3 commits into
NullNet-ai:mainfrom
antoncxx:ui-fix
Open

UI Fix: Topology View Centering & Edge Label Overlap#110
antoncxx wants to merge 3 commits into
NullNet-ai:mainfrom
antoncxx:ui-fix

Conversation

@antoncxx

Copy link
Copy Markdown
Contributor

Summary

This PR fixes two visual issues in the topology graph view — one affecting the initial layout and dynamic graph updates, the other affecting focused-client edge annotations.


Changes

1. Center topology graph within ZoomFrame (ZoomFrame.tsx)

Problem: The topology SVG was anchored to the top-left corner of the ZoomFrame container. Depending on the graph aspect ratio, this left significant empty space at the bottom and made the graph look misaligned.

Fix:

  • Added a useLayoutEffect that measures the container height vs. the rendered SVG height before first paint and computes a centered ty offset. Using useLayoutEffect (vs. useEffect) prevents a visible flash on load.
  • Added a ResizeObserver on the content div that re-fits the view whenever the SVG dimensions change — for example when a new session is created and internet/proxy nodes appear. Without this, the expanded graph was clipped at the old position.
  • resetZoom now returns to the computed centered home position instead of the raw {tx:0, ty:0} origin.
  • Both the dedicated Topology page (height 520) and the Dashboard mini-view (height 280) go through the same ZoomFrame, so both are fixed.

2. Fix overlapping edge labels on focused-client edges (layout.ts, TopologyGraphSvg.tsx)

Problem: When a connected client is selected, each focused edge renders three annotation boxes: a src IP label, a VNI info box, and a dst IP label. These boxes overlapped in two ways:

  • Vertical edges (proxy → service, V_GAP = 70px): the combined label height at the old sizes was 76px — guaranteed to overflow the 70px gap between nodes, causing all three boxes to pile on top of each other.
  • Horizontal edges: all three labels were placed at midY ± 16px, directly inside the VNI box's midY ± 24px range. On short edges (H_GAP = 60px) they also overlapped horizontally.

Additionally, textAnchor on the src/dst labels was sometimes start or end while the background rect was always centered on lp.src.x, misaligning the text within its own box.

Fix:

  • Vertical edges: Shrunk the VNI box from 134×48px to 120×32px with tighter line spacing (9px vs 13px). Adjusted src/dst anchor offsets so all three labels fit within the 70px gap with ~7–9px clearance between each box.
  • Horizontal edges: Redesigned label stacking — src is placed 30px above the VNI center, dst is placed 32px below it. Labels no longer share the same vertical band regardless of horizontal gap width.
  • Normalized all src/dst rects to use textAnchor="middle" consistently, matching the centered rect positioning.

antoncxx added 3 commits June 22, 2026 22:01
Use useLayoutEffect to measure container vs content height before first
paint and set an initial ty offset that vertically centers the SVG.
Also updates resetZoom to return to the centered home position rather
than the raw top-left origin.
useLayoutEffect only ran once on mount, so adding new nodes (internet,
proxy) after a session was created left the view clipped at the old
offset. Add a ResizeObserver on the content div that recomputes the
centered home position whenever the SVG height changes. prevContentH
is seeded in the layout effect so the observer skips its initial fire
and only triggers on real graph changes.
Three labels (src IP, VNI box, dst IP) were all positioned at similar
y-coordinates, causing them to stack on top of each other.

For vertical edges (proxy→service, V_GAP=70px): the combined label
height was 76px, guaranteed to overflow. Shrank VNI box from 48→32px
and tightened src/dst anchor offsets so all three fit cleanly with ~7px
gaps between them.

For horizontal edges: all three labels shared the same midY±16 band.
Redesigned to stack vertically — src above the VNI box, dst below —
so they never collide regardless of horizontal gap width.

Also normalized all src/dst label rects to use textAnchor=middle
(rect was already centered but anchor was sometimes start/end,
misaligning text inside the background box).
@antoncxx antoncxx marked this pull request as ready for review June 23, 2026 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant