Skip to content

Fix stale settings saves resetting style selection#747

Open
snvtac wants to merge 1 commit into
Open-Less:betafrom
snvtac:snvtac/742-style-selection-persists
Open

Fix stale settings saves resetting style selection#747
snvtac wants to merge 1 commit 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


Description

  • Preserve active style pack across generic settings saves

  • Add new write path that copies current style fields before persisting

  • Add tests verifying style preferences are retained


Diagram Walkthrough

flowchart LR
  A["Generic settings save"] --> B["read_settings()"]
  B --> C["preserve_style_preferences_from(current)"]
  C --> D["atomic_write to disk"]
  D --> E["Style fields unchanged"]
Loading

File Walkthrough

Relevant files
Bug fix
settings.rs
Preserve style in settings persist path                                   

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

  • Added write_settings_preserving_current_style_preferences trait method
  • Updated persist_settings and set_settings to use the new preserving
    write path
  • Added unit tests simulating race conditions and stale payloads
  • Emit actual saved preferences after write
+141/-10
Enhancement
preferences.rs
Add preserving write to PreferencesStore                                 

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

  • Added set_preserving_current_style_preferences method
  • Copies style fields from current store state before writing
  • Added test verifying disk and in-memory consistency
+53/-1   
types.rs
Add style preservation helper                                                       

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

  • Added preserve_style_preferences_from method on UserPreferences
  • Copies default_mode, enabled_modes, active_style_pack_id,
    style_system_prompts, custom_style_prompts
+10/-0   

@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

742 - Partially compliant

Compliant requirements:

  • 选择任意本地风格包后,应用重启或等待一段时间后仍保持该选择。
  • 后续转写/润色使用用户最后一次激活的风格包,而不是自动回退到“正式表达”。

Non-compliant requirements:

  • 若保存失败或配置被重置,界面能给出可观察的错误/提示,便于定位。

Requires further human verification:

  • The third requirement (UI error feedback on save failure) is not implemented in this PR; the error is only propagated as a string result. It may be addressed in a separate UI change or considered out of scope.
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

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] 风格选择会自动回到正式表达

1 participant