Add Mistral AI API provider support#1013
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughMistral API models, configuration defaults, provider mappings, built-in provider registration, legacy model resolution, OpenAI-compatible routing, API-key setup, and adapter tests are added. ChangesMistral API Provider
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Session
participant ProviderRegistry
participant OpenAICompatibleAPI
participant MistralAPI
Session->>ProviderRegistry: identify Mistral model and provider
ProviderRegistry->>OpenAICompatibleAPI: route session as compatible
OpenAICompatibleAPI->>MistralAPI: send chat-completions request
MistralAPI-->>OpenAICompatibleAPI: return response
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (8 files in current PR diff)
Note: This review covers the authoritative current PR diff (PR head vs Previous Review Summaries (13 snapshots, latest commit 3cdbfd2)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 3cdbfd2)Status: No Issues Found | Recommendation: Merge Previous CRITICAL at Incremental changes (this review)
No new issues found in the changed code. Files Reviewed (2 files in incremental diff)
Previous review (commit dbada74)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)CRITICAL
Files Reviewed (1 file in incremental diff)
Previous review (commit 0f93a82)Status: No Issues Found | Recommendation: Merge Incremental Review Notes (since 6237294)Incremental diff re-verified against current HEAD
No new defects introduced; all changed logic is internally consistent and covered by tests. The malformed-secret deletion is guarded by a value-equality check against Files Reviewed (7 files in incremental diff)
Previous review (commit 6237294)Status: No Issues Found | Recommendation: Merge Incremental Review Notes (since f4c3e30)Incremental diff re-verified against current HEAD
The change resolves the previously flagged qodo finding (disabled-provider reference handling). It now keeps a disabled custom provider referenced in The prior review's remaining bot/provider-scope findings (secret-slot collision at provider-registry.mjs:39, Mistral label localization at config/index.mjs:244, Mistral preset count at config/index.mjs:781, and providerId canonicalization at config/index.mjs:1555) were outside this incremental diff and remain resolved/addressed as of the prior review; they are not duplicated here. Files Reviewed (2 files in incremental diff)
Previous review (commit f4c3e30)Status: No Issues Found | Recommendation: Merge Files Reviewed (16 files)
Incremental Review Notes (vs
|
| Severity | Count |
|---|---|
| CRITICAL | 0 |
| WARNING | 0 |
| SUGGESTION | 0 |
Files Reviewed (4 files in incremental diff)
src/config/index.mjs- Mistral builtin provider ID reservation + one-time secret migration;completedBuiltinProviderIdMigrationstracking; session provider-id remap; import re-run hooksrc/popup/sections/import-data-cleanup.mjs- ResetcompletedBuiltinProviderIdMigrationson legacy provider-state imports so migration re-runstests/unit/config/migrate-mistral-provider.test.mjs- New comprehensive migration test suite (9 cases)tests/unit/popup/import-data-cleanup.test.mjs- New import-cleanup migration tests
Notes
The new migration logic for reserving the mistral builtin provider ID (previously a valid custom provider id) is carefully bounded: it uses providerSecretSnapshot so decisions are based on pre-mutation secrets, distinguishes raw (Mistral) vs normalized (mistral) secret slots, preserves a real builtin mistralApiKey when it differs from a colliding custom secret, and only clears the builtin slot/legacy field when the value actually belonged to the custom provider. Ambiguous multi-rename resolution matches by canonicalized chat-completions URL. The behavior is covered by an extensive new test suite that also asserts idempotency on re-run.
Previous review (commit d240a40)
Status: No Issues Found | Recommendation: Merge
All previously raised findings remain resolved, and the incremental changes in this revision (d240a40) introduce no new issues.
Overview
| Severity | Count |
|---|---|
| CRITICAL | 0 |
| WARNING | 0 |
| SUGGESTION | 0 |
Files Reviewed (4 files in incremental diff)
src/config/index.mjs- Mistral builtin provider ID reservation + one-time secret migration;completedBuiltinProviderIdMigrationstracking; session provider-id remap; import re-run hooksrc/popup/sections/import-data-cleanup.mjs- ResetcompletedBuiltinProviderIdMigrationson legacy provider-state imports so migration re-runstests/unit/config/migrate-mistral-provider.test.mjs- New comprehensive migration test suite (9 cases)tests/unit/popup/import-data-cleanup.test.mjs- New import-cleanup migration tests
Notes
The new migration logic for reserving the mistral builtin provider ID (previously a valid custom provider id) is carefully bounded: it uses providerSecretSnapshot so decisions are based on pre-mutation secrets, distinguishes raw (Mistral) vs normalized (mistral) secret slots, preserves a real builtin mistralApiKey when it differs from a colliding custom secret, and only clears the builtin slot/legacy field when the value actually belonged to the custom provider. Ambiguous multi-rename resolution matches by canonicalized chat-completions URL. The behavior is covered by an extensive new test suite that also asserts idempotency on re-run.
Previous review (commit cc6b85f)
Status: No Issues Found | Recommendation: Merge
All previously raised findings have been resolved in the current revision (32d17df):
- The Mistral default-enablement mismatch is now consistent — only
mistralMediumLatestis added toactiveApiModes(config/index.mjs:776), matching the updated PR description and thedefaultConfig enables only Mistral AI Medium latesttest. - The
resolveProviderIdFromLegacyModelNameMistral branch now uses braces (provider-registry.mjs:122-124), matching surrounding style. - The Mistral adapter test now uses a provider-specific
expectedApiKey: 'mistral-key'(thin-adapters.test.mjs:307).
Files Reviewed (8 files)
src/background/index.mjssrc/config/index.mjssrc/config/openai-provider-mappings.mjssrc/popup/sections/GeneralPart.jsxsrc/services/apis/provider-registry.mjstests/unit/config/config-predicates.test.mjstests/unit/services/apis/provider-registry.test.mjstests/unit/services/apis/thin-adapters.test.mjs
Previous review (commit 32d17df)
Status: No Issues Found | Recommendation: Merge
All previously raised findings have been resolved in the current revision (32d17df):
- The Mistral default-enablement mismatch is now consistent — only
mistralMediumLatestis added toactiveApiModes(config/index.mjs:776), matching the updated PR description and thedefaultConfig enables only Mistral AI Medium latesttest. - The
resolveProviderIdFromLegacyModelNameMistral branch now uses braces (provider-registry.mjs:122-124), matching surrounding style. - The Mistral adapter test now uses a provider-specific
expectedApiKey: 'mistral-key'(thin-adapters.test.mjs:307).
Files Reviewed (8 files)
src/background/index.mjssrc/config/index.mjssrc/config/openai-provider-mappings.mjssrc/popup/sections/GeneralPart.jsxsrc/services/apis/provider-registry.mjstests/unit/config/config-predicates.test.mjstests/unit/services/apis/provider-registry.test.mjstests/unit/services/apis/thin-adapters.test.mjs
Previous review (commit 41a3dfc)
Status: 1 Issue Found | Recommendation: Address before merge
Overview
| Severity | Count |
|---|---|
| CRITICAL | 0 |
| WARNING | 0 |
| SUGGESTION | 1 |
Issue Details (click to expand)
SUGGESTION
| File | Line | Issue |
|---|---|---|
src/config/index.mjs |
776 | PR description claims all three Mistral presets are enabled by default, but only mistralMediumLatest is added to activeApiModes (test asserts only Medium is enabled). Either enable all three or correct the description. |
Files Reviewed (8 files)
src/background/index.mjs- 0 issuessrc/config/index.mjs- 1 issuesrc/config/openai-provider-mappings.mjs- 0 issuessrc/popup/sections/GeneralPart.jsx- 0 issuessrc/services/apis/provider-registry.mjs- 0 new issues (1 pre-existing Copilot comment on brace style at line 123)tests/unit/config/config-predicates.test.mjs- 0 issuestests/unit/services/apis/provider-registry.test.mjs- 0 issuestests/unit/services/apis/thin-adapters.test.mjs- 0 new issues (1 pre-existing Copilot comment on test apiKey at line 58)
Fix these issues in Kilo Cloud
Previous review (commit 888c567)
Status: No Issues Found | Recommendation: Merge
Files Reviewed (8 files)
src/background/index.mjssrc/config/index.mjssrc/config/openai-provider-mappings.mjssrc/popup/sections/GeneralPart.jsxsrc/services/apis/provider-registry.mjstests/unit/config/config-predicates.test.mjstests/unit/services/apis/provider-registry.test.mjstests/unit/services/apis/thin-adapters.test.mjs
Reviewed by hy3:free · Input: 88.7K · Output: 9.9K · Cached: 1.9M
PR Summary by QodoAdd built-in Mistral AI OpenAI-compatible provider and model presets
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Code Review by Qodo
1.
|
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds Mistral AI as a built-in OpenAI-compatible API provider within the extension’s provider registry/config system, including model aliases and default enablement so users can select it from the existing API mode UI.
Changes:
- Register a new built-in provider (
mistral) with base URL routing and legacy-session provider resolution. - Add three Mistral “-latest” model presets, group them under
mistralApiModelKeys, and enable them by default. - Wire provider-key mapping/setup link behavior and add focused unit test coverage for provider resolution + request construction.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/services/apis/thin-adapters.test.mjs | Adds an adapter-case verifying Mistral base URL + auth header propagation through the OpenAI-compat layer. |
| tests/unit/services/apis/provider-registry.test.mjs | Adds unit coverage for provider ID resolution and request URL/key resolution for Mistral. |
| tests/unit/config/config-predicates.test.mjs | Adds predicate + default-config assertions for the new Mistral model group/keys. |
| src/services/apis/provider-registry.mjs | Registers built-in Mistral provider and supports resolving it from legacy model/session shapes. |
| src/popup/sections/GeneralPart.jsx | Adds the Mistral API key setup link for the popup UI. |
| src/config/openai-provider-mappings.mjs | Maps Mistral provider ID to its legacy key field and to the OpenAI-compatible apiMode group. |
| src/config/index.mjs | Defines mistralApiModelKeys, model entries/aliases, default config key field, default enablement, and predicate. |
| src/background/index.mjs | Treats Mistral sessions as OpenAI-compatible for background request routing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
✅ Action performedReview finished.
|
888c567 to
41a3dfc
Compare
41a3dfc to
32d17df
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32d17df1e4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Code review by qodo was updated up to the latest commit 32d17df |
32d17df to
cc6b85f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cc6b85fe50
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Code review by qodo was updated up to the latest commit cc6b85f |
cc6b85f to
d240a40
Compare
|
Code review by qodo was updated up to the latest commit f4c3e30 |
f4c3e30 to
6237294
Compare
|
Code review by qodo was updated up to the latest commit 6237294 |
6237294 to
0f93a82
Compare
|
Code review by qodo was updated up to the latest commit 0f93a82 |
0f93a82 to
dbada74
Compare
|
Code review by qodo was updated up to the latest commit dbada74 |
dbada74 to
3cdbfd2
Compare
|
Code review by qodo was updated up to the latest commit 3cdbfd2 |
Register Mistral AI as a built-in OpenAI-compatible chat provider and expose current flagship model presets. Wire shared API-key storage, request routing, setup links, and focused coverage for the Mistral API endpoint.
3cdbfd2 to
d6f21e2
Compare
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
tests/unit/services/apis/provider-registry.test.mjs (1)
44-47: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winExercise all legacy Mistral preset keys.
The test name covers Mistral preset keys, but only
mistralMediumLatestis asserted. AddmistralSmallLatestandmistralLargeLatestchecks so every newly supported legacy preset is verified.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/services/apis/provider-registry.test.mjs` around lines 44 - 47, Update the resolveProviderIdForSession test to cover all newly supported legacy Mistral presets by adding assertions for mistralSmallLatest and mistralLargeLatest, while preserving the existing mistralMediumLatest and custom-key checks.tests/unit/config/config-predicates.test.mjs (1)
228-234: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the
apiModebranch of the predicate.This test only supplies
modelName, whileisUsingMistralApiModelprioritizesapiModewhen present. Add assertions using{ apiMode: { groupName: 'mistralApiModelKeys', itemName: modelName } }so a regression in session routing cannot pass unnoticed.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/config/config-predicates.test.mjs` around lines 228 - 234, Extend the isUsingMistralApiModel test to cover inputs containing apiMode, using groupName 'mistralApiModelKeys' and each modelName as itemName, and assert they return true. Also assert a non-Mistral apiMode value returns false, preserving the existing modelName coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/unit/config/config-predicates.test.mjs`:
- Around line 228-234: Extend the isUsingMistralApiModel test to cover inputs
containing apiMode, using groupName 'mistralApiModelKeys' and each modelName as
itemName, and assert they return true. Also assert a non-Mistral apiMode value
returns false, preserving the existing modelName coverage.
In `@tests/unit/services/apis/provider-registry.test.mjs`:
- Around line 44-47: Update the resolveProviderIdForSession test to cover all
newly supported legacy Mistral presets by adding assertions for
mistralSmallLatest and mistralLargeLatest, while preserving the existing
mistralMediumLatest and custom-key checks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9613f7c2-dbc5-4dfb-8fa1-a319fc2f013e
📒 Files selected for processing (8)
src/background/index.mjssrc/config/index.mjssrc/config/openai-provider-mappings.mjssrc/popup/sections/GeneralPart.jsxsrc/services/apis/provider-registry.mjstests/unit/config/config-predicates.test.mjstests/unit/services/apis/provider-registry.test.mjstests/unit/services/apis/thin-adapters.test.mjs
🚧 Files skipped from review as they are similar to previous changes (4)
- src/popup/sections/GeneralPart.jsx
- tests/unit/services/apis/thin-adapters.test.mjs
- src/config/openai-provider-mappings.mjs
- src/services/apis/provider-registry.mjs
|
Code review by qodo was updated up to the latest commit d6f21e2 |
Summary
mistral-medium-latest,mistral-small-latest, andmistral-large-latest, with Mistral Medium enabled by default.Validation
npm test(795 tests passed)npm run lintnpm run buildManual browser smoke testing was not run because a browser extension runtime is not available in this environment.