feat(chat): allow custom model IDs#999
Conversation
📝 WalkthroughWalkthroughCustom 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. ChangesCustom model selection
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
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/chat/hooks/useChatProviderState.ts (1)
140-146: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the custom-model marker persistence into a shared helper. The
${provider}-custom-modelmarker convention (write'true'when custom, remove otherwise) is duplicated across two layers and read back bypickStoredOrCurrent. 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 insetStoredProviderModelwith the shared helper (e.g.setCustomModelMarker(targetProvider, isCustom)).src/components/chat/view/subcomponents/ProviderSelectionEmptyState.tsx#L158-L164: replace the inline marker write/remove insetModelForProviderwith 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
📒 Files selected for processing (3)
src/components/chat/hooks/useChatProviderState.tssrc/components/chat/view/subcomponents/CommandResultModal.tsxsrc/components/chat/view/subcomponents/ProviderSelectionEmptyState.tsx
Summary
/modelsdialog, including Enter-to-applyMotivation
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
Validation
npm run typecheckCommandResultModal.tsx)npm run build:client(successful; existing CSS minifier and bundle-size warnings remain)Summary by CodeRabbit