Skip to content

refactor(api): use canonical model cache provider identifiers#1020

Open
WebMad wants to merge 4 commits into
Zoo-Code-Org:mainfrom
WebMad:issue-957-canonical-model-cache-identifiers
Open

refactor(api): use canonical model cache provider identifiers#1020
WebMad wants to merge 4 commits into
Zoo-Code-Org:mainfrom
WebMad:issue-957-canonical-model-cache-identifiers

Conversation

@WebMad

@WebMad WebMad commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Closes #957

Description

Migrates model fetching and cache policy decisions to the canonical providerIdentifiers registry while preserving current behavior.

  • Uses canonical identifiers for model fetcher dispatch.
  • Uses canonical identifiers for URL-scoped and API-key-scoped cache-key rules.
  • Uses canonical identifiers for authentication-scoped cache isolation.
  • Uses canonical identifiers for background public-provider refreshes.
  • Preserves existing provider strings, cache-key construction, fetcher arguments, refresh behavior, and cross-user isolation.
  • Adds focused regression tests for representative public and credentialed fetchers plus Zoo Gateway authentication-sensitive caching.

TDD Summary

  • Canonical OpenRouter dispatch was first observed failing with Unknown provider and then made green.
  • Canonical Zoo Gateway cache isolation was first observed returning previous-user cached models and then made green.
  • Canonical Requesty dispatch triangulated credential and base-URL forwarding before the complete mechanical migration.

Test Procedure

  • cd src && npx vitest run api/providers/fetchers/__tests__/modelCache.spec.ts
  • cd src && npx vitest run api/providers/fetchers/__tests__ core/webview/__tests__/webviewMessageHandler.routerModels.spec.ts
  • cd src && npx eslint api/providers/fetchers/modelCache.ts api/providers/fetchers/__tests__/modelCache.spec.ts --max-warnings=0
  • pnpm check-types

Results:

  • Focused model-cache suite: 31 tests passed.
  • Broader fetcher/downstream suite: 209 tests passed across 17 files.
  • Repository pre-push type checks: 11 tasks passed.
  • Lint and formatting checks passed.

Notes

This is intentionally a behavior-preserving identifier migration. It does not redesign model caching or change authentication boundaries. No changeset was added per repository policy.

Summary by CodeRabbit

  • Bug Fixes
    • Improved provider routing when fetching and caching available models.
    • Correctly scoped cache behavior by provider credentials, including API keys and base URLs.
    • Improved cache isolation for authenticated providers (e.g., Zoo Gateway/KimiCode), avoiding unintended cache reads.
    • Updated automatic background refresh for public providers such as OpenRouter and Vercel AI Gateway.
  • Tests
    • Expanded coverage for cache-key derivation, in-flight request deduplication, and empty/error handling.
  • Chores
    • Removed an outdated ESLint suppression related to model-cache tests.

@coderabbitai

coderabbitai Bot commented Jul 25, 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: 45ffdf45-6be0-4e97-96cb-aa43e6a0b5ee

📥 Commits

Reviewing files that changed from the base of the PR and between 058bb63 and 7aa2062.

📒 Files selected for processing (1)
  • src/api/providers/fetchers/modelCache.ts

📝 Walkthrough

Walkthrough

Model fetching and cache scoping now use canonical provider identifiers from providerIdentifiers. Tests cover provider dispatch, credential handling, cache isolation, refresh behavior, deduplication, and cache-key derivation.

Changes

Canonical provider routing

Layer / File(s) Summary
Provider identifier wiring
src/api/providers/fetchers/modelCache.ts
Cache scoping, provider dispatch, and public refresh configuration now use providerIdentifiers constants.
Canonical fetch routing tests
src/api/providers/fetchers/__tests__/modelCache.spec.ts
Tests use canonical identifiers across provider dispatch, OpenRouter routing, Requesty credentials, and unknown-provider validation.
Cache behavior regression tests
src/api/providers/fetchers/__tests__/modelCache.spec.ts, src/eslint-suppressions.json
Cache fallback, authentication isolation, empty-response handling, refresh retention, request deduplication, cache-key derivation, and typed mocks are updated and validated.

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

Possibly related issues

Possibly related PRs

Suggested labels: awaiting-review

Suggested reviewers: navedmerchant, hannesrudolph

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main provider-identifier migration in model cache logic.
Description check ✅ Passed It includes the linked issue, implementation summary, and test procedure, so the required structure is mostly satisfied.
Linked Issues check ✅ Passed The code updates canonical identifiers in dispatch, cache scoping, refresh paths, and tests while preserving behavior, matching #957.
Out of Scope Changes check ✅ Passed The eslint suppression cleanup is tied to the test typing change and no unrelated functionality appears to be introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 Jul 25, 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 Jul 25, 2026
edelauna
edelauna previously approved these changes Jul 26, 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.

🔥

@edelauna
edelauna added this pull request to the merge queue Jul 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 26, 2026
Comment thread src/api/providers/fetchers/__tests__/modelCache.spec.ts Outdated
@github-actions github-actions Bot removed the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 26, 2026
Comment thread src/api/providers/fetchers/__tests__/modelCache.spec.ts Outdated
Comment thread src/api/providers/fetchers/__tests__/modelCache.spec.ts Outdated
Comment thread src/api/providers/fetchers/__tests__/modelCache.spec.ts Outdated
Comment thread src/api/providers/fetchers/modelCache.ts Outdated
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.

[ENHANCEMENT] Migrate model fetching and cache logic to canonical provider identifiers

2 participants