Skip to content

feat(tui): interfaces first-class — selectable detail tabs + cable-path visualizer (0.9.0) - #64

Merged
lance0 merged 10 commits into
masterfrom
feat/interface-first-class
Jun 22, 2026
Merged

lance0 merged 10 commits into
masterfrom
feat/interface-first-class

Conversation

@lance0

@lance0 lance0 commented Jun 22, 2026

Copy link
Copy Markdown
Owner

0.9.0 — UX completeness. Makes device interfaces first-class in the TUI, which unlocks both queued UX items. Two commits.

⚠️ Do not merge yet — held for local smoke testing before release.

Slice 1 — interfaces become first-class navigable objects (f9947af)

  • New ObjectKind::Interface, a navigation/detail target only (not added to the global search fan-out — interfaces need a device for context).
  • A device's interfaces (i) and cables (c) tabs are now selectable lists: Enter opens the interface's detail (its attributes + cable-path trace), with a navigable link back to the device. Cable rows open the local interface (where the full trace lives).
  • IfaceRow/CableRow gain a non-serialized id → the nbox device JSON/CSV/MCP contract is unchanged.
  • Services (s) stay plain text — they have no detail view to open; a highlight-but-inert cursor would be worse UX than clean text.
  • Wired through as_str, subtitle_header, object_web_url, and both load_detail paths.

Slice 2 — cable-path visualizer (d568b17)

  • Draws the trace as a vertical A↔Z diagram (each termination on its own line, joined by a ┿ cable segment carrying label · type · length · status — from fields the trace JSON already returns but the flat renderer ignored). Through-panel hops aren't doubled.
  • TUI: a dedicated, scrollable "cable path" tab on the interface detail. CLI: nbox interface renders the diagram under the Cable Path heading.
  • The flat trace lines remain the machine-readable JSON form (the diagram is #[serde(skip)]), so the JSON contract is unchanged.

Verification

  • cargo fmt --all --check ✓
  • cargo clippy --all-targets --all-features -- -D warnings ✓ (pedantic gate)
  • cargo clippy --all-targets --no-default-features -- -D warnings ✓
  • cargo test both feature modes ✓ (789 + integration, 0 failed)
  • JSON goldens (interface.json, device_detail.json) unchanged by design.

Smoke test

target/debug/nbox --config /tmp/nbox-newuser-test/config.toml

Open a device → i/c tabs are now navigable (j/k + Enter) → an interface detail with a "cable path" tab. Also nbox interface <device> <iface> for the CLI diagram.

lance0 added 10 commits June 22, 2026 13:53
Add ObjectKind::Interface as a navigation/detail target (not part of the
global search fan-out — interfaces need a device for context). A device's
interfaces (i) and cables (c) tabs are now selectable lists: Enter opens
the interface's detail (its attributes + cable-path trace), the same
InterfaceView the CLI renders, with a navigable link back to the device.
Cable rows open the local interface (where the full trace lives).

IfaceRow/CableRow gain a non-serialized id (the JSON/CSV/MCP device
contract is unchanged). Services (s) stay plain text — they have no
detail view to open. Wires the new variant through as_str,
subtitle_header, object_web_url, and both load_detail paths.
Draw an interface's cable trace as a vertical A↔Z diagram (each
termination on its own line, joined by a cable segment carrying its
descriptor — label · type · length · status, from fields the trace JSON
already returns). A through-panel hop whose near end repeats the prior
far end isn't doubled.

In the TUI it's a dedicated, scrollable 'cable path' tab on the new
interface detail; the body holds the attributes + VLAN/connection/IP
sections. The CLI 'nbox interface' output renders the diagram under the
Cable Path heading. The flat, machine-readable 'trace' lines remain the
JSON form (diagram is not serialized), so the JSON contract is unchanged.
…its label

NetBox's interface-trace serializer sends the cable with display_url
(not display) and frequently an empty label, so cable_label() found no
name and the diagram showed only the status (e.g. '┿ connected').
Fall back to NetBox's canonical '#<id>' so the cable identity survives
('┿ #4120 · connected'). Verified against a live 4.6 instance.
render_detail only painted the selection cursor + rows for details that
carry a header card (VRF, route-target); every other detail
(device/prefix/vlan/site/rack) fell into the text-only path, so its
navigable tabs — interfaces/cables/IPs/VLANs/children — showed as plain
text with no cursor despite having row targets.

Pin the tab bar (and any header card) in a fixed band whenever the
detail has tabs or a header, and render the active section through one
shared builder (detail_section_lines) so rows get the gutter/highlight
everywhere. detail_content_lines follows suit (the tab bar no longer
counts as scrollable content). Regression test added.
The Cables tab and interface 'Connected To' showed only the remote port
('swp2 -> swp2'), never the remote device. NetBox carries the far device
nested under each connected endpoint, so capture it (BriefObject.device)
and render endpoints as 'device port' — you can now see where a cable
goes ('swp2 → mgmt-core-02a-... swp2').

Redraw the cable-path diagram as a vertical A↔Z chain: the near end on
top (A), the far end on the bottom (Z), the device emphasized over its
port, and each cable segment between. A patch panel in the path (its two
faces share a device) collapses to one pass-through stop (front → rear);
an unterminated side renders explicitly. Tests updated.
…llow-up

Document the 0.9.0 work under [Unreleased] (renamed to [0.9.0] at ship):
interfaces first-class in the TUI, the cable-path visualizer, far-device
cable views, and the header-less-detail row-render fix — calling out the
cable-row format change (→ + far device) per review. Roadmap a future
'interface journal' item (needs by-id resolution + a journal kind entry),
the one review suggestion that's a feature rather than a nit.
The far-device enrichment feeds the serialized connected_to too, not just
the display — correct the earlier 'JSON unchanged' wording to scope it to
shape (the id fields stay non-serialized) and call out the label content
change to nbox interface/device JSON + MCP nbox_get.
The browse rail rendered the full per-kind count right-aligned, so on a
big instance a wide number was clipped to its first digit(s) (e.g.
'● Devices 3' for 30142). Humanize counts — exact below 1000, then k/M
with one decimal under ten (30k, 2.6M) — so the count column always fits.
Truncates rather than rounds (no 9.99k → 10.0k jump).
NAV_WIDTH was a fixed 16 cols, sized for a 2-digit count — even with
humanized counts, 'Prefixes' (8) + bullet + a 302k/2.1M count overflowed,
clipping long-label counts ('Devices 3', 'Prefixes' with none). Widen to
20 (inner 16: gutter + bullet + longest label + gap + a 4-col count).
Per PR #64 review: device names should stay visually stable, so cable
endpoint labels (Cables tab, interface Connected-To, the A↔Z diagram, the
interface detail title) now use the bare device name (BriefObject::name_label /
term_one preferring `name`) instead of NetBox's display, which appends an
asset tag like '(m057545)'. The asset tag still lives in the object's own
detail fields. Cable status in the diagram is title-cased ('connected' →
'Connected'), idempotent for already-cased choice labels. Roadmap a
filtered-only cable browse.
@lance0
lance0 merged commit b6ac273 into master Jun 22, 2026
4 checks passed
@lance0
lance0 deleted the feat/interface-first-class branch June 22, 2026 20:41
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