The VIP editor put routing and traffic observations in a dense text block, while nested layouts in the devices grid could let text escape its row. Separate the VIP overview from configuration and draw both live tables with explicit cell bounds, font-aware row heights, clipping and horizontal overflow. Measure columns before painting and keep widths stable as live values change. The overview reuses the existing traffic sparklines for service totals and individual listener backends, with TX/RX rates, health, RTT, open flows and counters. Retain bounded histories by service/listener/backend identity and release them when their resources disappear. Recreated listeners start fresh. Use egui 0.31 Scene and Painter for a pannable, zoomable routing diagram with Fit, clickable backend details and linked table selection. Highlight recent counter growth separately from the backend selected for new connections; idle bindings alone do not imply traffic, and stale activity expires. Draw legend markers directly rather than depending on optional font glyphs. The overview only reads saved observations; edits and deletion still require Save. No dependencies, wire formats, IPC or persistent schemas change. Validation on Linux through nix develop: - cargo fmt --all -- --check - cargo clippy --locked --workspace --all-targets -- -D warnings - cargo test --locked --workspace --all-targets: 566 passed, 3 ignored - cargo build --locked -p tsunagi-tray The inherited TSUNAGI_CONTROL_SOCKET was unset for Clippy and tests. Seven new GUI tests cover enlarged fonts, mixed online/offline rows, long names, large counters, narrow/wide layouts, scene clicks, traffic selection, stale samples, counter resets, listener recreation and history cleanup. The first enlarged-font regression exposed an override-font height mismatch; row sizing now resolves the actual selected font and the regression passes. A disposable fixture preview rendered successfully with software OpenGL on an isolated Xvfb display. Initial Xvfb attempts needed explicit xkbcommon and OpenGL runtime paths in the Nix environment. The preview never contacted an agent; its temporary source was removed. macOS, Windows, Wayland and live host TUN traffic were not exercised by this UI change.
82 lines
2.4 KiB
Rust
82 lines
2.4 KiB
Rust
//! Tray application for managing a running tsunagi agent.
|
|
//!
|
|
//! A tray icon and menu (Open, Quit) that opens a small window (networks, their
|
|
//! peers and addresses, join/leave, per-network active and broadcast switches).
|
|
//! There is no window until Open, and closing it leaves the icon. The window
|
|
//! is a thin client over the agent's local control socket — the same interface
|
|
//! the CLI uses.
|
|
|
|
// Nothing here is a library.
|
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
|
|
|
mod about;
|
|
mod agent;
|
|
mod app;
|
|
mod devices;
|
|
mod exit;
|
|
mod format;
|
|
mod icon;
|
|
mod stats;
|
|
mod table;
|
|
mod tray;
|
|
mod ui;
|
|
mod vip;
|
|
mod vip_status;
|
|
mod watch;
|
|
|
|
use eframe::egui;
|
|
|
|
use crate::app::App;
|
|
|
|
/// The argument that makes this binary the window rather than the tray.
|
|
const WINDOW_ARG: &str = "--window";
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
let filter = tracing_subscriber::EnvFilter::try_from_default_env()
|
|
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("warn"));
|
|
let _ = tracing_subscriber::fmt().with_env_filter(filter).try_init();
|
|
|
|
// Two processes from one binary. The tray is what stays; the window is
|
|
// started by it and ends when it is closed. A window that merely hides is
|
|
// not something every platform can do — Wayland has no such thing — and a
|
|
// hidden one that stays is worse than none.
|
|
if std::env::args().any(|arg| arg == WINDOW_ARG) {
|
|
window()
|
|
} else {
|
|
tray::run()
|
|
}
|
|
}
|
|
|
|
/// Runs the window until it is closed.
|
|
fn window() -> Result<(), Box<dyn std::error::Error>> {
|
|
let runtime = tokio::runtime::Builder::new_multi_thread()
|
|
.enable_all()
|
|
.build()?;
|
|
let handle = runtime.handle().clone();
|
|
|
|
let options = eframe::NativeOptions {
|
|
// A fixed, small window; the whole layout targets this size.
|
|
viewport: egui::ViewportBuilder::default()
|
|
.with_title("tsunagi")
|
|
.with_app_id(icon::APP_ID)
|
|
.with_icon(icon::window())
|
|
.with_inner_size([360.0, 600.0])
|
|
.with_resizable(false),
|
|
..Default::default()
|
|
};
|
|
|
|
eframe::run_native(
|
|
"tsunagi",
|
|
options,
|
|
Box::new(move |cc| {
|
|
App::new(cc, handle.clone())
|
|
.map(|app| Box::new(app) as Box<dyn eframe::App>)
|
|
.map_err(std::convert::Into::into)
|
|
}),
|
|
)?;
|
|
|
|
// The window loop has ended; let the runtime wind down.
|
|
drop(runtime);
|
|
Ok(())
|
|
}
|