feat: config page overlay and panel toggle (Esc, 1-5)#39
feat: config page overlay and panel toggle (Esc, 1-5)#39tbouquet wants to merge 6 commits intograykode:mainfrom
Conversation
Add a config overlay (Esc) for changing theme and toggling panels. Press 1-5 to quickly show/hide panels without opening the config page. Panel mapping: 1 — context 2 — quota 3 — tokens 4 — ports 5 — sessions Hidden panels redistribute space to visible ones. The config overlay shows the current state of all settings with version info, and captures input while open.
graykode
left a comment
There was a problem hiding this comment.
Thanks for this! Really like the direction — an Esc overlay + number keys is a nice way to let users shape the layout, and the dynamic redistribution works well.
A few things I noticed while reading through:
1. q in the config overlay quits abtop (small bug)
The PR description says "Esc/q to close" the overlay, but in main.rs the q branch inside the config_open block calls app.quit() instead of app.toggle_config(). So pressing q with the overlay open kills abtop rather than dismissing the overlay. I think the fix is just routing q to toggle_config() while the overlay is open.
2. Hiding all three toggleable mid panels also hides Projects
The PR description notes "Projects panel always visible (provides essential git context)", but:
let any_mid = app.show_quota || app.show_tokens || app.show_ports;
let mid_h_ideal: u16 = if any_mid { 8 } else { 0 };If a user toggles off Quota, Tokens, and Ports, any_mid becomes false, mid_h becomes 0, and the whole mid row — including Projects — disappears. I think any_mid should effectively be true whenever Projects is shown, or the variable can just be dropped so the mid row always renders at least Projects.
3. Toggle key numbering vs. panel numbering in CLAUDE.md
CLAUDE.md documents the panels as ¹context ²quota ³tokens ⁴projects ⁵ports ⁶sessions, but the toggle keys are 1=context, 2=quota, 3=tokens, 4=ports, 5=sessions (skipping Projects). Users glancing at the layout diagram may expect 4 to toggle Projects and 5 to toggle Ports. Two possible fixes: (a) keep the CLAUDE.md numbering and leave 4 unbound since Projects is always on, or (b) update the CLAUDE.md panel numbers to match this PR's scheme. Either works — just worth being consistent.
4. Esc as an "open" key is a little unusual
In most TUIs, Esc means close/cancel. Using it to both open and close the config overlay works, but a more conventional pairing would be c (or ?) to open and Esc to close. Not blocking, just a small UX note — happy either way.
Nice-to-haves (not blockers)
- The mid constraint construction in
ui/mod.rsbuilds aVecofLength(0)dummies just to count them, then rebuilds asRatio(1, count). Could be simplified to counting directly:let count = 1 + app.show_quota as u32 + app.show_tokens as u32 + app.show_ports as u32; let mid_constraints: Vec<Constraint> = (0..count).map(|_| Constraint::Ratio(1, count)).collect();
- The
codex.rsclippy fix (match guard foruser_message) is also included in #36, so whichever lands second will need a small rebase — nothing to do here, just a heads up. - A unit test for
toggle_panel/config_select_next/config_select_prevwould be easy and would lock in the bounds behavior (e.g.config_selectednot overflowingconfig_item_count). config_item_counthardcodes6; deriving it from the item list (or a const) would keep it in sync if you add more options later.- Persisting panel visibility across runs (e.g.
~/.config/abtop/config.toml) would be a natural follow-up.
Thanks again — once #1 and #2 are addressed I think this is in great shape to merge. The rest are all discussable / follow-up material.
Summary
1Context2Quota3Tokens4Ports5SessionsDemo
Shows: panel toggle (2/3 keys), config overlay (Esc), theme cycling, panel toggle from config
Design
App(session-scoped, not persisted)Test plan
cargo clippy -- -D warningspassescargo test- all 31 tests passcargo build --releasepasses