Skip to content

refactor(webview): canonicalize provider settings identifiers - #1143

Open
WebMad wants to merge 1 commit into
Zoo-Code-Org:mainfrom
WebMad:refactor/944-provider-settings-identifiers
Open

refactor(webview): canonicalize provider settings identifiers#1143
WebMad wants to merge 1 commit into
Zoo-Code-Org:mainfrom
WebMad:refactor/944-provider-settings-identifiers

Conversation

@WebMad

@WebMad WebMad commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Extracts the provider-settings portion of #1141 into a focused pull request:

  • replaces provider string literals with providerIdentifiers in webview-ui/src/components/settings/providers
  • canonicalizes router-model lookups, refresh requests, OAuth callbacks, and provider response filters
  • refreshes both provider-scoped and shared LiteLLM model caches
  • adds focused coverage for provider identifier behavior

Serialized provider values and runtime behavior remain unchanged.

Validation

  • 6 focused provider test files: 28 tests passed
  • pnpm check-types in webview-ui
  • ESLint with --prune-suppressions --max-warnings=0 for all changed files
  • repository pre-push type checks
  • git diff --check

Related to #944. Extracted from #1141.

Summary by CodeRabbit

  • Bug Fixes

    • Improved consistency when refreshing and selecting models across multiple providers.
    • Ensured provider-specific refresh errors are handled correctly without affecting unrelated providers.
    • Improved cache updates after successful model refreshes.
    • Ensured model-specific settings are cleared when changing models.
    • Standardized OAuth and model-refresh provider handling.
  • Tests

    • Added coverage for model discovery, fallback models, refresh flows, error handling, caching, OAuth links, and model changes.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cf68996f-1ac8-4d83-bd3d-9039a5ed80db

📥 Commits

Reviewing files that changed from the base of the PR and between d0af4c0 and a38deb9.

📒 Files selected for processing (16)
  • webview-ui/src/components/settings/providers/Kenari.tsx
  • webview-ui/src/components/settings/providers/KimiCode.tsx
  • webview-ui/src/components/settings/providers/LiteLLM.tsx
  • webview-ui/src/components/settings/providers/Moonshot.tsx
  • webview-ui/src/components/settings/providers/OpenCodeGo.tsx
  • webview-ui/src/components/settings/providers/Poe.tsx
  • webview-ui/src/components/settings/providers/Requesty.tsx
  • webview-ui/src/components/settings/providers/Unbound.tsx
  • webview-ui/src/components/settings/providers/VercelAiGateway.tsx
  • webview-ui/src/components/settings/providers/ZooGateway.tsx
  • webview-ui/src/components/settings/providers/__tests__/KimiCode.spec.tsx
  • webview-ui/src/components/settings/providers/__tests__/LiteLLM.spec.tsx
  • webview-ui/src/components/settings/providers/__tests__/Moonshot.spec.tsx
  • webview-ui/src/components/settings/providers/__tests__/Poe.spec.tsx
  • webview-ui/src/components/settings/providers/__tests__/ProviderRouting.spec.tsx
  • webview-ui/src/components/settings/providers/__tests__/Requesty.spec.tsx
🚧 Files skipped from review as they are similar to previous changes (16)
  • webview-ui/src/components/settings/providers/Poe.tsx
  • webview-ui/src/components/settings/providers/tests/Requesty.spec.tsx
  • webview-ui/src/components/settings/providers/LiteLLM.tsx
  • webview-ui/src/components/settings/providers/tests/Poe.spec.tsx
  • webview-ui/src/components/settings/providers/KimiCode.tsx
  • webview-ui/src/components/settings/providers/ZooGateway.tsx
  • webview-ui/src/components/settings/providers/tests/LiteLLM.spec.tsx
  • webview-ui/src/components/settings/providers/tests/ProviderRouting.spec.tsx
  • webview-ui/src/components/settings/providers/Unbound.tsx
  • webview-ui/src/components/settings/providers/OpenCodeGo.tsx
  • webview-ui/src/components/settings/providers/Requesty.tsx
  • webview-ui/src/components/settings/providers/Kenari.tsx
  • webview-ui/src/components/settings/providers/tests/Moonshot.spec.tsx
  • webview-ui/src/components/settings/providers/tests/KimiCode.spec.tsx
  • webview-ui/src/components/settings/providers/Moonshot.tsx
  • webview-ui/src/components/settings/providers/VercelAiGateway.tsx

📝 Walkthrough

Walkthrough

Provider settings now use centralized providerIdentifiers values for model lookup, refresh requests, OAuth callbacks, error filtering, cache invalidation, and model-change effects. Tests cover these provider-specific flows.

Changes

Provider identifier migration

Layer / File(s) Summary
Canonical model lookup wiring
webview-ui/src/components/settings/providers/{Kenari,KimiCode,OpenCodeGo,VercelAiGateway,ZooGateway}.tsx
Model pickers and router-model lookups use shared provider identifiers.
Refresh, error, and side-effect handling
webview-ui/src/components/settings/providers/{KimiCode,LiteLLM,Moonshot,OpenCodeGo,Poe,Requesty,Unbound}.tsx
Refresh payloads, OAuth callbacks, error checks, cache invalidation, and model-change effects use centralized identifiers.
Provider flow validation
webview-ui/src/components/settings/providers/__tests__/{KimiCode,LiteLLM,Moonshot,Poe,Requesty,ProviderRouting}.spec.tsx
Tests cover model fallback, cache invalidation, refresh errors, provider filtering, OAuth requests, routing, and model-change cleanup.

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

Possibly related PRs

Suggested reviewers: taltas

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the provider identifier refactor in the webview settings.
Description check ✅ Passed The description covers the implementation, issue context, behavior, and validation, but omits the template checklist and optional sections.
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/providers/Kenari.tsx

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/providers/KimiCode.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

webview-ui/src/components/settings/providers/LiteLLM.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

  • 13 others

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.

@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: 2

🧹 Nitpick comments (1)
webview-ui/src/components/settings/providers/__tests__/Requesty.spec.tsx (1)

45-45: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the Requesty callback route.

Line 45 only checks that the URL contains callback_url. In webview-ui/src/oauth/urls.ts, Lines 3-5 add this parameter for every provider. The test passes if the callback route uses another provider. Parse the URL and assert that the callback route ends in /${providerIdentifiers.requesty}.

Proposed test update
-		expect(screen.getByRole("link")).toHaveAttribute("href", expect.stringContaining("callback_url="))
+		const callbackUrl = new URL(screen.getByRole("link").getAttribute("href") ?? "").searchParams.get(
+			"callback_url",
+		)
+		expect(callbackUrl ?? "").toMatch(new RegExp(`/${providerIdentifiers.requesty}$`))
🤖 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/providers/__tests__/Requesty.spec.tsx` at
line 45, Strengthen the link assertion in the Requesty test by parsing the
generated href and verifying its callback route ends with
`/${providerIdentifiers.requesty}`. Keep the existing `callback_url` check if
useful, but ensure the assertion specifically confirms Requesty rather than
merely any provider callback.
🤖 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/providers/LiteLLM.tsx`:
- Around line 64-65: Update the Save-handler invalidation calls using
queryClient.invalidateQueries for the LiteLLM and "all" routerModels keys so
their returned promises are explicitly handled; either await both invalidations
together or mark each intentional non-blocking call with void, preserving the
existing invalidation keys.

In `@webview-ui/src/components/settings/providers/OpenAICodex.tsx`:
- Line 3: Update the OpenAICodex component tests to remove calls to getByRole
for the deleted “Speed” combobox and instead assert that the
OpenAICodexSpeedSelector is absent in both affected tests. Leave the
service-tier compatibility tests in the API provider suite unchanged.

---

Nitpick comments:
In `@webview-ui/src/components/settings/providers/__tests__/Requesty.spec.tsx`:
- Line 45: Strengthen the link assertion in the Requesty test by parsing the
generated href and verifying its callback route ends with
`/${providerIdentifiers.requesty}`. Keep the existing `callback_url` check if
useful, but ensure the assertion specifically confirms Requesty rather than
merely any provider callback.
🪄 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: 5a7309f4-7f15-4c4c-886e-f0419ee0f25f

📥 Commits

Reviewing files that changed from the base of the PR and between 7918f6b and b88090a.

📒 Files selected for processing (17)
  • webview-ui/src/components/settings/providers/Kenari.tsx
  • webview-ui/src/components/settings/providers/KimiCode.tsx
  • webview-ui/src/components/settings/providers/LiteLLM.tsx
  • webview-ui/src/components/settings/providers/Moonshot.tsx
  • webview-ui/src/components/settings/providers/OpenAICodex.tsx
  • webview-ui/src/components/settings/providers/OpenCodeGo.tsx
  • webview-ui/src/components/settings/providers/Poe.tsx
  • webview-ui/src/components/settings/providers/Requesty.tsx
  • webview-ui/src/components/settings/providers/Unbound.tsx
  • webview-ui/src/components/settings/providers/VercelAiGateway.tsx
  • webview-ui/src/components/settings/providers/ZooGateway.tsx
  • webview-ui/src/components/settings/providers/__tests__/CanonicalProviderIdentifiers.spec.tsx
  • webview-ui/src/components/settings/providers/__tests__/KimiCode.spec.tsx
  • webview-ui/src/components/settings/providers/__tests__/LiteLLM.spec.tsx
  • webview-ui/src/components/settings/providers/__tests__/Moonshot.spec.tsx
  • webview-ui/src/components/settings/providers/__tests__/Poe.spec.tsx
  • webview-ui/src/components/settings/providers/__tests__/Requesty.spec.tsx

Comment thread webview-ui/src/components/settings/providers/LiteLLM.tsx Outdated
Comment thread webview-ui/src/components/settings/providers/OpenAICodex.tsx Outdated
@codecov

codecov Bot commented Aug 4, 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
Comment thread webview-ui/src/components/settings/providers/__tests__/KimiCode.spec.tsx Outdated
Comment thread webview-ui/src/components/settings/providers/__tests__/KimiCode.spec.tsx Outdated
@WebMad

WebMad commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

A note on the two LiteLLM invalidations: there are currently two independent React Query entries for router models. useSelectedModel() uses the provider-scoped ["routerModels", providerIdentifiers.litellm] key, while ApiOptions calls useRouterModels() without a provider and uses ["routerModels", "all"]. The refresh message does not update either cache directly, so both exact keys must be invalidated to keep model IDs/metadata and the settings model list in sync. Using the broader ["routerModels"] prefix would also refetch unrelated provider-scoped queries. This is the minimal fix without consolidating the router-model caches.

@WebMad
WebMad force-pushed the refactor/944-provider-settings-identifiers branch from c6cac6d to a38deb9 Compare August 5, 2026 12:10
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR changes are ready and waiting for maintainer re-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant