Skip to content

feat(chat): allow custom model IDs#999

Open
zhoubeiqing wants to merge 1 commit into
siteboon:mainfrom
zhoubeiqing:feat/custom-model-id-input
Open

feat(chat): allow custom model IDs#999
zhoubeiqing wants to merge 1 commit into
siteboon:mainfrom
zhoubeiqing:feat/custom-model-id-input

Conversation

@zhoubeiqing

@zhoubeiqing zhoubeiqing commented Jul 11, 2026

Copy link
Copy Markdown

Summary

  • allow users to enter a custom model ID from the new-conversation model selector
  • add a custom model action to the in-session /models dialog, including Enter-to-apply
  • persist explicitly selected custom defaults so provider catalog refreshes do not reset them
  • clear the custom marker when the user returns to a catalog model

Motivation

Provider adapters already pass model values through to their SDK/CLI integrations, but the UI only allowed selecting values present in the provider catalog. The catalog reconciliation logic also replaced any non-catalog value with the provider default.

This provides a manual fallback for custom Anthropic-compatible gateways and other providers that expose model IDs CloudCLI cannot discover. It addresses the selection limitation described in #910 and is complementary to #975: dynamically discovered models can still appear in the catalog, while unlisted models remain usable through explicit input.

Behavior

  • exact catalog model IDs continue to use the existing selection flow
  • a non-empty value that is not an exact catalog ID is offered as a custom model
  • existing sessions apply the custom model on the next response
  • new-session defaults survive reloads and model catalog refreshes

Validation

  • npm run typecheck
  • ESLint on the three changed files (0 errors; one existing Tailwind arbitrary-value warning in CommandResultModal.tsx)
  • npm run build:client (successful; existing CSS minifier and bundle-size warnings remain)

Summary by CodeRabbit

  • New Features
    • Added support for entering and selecting custom model IDs for each provider.
    • Model search now offers a “Use custom model ID” option when no matching model is found.
    • Custom model IDs can be selected by clicking the option or pressing Enter.
    • Custom selections are remembered and remain available even when not listed among current models.
    • Improved model selector prompts to clarify that users can search or enter a custom ID.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Custom model IDs can be entered and selected from provider model interfaces. Selections are passed through updated callbacks, persisted with per-provider markers, and retained during model reconciliation even when absent from current provider options.

Changes

Custom model selection

Layer / File(s) Summary
Persist and reconcile custom models
src/components/chat/hooks/useChatProviderState.ts
Provider state stores custom-model markers, preserves marked models outside current options, and accepts custom-selection options.
Add custom models to command modal
src/components/chat/view/subcomponents/CommandResultModal.tsx
The modal supports custom model IDs through search, Enter-key selection, and a dedicated action.
Add custom models to empty-state selector
src/components/chat/view/subcomponents/ProviderSelectionEmptyState.tsx
The selector controls model input, offers unmatched IDs as custom options, and persists custom selections.

Sequence Diagram(s)

sequenceDiagram
  participant ModelSelector
  participant useChatProviderState
  participant localStorage
  ModelSelector->>useChatProviderState: selectProviderModel(provider, model, custom option)
  useChatProviderState->>localStorage: store model and custom marker
  useChatProviderState->>localStorage: read custom marker during reconciliation
  useChatProviderState-->>ModelSelector: preserve selected custom model
Loading

Suggested reviewers: viper151

Poem

A rabbit typed a model ID,
Then hopped where custom choices hide.
The marker stayed, the model remained,
Though provider lists were rearranged.
“Enter,” I cheered, “and let it run!”
🐇✨ Custom models, carrots won!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding support for custom model IDs in chat.
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

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.

🧹 Nitpick comments (1)
src/components/chat/hooks/useChatProviderState.ts (1)

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

Extract the custom-model marker persistence into a shared helper. The ${provider}-custom-model marker convention (write 'true' when custom, remove otherwise) is duplicated across two layers and read back by pickStoredOrCurrent. A single helper keeps the storage-key/value convention from silently diverging.

  • src/components/chat/hooks/useChatProviderState.ts#L140-L146: replace the inline marker write/remove in setStoredProviderModel with the shared helper (e.g. setCustomModelMarker(targetProvider, isCustom)).
  • src/components/chat/view/subcomponents/ProviderSelectionEmptyState.tsx#L158-L164: replace the inline marker write/remove in setModelForProvider with the same helper.
🤖 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 `@src/components/chat/hooks/useChatProviderState.ts` around lines 140 - 146,
The custom-model marker persistence is duplicated across setStoredProviderModel
and setModelForProvider. Add a shared setCustomModelMarker helper that writes
'true' for custom models and removes the marker otherwise, then replace both
inline implementations in src/components/chat/hooks/useChatProviderState.ts
(lines 140-146) and
src/components/chat/view/subcomponents/ProviderSelectionEmptyState.tsx (lines
158-164) with calls to that helper.
🤖 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.

Nitpick comments:
In `@src/components/chat/hooks/useChatProviderState.ts`:
- Around line 140-146: The custom-model marker persistence is duplicated across
setStoredProviderModel and setModelForProvider. Add a shared
setCustomModelMarker helper that writes 'true' for custom models and removes the
marker otherwise, then replace both inline implementations in
src/components/chat/hooks/useChatProviderState.ts (lines 140-146) and
src/components/chat/view/subcomponents/ProviderSelectionEmptyState.tsx (lines
158-164) with calls to that helper.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7a929ed4-af55-4eb5-a70c-a9c5e57a9578

📥 Commits

Reviewing files that changed from the base of the PR and between 5884573 and fa0980e.

📒 Files selected for processing (3)
  • src/components/chat/hooks/useChatProviderState.ts
  • src/components/chat/view/subcomponents/CommandResultModal.tsx
  • src/components/chat/view/subcomponents/ProviderSelectionEmptyState.tsx

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.

1 participant