Repository navigation
fix: web search button not showing for models with web search capability - #2216
Conversation
WalkthroughThis PR refactors model capability detection for reasoning and web search. A new data contract extends ChangesModel Capability Flags Propagation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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)
apps/playground/src/components/playground/chat-page-client.tsx (1)
344-350: ⚡ Quick winConsider extracting the model lookup pattern into a helper function.
The same model lookup logic (exact ID match, then
endsWithfallback) is repeated 8 times acrossChatPageClientandExtraChatPanel. A small helper would reduce duplication:♻️ Optional refactor to reduce duplication
+const getModelCapability = ( + availableModels: ComboboxModel[], + selectedModel: string, + capability: keyof Pick<ComboboxModel, 'vision' | 'imageGen' | 'reasoning' | 'webSearch'>, +): boolean => { + let model = availableModels.find((m) => m.id === selectedModel); + if (!model && !selectedModel.includes("/")) { + model = availableModels.find((m) => m.id.endsWith(`/${selectedModel}`)); + } + return !!model?.[capability]; +}; const supportsImages = useMemo(() => { - let model = availableModels.find((m) => m.id === selectedModel); - if (!model && !selectedModel.includes("/")) { - model = availableModels.find((m) => m.id.endsWith(`/${selectedModel}`)); - } - return !!model?.vision; + return getModelCapability(availableModels, selectedModel, 'vision'); }, [availableModels, selectedModel]);Also applies to: 352-358, 360-366, 368-374, 1293-1299, 1301-1307, 1309-1315, 1317-1323
🤖 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 `@apps/playground/src/components/playground/chat-page-client.tsx` around lines 344 - 350, Extract the repeated model lookup (exact match by id then fallback to id.endsWith(`/selectedModel`)) into a single helper, e.g., getModelForSelected(availableModels, selectedModel), and replace the duplicated logic in ChatPageClient (used by supportsImages) and ExtraChatPanel with calls to that helper; ensure the helper returns the matched model (or undefined) so existing checks like !!model?.vision continue to work and update all occurrences referenced (the blocks around supportsImages and the four other locations) to call getModelForSelected instead of repeating the find/endsWith logic.
🤖 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 `@apps/playground/src/components/playground/chat-page-client.tsx`:
- Around line 344-350: Extract the repeated model lookup (exact match by id then
fallback to id.endsWith(`/selectedModel`)) into a single helper, e.g.,
getModelForSelected(availableModels, selectedModel), and replace the duplicated
logic in ChatPageClient (used by supportsImages) and ExtraChatPanel with calls
to that helper; ensure the helper returns the matched model (or undefined) so
existing checks like !!model?.vision continue to work and update all occurrences
referenced (the blocks around supportsImages and the four other locations) to
call getModelForSelected instead of repeating the find/endsWith logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ce68a7f4-0914-4b00-b0b8-4282075b0f76
📒 Files selected for processing (3)
apps/playground/src/components/playground/chat-page-client.tsxapps/playground/src/lib/mapmodels.tsapps/playground/src/lib/types.ts
Reverts #2216 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Refined how the system determines which models support reasoning and web search capabilities through an improved lookup mechanism. [](https://app.coderabbit.ai/change-stack/theopenco/llmgateway/pull/2221) <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
Bug Fixes