Skip to content

修复 Style 总开关关闭后的兜底风格#383

Merged
H-Chris233 merged 2 commits into
Open-Less:betafrom
H-Chris233:fix/issue-312-style-master-toggle
May 9, 2026
Merged

修复 Style 总开关关闭后的兜底风格#383
H-Chris233 merged 2 commits into
Open-Less:betafrom
H-Chris233:fix/issue-312-style-master-toggle

Conversation

@H-Chris233
Copy link
Copy Markdown
Collaborator

@H-Chris233 H-Chris233 commented May 9, 2026

User description

摘要

Closes #312

验证

  • cd openless-all/app && npx tsx src/lib/stylePrefs.test.ts
  • cd openless-all/app && npm run build

备注

coordinator.rsenabled_modes 目前用于切换风格热键过滤;听写主流程仍读取 default_mode。因此本修复避免空集合让风格热键无可选项,同时保持主听写路径行为稳定。


PR Type

Bug fix, Tests


Description

  • Preserve raw/default fallback modes

  • Keep master-off state stable

  • Recompute saved modes after default changes

  • Add regression coverage for toggle and rollback


Diagram Walkthrough

flowchart LR
  StylePage["Style page"]
  StylePrefs["stylePrefs helpers"]
  IPC["Settings IPC"]
  Tests["Regression tests"]

  StylePage -- "toggle default / master" --> StylePrefs
  StylePrefs -- "persist fallback modes" --> IPC
  Tests -- "verify master-off semantics" --> StylePrefs
Loading

File Walkthrough

Relevant files
Bug fix
stylePrefs.ts
Centralize style master fallback and rollback logic           

openless-all/app/src/lib/stylePrefs.ts

  • Adds styleMasterFallbackModes to derive raw plus the current default
    mode.
  • Introduces isStyleMasterEnabled and styleMasterOffPreferences to
    centralize master-toggle state.
  • Updates default-mode changes to recompute fallback modes when the
    master switch is off.
  • Adds rollbackDefaultAndEnabledChange plus a set-comparison helper for
    off-state rollbacks.
+43/-0   
Style.tsx
Use shared helpers for Style page state                                   

openless-all/app/src/pages/Style.tsx

  • Switches master-toggle and default-selection logic to shared style
    preference helpers.
  • Persists full settings when default mode changes while master is off,
    keeping enabledModes in sync.
  • Replaces direct enabledModes.length checks with semantic
    master-enabled detection.
  • Updates the master-off save path to keep raw and the current default
    mode.
+13/-6   
Tests
stylePrefs.test.ts
Extend style preference regression tests                                 

openless-all/app/src/lib/stylePrefs.test.ts

  • Adds assertions for master-off fallback modes and master-enabled
    detection.
  • Covers the raw default edge case so fallback mode lists are not
    duplicated.
  • Verifies default changes while master is off recompute enabledModes
    correctly.
  • Adds rollback coverage for failed off-state default updates.
+55/-0   

Style 页总开关关闭时沿用现有注释语义:保留 raw 和当前 default mode,避免把 enabledModes 持久化为空集合。\n\n将 master toggle 的 off 判定抽到 stylePrefs,确保仅剩 raw/default 时 UI 仍显示为关闭,并用现有手写测试覆盖最终保存值。\n\nConstraint: Issue Open-Less#312 要求总开关实现与注释一致,并覆盖关闭后的 enabledModes。\nRejected: 保持 enabledModes=[] 仅改注释 | 会让切换风格热键面对空集合,偏离 raw/default 兜底语义。\nConfidence: high\nScope-risk: narrow\nTested: cd openless-all/app && npx tsx src/lib/stylePrefs.test.ts\nTested: cd openless-all/app && npm run build\nNot-tested: Real Tauri UI click path on macOS/Windows.\nRelated: https://github.com/appergb/openless/issues/312\nCo-authored-by: OmX <omx@oh-my-codex.dev>
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

PR Reviewer Guide 🔍

(Review updated until commit 6341f19)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

312 - PR Code Verified

Compliant requirements:

  • Uses raw plus the current defaultMode when the master toggle is turned off.
  • Keeps the UI state and persisted settings aligned through shared style preference helpers.
  • Adds regression tests covering master-toggle-off behavior and rollback.

Requires further human verification:

  • Confirm coordinator.rs behaves correctly with persisted enabledModes of ['raw', defaultMode] in all runtime paths.
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

Review noted that changing defaultMode after turning Style master off made the switch look on again because enabledModes still reflected the old fallback pair.\n\nWhen master is already off, default-mode changes now persist the whole style preference set through setSettings so enabledModes is recomputed to raw plus the new default. Normal enabled master behavior still uses the narrower setDefaultPolishMode IPC.\n\nConstraint: Issue Open-Less#312 selected raw/default fallback semantics for master-off state.\nRejected: Add a separate persisted masterEnabled flag | broader schema and migration change for a narrow UI consistency bug.\nConfidence: high\nScope-risk: narrow\nTested: cd openless-all/app && npx tsx src/lib/stylePrefs.test.ts\nTested: cd openless-all/app && npm run build\nNot-tested: Manual Style page click flow in packaged Tauri app.\nRelated: https://github.com/appergb/openless/pull/383\nCo-authored-by: OmX <omx@oh-my-codex.dev>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Persistent review updated to latest commit 6341f19

@H-Chris233 H-Chris233 merged commit 4475e02 into Open-Less:beta May 9, 2026
4 checks passed
appergb pushed a commit that referenced this pull request May 10, 2026
CI ci.yml "Verify version sync across all 5 files" 步骤要求 5 处版本号一致:
package.json / package-lock.json (root + nested) / tauri.conf.json /
Cargo.toml / Cargo.lock 的 [openless] 包。上一个 commit (568d30d) 漏改了
package-lock.json 两处 → Linux + macOS CI fail。

修法跟 PR #383 后续 commit 941542c 同形:手动同步两处 'version'
字段到 1.2.24-7。下次正确流程是用 scripts/bump-version.sh 一把过。
@H-Chris233 H-Chris233 deleted the fix/issue-312-style-master-toggle branch May 10, 2026 10:58
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.

[ui][bug] Style 页"总开关"注释与实现不一致 — 注释说留 raw/default 兜底,实际全清空

1 participant