refactor(webview): canonicalize provider model config identifiers - #1147
Conversation
📝 WalkthroughWalkthroughThe provider configuration utilities replace hardcoded provider keys with ChangesProvider identifier migration
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
webview-ui/src/components/settings/utils/__tests__/providerModelConfig.spec.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. webview-ui/src/components/settings/utils/providerModelConfig.tsESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox. 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! |
edelauna
left a comment
There was a problem hiding this comment.
Looks good, ended up bumping up test coverage before approving and merging.
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
`@webview-ui/src/components/settings/utils/__tests__/providerModelConfig.spec.ts`:
- Around line 154-155: Remove the unnecessary as any cast in the
getProviderModelConfig test and pass "unknown-provider" directly, since the
function accepts a string.
🪄 Autofix
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: 0895a605-fbc5-43ce-a381-325c2145b0d4
📒 Files selected for processing (2)
webview-ui/src/components/settings/utils/__tests__/providerModelConfig.spec.tswebview-ui/src/components/settings/utils/providerModelConfig.ts
| it("returns undefined for a provider with no model config entry", () => { | ||
| expect(getProviderModelConfig("unknown-provider" as any)).toBeUndefined() |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ast-grep outline webview-ui/src/components/settings/utils/providerModelConfig.ts \
--match getProviderModelConfig --view expanded
ast-grep run --lang ts \
--pattern 'getProviderModelConfig($ARG)' \
webview-ui/src/components/settings/utils/__tests__/providerModelConfig.spec.tsRepository: Zoo-Code-Org/Zoo-Code
Length of output: 639
Remove the unnecessary as any cast.
getProviderModelConfig accepts a string, so pass "unknown-provider" directly.
Proposed fix
- expect(getProviderModelConfig("unknown-provider" as any)).toBeUndefined()
+ expect(getProviderModelConfig("unknown-provider")).toBeUndefined()📝 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("returns undefined for a provider with no model config entry", () => { | |
| expect(getProviderModelConfig("unknown-provider" as any)).toBeUndefined() | |
| it("returns undefined for a provider with no model config entry", () => { | |
| expect(getProviderModelConfig("unknown-provider")).toBeUndefined() |
🤖 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
`@webview-ui/src/components/settings/utils/__tests__/providerModelConfig.spec.ts`
around lines 154 - 155, Remove the unnecessary as any cast in the
getProviderModelConfig test and pass "unknown-provider" directly, since the
function accepts a string.
Source: Coding guidelines
Summary
Extracts the provider model configuration utility changes from #1141 into a focused pull request:
This PR is intentionally limited to
webview-ui/src/components/settings/utils.Validation
npx vitest run src/components/settings/utils/__tests__/providerModelConfig.spec.ts— 29 tests passedpnpm check-typesinwebview-ui--prune-suppressions --max-warnings=0for both changed filesgit diff --checkRelated to #944.
Extracted from #1141.
Summary by CodeRabbit