# RdkTube Agent V5 UI Architecture

V5 keeps the Agent_v4 operational logic intact and moves the visual shell into `_ui_v5.py`.

## Current Choice

- UI toolkit: PySide6
- Tray: pystray
- Images/thumbnails: Pillow
- Windows/process control: pywin32 + psutil
- API/client work: httpx
- Auto update: `_update_client.py` + external `updater.py`

CustomTkinter is kept only as a temporary fallback module (`_ui_v5.py`). The primary V5 visual shell is `_ui_qt_v5.py`.

## V5 UX Rules

- No visible Config tab.
- Main tabs: Canales and Perfiles.
- Closing the app hides it to the system tray.
- Tray double click / Abrir panel shows the app again.
- Advanced defaults live in config.ini and are normalized once with `UI.ui_version = 5`.
- Agent ID / Agent Token use a singleton PySide6 dialog from the settings window.
- Auto update uses `[Update].manifest_url`, defaulting to `https://www.rdktube.com/downloads/rdk-agent-manifest.json`.
- If the Windows Run registry entry exists but points to an older install path, V5 repairs it on launch.
- With a valid Agent ID / Token, V5 starts monitoring automatically on launch (`[Runtime].start_on_launch = yes`).

## Hidden Defaults

- heartbeat_seconds = 180
- plan_poll_seconds = 300
- live_poll_fallback = 600
- window_w = 600
- window_h = 400
- grid_cols = 3
- grid_spacing = 2
- start_x = 0
- start_y = 0
- force_resize = yes
- hard_kill = yes
- use_app_mode = yes
- notifications = yes
- start_on_launch = yes

## Future PySide6 Migration

The first migration step is complete. Next refactor should keep the same boundary and extract runtime logic from `_impl.py` into smaller modules:

- `_impl.py`: agent runtime and behavior
- UI module: windows, tabs, cards, tray integration
- config/auth/profiles/window-control should be extracted next so future UI changes do not touch runtime behavior
