fix(renderer): synchronize miniapp settings state and respect region filter#13166
fix(renderer): synchronize miniapp settings state and respect region filter#13166DeJeune merged 1 commit intoCherryHQ:mainfrom
Conversation
DeJeune
left a comment
There was a problem hiding this comment.
Clean, focused fix for the mini app settings region sync issue.
What works well:
- The
useEffectcorrectly syncs local component state when the store data (e.g., region) changes, eliminating the stale-state problem. handleResetMinAppsnow respects region filtering (minappsinstead ofallMinApps), preventing "ghost" apps from appearing after reset.- The store-level write (
updateMinapps(allMinApps)) still preserves all apps correctly since theuseMinappshook handles region-aware merging internally.
Minor notes (non-blocking):
- The
useEffectduplicates theuseStateinitializers on first mount — harmless but could be skipped with a ref guard if desired.
LGTM — approving.
| // 当 store 数据变化时(例如切换地区)同步本地状态 | ||
| useEffect(() => { | ||
| setVisibleMiniApps(minapps) | ||
| setDisabledMiniApps(disabled || []) |
There was a problem hiding this comment.
Nit: The useEffect also runs on initial mount, duplicating the work already done by the useState initializers on lines 52–53. This is harmless since React batches the updates, but if you wanted to be explicit you could skip the first render with a ref guard. Not blocking — just a note.
| const handleResetMinApps = useCallback(() => { | ||
| setVisibleMiniApps(allMinApps) | ||
| // 仅重置为当前地区可见的应用,以避免混淆 | ||
| setVisibleMiniApps(minapps) | ||
| setDisabledMiniApps([]) |
There was a problem hiding this comment.
Observation: handleResetMinApps now sets local state to minapps (region-filtered) but still dispatches updateMinapps(allMinApps) to the store (all apps). This is actually correct — the store preserves all apps, and the useEffect above will re-sync local state to the region-filtered view after the store updates. Just confirming this asymmetry is intentional and works as expected.
GeorgeDong32
left a comment
There was a problem hiding this comment.
LGTM! This PR correctly fixes the MiniApp settings state synchronization issue. The useEffect hook properly syncs local state with Redux store when region changes, and the handleResetMinApps fix respects region filtering. Clean, minimal changes following the project architecture.
| useEffect(() => { | ||
| setVisibleMiniApps(minapps) | ||
| setDisabledMiniApps(disabled || []) | ||
| }, [minapps, disabled]) |
There was a problem hiding this comment.
是否可以总是使用store state作为SSOT,而不使用组件本地状态+useEffect同步?
### What this PR does This is a release PR for **Cherry Studio v1.7.23**. **Changes included:** - Bump version from 1.7.22 to 1.7.23 - Update release notes with user-facing bug fixes ### Release Notes <!--LANG:en--> Cherry Studio 1.7.23 - Bug Fixes 🐛 Bug Fixes - [Selection] Fix app crash on Windows when closing action window - [MiniApp] Fix settings state synchronization and region filter consistency - [Plugin Browser] Make detail modal text selectable and improve search experience - [Tools] Fix approval card not showing for builtin and provider tools ### Included Commits - fix(Selection): prevent Windows crash when closing transparent action window (#13177) - fix(renderer): synchronize miniapp settings state and respect region filter (#13166) - fix: improve plugin browser UX with three small fixes (#13153) - fix: show approval card for builtin and provider tools (#13154) - fix: support esc to close modal (#13159) - fix: open external editor in new window instead of reusing existing one (#13160) - fix: render directory Select options with optionRender (#13152) - refactor: replace static pnpm patch with postinstall script for claude-agent-sdk (#13139) - feat: add dev-only message data inspection button (#13142) - docs: add review workflow to CLAUDE.md (#13145) - chore(deps): upgrade @uiw/codemirror packages to 4.25.7 (#13149) - fix(ci): skip CI on PR body/title edits, only re-run on base branch changes (#13150) ### Review Checklist - [ ] Review generated release notes in `electron-builder.yml` - [ ] Verify version bump in `package.json` - [ ] CI passes - [ ] Merge to trigger release build ### Release note ```release-note Cherry Studio 1.7.23 - Bug Fixes 🐛 Bug Fixes - [Selection] Fix app crash on Windows when closing action window - [MiniApp] Fix settings state synchronization and region filter consistency - [Plugin Browser] Make detail modal text selectable and improve search experience - [Tools] Fix approval card not showing for builtin and provider tools ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: suyao <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
What this PR does
Before this PR:
After this PR:
Added a
useEffecthook inMiniAppSettings.tsxto synchronize local state with theuseMinappshook whenever the underlying store data or region settings change.
Refactored
handleResetMinAppsto respect the current region's filtering rules, ensuring UI consistency.Updated relevant code comments to Chinese as requested for better local team understanding.
Visual Evidence (Bug Demonstration)
Before Clicking "Reset" (Restricted apps hidden):
After Clicking "Reset" (Ghost apps appear):

Why we need it and why it was done in this way
Users in different regions (CN vs. Global) expect a consistent experience. The prior implementation had a disconnect between the persistent data layer and the configuration UI. By enforcing state synchronization at the component level, we eliminate "ghost" icons and ensure the settings UI always matches the actual application state.
Checklist
PR: The PR description is expressive enough and will help future contributors
Code: Write code that humans can understand and Keep it simple
Self-review: I have reviewed my own code
Release note