Skip to content

Profile/config robustness and tidy-up - #19

Merged
cyb0rg56 merged 2 commits into
mainfrom
refactor/tidy-up
Sep 29, 2026
Merged

cyb0rg56 merged 2 commits into
mainfrom
refactor/tidy-up

Conversation

@cyb0rg56

Copy link
Copy Markdown
Owner

Summary

Fixes from a code review: profile operations are now ordered so they can't overlap, config and registry writes no longer run on the UI thread, error handling is stricter, and some dependencies and dead code are removed. No new features.

Changes

Profiles

  • Deletes no longer overlap saves or applies. Deleting now goes through the hardware queue as a new HardwareJob::DeleteProfile, in order with SaveProfile and ApplyProfile.
  • Out-of-date profile lists are ignored. Each refresh gets a request number, and a result that arrives after a newer refresh is dropped.
  • Saving no longer checks for an existing profile on the UI thread. The background save tries to create the file; if the profile already exists it returns HardwareOutcome::ProfileExists, which shows the replace prompt.
  • Delete no longer reports false success. delete_profile calls remove_file directly and treats only NotFound as success.

Config

  • Config writes run in the background. New app/config_ops.rs runs save, the hotkeys toggle, the startup toggles, and retry/recover/reset one at a time in the background. Each one uses the config as it is when it starts, not when it was requested.
  • Duplicate hotkey bindings: in build_hotkey_map, the first binding wins, later copies are logged and shown as inactive.
  • Removed the unused refresh_interval_secs setting.

Cleanups

  • Dependencies: removed display-info and futures-util; tokio features cut from full to rt, time, sync, macros.
  • Tray icon: loaded from the icon embedded in the executable (ID 1) instead of writing a temp .ico file.
  • Turning monitors off: turn_off_monitors logs a failed PostMessageW.
  • Startup registry entry: the Run command is built as an OsString.
  • Code tidy-up:
    • Merged the brightness and contrast slider handlers.
    • Replaced an unwrap in HardwareCoordinator::retry.
    • Removed the unused Message::Error, SetBrightness and SetContrast variants.

Testing

  • cargo clippy --all-targets shows no warnings, cargo fmt --check passes, and cargo test passes 121 of 121.
  • New tests:
    • Profile listing: a missing folder counts as empty, non-JSON files are skipped, and errors are returned.
    • Profile delete: deleting a missing profile succeeds, and other errors are returned.
    • Duplicate hotkey bindings keep the first action chain.

@cyb0rg56
cyb0rg56 merged commit 1114e71 into main Sep 29, 2026
2 checks passed
@cyb0rg56
cyb0rg56 deleted the refactor/tidy-up branch September 29, 2026 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant