mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
fix: migrate and persist modeApiConfigs for per-mode API profiles (#3071)
This commit is contained in:
parent
bf38b830b8
commit
01fec4c1db
2 changed files with 19 additions and 2 deletions
|
|
@ -79,6 +79,18 @@ export class ProviderSettingsManager {
|
|||
|
||||
let isDirty = false
|
||||
|
||||
// Migrate existing installs to have per-mode API config map
|
||||
if (!providerProfiles.modeApiConfigs) {
|
||||
// Use the currently selected config for all modes initially
|
||||
const currentName = providerProfiles.currentApiConfigName
|
||||
const seedId =
|
||||
providerProfiles.apiConfigs[currentName]?.id ??
|
||||
Object.values(providerProfiles.apiConfigs)[0]?.id ??
|
||||
this.defaultConfigId
|
||||
providerProfiles.modeApiConfigs = Object.fromEntries(modes.map((m) => [m.slug, seedId]))
|
||||
isDirty = true
|
||||
}
|
||||
|
||||
// Ensure all configs have IDs.
|
||||
for (const [_name, apiConfig] of Object.entries(providerProfiles.apiConfigs)) {
|
||||
if (!apiConfig.id) {
|
||||
|
|
@ -340,8 +352,12 @@ export class ProviderSettingsManager {
|
|||
try {
|
||||
return await this.lock(async () => {
|
||||
const providerProfiles = await this.load()
|
||||
const { modeApiConfigs = {} } = providerProfiles
|
||||
modeApiConfigs[mode] = configId
|
||||
// Ensure the per-mode config map exists
|
||||
if (!providerProfiles.modeApiConfigs) {
|
||||
providerProfiles.modeApiConfigs = {}
|
||||
}
|
||||
// Assign the chosen config ID to this mode
|
||||
providerProfiles.modeApiConfigs[mode] = configId
|
||||
await this.store(providerProfiles)
|
||||
})
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ describe("ProviderSettingsManager", () => {
|
|||
fuzzyMatchThreshold: 1.0,
|
||||
},
|
||||
},
|
||||
modeApiConfigs: {},
|
||||
migrations: {
|
||||
rateLimitSecondsMigrated: true,
|
||||
diffSettingsMigrated: true,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue