-
Notifications
You must be signed in to change notification settings - Fork 625
fix: sync provider order changes across all tabs #765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -654,8 +654,9 @@ export const useSettingsStore = defineStore('settings', () => { | |||||||||||||||||||||||||||
| const setupProviderListener = () => { | ||||||||||||||||||||||||||||
| // 监听配置变更事件 | ||||||||||||||||||||||||||||
| window.electron.ipcRenderer.on(CONFIG_EVENTS.PROVIDER_CHANGED, async () => { | ||||||||||||||||||||||||||||
| console.log('changed') | ||||||||||||||||||||||||||||
| console.log('Provider changed - updating providers and order') | ||||||||||||||||||||||||||||
| providers.value = await configP.getProviders() | ||||||||||||||||||||||||||||
| await loadSavedOrder() | ||||||||||||||||||||||||||||
| await refreshAllModels() | ||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -1514,6 +1515,7 @@ export const useSettingsStore = defineStore('settings', () => { | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // 强制更新 providers 以触发视图更新 | ||||||||||||||||||||||||||||
| providers.value = [...providers.value] | ||||||||||||||||||||||||||||
| await configP.setProviders(providers.value) | ||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||
|
Comment on lines
1516
to
1519
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sanitize before persisting providers to avoid leaking transient fields Persisting providers.value directly may write large/ephemeral fields (e.g., websites) to config, which other code paths explicitly strip before saving. Save a sanitized, raw copy instead. Apply this diff: - // 强制更新 providers 以触发视图更新
- providers.value = [...providers.value]
- await configP.setProviders(providers.value)
+ // 强制更新 providers 以触发视图更新
+ providers.value = [...providers.value]
+ // Persist a sanitized snapshot (strip transient fields like `websites`)
+ const sanitizedProviders = providers.value.map((p) => {
+ const raw = toRaw(p) as any
+ const { websites, ...rest } = raw
+ return rest
+ })
+ await configP.setProviders(sanitizedProviders)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| console.error('Failed to update provider order:', error) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Wrap async IPC handler in try–catch and use structured logging
Per the repo’s TS guidelines, guard presenter calls with try–catch and log with context to avoid unhandled rejections from IPC failures.
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents