fix: allow correcting API key after entering an invalid one for xAI/Gemini (#11854)
* fix: update existing model API key instead of creating duplicate when re-adding When a user enters an invalid API key for a provider (e.g. xAI or Gemini) and later tries to add the same model again with a correct key, the addModel function previously either skipped (exact match) or created a duplicate with a numbered suffix. Now it detects models with the same provider and model name and updates the existing entry in-place, allowing users to correct their API key by re-adding the model. Closes #9995 * fix: update existing provider models in setupProviderConfig instead of appending duplicates When re-entering an API key through the onboarding flow, setupProviderConfig previously appended new model entries without removing the old ones with the invalid key. Now it filters out existing models with the same hub slug before adding the new ones, ensuring the user ends up with a single set of correctly-configured models. * fix: narrow addModel update to only change apiKey on existing models Avoid overwriting user-customized fields (apiBase, completionOptions, title, etc.) when updating an existing model. Only the apiKey is changed. * fix: merge API key into existing models instead of replacing or duplicating Address review feedback: update only the API key on existing model entries to preserve user-customized fields (roles, options, etc.). - setupProviderConfig: merge `with` into existing hub-slug models, only append entries for slugs not yet in config - addModel: narrow update to only set apiKey on matching provider+model * fix: resolve TS2339 error for apiKey on YAML config model union type The YAML config model type is a union that includes uses-based models without an apiKey property. Use 'provider' in m guard and cast to any for the assignment. * style: fix prettier formatting * fix: show toast and open config when model already exists, merge API keys in onboarding When a user tries to add a model that already exists (e.g. after entering an invalid API key), show a warning toast and open the config file so they can update the key directly. Also fix setupProviderConfig to merge API keys into existing models instead of creating duplicates. Closes #9995 * refactor: remove all :any type annotations from changed code Use 'uses' in m type guards to narrow the union type instead of casting to any. * fix: use modelsByRole instead of non-existent models property on ContinueConfig
D
Dallin Romney committed
9396142fb0759bf47fef615380e8e41245727eef
Parent: 3a997fe
Committed by GitHub <noreply@github.com>
on 3/26/2026, 4:32:35 AM