feat: remember an API key per provider - #8
Merged
Conversation
A single shared key meant switching preset carried the previous provider's credential over. Clearing it didn't help either — the next provider inherited whatever was left in the field, so an OpenAI `sk-…` went out as an Anthropic `x-api-key` and 401'd. Keys now live in a per-provider map. Selecting a provider shows its own key (blank until set), and coming back restores the one already typed. Clearing drops that provider's entry only. Editing the Base URL still flips to Custom, which carries the current key across unless Custom is already keyed. Storage stays sessionStorage-only. The old shared `wingman:apiKey` slot is migrated onto the provider that was active, then dropped.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💭 Why
Switching provider preset kept the previous provider's API key in the field. Clearing it didn't stick either, so an OpenAI
sk-…would go out as an Anthropicx-api-keyand 401. There was no way to get an earlier key back short of re-pasting it.✨ What changed
👤 For users
Pick OpenAI, paste your key, switch to Anthropic: the field is empty instead of preloaded with the wrong key. Switch back to OpenAI and your key is there again.
🔧 For operators
None. Storage stays sessionStorage-only (cleared on tab close), now under
wingman:apiKeys. The oldwingman:apiKeyslot is migrated onto whichever provider was active, then dropped, so an open session doesn't lose its key.📝 Notes
Verified in a browser across all 16 presets' switching paths: key isolation, restore, clear, reload persistence, legacy migration, and the actual outgoing request (Anthropic sends
x-api-key, OpenAI sendsBearer, no cross-contamination).