Skip to content

Modernize mgr: ManagerController, unified console footer, link dialog validation - #41

Merged
gh0st42 merged 10 commits into
mainfrom
feat/modernize-mgr
Oct 9, 2026
Merged

gh0st42 merged 10 commits into
mainfrom
feat/modernize-mgr

Conversation

@axodentally

Copy link
Copy Markdown
Collaborator

AI generated summary:

Summary

Modernizes the mgr web UI, unifies the shared webui code between mgr and
netviz, and cleans up shutdown behavior.

Changes

Unified console footer (tools/webui/console.py, new)

  • Shared ConsoleFooter used by both mgr and netviz: per-container terminals
    (xterm.js) and log viewers dockable at the bottom, with split view and
    alphabetical, deterministic container ordering in both apps.
  • Removes the mgr overview tab (superseded by the footer).

mgr refactor

  • helpers.py: drop run_in_container / set_on_interface duplicates in favor
    of tools.contact_player.tc_netem.run_in_container; remove unused helpers;
    parse tc qdisc output in-process instead of shelling out to grep.
  • mgr.py: move module-level globals (network graph, link memory, time socket,
    modal-dialog flag, timers) into a ManagerController class; parse tc output
    into a typed Link dict (bandwidth, loss, delay, jitter with units) shared by
    the link dialog; convert delay/jitter s→ms on apply; guard draw_links with
    an asyncio lock; argparse CLI; restore shared graph state on startup before
    ui.run.
  • Link dialog: validators for bandwidth (tc rate syntax), loss (0–100), and
    delay/jitter (non-negative) with inline highlighting; block Apply with a
    negative toast on invalid input; surface tc/docker failures as notifications
    instead of server-log-only.

Remove run_in_container and set_on_interface, which duplicated the
contact_player implementations, and import run_in_container from
tools.contact_player.tc_netem instead.

Remove unused expand_human_bitrates, get_netem_from_if and
get_container_interfaces_parallel helpers.

Parse tc qdisc output in-process instead of shelling out to grep,
replace quit() with RuntimeError on host command failure, and add
type annotations.
Move the module-level globals (network graph, link memory, time
socket, modal dialog flag, timers) into a ManagerController class
whose methods own the state and UI callbacks.

Parse tc qdisc output into a typed Link dict (bandwidth, loss, delay,
jitter with units) that is reused by the link dialog, and convert
delay/jitter from s to ms before applying them.

Guard draw_links with an asyncio lock instead of a boolean flag, use
argparse for the CLI, and restore the shared graph state on startup
before ui.run so all clients start from the same topology.
Container names came from docker compose (mgr) or viz.json (netviz)
in arbitrary order, so the footer tab order differed between the two
apps. Sort them in ConsoleFooter so both apps show the same
deterministic order.
Add validators for bandwidth (tc rate syntax), loss (0-100) and
delay/jitter (non-negative numbers) that highlight invalid fields in
the link dialog while typing. Block Apply with a negative toast until
all fields are valid.

Wrap the set_on_interface calls of the link dialog and the link
toggles so tc/docker failures are reported via notification instead
of only ending up in the server log.
Guard dialog.clear() in show_link_dialog with is_deleted so cancelling
the handler during shutdown no longer triggers the "element has been
deleted" warning with its full stack trace.

Catch KeyboardInterrupt around ui.run in mgr and netviz and print a
short "Stopped." message so the CancelledError/KeyboardInterrupt chain
no longer escapes main() uncaught.
@axodentally

Copy link
Copy Markdown
Collaborator Author

This change is part of the following stack:

Change managed by git-spice.

Comment thread tools/webui/console.py Fixed
Comment thread tools/webui/console.py Fixed
Comment thread tools/webui/console.py Fixed
Comment thread tools/webui/console.py Fixed
Comment thread tools/webui/console.py Fixed
Replace the five try/except-pass blocks in attach_container_to_xterm
with contextlib.suppress: writing keystrokes or a resize ioctl to an
already-closed pty drops the event, and the cleanup close/kill/waitpid
tolerate an already-closed, already-exited, or already-reaped child.
contextlib.suppress makes this deliberate intent explicit and satisfies
the code quality bot's empty-except-clause report.
@axodentally

Copy link
Copy Markdown
Collaborator Author
image

this PR refines the footer, adding logs next to the terminals and the possibility for resizable split view, instead of only one window in the footer. And the footer is now a re-usable component that got added to the mgr and not only the netviz visualiser

@gh0st42

gh0st42 commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

# Conflicts:
#	tools/mgr/mgr.py
#	tools/netviz/netviz.py

Co-authored-by: gh0st42 <1264131+gh0st42@users.noreply.github.com>

Copilot AI commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Conflicts are resolved by merging main into this branch and resolving tools/mgr/mgr.py and tools/netviz/netviz.py in commit c7fa847.

Copilot AI requested a review from gh0st42 October 9, 2026 13:19
@gh0st42
gh0st42 merged commit 0075899 into main Oct 9, 2026
4 checks passed
@gh0st42
gh0st42 deleted the feat/modernize-mgr branch October 9, 2026 13:32
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.

3 participants