Skip to content

Allow API Key users to select models directly when configured#52

Open
BingqingLyu wants to merge 2 commits into
mainfrom
pr-2412-mingholy-fix-api-key-auth
Open

Allow API Key users to select models directly when configured#52
BingqingLyu wants to merge 2 commits into
mainfrom
pr-2412-mingholy-fix-api-key-auth

Conversation

@BingqingLyu

@BingqingLyu BingqingLyu commented Apr 27, 2026

Copy link
Copy Markdown
Owner

TLDR

Allow API Key users to select models directly when modelProviders are 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.json couldn't complete authentication without first using OAuth or Coding Plan. The "API Key" option only displayed documentation links without actionable next steps.

Changes made:

  • Added openModelDialog to UIActionsContext to expose the model selection dialog to auth components
  • Modified AuthDialog to detect pre-configured USE_OPENAI models when "API Key" is selected
  • When models are detected, open ModelDialog directly for immediate model selection
  • AuthDialog remains open in the background (via DialogManager's z-order), ensuring users return to authentication if they close the model dialog without completing auth

This preserves the security requirement that unauthenticated users cannot skip auth, while allowing properly configured users to proceed directly to model selection.

Reviewer Test Plan

  1. Configure a custom model in settings.json under modelProviders.USE_OPENAI:
{
  "modelProviders": {
    "USE_OPENAI": [
      {
        "id": "my-model",
        "label": "My Custom Model",
        "baseUrl": "https://api.example.com/v1",
        "envKey": "MY_API_KEY"
      }
    ]
  }
}
  1. Set the environment variable: export MY_API_KEY=your-api-key

  2. Start Qwen Code without being authenticated

  3. Select "API Key" authentication option

  4. Expected: ModelDialog opens showing your configured model instead of just showing documentation

  5. Select a model and verify authentication completes successfully

  6. Edge case: Close ModelDialog without selecting a model - should return to AuthDialog

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

Mingholy and others added 2 commits March 16, 2026 12:06
…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>
… 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>
@BingqingLyu BingqingLyu added conflicting-group-1 conflicting-group-1 Conflicting PR group 1 — review as a batch conflicting-pr Shares at least one cross-PR dependency with other PRs and removed conflicting-pr labels May 7, 2026
@BingqingLyu

BingqingLyu commented May 7, 2026

Copy link
Copy Markdown
Owner Author

Conflict Group 1

This PR shares modified functions with 9 other PR(s): #100, #107, #109, #113, #114, #117, #46, #88, #96.

These PRs should be reviewed as a batch — merging one may affect the others.

Function File Also modified by
ModelDialog ModelDialog.tsx #46
isToolExecuting AppContainer.tsx #100, #107, #109, #113, #114, #117, #88, #96
graph LR
    PR52["PR #52"]
    FModelDialog_7258["ModelDialog<br>ModelDialog.tsx"]
    PR52 -->|modifies| FModelDialog_7258
    PR46["PR #46"]
    PR46 -->|modifies| FModelDialog_7258
    FisToolExecuting_7261["isToolExecuting<br>AppContainer.tsx"]
    PR52 -->|modifies| FisToolExecuting_7261
    PR100["PR #100"]
    PR100 -->|modifies| FisToolExecuting_7261
    PR107["PR #107"]
    PR107 -->|modifies| FisToolExecuting_7261
    PR109["PR #109"]
    PR109 -->|modifies| FisToolExecuting_7261
    PR113["PR #113"]
    PR113 -->|modifies| FisToolExecuting_7261
    PR114["PR #114"]
    PR114 -->|modifies| FisToolExecuting_7261
    PR117["PR #117"]
    PR117 -->|modifies| FisToolExecuting_7261
    PR88["PR #88"]
    PR88 -->|modifies| FisToolExecuting_7261
    PR96["PR #96"]
    PR96 -->|modifies| FisToolExecuting_7261
Loading

Posted by codegraph-ai conflict detection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicting-group-1 Conflicting PR group 1 — review as a batch conflicting-pr Shares at least one cross-PR dependency with other PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants