refactor: finish canonical provider identifier audit#1030
Conversation
📝 WalkthroughWalkthroughThe change centralizes provider and protocol constants, updates ChangesProvider identifier centralization
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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/shared/__tests__/checkExistApiConfig.spec.ts`:
- Around line 69-72: Update the keyless-provider tests around checkExistKey to
exercise providerIdentifiers.openaiCodex and providerIdentifiers.qwenCode in
addition to providerIdentifiers.fakeAi. Replace any hard-coded openaiCodex or
qwenCode identifiers in the nearby cases with their corresponding registry
values.
🪄 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 Plus
Run ID: 73331000-75cf-46be-b611-189c7fe8291a
📒 Files selected for processing (6)
packages/types/src/__tests__/provider-settings.test.tspackages/types/src/provider-settings.tspackages/types/src/providers/anthropic.tspackages/types/src/providers/openai.tssrc/shared/__tests__/checkExistApiConfig.spec.tssrc/shared/checkExistApiConfig.ts
| it("recognizes keyless providers through their canonical identifiers", () => { | ||
| expect(checkExistKey({ apiProvider: providerIdentifiers.fakeAi })).toBe(true) | ||
| }) | ||
|
|
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Exercise all configuration-free provider identifiers.
This regression test covers only providerIdentifiers.fakeAi; the openaiCodex and qwenCode paths still rely on hard-coded strings at Lines 73-85. A bad registry value for either identifier could therefore pass the suite while breaking the new production path. Add both canonical identifiers to this test or update those existing cases to use the registry.
Suggested test update
it("recognizes keyless providers through their canonical identifiers", () => {
expect(checkExistKey({ apiProvider: providerIdentifiers.fakeAi })).toBe(true)
+ expect(checkExistKey({ apiProvider: providerIdentifiers.openaiCodex })).toBe(true)
+ expect(checkExistKey({ apiProvider: providerIdentifiers.qwenCode })).toBe(true)
})📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| it("recognizes keyless providers through their canonical identifiers", () => { | |
| expect(checkExistKey({ apiProvider: providerIdentifiers.fakeAi })).toBe(true) | |
| }) | |
| it("recognizes keyless providers through their canonical identifiers", () => { | |
| expect(checkExistKey({ apiProvider: providerIdentifiers.fakeAi })).toBe(true) | |
| expect(checkExistKey({ apiProvider: providerIdentifiers.openaiCodex })).toBe(true) | |
| expect(checkExistKey({ apiProvider: providerIdentifiers.qwenCode })).toBe(true) | |
| }) |
🤖 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 `@src/shared/__tests__/checkExistApiConfig.spec.ts` around lines 69 - 72,
Update the keyless-provider tests around checkExistKey to exercise
providerIdentifiers.openaiCodex and providerIdentifiers.qwenCode in addition to
providerIdentifiers.fakeAi. Replace any hard-coded openaiCodex or qwenCode
identifiers in the nearby cases with their corresponding registry values.
Summary
providerIdentifiersregistryCloses #960
TDD
Each migrated branch was driven by an observed red-green cycle:
Verification
cd packages/types && npx vitest run src/__tests__/provider-settings.test.ts src/__tests__/provider-identifiers.test.ts src/__tests__/provider-default-model.test.ts— 38 passedcd src && npx vitest run shared/__tests__/checkExistApiConfig.spec.ts shared/__tests__/ProfileValidator.spec.ts— 50 passedKnown unrelated environment issue
The repository pre-push type-check reaches the new Playwright visual-test files and fails because local dependencies
@playwright/experimental-ct-react,@playwright/test, andmonocart-reporterare unavailable. The types and extension packages affected by this PR type-check successfully. The local runtime is Node 24.7.0 while the repository requests Node 22.23.1.Summary by CodeRabbit
Bug Fixes
Tests