Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 25, 2025

Description

This PR implements comprehensive support for Qwen's advanced coding models with enterprise-grade OAuth2 authentication, based on PR #5766 from the Cline repository.

Features

🔐 OAuth2 Authentication

  • Secure OAuth2 authentication flow with automatic token refresh
  • 30-second buffer before token expiry for seamless renewal
  • Configurable OAuth credential paths with home directory (~/) expansion support
  • Automatic retry on 401 responses with token refresh

🤖 Model Support

  • qwen3-coder-plus: High-performance coding model with 1M context window for large codebases
  • qwen3-coder-flash: Fast coding model with 1M context window optimized for speed

🎨 UI Integration

  • New settings panel for Qwen Code configuration
  • OAuth credential path input with validation
  • Setup instructions and documentation links
  • Seamless integration with existing provider selection UI

🛠️ Technical Implementation

  • New QwenCodeHandler class extending BaseProvider
  • Token caching with expiry management
  • Robust error handling for OAuth failures
  • Full TypeScript support with proper type definitions

Changes

Added

  • src/api/providers/qwen-code.ts - Core OAuth provider implementation
  • packages/types/src/providers/qwen-code.ts - Model definitions and types
  • webview-ui/src/components/settings/providers/QwenCode.tsx - UI component for settings

Modified

  • packages/types/src/provider-settings.ts - Added qwen-code to provider names and schemas
  • packages/types/src/providers/index.ts - Exported Qwen Code models and types
  • src/api/index.ts - Integrated QwenCodeHandler into API routing
  • src/api/providers/index.ts - Exported QwenCodeHandler
  • webview-ui/src/components/settings/ApiOptions.tsx - Added Qwen Code to provider options
  • webview-ui/src/components/settings/providers/index.ts - Exported QwenCode component
  • webview-ui/src/components/ui/hooks/useSelectedModel.ts - Added Qwen Code model selection support
  • webview-ui/src/utils/validate.ts - Added validation for Qwen Code OAuth path

Testing

  • ✅ All existing tests pass
  • ✅ Build completes successfully
  • ✅ Linting passes without warnings
  • ✅ TypeScript compilation successful

Documentation

The implementation includes:

  • Inline code documentation
  • Setup instructions in the UI
  • Links to official Qwen documentation

Breaking Changes

None - this is a purely additive feature that doesn't affect existing functionality.

Related Issues

Checklist

  • Code follows the project's style guidelines
  • Self-review of code completed
  • Comments added for complex logic
  • Documentation updated
  • No new warnings introduced
  • Tests pass locally
  • Dependent changes merged and published

Important

Adds Qwen Code CLI API support with OAuth authentication, including UI and validation updates.

  • Behavior:
    • Adds OAuth2 authentication for Qwen Code CLI API with automatic token refresh and retry on 401 responses.
    • Supports qwen3-coder-plus and qwen3-coder-flash models.
  • UI Integration:
    • Adds settings panel for Qwen Code configuration in QwenCode.tsx.
    • Validates OAuth credential path input.
  • Validation:
    • Updates validate.ts to include qwen-code OAuth path validation.
  • Localization:
    • Adds qwenCodeOauthPath validation message in multiple locale files.

This description was created by Ellipsis for 70f3bbe. You can customize this summary. It will automatically update as commits are pushed.

- Add QwenCodeHandler with OAuth2 authentication flow
- Support automatic token refresh with 30-second buffer
- Add configurable OAuth credential paths (supports ~/ expansion)
- Integrate Qwen Code models (qwen3-coder-plus, qwen3-coder-flash)
- Add UI components for OAuth path configuration
- Include setup instructions and documentation links
- Add validation for required OAuth credentials

Implements comprehensive support for Qwen advanced coding models with
enterprise-grade OAuth2 authentication, based on PR #5766 from Cline repository.
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 25, 2025 00:16
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. documentation Improvements or additions to documentation enhancement New feature or request labels Aug 25, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing my own code is like debugging in a mirror - everything looks backwards and I still can't find the bug.


return response.choices[0]?.message.content || ""
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical: No test coverage for this OAuth provider implementation. We need comprehensive tests for:

  • Token refresh logic
  • Authentication failures
  • API retry mechanism
  • Credential file operations

Could we add tests similar to other providers in the codebase?

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 25, 2025
- Add missing qwenCodeOauthPath validation message to all 18 language files
- Ensures proper error messages for OAuth path validation
- Translations are culturally appropriate for each locale
- Changed value prop to show empty string instead of default path
- Default path only appears as placeholder
- On blur, if field is empty, it sets the default path in config
- Removed redundant element.value assignment in handleBlur

This prevents the default path from immediately appearing while typing/deleting
- Replaced all inline styles with Tailwind utility classes
- Uses consistent text sizing with text-xs
- Uses VSCode color variables through Tailwind classes
- Maintains same visual appearance with cleaner code
- Import qwenCodeModels from @roo-code/types
- Add qwen-code to MODELS_BY_PROVIDER mapping
- Add Qwen Code to PROVIDERS list for UI dropdown

This fixes the issue where Qwen Code was not appearing as a selectable provider in the settings UI
- Add mutex/promise-based deduplication to prevent race conditions in token refresh
- Add error handling for credential file write operations
- Ensure only one token refresh happens at a time for concurrent requests
- Continue with refreshed token in memory if file write fails

Addresses review feedback from PR #7380
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Aug 25, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 25, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Aug 25, 2025
…tion

- Added qwen-code to the list of providers in checkExistKey that can proceed without API keys
- This allows qwen-code to use its default OAuth path (~/.qwen/oauth_creds.json) without blocking the Welcome View
- Treats qwen-code similar to claude-code and other local authentication providers
- Import qwenCodeModels from providers
- Remove qwen-code from the Exclude list in MODELS_BY_PROVIDER type
- Add qwen-code entry with its models to MODELS_BY_PROVIDER object
@cte cte merged commit 2e99d5b into main Aug 25, 2025
10 checks passed
@cte cte deleted the feature/qwen-code-oauth-support branch August 25, 2025 17:43
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Aug 25, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 25, 2025
@evinelias
Copy link

evinelias commented Aug 26, 2025

Thank you for merging my PR. Means a lot! ❤🙏🏻

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

Labels

documentation Improvements or additions to documentation enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants