refactor: split dashboard modules and share UI sync helpers

Break the oversized overview page into focused dashboard submodules and
centralize the repeated validation/save-button refresh flows used by page
widgets. This keeps the UI behavior stable while making future edits less
fragile and easier to reason about.
This commit is contained in:
2026-03-31 18:51:16 -04:00
parent a36c02bbf7
commit fc840e9e98
15 changed files with 3229 additions and 3470 deletions
+17 -11
View File
@@ -1,6 +1,6 @@
# PROJECT_MAP.md
# Auto-generated project index. Update this file whenever you add, remove, or significantly change a file or feature.
# Last updated: 2026-03-31 - preview update behavior is now documented and partially centralized around shared live-apply helpers (`docs/PREVIEW_UPDATE_MAP.md`, `src/ui/pages/mod.rs`), the top config strip uses an inline target picker instead of the old switch-config dialog, per-app config creation now supports a searchable bundled game-config database (`data/game_config_db.toml`) with documented maintenance workflow, the `HUD Order` page still reorders real HUD groups with live preview sync but currently uses explicit up/down controls after drag-and-drop proved unstable, MangoTune profiles are now framed as real MangoHud `.conf` files applied into the active target, and the shell/menu/popup surfaces have been tightened and moved onto app-owned compact popover/layout hooks instead of relying on stock roomy menu chrome
# Last updated: 2026-03-31 - preview update behavior is now documented and centralized around shared page-level config-sync/live-apply helpers (`docs/PREVIEW_UPDATE_MAP.md`, `src/ui/pages/mod.rs`), the top config strip uses an inline target picker instead of the old switch-config dialog, per-app config creation now supports a searchable bundled game-config database (`data/game_config_db.toml`) with documented maintenance workflow, the `HUD Order` page still reorders real HUD groups with live preview sync but currently uses explicit up/down controls after drag-and-drop proved unstable, MangoTune profiles are now framed as real MangoHud `.conf` files applied into the active target, the shell/menu/popup surfaces have been tightened and moved onto app-owned compact popover/layout hooks instead of relying on stock roomy menu chrome, and the oversized dashboard monolith has been split into `src/ui/pages/overview/` submodules so preview runtime controls, presets, profiles, and dashboard cards now have clearer ownership boundaries
---
@@ -47,7 +47,7 @@ dashboard control change -> in-memory config updates -> `src/preview/mod.rs` wri
| `src/lib.rs` | Library root | Re-exports core modules for app/tests |
| `src/debug_log.rs` | In-app diagnostics buffer | Shared recent-log ring buffer used by the app shell and config parser, with copy/clear support for the Debug page |
| `src/app.rs` | Application bootstrap | GTK/libadwaita app setup, CSS load, startup detection |
| `src/window.rs` | Main shell | App state, header/actions, sidebar, accordion-style section navigation, async config-bar layer discovery, visible-page rebuilds with scroll-position preservation, a top config strip that now acts as an inline active-target picker plus read-only layer-stack summary, periodic layer-summary refresh with real detected-conflict counts, narrower default sizing and a slimmer sidebar so the app fits better on typical 16:9 desktops, dashboard-first startup without restoring the last visited page, a clearer header-led save/reload/revert/close flow, reset-to-defaults and restore-latest-safety-backup menu actions alongside safety backups, real target switching between writable global/per-app XDG configs with save/discard guarding, a sane MangoTune baseline for reset instead of an empty config, selective app-preference reset for preview/backup defaults, a save-menu `Auto backup on save` toggle instead of a mostly-empty Preferences screen, explicit shell styling hooks for the header/sidebar/config strip, app-owned compact popovers for the top-bar menus, and an Adwaita in-app unsaved-changes alert sheet instead of a standalone popup window |
| `src/window.rs` | Main shell | App state, header/actions, sidebar, accordion-style section navigation, async config-bar layer discovery, visible-page rebuilds with scroll-position preservation, a top config strip that now acts as an inline active-target picker plus read-only layer-stack summary, periodic layer-summary refresh with real detected-conflict counts, narrower default sizing and a slimmer sidebar so the app fits better on typical 16:9 desktops, dashboard-first startup without restoring the last visited page, a clearer header-led save/reload/revert/close flow, reset-to-defaults and restore-latest-safety-backup menu actions alongside safety backups, real target switching between writable global/per-app XDG configs with save/discard guarding, a sane MangoTune baseline for reset instead of an empty config, selective app-preference reset for preview/backup defaults, a save-menu `Auto backup on save` toggle instead of a mostly-empty Preferences screen, explicit shell styling hooks for the header/sidebar/config strip, app-owned compact popovers for the top-bar menus, an Adwaita in-app unsaved-changes alert sheet instead of a standalone popup window, and shared helpers for “config replaced” window refresh flows so reload/revert/reset/restore paths stay consistent |
| `src/preview/` | Managed live preview | Preview-session state, temp preview config writing, start/reload/restart/stop flow |
| `src/preview/mod.rs` | Preview controller | Uses a temporary preview config and launches the actual preview/test process directly, including persisted studio load/FPS/VSync settings, live socket-driven Studio runtime updates for load/FPS/VSync/VRAM/particle/pause controls, temp-config live-apply for ordinary Studio edits without signaling/restarting the process, safer studio restart behavior for window-size changes, legacy flag normalization before preview writes, explicit `horizontal_stretch=0` serialization for stretch-off sessions, effective HUD-width-based preview sizing, preview-only bounded widths for horizontal auto-layout sessions, per-metric auto-width estimation with separate sparse compact/non-compact tuning, preview-only right-anchor emulation for horizontal right-aligned layouts, and Studio-only post-launch window-size calibration so fractional desktop scaling does not throw off width-sensitive preview placement |
| `src/config/normalize.rs` | Legacy option cleanup | Shared normalization for old flag/bool encodings like `key=0`/`key=1`, normalization of old negative offsets back to unsigned values, plus cleanup for the mistaken standalone `gpu_load` / `cpu_load` keys; reused by save/load/profile/preview flows |
@@ -68,8 +68,12 @@ dashboard control change -> in-memory config updates -> `src/preview/mod.rs` wri
| `src/ui/` | UI layer | Page builders and reusable widgets |
| `src/ui/toast.rs` | Toast helper | Shared short-lived toast helper that dismisses older queued messages and gives errors/warnings a slightly longer lifetime |
| `src/ui/widgets/tool_page.rs` | Shared page/window scaffolds | Owns the shared page frame/header, section shells, callouts, and now the reusable utility-window shell used by raw editor and small modal-style utility windows so spacing/frame rules stay consistent |
| `src/ui/pages/mod.rs` | Page registry | Sidebar structure, navigation-page factory, current-config snapshots, search-result routing, and the shared preview-update helpers that now define the two main MangoHud config refresh modes: debounced live apply and immediate live apply |
| `src/ui/pages/overview.rs` | Dashboard page | Dashboard now uses the same flat page-header scaffold and outer spacing as the rest of the app, while focusing on quick everyday tuning: `Layout & Position`, `Make It Readable`, `Show These Metrics`, a compact profile utility strip with icon actions, and a single-line status strip at the bottom. Live Preview and Presets now live on their own dedicated pages under `Start`, while the dashboard keeps MangoHud-faithful unsigned offsets, uses live apply for the common metric/appearance toggles, and separates Studio runtime controls from true preview-window restart cases |
| `src/ui/pages/mod.rs` | Page registry | Sidebar structure, navigation-page factory, current-config snapshots, search-result routing, shared preview-update helpers defining the two main MangoHud config refresh modes (debounced live apply and immediate live apply), and shared page-level config-sync helpers used by widgets/pages after in-memory config edits |
| `src/ui/pages/overview/mod.rs` | Dashboard page shell | Dashboard entry point and tests; wires together the split dashboard submodules while keeping the public `overview::build_page` / `overview::build_preview_panel` / `overview::build_presets_panel` surface stable |
| `src/ui/pages/overview/cards.rs` | Dashboard cards/helpers | Owns the dashboards layout/appearance/metrics/workspace cards plus the shared slider, color, metric-toggle, and config-mutation helpers they use |
| `src/ui/pages/overview/preview.rs` | Preview runtime panel | Owns the shared Studio preview panel used by both the dashboard and `Live Preview`, including window sizing, runtime controls, and preview restart/runtime-update helpers |
| `src/ui/pages/overview/presets.rs` | Dashboard presets | Owns the starter preset grid, preset mappings, and fallback profile-aware preset application logic |
| `src/ui/pages/overview/profiles.rs` | Dashboard profiles | Owns the dashboard profile strip, picker persistence, save/apply/delete flows, and active-config naming helper used in the dashboard header chips |
| `src/ui/pages/live_preview.rs` | Live Preview page | Dedicated `Start` page for Studio preview launch/apply/restart/stop, preview window size, scene selection, and direct runtime tuning controls without touching the saved MangoHud config, using the same flat page-header scaffold and spacing rules as the rest of the app |
| `src/ui/pages/presets_page.rs` | Presets page | Dedicated `Start` page for loading the practical starter presets/profile-backed overlay shapes without mixing them into the preview workflow, using the same flat page-header scaffold and spacing rules as the rest of the app |
| `src/ui/pages/debug.rs` | Debug page | Tool-page style diagnostics surface with a live recent-log view, current in-memory config snapshot, and clipboard actions for support/debugging |
@@ -91,10 +95,10 @@ dashboard control change -> in-memory config updates -> `src/preview/mod.rs` wri
| `src/ui/pages/opengl_quirks.rs` | OpenGL page | OpenGL-specific workarounds |
| `src/ui/pages/raw_editor.rs` | Raw editor | Tool-page style raw-config launcher with workspace stats, lighter-use guidance, and a richer editor pop-out now using the shared utility-window shell instead of hand-rolled framing |
| `src/ui/pages/integrations.rs` | Integrations page | Tool-page style Steam/Lutris/Heroic/GameMode helpers with live Steam command generation |
| `src/ui/widgets/toggle_row.rs` | Schema row factory | Builds switch/combo/entry rows plus explicit compact spin-button suffix controls for numeric schema fields, applies verified friendly titles/help text, surfaces inline validation, refreshes live preview after edits, routes palette-style comma-separated color fields to richer swatch controls, treats free-text entries as commit-based preview updates that only fire after an actual edit, and filters typed/pasted junk out of numeric controls at both the key and editable layers instead of only validating later |
| `src/ui/widgets/toggle_row.rs` | Schema row factory | Builds switch/combo/entry rows plus explicit compact spin-button suffix controls for numeric schema fields, applies verified friendly titles/help text, surfaces inline validation, refreshes live preview after edits, routes palette-style comma-separated color fields to richer swatch controls, treats free-text entries as commit-based preview updates that only fire after an actual edit, filters typed/pasted junk out of numeric controls at both the key and editable layers instead of only validating later, and now leans on shared page-level config-sync helpers instead of open-coding validation/save-button refreshes |
| `src/ui/widgets/hotkey_row.rs` | Hotkey row widget | Keybinding editor rows with a modal edit dialog now using the shared utility-window shell instead of a one-off padded box |
| `src/ui/widgets/tool_page.rs` | Tool-page shell builder | Shared custom page hero/section/callout helpers used to move deep pages away from stock preferences layouts, including top-aligned section badges, explicit section-header wrappers, and chip rows that follow the redesign-inspired shell language |
| `src/ui/widgets/color_row.rs` | Color control widget | Hex + color-dialog row with shared live-preview refresh, plus palette-list swatches for comma-separated color fields like `fps_color`, `gpu_load_color`, and `cpu_load_color`; text editing now validates live but only refreshes preview on commit/focus-leave after a real edit, unset swatches now render in a neutral placeholder state, and palette entry fields live in a fixed editor cluster instead of resizing around current content |
| `src/ui/widgets/color_row.rs` | Color control widget | Hex + color-dialog row with shared live-preview refresh, plus palette-list swatches for comma-separated color fields like `fps_color`, `gpu_load_color`, and `cpu_load_color`; text editing now validates live but only refreshes preview on commit/focus-leave after a real edit, unset swatches now render in a neutral placeholder state, palette entry fields live in a fixed editor cluster instead of resizing around current content, and the widget now uses the shared page-level config-sync helpers for validation/save-state refresh |
| `src/ui/widgets/hotkey_row.rs` | Hotkey widget | Keybinding capture/edit UI with shared live-preview refresh |
| `src/ui/widgets/cascade_view.rs` | Conflict widget | Cascade/layer visualization plus filter-aware visibility helpers |
| `src/ui/widgets/validation_label.rs` | Validation helper | Inline row error presentation |
@@ -106,9 +110,9 @@ dashboard control change -> in-memory config updates -> `src/preview/mod.rs` wri
- Add or change a major window/workflow: `src/window.rs`, `src/ui/pages/mod.rs`, affected page module(s), `data/style.css`
- Change a MangoHud options validation/type/category: `src/config/schema.rs`, `src/config/help.rs`, `src/config/validator.rs`, affected page in `src/ui/pages/`
- Change config parsing or write behavior: `src/config/parser.rs`, `src/config/types.rs`, parser tests
- Change launcher/test-preview behavior: `src/preview/mod.rs`, `src/bin/mangotune-preview.rs`, `src/launcher/runner.rs`, `src/ui/pages/overview.rs`, `data/com.mangotune.MangoTune.gschema.xml`, `Makefile`
- Change launcher/test-preview behavior: `src/preview/mod.rs`, `src/bin/mangotune-preview.rs`, `src/launcher/runner.rs`, `src/ui/pages/overview/preview.rs`, `src/ui/pages/live_preview.rs`, `data/com.mangotune.MangoTune.gschema.xml`, `Makefile`
- Change direct MangoHud validation flow: `scripts/mangohud-position-lab.sh`, `scripts/mangohud-position-matrix.sh`, `docs/MANGOHUD_POSITION_LAB.md`
- Change profile behavior: `src/profiles/mod.rs`, `src/ui/pages/overview.rs`
- Change profile behavior: `src/profiles/mod.rs`, `src/ui/pages/overview/profiles.rs`, `src/ui/pages/overview/presets.rs`
- Change config-layer/conflict behavior: `src/config/resolver.rs`, `src/ui/pages/conflicts.rs`, `src/window.rs`
- Change desktop app settings/preferences: `data/com.mangotune.MangoTune.gschema.xml`, `build.rs`, `src/window.rs`
- Change integration strings/behavior: `src/integrations/*.rs`, `src/ui/pages/integrations.rs`
@@ -159,7 +163,7 @@ dashboard control change -> in-memory config updates -> `src/preview/mod.rs` wri
---
## 🧪 Test Coverage Map
- Unit tests live inline in Rust modules such as `src/config/parser.rs`, `src/launcher/runner.rs`, `src/profiles/mod.rs`, `src/integrations/steam.rs`, and `src/ui/pages/overview.rs`
- Unit tests live inline in Rust modules such as `src/config/parser.rs`, `src/launcher/runner.rs`, `src/profiles/mod.rs`, `src/integrations/steam.rs`, and `src/ui/pages/overview/mod.rs`
- Parser/schema/validator/resolver changes should get module tests updated where the logic lives
- Launcher/preview behavior changes usually require tests in `src/launcher/runner.rs`, `src/preview/mod.rs`, `src/bin/mangotune-preview.rs` when practical, and any overview helpers that drive preview state
- UI shell/page layout currently has light automated coverage; visual/interaction changes need manual GTK testing in addition to `cargo test`
@@ -170,8 +174,8 @@ dashboard control change -> in-memory config updates -> `src/preview/mod.rs` wri
- **App shell and navigation**: `src/app.rs`, `src/window.rs`, `src/ui/pages/mod.rs`, `data/style.css`
- **MangoHud config engine**: `src/config/`
- **Runtime/system detection**: `src/system/`
- **Preview/test launching**: `src/preview/`, `src/bin/mangotune-preview.rs`, `src/launcher/`, `src/ui/pages/overview.rs`
- **Profiles**: `src/profiles/`, `src/ui/pages/overview.rs`
- **Preview/test launching**: `src/preview/`, `src/bin/mangotune-preview.rs`, `src/launcher/`, `src/ui/pages/overview/preview.rs`, `src/ui/pages/live_preview.rs`
- **Profiles**: `src/profiles/`, `src/ui/pages/overview/profiles.rs`, `src/ui/pages/overview/presets.rs`
- **Desktop integrations**: `src/integrations/`, `src/ui/pages/integrations.rs`
- **Page-specific UI**: `src/ui/pages/`
- **Reusable controls**: `src/ui/widgets/`
@@ -244,3 +248,5 @@ Do not update this file for:
- 2026-03-24 Simplified preview-only right-anchor emulation by dropping fake vertical offsets and adding a small no-margin right-edge safety for horizontal right-aligned layouts
- 2026-03-24 Tried preserving native MangoHud right-side positions directly, but reverted that change after it made horizontal previews disappear again; preview-side right-anchor emulation remains the last usable path while MangoHud-native behavior is being investigated separately
- 2026-03-24 Added a direct MangoHud position lab and matrix runner so margin/compact/right-anchor behavior can be validated outside MangoTune on a real X11 session, including an isolated-Xorg workflow for `arch.lan`
- 2026-03-31 Split the oversized dashboard module into `src/ui/pages/overview/{cards,preview,presets,profiles}.rs` while keeping the public overview page surface and tests intact
- 2026-03-31 Added shared page-level config-sync helpers plus shared window-level “config replaced” refresh helpers, and used them to deduplicate repeated validation/save/preview refresh logic across overview widgets, shared control rows, color rows, typography/raw-editor/hud-order pages, and top-level reload/revert/reset flows