refactor: extract the tray into gui/tray.py #106

Merged
mysticalsoap merged 2 commits from refactor/gui-tray into trunk 2026-08-20 20:31:31 -04:00
Owner

Problem

Tray behavior was spread across five AqomuiGui handlers poking icon names and tooltips directly (systemtray, pop_tray_menu, toggle_visibility, set_tray_icon, plus the state resets in connection_established/tunnel_terminated/kill). #83 wants extractions to ride along when work touches an area — the #69/#104 tray wave is that occasion — and per its amended rule, new extractions land directly in aqomui/gui/.

Fix

New aqomui/gui/tray.py with TrayIcon: wraps QSystemTrayIcon + menu, signals out (clicked, show_window, hide_window, profile_chosen, quit_app), state methods in (connected(name) / disconnected()), usable for the no-tray fallback. AqomuiGui wires signals in systemtray() and calls state methods; pop_tray_menu/toggle_visibility/set_tray_icon are gone. setup.py gains the aqomui.gui package.

Pure move, with one deliberate dedup: connection_established used to set the tooltip twice with different wording ("Status: connected to X" then "Connected to X" overwriting it) — now once, matching the "Status: …" form. Two latent quirks preserved as-is and now visible for future fixes: the profile menu is populated once at startup (stale after profile changes), and the Hide/Show label doesn't track visibility toggled by clicking the tray icon.

Verification

New tests/test_gui_tray.py (9 tests, offscreen platform): menu layout incl. separators, repopulate doesn't stack, visibility toggle emits + flips label, profile action emits its key, quit emits, connected/disconnected state + tooltips, unusable-tray construction. The #69 regression tests now assert against the TrayIcon interface. Full suite: 180 passed.

Refs #83

🤖 Generated with Claude Code

**Problem** Tray behavior was spread across five AqomuiGui handlers poking icon names and tooltips directly (`systemtray`, `pop_tray_menu`, `toggle_visibility`, `set_tray_icon`, plus the state resets in `connection_established`/`tunnel_terminated`/`kill`). #83 wants extractions to ride along when work touches an area — the #69/#104 tray wave is that occasion — and per its amended rule, new extractions land directly in `aqomui/gui/`. **Fix** New `aqomui/gui/tray.py` with `TrayIcon`: wraps `QSystemTrayIcon` + menu, signals out (`clicked`, `show_window`, `hide_window`, `profile_chosen`, `quit_app`), state methods in (`connected(name)` / `disconnected()`), `usable` for the no-tray fallback. AqomuiGui wires signals in `systemtray()` and calls state methods; `pop_tray_menu`/`toggle_visibility`/`set_tray_icon` are gone. setup.py gains the `aqomui.gui` package. Pure move, with one deliberate dedup: `connection_established` used to set the tooltip twice with different wording ("Status: connected to X" then "Connected to X" overwriting it) — now once, matching the "Status: …" form. Two latent quirks preserved as-is and now visible for future fixes: the profile menu is populated once at startup (stale after profile changes), and the Hide/Show label doesn't track visibility toggled by clicking the tray icon. **Verification** New `tests/test_gui_tray.py` (9 tests, offscreen platform): menu layout incl. separators, repopulate doesn't stack, visibility toggle emits + flips label, profile action emits its key, quit emits, connected/disconnected state + tooltips, unusable-tray construction. The #69 regression tests now assert against the `TrayIcon` interface. Full suite: 180 passed. Refs #83 🤖 Generated with [Claude Code](https://claude.com/claude-code)
refactor: extract the tray into gui/tray.py
All checks were successful
ci / test (pull_request) Successful in 30s
2e67f42cfa
First extraction into the aqomui/gui subpackage (#83): TrayIcon wraps
QSystemTrayIcon and its menu, exposing signals (clicked, show_window,
hide_window, profile_chosen, quit_app) and state methods
(connected(name) / disconnected()), so AqomuiGui stops poking icon
names and tooltips from five handlers. systemtray, pop_tray_menu,
toggle_visibility and set_tray_icon leave AqomuiGui.

One behavioral nit resolved on the way: connection_established set the
tooltip twice with different wording ("Status: connected to X", then
"Connected to X" overwriting it); connected() now sets it once,
matching the "Status: ..." form of the disconnected state. Everything
else is a pure move, including two latent quirks preserved as-is: the
profile menu is populated once at startup, and the Hide/Show label does
not track visibility changes made by clicking the tray icon itself.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
refactor: tests mirror the package layout
All checks were successful
ci / test (pull_request) Successful in 32s
ci / test (push) Successful in 29s
d8d46fe8b7
tests/gui/test_tray.py for aqomui/gui/tray.py, with an __init__.py so
pytest namespaces the subdirectory's modules -- flat test dirs import
by basename, and a future tests/gui/test_widgets.py would otherwise
collide with tests/test_widgets.py.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mysticalsoap deleted branch refactor/gui-tray 2026-08-20 20:31:31 -04:00
Sign in to join this conversation.
No description provided.