Skip to content

fix(gui-client): don't reset favourites when settings change#9211

Merged
thomaseizinger merged 2 commits into
mainfrom
fix/gui-client-split-local-settings
May 23, 2025
Merged

fix(gui-client): don't reset favourites when settings change#9211
thomaseizinger merged 2 commits into
mainfrom
fix/gui-client-split-local-settings

Conversation

@thomaseizinger

Copy link
Copy Markdown
Member

The GUI client currently has a bug that resets the favourites and the status of the Internet Resource every time the advanced settings are saved. This happens because those fields are annotated with #[serde(default)] and are thus initialised to their default value when the struct is deserialised from the frontend.

To mitigate this, we introduce a new GeneralSettings struct that holds the status of the Internet Resource and the list of favourites. When a client starts up, it will try to migrate the existing advanced settings into the new split of general and advanced settings.

@thomaseizinger
thomaseizinger requested review from Copilot and jamilbk May 23, 2025 02:02
@vercel

vercel Bot commented May 23, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 23, 2025 2:05am

@thomaseizinger
thomaseizinger enabled auto-merge May 23, 2025 02:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR separates user-facing settings (favourites and Internet resource status) from developer-focused advanced settings to prevent overwriting favourites on saving advanced settings. It introduces a GeneralSettings struct, renames the original AdvancedSettings to AdvancedSettingsLegacy, and implements a migration path on startup.

  • Split settings into GeneralSettings (favourites, Internet resource) and AdvancedSettings (URLs, log filter)
  • Renamed original struct to AdvancedSettingsLegacy and created new AdvancedSettings
  • Added migrate_legacy_settings logic and updated load/save calls across modules

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
settings.rs Refactored settings structs, added migration, new load/save functions, paths for general and advanced settings
gui.rs Updated run signature to accept legacy settings and invoke migration; replaced calls to save with save_advanced
controller.rs Added general_settings field, updated constructor and event handlers to use GeneralSettings and save_general
Comments suppressed due to low confidence (3)

rust/gui-client/src-tauri/src/settings.rs:96

  • [nitpick] The method name internet_resource_enabled conflicts with the field of the same name. Renaming it to is_internet_resource_enabled would improve clarity.
pub fn internet_resource_enabled(&self) -> bool {

rust/gui-client/src-tauri/src/settings.rs:190

  • [nitpick] The generic load_advanced_settings<T> may be confusing since it always reads from the advanced settings path. Consider restricting it to a concrete return type or renaming to clarify its use.
pub fn load_advanced_settings<T>() -> Result<T>

rust/gui-client/src-tauri/src/settings.rs:210

  • There are no tests covering migrate_legacy_settings. Adding unit tests for both migration success and failure paths would ensure future changes don’t regress this logic.
#[cfg(test)]

Comment thread rust/gui-client/src-tauri/src/settings.rs
Comment thread rust/gui-client/src-tauri/src/settings.rs
@thomaseizinger

Copy link
Copy Markdown
Member Author

Tested in the Windows VM and works.

@thomaseizinger
thomaseizinger added this pull request to the merge queue May 23, 2025
Merged via the queue into main with commit 67d11b1 May 23, 2025
@thomaseizinger
thomaseizinger deleted the fix/gui-client-split-local-settings branch May 23, 2025 17:54
thomaseizinger pushed a commit that referenced this pull request May 18, 2026
A user who skipped every GUI release between #9211 (May 2025, when
`auth_base_url` was renamed to `auth_url`) and this PR would otherwise
have their custom self-hosted portal URL silently reset to the default
when the new `AdvancedSettings` struct failed to parse the old field
name.

Add a serde alias so the old field name still deserializes, with a
regression test covering the pre-9211 on-disk shape. Favourites and
internet-resource state from that era still get dropped (they're
recoverable from the UI), but URL configuration is preserved.
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.

3 participants