Skip to content

[refactor] Move default provider ID functionality into provider definition - #2233

Merged
edelauna merged 2 commits into
Zoo-Code-Org:mainfrom
p12tic:provider-settings-default-model-id
Oct 31, 2026
Merged

edelauna merged 2 commits into
Zoo-Code-Org:mainfrom
p12tic:provider-settings-default-model-id

Conversation

@p12tic

@p12tic p12tic commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Simple refactor.

Description

Move default provider ID functionality into provider definition. This replaces yet another switch statement with declarative style. Provider definitions were moved into files containing provider model data to reduce the number of unnecessary imports.

Test Procedure

unit, integration tests.

Pre-Submission Checklist

  • [n/a] Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I reviewed my own code with care.
  • Writing Style: The PR title and description use Simplified Technical English (ASD-STE100): short sentences, plain words, active voice, one idea per sentence, no contractions.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • [n/a] Visual Snapshot (UI changes only): If a user would notice this change at a glance (layout, theme tokens, brand elements, empty/error states), I added or updated a *.visual.tsx snapshot in webview-ui/. See webview-ui/AGENTS.md → "When a UI change needs a snapshot".
  • [n/a] Documentation Impact: I checked if my changes need documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I read and agree to the Contributor Guidelines.

Visual Snapshots

n/a

Videos (interaction / animation only)

n/a

Documentation Updates

n/a

Merge packages/types/src/provider-settings/*.ts into
packages/types/src/providers/, appending each source file's code to the
end of the same-named destination file and combining their imports.

Files without a same-named counterpart (common, fake-ai, gemini-cli,
litellm, openai-native, vscode-lm) move over unchanged. The
providerDefinitionList registry from provider-settings/index.ts is
appended to providers/index.ts, and all import sites now point at the
new location.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between e7181c0 and 3b0d281.

Files selected for processing: 2
  • packages/types/src/__tests__/provider-default-model.test.ts
  • packages/types/src/providers/zai.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Recent review details
CI failures not shown inline: 2

GitHub Actions: Changed-code mutation testing / 0_mutation-diff.txt: [refactor] Move default provider ID functionality into provider definition

Conclusion: failure

View job details

##[group]Run BASE_SHA="$(git rev-parse "$HEAD_SHA^1")"
 �[36;1mBASE_SHA="$(git rev-parse "$HEAD_SHA^1")"�[0m
 �[36;1mnode scripts/stryker-diff.mjs ci --base "$BASE_SHA" --head "$HEAD_SHA"�[0m
 shell: /usr/bin/bash -e {0}
 env:
   PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin
   STORE_PATH: /home/runner/setup-pnpm/node_modules/.bin/store/v10
   HEAD_SHA: cea90f4971fecdd2c9b1266d1c96d714742b4c72
 ##[endgroup]
 Mutation gate failed: types has 630 changed executable lines (limit 500). Split the PR or obtain a maintainer-reviewed narrow exclusion.
 ##[error]Process completed with exit code 1.

GitHub Actions: Changed-code mutation testing / mutation-diff: [refactor] Move default provider ID functionality into provider definition

Conclusion: failure

View job details

##[group]Run BASE_SHA="$(git rev-parse "$HEAD_SHA^1")"
 �[36;1mBASE_SHA="$(git rev-parse "$HEAD_SHA^1")"�[0m
 �[36;1mnode scripts/stryker-diff.mjs ci --base "$BASE_SHA" --head "$HEAD_SHA"�[0m
 shell: /usr/bin/bash -e {0}
 env:
   PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin
   STORE_PATH: /home/runner/setup-pnpm/node_modules/.bin/store/v10
   HEAD_SHA: cea90f4971fecdd2c9b1266d1c96d714742b4c72
 ##[endgroup]
 Mutation gate failed: types has 630 changed executable lines (limit 500). Split the PR or obtain a maintainer-reviewed narrow exclusion.
 ##[error]Process completed with exit code 1.
Additional context used
Path-based instructions: 4
For persisted settings, verify the complete schema/storage/runtime/webview round trip, shared default semantics, and focused true plus false/unset tests.

CodeRabbit configuration file

Files:

  • packages/types/src/__tests__/provider-default-model.test.ts
  • packages/types/src/providers/zai.ts
Require regression coverage at the lowest valid harness with behavior-focused assertions, including relevant negative, error, false/unset, and boundary cases.

CodeRabbit configuration file

Files:

  • packages/types/src/__tests__/provider-default-model.test.ts
Check strict typing and exhaustive behavior across normal, boundary, error, cancellation, retry, and compatibility paths.

CodeRabbit configuration file

Files:

  • packages/types/src/__tests__/provider-default-model.test.ts
  • packages/types/src/providers/zai.ts
Act as an adversarial second-opinion reviewer.

CodeRabbit configuration file

Files:

  • packages/types/src/__tests__/provider-default-model.test.ts
  • packages/types/src/providers/zai.ts
📝 Summary

Summary by CodeRabbit

  • New Features
    • Provider default models now reflect saved configuration, including Z.AI’s selected API region.
    • Default-model lookup is available across providers, with provider-specific defaults applied consistently.
  • Bug Fixes
    • Improved default-model selection when settings are missing or Z.AI’s API line is unset or invalid.

Provider definitions and settings schemas move into provider modules. A central registry lists those definitions. Default-model resolution now uses provider settings, including Z.ai API-line selection, with an Anthropic fallback when a provider returns no default.

Changes: Provider definitions and default model resolution

Layer / File(s) Summary
Default-model accessor contract
packages/types/src/providers/common.ts
Provider definitions now require a getDefaultModelId accessor. The shared module adds NO_DEFAULT_MODEL_ID for providers without a meaningful default.
Provider module definitions
packages/types/src/provider-settings/*, packages/types/src/providers/*
Provider definitions and settings schemas move into provider modules, with model-ID accessors and default-model callbacks. The OpenAI extra-body parser and NanoGPT routing preferences are defined in their provider modules.
Provider definition registry
packages/types/src/provider-settings/index.ts, packages/types/src/providers/index.ts
The providers barrel exports an ordered providerDefinitionList and the ProviderDefinition type. It adds exports for Fake AI, Gemini CLI, LiteLLM, OpenAI Native, and VS Code LM.
Settings-aware default resolution
packages/types/src/provider-settings.ts, packages/types/src/__tests__/*, webview-ui/src/components/settings/utils/providerModelConfig.ts, webview-ui/src/components/ui/hooks/useSelectedModel.ts
getProviderDefaultModelId reads the provider definition’s default using the supplied settings and falls back to the Anthropic default. Webview callers pass the current configuration. Tests cover provider accessors and Z.ai defaults for configured and unset API lines.

Priority: Low

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Refactor

Merge Risk: Minimal · up to 3b0d2

The Z.ai default selection behaves correctly. Its remaining test-coverage limitation is already documented and does not establish a runtime failure; no concrete blocker remains.

Pre-merge checks: Passed 6 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the refactor and lists testing, but it does not provide the required approved GitHub Issue link. The test procedure is also too vague to reproduce. Add an approved issue reference in the Related GitHub Issue section, such as "Closes: #123". Provide specific unit and integration test commands or steps, including relevant environment details.
Regression Evidence Warning The refactor changes the default-model behavior for every provider through providerDefinitionList and getProviderDefaultModelId (packages/types/src/providers/index.ts:82-120, `packages/types/src… Add a table-driven unit test at the getProviderDefaultModelId layer that covers every provider definition, including each static default constant, the empty defaults for OpenAI/Ollama/LM Studio, the Anthropic fallback providers, and all Z…
Passed Passed checks: 6 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes moving default provider ID functionality into provider definitions.
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.
Security Boundaries Passed No changed path meets the security failure conditions. createProviderDefinition still validates model settings with Zod safeParse before model-ID access. getProviderDefaultModelId only dispatche…
Persistence Integrity Passed No changed persistence operation exists. The PR changes provider-definition schemas and default-model resolution only; ProviderSettingsManager and its awaited load/store paths are unchanged. The…
Lifecycle Resource Cleanup Passed PASS. The reviewed changes move provider definitions and default-model resolution between TypeScript modules. The changed UI paths only pass provider settings to synchronous `getProviderDefaultModelId…
Full details: Security Boundaries

Explanation

No changed path meets the security failure conditions. createProviderDefinition still validates model settings with Zod safeParse before model-ID access. getProviderDefaultModelId only dispatches to static provider callbacks; the only settings-dependent callback, Z.ai, validates zaiApiLine with safeParse and uses an allowlisted enum with an international fallback. The moved OpenAI extra-body parser retains rejection of reserved and prototype-pollution keys. No changed code leaks secrets or PII, executes unvalidated input, or bypasses an approval or allowlist control.

Full details: Persistence Integrity

Explanation

No changed persistence operation exists. The PR changes provider-definition schemas and default-model resolution only; ProviderSettingsManager and its awaited load/store paths are unchanged. The changed consumers pass persisted apiConfiguration into getProviderDefaultModelId, including Z.AI API-line settings, so no persisted default propagation failure is present.

Full details: Lifecycle Resource Cleanup

Explanation

PASS. The reviewed changes move provider definitions and default-model resolution between TypeScript modules. The changed UI paths only pass provider settings to synchronous getProviderDefaultModelId calls. The diff adds no listener, watcher, subscription, timer, task, worker, cancellation, disposal, or restart path. No changed lifecycle path can leak a resource or duplicate work.

Full details: Regression Evidence

Explanation

The refactor changes the default-model behavior for every provider through providerDefinitionList and getProviderDefaultModelId (packages/types/src/providers/index.ts:82-120, packages/types/src/provider-settings.ts:363-369). Focused assertions cover only a subset, plus Z.ai branches and a few added providers. The new all-provider test (packages/types/src/__tests__/provider-settings.test.ts:21-29) checks only that the accessor exists and returns any string. It would pass if a provider returned the wrong model ID. For example, the new DeepSeek callback (packages/types/src/providers/deepseek.ts:88-92) has no assertion that the resolver returns deepSeekDefaultModelId. The same gap applies to many moved defaults.

Resolution

Add a table-driven unit test at the getProviderDefaultModelId layer that covers every provider definition, including each static default constant, the empty defaults for OpenAI/Ollama/LM Studio, the Anthropic fallback providers, and all Z.ai API-line and unset/invalid cases. Keep the existing structural registration test, but do not use its string-type assertion as semantic coverage.

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review status

Thanks for contributing. This comment tracks the review sequence and the next action.

Current step: Awaiting fresh human maintainer or CODEOWNER approval.

Automated review is complete for the latest commit but does not replace human approval.

Review-state labels are managed by this workflow; do not edit them manually. community-approved is managed the same way — do not add or remove it manually. It signals a fresh community code approval for the current head as an advisory priority only; maintainer review is still required.

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...iew-ui/src/components/ui/hooks/useSelectedModel.ts 80.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@p12tic

p12tic commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@github-actions github-actions Bot added coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Oct 29, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 29, 2026
@github-actions github-actions Bot added awaiting-maintainer CodeRabbit approved; waiting for a human maintainer and removed coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Oct 29, 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.

Nice! One comment to boost the test coverage for z.ai - otherwise this looks good.

@github-actions github-actions Bot added awaiting-author PR is waiting for the author to address requested changes and removed awaiting-maintainer CodeRabbit approved; waiting for a human maintainer labels Oct 29, 2026
…itions

Each provider definition now declares its own `getDefaultModelId`, mirroring
`getModelId`, so per-provider default-model data lives next to the rest of that
provider's configuration instead of in a central switch.

- Add `getDefaultModelId` to `ProviderDefinition`/`createProviderDefinition`
  and a shared `NO_DEFAULT_MODEL_ID` constant.
- Move every provider's default into its definition; Z.ai keeps its
  region-dependent logic by reading `zaiApiLine` from settings.
- Remove the `getProviderDefaultModelId` switch from `providers/index.ts`.
- Re-add `getProviderDefaultModelId(provider, settings)` in
  `provider-settings.ts`, resolving the definition and falling back to the
  Anthropic default.
- Update webview callers to pass `apiConfiguration` and drop the duplicated
  Z.ai region logic in `providerModelConfig.ts`.
- Extend tests to cover the new accessor and the Z.ai API-line defaults.
@p12tic
p12tic force-pushed the provider-settings-default-model-id branch from e7181c0 to 3b0d281 Compare October 30, 2026 11:07
@github-actions github-actions Bot removed the awaiting-author PR is waiting for the author to address requested changes label Oct 30, 2026
@p12tic
p12tic requested a review from edelauna October 30, 2026 11:20
@github-actions github-actions Bot added coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Oct 30, 2026
@github-actions github-actions Bot added awaiting-maintainer CodeRabbit approved; waiting for a human maintainer and removed coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Oct 30, 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.

Nice - thank you.

@edelauna
edelauna added this pull request to the merge queue Oct 31, 2026
Merged via the queue into Zoo-Code-Org:main with commit 070ee98 Oct 31, 2026
40 of 45 checks passed
myk1yt added a commit to myk1yt/Zoo-Code that referenced this pull request Oct 31, 2026
…ove)

Re-anchors the prompt cache TTL knob onto Zoo-Code-Org#2233's new provider-definition
layout: the knob stays in baseProviderSettingsShape, which now lives in
packages/types/src/providers/common.ts. Updates the TTL spec imports to
the new module paths.
myk1yt added a commit to myk1yt/Zoo-Code that referenced this pull request Oct 31, 2026
Re-merges the Bedrock cache-TTL gate onto the updated parent Zoo-Code-Org#2264, which
now carries Zoo-Code-Org#2233's provider-settings -> providers move. No conflicts: this
branch never edited packages/types/src/providers/common.ts, so the parent's
re-anchored TTL knob lands unmodified and the gate's six files apply clean.

Verified: origin/main is an ancestor; 29 co-touched specs pass by name; no
stale provider-settings/ imports remain.
myk1yt added a commit to myk1yt/Zoo-Code that referenced this pull request Oct 31, 2026
Brings the leaf's settings/UI prompt-cache-TTL surface onto the parent's
re-anchored provider layout (Zoo-Code-Org#2233 moved provider-settings/ to providers/
and added the TTL knob to baseProviderSettingsShape).

No textual conflict: the two sides touch disjoint paths. The leaf's delta is
webview/settings/UI only (Anthropic.tsx control, i18n, SettingsView and
ClineProvider specs); the parent's delta is packages/types + provider runtime.
packages/types/src/providers/common.ts resolves byte-identical to the parent,
which already carries both Zoo-Code-Org#2233's structure and the TTL knob.

Verified: 32 co-touched specs run by name (1178 tests), check-types green for
packages/types, src and webview-ui, eslint --max-warnings=0 on all 97 touched
files, no stale provider-settings/ imports, eslint-suppressions.json unchanged.
myk1yt added a commit to myk1yt/Zoo-Code that referenced this pull request Oct 31, 2026
Round-3 re-merge onto main@33b56507188f. Conflict set (2 paths):
- packages/types/src/provider-settings/mimo.ts (modify/delete): main's
  Zoo-Code-Org#2233 moved every provider definition into packages/types/src/providers/.
  The deletion wins; this branch's added comment on the mimoBaseUrl union
  moved with the definition into providers/mimo.ts.
- webview-ui/src/components/ui/hooks/useSelectedModel.ts (content): kept
  this branch's static-catalog fallback branch and applied main's new
  two-argument getProviderDefaultModelId signature to the final fallback.

Also retargeted two comments that named the deleted path
(src/api/providers/fetchers/mimo.ts and its spec).
edelauna pushed a commit that referenced this pull request Nov 2, 2026
…ition (#2233)

* refactor(types): move provider-settings into providers

Merge packages/types/src/provider-settings/*.ts into
packages/types/src/providers/, appending each source file's code to the
end of the same-named destination file and combining their imports.

Files without a same-named counterpart (common, fake-ai, gemini-cli,
litellm, openai-native, vscode-lm) move over unchanged. The
providerDefinitionList registry from provider-settings/index.ts is
appended to providers/index.ts, and all import sites now point at the
new location.

* refactor(types): move provider default model data into provider definitions

Each provider definition now declares its own `getDefaultModelId`, mirroring
`getModelId`, so per-provider default-model data lives next to the rest of that
provider's configuration instead of in a central switch.

- Add `getDefaultModelId` to `ProviderDefinition`/`createProviderDefinition`
  and a shared `NO_DEFAULT_MODEL_ID` constant.
- Move every provider's default into its definition; Z.ai keeps its
  region-dependent logic by reading `zaiApiLine` from settings.
- Remove the `getProviderDefaultModelId` switch from `providers/index.ts`.
- Re-add `getProviderDefaultModelId(provider, settings)` in
  `provider-settings.ts`, resolving the definition and falling back to the
  Anthropic default.
- Update webview callers to pass `apiConfiguration` and drop the duplicated
  Z.ai region logic in `providerModelConfig.ts`.
- Extend tests to cover the new accessor and the Z.ai API-line defaults.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-maintainer CodeRabbit approved; waiting for a human maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants