Add xAI API provider support#1011
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:
📝 WalkthroughWalkthroughAdds xAI Grok API models, provider configuration, API-key mapping, OpenAI-compatible session routing, setup URL handling, provider resolution, and unit-test coverage. ChangesxAI provider integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Session
participant Background
participant OpenAICompatibleAPI
participant XAI
Session->>Background: Select xAI model session
Background->>OpenAICompatibleAPI: Generate answers
OpenAICompatibleAPI->>XAI: Send chat completion request
XAI-->>OpenAICompatibleAPI: Return assistant output
OpenAICompatibleAPI-->>Session: Update conversation record
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 Incremental re-review of PR 1011 against current HEAD ( All prior P2 findings are confirmed resolved in earlier commits and remain fixed in the current code:
The new xAI provider wiring — model keys/presets ( Files Reviewed (8 files in current diff)
Previous Review Summaries (12 snapshots, latest commit d5f235e)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit d5f235e)Status: No Issues Found | Recommendation: Merge Full re-review of all 17 changed files against current HEAD ( All prior P2 findings are confirmed resolved against current code:
New production code — xAI builtin provider registration/presets (provider-registry.mjs:81-88, config/index.mjs), Files Reviewed (17 files)
Previous review (commit 90d783a)Status: No Issues Found | Recommendation: Merge Full re-review of all 17 changed files against current HEAD ( All prior P2 findings are confirmed resolved against current code:
New production code — xAI builtin provider registration/presets (provider-registry.mjs:81-88, config/index.mjs), Files Reviewed (17 files)
Previous review (commit 73328bb)Status: No Issues Found | Recommendation: Merge Full re-review of all 17 changed files against current HEAD ( Prior P2 findings (config migration session write race, duplicate/ambiguous provider-ID mapping, secret drop on rename, diagnostic ignores legacy IDs) were already fixed in earlier commits (
New production code reviewed — xAI builtin provider registration/presets (provider-registry.mjs, config/index.mjs), Files Reviewed (17 files)
Previous review (commit a109bd9)Status: No Issues Found | Recommendation: Merge Full re-review of all 16 changed files against the current HEAD ( Prior P2 findings (config migration session write, duplicate/ambiguous provider-ID mapping, secret drop on rename) were already fixed in earlier commits ( New production code reviewed — xAI builtin provider registration/presets ( Files Reviewed (16 files)
Previous review (commit ad570ab)Status: No Issues Found | Recommendation: Merge The previous incremental base commit ( Prior P2 findings are verified resolved in the current HEAD:
New production code reviewed — xAI builtin provider registration and presets, Files Reviewed (16 files)
Previous review (commit 90a7795)Status: No Issues Found | Recommendation: Merge Incremental review collapsed to a full review because the previous commit ( Prior P2 findings are verified resolved in the current head:
New code reviewed (helpers Files Reviewed (15 files)
Previous review (commit d541947)Status: No Issues Found | Recommendation: Merge Incremental review collapsed to a full review because the previous commit ( Prior P2 findings are verified resolved in the current head:
New code reviewed (helpers Files Reviewed (15 files)
Previous review (commit 58a2730)Status: No Issues Found | Recommendation: Merge Incremental review against the previous run (commit The prior P2/session-write-race and duplicate-provider-ID findings were confirmed addressed by the author in Files Reviewed (2 files)
Previous review (commit b71c520)Status: No Issues Found | Recommendation: Merge Incremental review against the previous run (commit I traced the rename→copy→delete ordering across all changed branches in Files Reviewed (4 files)
Note: the pre-existing discussion on Previous review (commit fa8e341)Status: No Issues Found | Recommendation: Merge Files Reviewed (8 files)
Incremental review against the previous run (commit Previous review (commit 19cb00b)Status: No Issues Found | Recommendation: Merge Files Reviewed (8 files)
Incremental review against the previous run (commit Previous review (commit b90539c)Status: No Issues Found | Recommendation: Merge Files Reviewed (8 files)
Reviewed by hy3:free · Input: 26.7K · Output: 2.1K · Cached: 144K |
PR Summary by QodoAdd xAI as an OpenAI-compatible API provider with Grok presets
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Pull request overview
This PR adds xAI as a built-in OpenAI-compatible API provider so the extension can route chat-completions requests to xAI using the existing OpenAI-compatible infrastructure and store secrets consistently (legacy xaiApiKey + providerSecrets).
Changes:
- Registered a new built-in provider
xaiwith base URLhttps://api.x.ai/v1and/chat/completionspath, including legacy-model-name and apiMode-group resolution. - Added
xaiApiModelKeysmodel group plus Grok 4.5 / 4.3 model presets, and integrated xAI into OpenAI-compatible session detection. - Wired provider-to-secret-field mapping (
xai -> xaiApiKey) and added a provider API-key setup link in the popup.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/services/apis/thin-adapters.test.mjs | Adds coverage ensuring thin adapter resolution includes xAI with expected base URL and key retrieval. |
| tests/unit/services/apis/provider-registry.test.mjs | Adds focused tests for provider registry inclusion, provider-id resolution, and request resolution for xAI (legacy + providerSecrets). |
| tests/unit/config/config-predicates.test.mjs | Adds predicate coverage to ensure xAI API models are detected correctly. |
| src/services/apis/provider-registry.mjs | Registers built-in xai provider and maps legacy model/apiMode identifiers to provider id xai. |
| src/popup/sections/GeneralPart.jsx | Adds xAI API-key setup URL routing in the popup. |
| src/config/openai-provider-mappings.mjs | Adds provider-id mappings for legacy key field (xaiApiKey) and apiMode group (xaiApiModelKeys). |
| src/config/index.mjs | Introduces xaiApiModelKeys, model group entry, Grok presets, default config key field, and isUsingXaiApiModel. |
| src/background/index.mjs | Includes xAI in OpenAI-compatible API session detection for request routing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
✅ Action performedReview finished.
|
b90539c to
19cb00b
Compare
|
Code review by qodo was updated up to the latest commit 19cb00b |
19cb00b to
fa8e341
Compare
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit fa8e341 |
fa8e341 to
b71c520
Compare
|
/agentic_review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b71c5206a3
ℹ️ 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".
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@src/config/index.mjs`:
- Around line 1193-1197: Update the persisted-session remapping flow around
sessionProviderIdRenameLookup so duplicate provider IDs are not removed from the
rename candidates. Preserve the mappings and add session disambiguation based on
each custom session’s URL, matching the existing custom API mode handling, so
legacy sessions resolve to the correct renamed custom provider rather than the
builtin provider.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 01f1a6e8-fd8f-4bfa-9766-ae3514ea27b4
📒 Files selected for processing (11)
src/background/index.mjssrc/config/index.mjssrc/config/openai-provider-mappings.mjssrc/popup/sections/GeneralPart.jsxsrc/popup/sections/import-data-cleanup.mjssrc/services/apis/provider-registry.mjstests/unit/config/config-predicates.test.mjstests/unit/config/migrate-xai-provider.test.mjstests/unit/popup/import-data-cleanup.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 (5)
- tests/unit/services/apis/thin-adapters.test.mjs
- src/popup/sections/GeneralPart.jsx
- src/background/index.mjs
- tests/unit/config/config-predicates.test.mjs
- tests/unit/services/apis/provider-registry.test.mjs
|
Code review by qodo was updated up to the latest commit ad570ab |
ad570ab to
a109bd9
Compare
|
/agentic_review |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/services/apis/provider-registry.mjs:738
matchedConfiguredProviderIdis already canonicalized vianormalizeProviderId(...), but the lookup compares it againstitem.idverbatim. If a stored provider ID isn’t already in canonical form (e.g. imported / legacy configs), this label-based recovery path will fail to find the intended provider even when it exists. Compare using canonicalized IDs (or reusegetProviderById).
const matchedConfiguredProviderId = normalizeProviderId(matchedConfiguredApiMode?.providerId)
if (matchedConfiguredProviderId) {
const matchedConfiguredProvider = customProviders.find(
(item) => item.enabled !== false && item.id === matchedConfiguredProviderId,
)
|
Code review by qodo was updated up to the latest commit a109bd9 |
a109bd9 to
73328bb
Compare
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 73328bb |
73328bb to
90d783a
Compare
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 90d783a |
90d783a to
d5f235e
Compare
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit d5f235e |
Register xAI as a built-in OpenAI-compatible chat provider and offer current Grok 4.5 and Grok 4.3 presets. Wire shared API-key storage, request routing, setup links, and focused coverage so the provider behaves like existing built-in adapters.
d5f235e to
2f937f2
Compare
|
/agentic_review |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@tests/unit/services/apis/provider-registry.test.mjs`:
- Around line 2581-2585: Add an assertion in resolveProviderIdForSession’s
legacy xAI model-name test for modelName 'xaiGrok4_3', and verify it resolves to
'xai' alongside the existing Grok 4.5 coverage.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6c524d55-0a97-4c2e-a576-5822f5bf316d
📒 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 (5)
- src/config/openai-provider-mappings.mjs
- src/popup/sections/GeneralPart.jsx
- tests/unit/services/apis/thin-adapters.test.mjs
- src/background/index.mjs
- src/services/apis/provider-registry.mjs
|
Code review by qodo was updated up to the latest commit 2f937f2 |
Summary
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.