Skip to content

refactor(webview): canonicalize provider model config identifiers - #1147

Merged
edelauna merged 2 commits into
Zoo-Code-Org:mainfrom
WebMad:refactor/944-provider-model-config-identifiers
Aug 9, 2026
Merged

refactor(webview): canonicalize provider model config identifiers#1147
edelauna merged 2 commits into
Zoo-Code-Org:mainfrom
WebMad:refactor/944-provider-model-config-identifiers

Conversation

@WebMad

@WebMad WebMad commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Extracts the provider model configuration utility changes from #1141 into a focused pull request:

  • canonicalizes provider registry keys in the settings model configuration utilities
  • canonicalizes provider comparisons, docs slugs, and custom model UI entries
  • adds focused coverage for canonical keys, Z.ai defaults, and model-change side effects

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 passed
  • pnpm check-types in webview-ui
  • ESLint with --prune-suppressions --max-warnings=0 for both changed files
  • repository pre-commit lint
  • repository pre-push type checks
  • git diff --check

Related to #944.
Extracted from #1141.

Summary by CodeRabbit

  • Bug Fixes
    • Improved provider configuration handling across supported services.
    • Preserved correct defaults and settings when switching models, including reasoning options and Bedrock model identifiers.
    • Improved handling for Z.ai, static, custom, and unrecognized providers.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The provider configuration utilities replace hardcoded provider keys with providerIdentifiers. Tests cover canonical registry access, provider-specific model configuration, custom model UI membership, Bedrock ARN handling, and reasoning-setting resets.

Changes

Provider identifier migration

Layer / File(s) Summary
Canonicalize provider configuration mappings
webview-ui/src/components/settings/utils/providerModelConfig.ts
Provider metadata, defaults, model configuration, documentation mappings, custom model lists, and Bedrock cleanup use providerIdentifiers constants.
Validate canonical provider behavior
webview-ui/src/components/settings/utils/__tests__/providerModelConfig.spec.ts
Tests cover canonical keys, Z.ai defaults, unknown providers, static providers, custom model UI membership, Bedrock ARN clearing, and reasoning-setting resets.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: edelauna, navedmerchant, taltas

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the refactor and validation, but it omits required template sections, checklist items, and the required issue-link format. Use the repository template, add the required issue link, complete the pre-submission checklist, and address documentation, snapshot, and reviewer-contact sections.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: canonicalizing provider model configuration identifiers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

webview-ui/src/components/settings/utils/__tests__/providerModelConfig.spec.ts

ESLint 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.ts

ESLint 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Aug 5, 2026

@edelauna edelauna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, ended up bumping up test coverage before approving and merging.

@edelauna
edelauna enabled auto-merge August 9, 2026 14:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0ae9217 and fe0956b.

📒 Files selected for processing (2)
  • webview-ui/src/components/settings/utils/__tests__/providerModelConfig.spec.ts
  • webview-ui/src/components/settings/utils/providerModelConfig.ts

Comment on lines +154 to +155
it("returns undefined for a provider with no model config entry", () => {
expect(getProviderModelConfig("unknown-provider" as any)).toBeUndefined()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 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.ts

Repository: 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.

Suggested change
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

@github-actions github-actions Bot removed the awaiting-review PR changes are ready and waiting for maintainer re-review label Aug 9, 2026
@edelauna
edelauna added this pull request to the merge queue Aug 9, 2026
Merged via the queue into Zoo-Code-Org:main with commit 6012257 Aug 9, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants