fix: migration for missing providers … (#10438)

chore: bump version to 1.6.3 and add migration for missing providers #10425

fix: #10425

- Updated the version from 158 to 159 in the persisted reducer configuration.
- Implemented a migration function to ensure missing system providers are added to the state during the migration to version 159, enhancing state consistency.
This commit is contained in:
亢奋猫 2025-10-08 19:28:08 +08:00 committed by GitHub
parent 504531d4d5
commit 65d066cbef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -67,7 +67,7 @@ const persistedReducer = persistReducer(
{
key: 'cherry-studio',
storage,
version: 158,
version: 159,
blacklist: ['runtime', 'messages', 'messageBlocks', 'tabs'],
migrate
},

View File

@ -85,6 +85,15 @@ function addProvider(state: RootState, id: string) {
}
}
// Fix missing provider
function fixMissingProvider(state: RootState) {
SYSTEM_PROVIDERS.forEach((p) => {
if (!state.llm.providers.find((provider) => provider.id === p.id)) {
state.llm.providers.push(p)
}
})
}
// add ocr provider
function addOcrProvider(state: RootState, provider: BuiltinOcrProvider) {
if (!state.ocr.providers.find((p) => p.id === provider.id)) {
@ -2553,6 +2562,7 @@ const migrateConfig = {
'159': (state: RootState) => {
try {
addProvider(state, 'ovms')
fixMissingProvider(state)
return state
} catch (error) {
logger.error('migrate 159 error', error as Error)