Skip to content

Fix stale settings saves resetting style selection#747

Merged
H-Chris233 merged 2 commits into
Open-Less:betafrom
snvtac:snvtac/742-style-selection-persists
Jul 11, 2026
Merged

Fix stale settings saves resetting style selection#747
H-Chris233 merged 2 commits into
Open-Less:betafrom
snvtac:snvtac/742-style-selection-persists

Conversation

@snvtac

@snvtac snvtac commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

User description

Summary

  • Preserve style-pack-owned preference fields when generic settings saves persist a full preferences payload.
  • Add a locked PreferencesStore write path so a stale settings payload cannot roll back the current active style pack.
  • Emit the actual saved preferences after set_settings and set_update_channel persist.

Root Cause

Generic settings saves send a complete UserPreferences snapshot. If the user switches to a local style pack and a later settings save uses an older snapshot, that stale payload can overwrite active_style_pack_id and related legacy style fields, sending the app back to the previous formal/builtin style.

Fix

The generic settings save path now treats style-pack preferences as owned by the style-pack commands. Before writing a generic settings payload, PreferencesStore::set_preserving_current_style_preferences copies the current store style fields under the same store lock used for the disk write and in-memory update. Style-pack commands still use the normal store write path, so intentional style changes continue to persist.

Fixes #742.

Validation

  • rustfmt --edition 2021 --check openless-all/app/src-tauri/src/commands/settings.rs openless-all/app/src-tauri/src/persistence/preferences.rs openless-all/app/src-tauri/src/types.rs
  • cargo test settings
  • cargo test sync_style_pack_preferences
  • cargo test set_preserving_current_style_preferences
  • git diff --check

PR Type

Bug fix, Enhancement


Description

  • Preserve active style preferences when generic settings saves overwrite them.

  • Add write_settings_preserving_current_style_preferences method to SettingsWriter.

  • Modify persist_settings, set_settings, and set_update_channel to use the new path.

  • Add unit tests for the new behavior.


Diagram Walkthrough

flowchart LR
  A["User switches style pack"] --> B["Style pack command writes prefs via normal path"]
  C["Generic settings save triggered"] --> D["Read current prefs from store"]
  D --> E["Call preserve_style_preferences_from"]
  E --> F["Write merged prefs (keeps style)"]
  B --> G["Style change persists"]
  F --> G
  G --> H["Frontend receives updated prefs"]
Loading

File Walkthrough

Relevant files
Bug fix
settings.rs
Add style-preserving write path to SettingsWriter               

openless-all/app/src-tauri/src/commands/settings.rs

  • Added write_settings_preserving_current_style_preferences method to
    SettingsWriter trait.
  • Replaced write_settings calls with the preserving variant in
    persist_settings_with_keyboard_apply and persist_settings.
  • Updated set_settings to read back the saved prefs after writing.
  • Added unit tests
    settings_save_preserves_current_style_preferences_before_write and
    persist_settings_keeps_style_change_that_lands_before_write.
+141/-10
Enhancement
preferences.rs
Add style-preserving write to PreferencesStore                     

openless-all/app/src-tauri/src/persistence/preferences.rs

  • Added set_preserving_current_style_preferences method to
    PreferencesStore.
  • Method copies current store style fields into the incoming payload
    before writing.
  • Added unit test
    set_preserving_current_style_preferences_keeps_store_style_fields.
+53/-1   
types.rs
Add preserve_style_preferences_from to UserPreferences     

openless-all/app/src-tauri/src/types.rs

  • Added preserve_style_preferences_from method to UserPreferences.
  • Method copies default_mode, enabled_modes, active_style_pack_id,
    style_system_prompts, and custom_style_prompts from another instance.
+10/-0   

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit 117aa1b)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

742 - Partially compliant

Compliant requirements:

  • After selecting a local style pack, the selection should persist after app restart or waiting.
  • Subsequent writings/edits should use the last activated style pack, not revert to formal.

Non-compliant requirements:

  • If save fails or config is reset, the UI should give an observable error/hint.
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

H-Chris233
H-Chris233 previously approved these changes Jul 3, 2026
@H-Chris233

Copy link
Copy Markdown
Collaborator

Could you please resolve conflicts for this?
I reviewed this pr,If you resolve conflicts, i will merge it.

@H-Chris233

H-Chris233 commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

@appergb 你有时间的话cherry pick一下吧,作者不回复了,或者直接将此工作分配给我。

@H-Chris233

Copy link
Copy Markdown
Collaborator

接管

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 117aa1b

@H-Chris233

Copy link
Copy Markdown
Collaborator

接管

@H-Chris233 H-Chris233 merged commit f2c2372 into Open-Less:beta Jul 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[area:style] 风格选择会自动回到正式表达

2 participants