Allow API Key users to select models directly when configured#2412
Allow API Key users to select models directly when configured#2412Mingholy wants to merge 2 commits into
Conversation
…ured When users select API Key auth option and have already configured models in modelProviders, open ModelDialog directly instead of just showing configuration instructions. This allows new users using custom API keys to complete authentication without going through OAuth or Coding Plan first. - Add openModelDialog to UIActionsContext - Check for configured USE_OPENAI models in AuthDialog - Keep AuthDialog open in background so users return to it after closing ModelDialog, ensuring unauthenticated users cannot skip auth Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
📋 Review SummaryThis PR addresses a gap in the authentication flow where users with pre-configured API keys couldn't directly select models without first authenticating via OAuth or Coding Plan. The implementation is minimal and focused, adding 🔍 General Feedback
🎯 Specific Feedback🟡 High
🟢 Medium
🔵 Low
✅ Highlights
|
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
… auth - Add closeAuthDialog() to close AuthDialog via React state after successful model switch - Fix handleModelChange to call refreshAuth for initial auth (no contentGeneratorConfig) Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
| // Check if there are already configured models for USE_OPENAI | ||
| const configuredModels = | ||
| config?.getAllConfiguredModels([AuthType.USE_OPENAI]) ?? []; | ||
| if (configuredModels.length > 0) { |
There was a problem hiding this comment.
[Critical] API_KEY currently treats any USE_OPENAI configured model as eligible for the direct model-picker flow, but Coding Plan models are also stored under USE_OPENAI. If a user only has Coding Plan models configured, selecting API Key can still open ModelDialog instead of the custom API-key guidance flow. Please filter out Coding Plan entries (for example with isCodingPlanConfig(baseUrl, envKey)) before deciding to call openModelDialog().
| if (configuredModels.length > 0) { | |
| const configuredModels = | |
| (config?.getAllConfiguredModels([AuthType.USE_OPENAI]) ?? []).filter( | |
| (model) => !isCodingPlanConfig(model.baseUrl, model.envKey), | |
| ); |
— gpt-5.4 via Qwen Code /review
TLDR
Allow API Key users to select models directly when
modelProvidersare already configured. Previously, selecting "API Key" only showed static configuration instructions, forcing users to authenticate via OAuth or Coding Plan first.Dive Deeper
The authentication flow had a gap: users who configured their own API keys in
settings.jsoncouldn't complete authentication without first using OAuth or Coding Plan. The "API Key" option only displayed documentation links without actionable next steps.Changes made:
openModelDialogtoUIActionsContextto expose the model selection dialog to auth componentsAuthDialogto detect pre-configuredUSE_OPENAImodels when "API Key" is selectedModelDialogdirectly for immediate model selectionAuthDialogremains open in the background (via DialogManager's z-order), ensuring users return to authentication if they close the model dialog without completing authThis preserves the security requirement that unauthenticated users cannot skip auth, while allowing properly configured users to proceed directly to model selection.
Reviewer Test Plan
settings.jsonundermodelProviders.USE_OPENAI:{ "modelProviders": { "USE_OPENAI": [ { "id": "my-model", "label": "My Custom Model", "baseUrl": "https://api.example.com/v1", "envKey": "MY_API_KEY" } ] } }Set the environment variable:
export MY_API_KEY=your-api-keyStart Qwen Code without being authenticated
Select "API Key" authentication option
Expected: ModelDialog opens showing your configured model instead of just showing documentation
Select a model and verify authentication completes successfully
Edge case: Close ModelDialog without selecting a model - should return to AuthDialog
Testing Matrix
Linked issues / bugs