Skip to content

feat(claude-code): add model catalog and provider settings types#801

Open
edelauna wants to merge 1 commit into
mainfrom
feat/claude-code-provider-types
Open

feat(claude-code): add model catalog and provider settings types#801
edelauna wants to merge 1 commit into
mainfrom
feat/claude-code-provider-types

Conversation

@edelauna

@edelauna edelauna commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Closes: #757

Description

Adds the @roo-code/types definitions for the new "Claude Code (Subscription)" provider, the first of 7 sub-issues under the #756 epic. This is types/schema only — no runtime handler, UI, or auth wiring yet (those land in #758-763).

  • packages/types/src/providers/claude-code.ts (new): claudeCodeModels catalog (7 models: Fable 5, Opus 4.8/4.7/4.6, Sonnet 5, Sonnet 4.6 + its [1m] 1M-context variant, Haiku 4.5), ClaudeCodeModelId, claudeCodeDefaultModelId. Runtime inputPrice/outputPrice are 0 (subscription-covered); real list prices are recorded as comments for reference.
  • packages/types/src/provider-settings.ts: adds "claude-code" to the provider union, claudeCodeSchema (apiModelId + optional claudeCodeCliPath, no API key field), wired into the discriminated union, modelIdKeysByProvider, and MODELS_BY_PROVIDER.
  • packages/types/src/providers/index.ts: export + getProviderDefaultModelId wiring.
  • webview-ui/src/components/ui/hooks/useSelectedModel.ts: added a claude-code case. This was required, not optional scope creep — adding "claude-code" to ProviderName broke an existing exhaustiveness (satisfies) check in this hook's default branch, so a matching case was needed to keep the build green.

Model catalog grounding: contextWindow/maxTokens values are verified against live claude --model <id> --output-format json output (modelUsage[id].contextWindow / .maxOutputTokens) rather than copied from anthropic.ts, since the Agent SDK/CLI path reports different (generally lower) max-output caps than the direct API for the same model name. Pricing was cross-checked against Anthropic's live pricing page.

Test Procedure

  • packages/types/src/__tests__/claude-code.spec.ts (new): default model exists, all models have inputPrice/outputPrice of 0, schema accepts empty object / claudeCodeCliPath, rejects unknown keys in strict mode, and the discriminated-union arm (apiProvider: "claude-code") parses correctly with and without claudeCodeCliPath.
  • webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts: added coverage for the new claude-code branch (default model, custom model ID) to satisfy patch coverage.
  • Full monorepo check-types (11 packages) and test suites for @roo-code/types and @roo-code/vscode-webview pass locally and in CI.

Pre-Submission Checklist

  • 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 have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

This is a types-only foundation for the epic in #756. Downstream sub-issues (#758 message conversion, #759 core handler, #760 usage tracking, #761 CLI detection, #762 settings UI, #763 usage dashboard) build on top of what's added here.

Summary by CodeRabbit

  • New Features
    • Added Claude Code provider support across provider settings, default model selection, and model catalog browsing (including supported models and capability/cost metadata).
  • Bug Fixes
    • Improved provider settings validation for Claude Code, including strict schema handling and discriminated parsing.
    • Fixed model selection to correctly resolve a chosen Claude Code model (or the provider default when unset).
  • Tests
    • Added/updated test coverage for Claude Code defaults, schema behavior, and model-selection hook logic.

@coderabbitai

coderabbitai Bot commented Jul 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: ac0e5795-dbd1-41f2-9d72-04dffd9369a2

📥 Commits

Reviewing files that changed from the base of the PR and between cf63e5f and a346855.

📒 Files selected for processing (7)
  • packages/types/src/__tests__/claude-code.spec.ts
  • packages/types/src/provider-settings.ts
  • packages/types/src/providers/claude-code.ts
  • packages/types/src/providers/index.ts
  • src/core/config/__tests__/importExport.spec.ts
  • webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts
  • webview-ui/src/components/ui/hooks/useSelectedModel.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/types/src/tests/claude-code.spec.ts
  • webview-ui/src/components/ui/hooks/useSelectedModel.ts
  • webview-ui/src/components/ui/hooks/tests/useSelectedModel.spec.ts
  • packages/types/src/providers/claude-code.ts
  • packages/types/src/provider-settings.ts
  • packages/types/src/providers/index.ts

📝 Walkthrough

Walkthrough

Adds a new claude-code provider with a zero-cost model catalog, provider-settings schema wiring, default model resolution, webview model selection, and tests. Existing import/export tests now use generic removed-provider identifiers.

Changes

Claude Code provider integration

Layer / File(s) Summary
Model catalog
packages/types/src/providers/claude-code.ts
Defines the Claude Code model type, default model, metadata, capabilities, limits, and zero pricing.
Schema and registry wiring
packages/types/src/provider-settings.ts
Adds claude-code to provider names, schemas, model-id mappings, and the provider model registry.
Default resolution and validation
packages/types/src/providers/index.ts, packages/types/src/__tests__/claude-code.spec.ts
Exports the provider, resolves its default model, and tests catalog and schema behavior.
Webview model selection
webview-ui/src/components/ui/hooks/useSelectedModel.ts, webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts
Selects Claude Code default or explicit models and returns their metadata.
Import/export fixtures
src/core/config/__tests__/importExport.spec.ts
Uses generic removed-provider identifiers in invalid-provider test fixtures and assertions.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Webview as useSelectedModel
  participant Types as providerSettingsSchema
  participant Catalog as claudeCodeModels
  Webview->>Types: validate claude-code settings
  Types-->>Webview: validated provider configuration
  Webview->>Catalog: lookup apiModelId or default model
  Catalog-->>Webview: return ModelInfo
Loading

Possibly related issues

Possibly related PRs

Suggested labels: awaiting-review

Suggested reviewers: taltas, hannesrudolph, jamesrobert20

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the new Claude Code model catalog and provider settings work.
Description check ✅ Passed The PR description matches the template with issue link, implementation details, testing, checklist, and notes.
Linked Issues check ✅ Passed The changes satisfy #757 with exports, zero-priced models, optional CLI path schema, valid provider value, and tests.
Out of Scope Changes check ✅ Passed The hook and import/export test updates support the new provider and prevent breakage, so no unrelated scope stands out.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/claude-code-provider-types

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.

@edelauna edelauna force-pushed the feat/claude-code-provider-types branch from 0c5fead to 4083b40 Compare July 4, 2026 18:00
@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@edelauna edelauna force-pushed the feat/claude-code-provider-types branch from 4083b40 to cf63e5f Compare July 4, 2026 18:24
@edelauna edelauna marked this pull request as ready for review July 4, 2026 18:30
@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 4, 2026
import { describe, it, expect } from "vitest"

import { claudeCodeModels, claudeCodeDefaultModelId } from "../providers/claude-code.js"
import { providerSettingsSchema, providerSettingsSchemaDiscriminated } from "../provider-settings.js"

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.

why .js?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TS config requires .js - it's actually used throughout:

image

Looks like this is configured correctly: https://www.totaltypescript.com/relative-import-paths-need-explicit-file-extensions-in-ecmascript-imports

@navedmerchant navedmerchant 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.

lets remove the .js from the imports otherwise looks good to merge

@github-actions github-actions Bot added awaiting-author PR is waiting for the author to address requested changes has-conflicts PR has merge conflicts with the base branch and removed awaiting-review PR changes are ready and waiting for maintainer re-review awaiting-author PR is waiting for the author to address requested changes has-conflicts PR has merge conflicts with the base branch labels Jul 5, 2026
@github-actions github-actions Bot added awaiting-author PR is waiting for the author to address requested changes and removed has-conflicts PR has merge conflicts with the base branch labels Jul 14, 2026
@github-actions github-actions Bot added has-conflicts PR has merge conflicts with the base branch and removed awaiting-author PR is waiting for the author to address requested changes labels Jul 14, 2026
@edelauna edelauna force-pushed the feat/claude-code-provider-types branch from cf63e5f to a346855 Compare July 15, 2026 00:42
@github-actions github-actions Bot removed the has-conflicts PR has merge conflicts with the base branch label Jul 15, 2026
@edelauna edelauna requested a review from navedmerchant July 15, 2026 00:42
@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 15, 2026
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.

[claude-code] Add model catalog and provider settings types

2 participants