Skip to content

fix: web search button not showing for models with web search capability - #2216

Merged
smakosh merged 2 commits into
theopenco:mainfrom
amelitoalcuitas:fix/web-search-issue
May 9, 2026
Merged

smakosh merged 2 commits into
theopenco:mainfrom
amelitoalcuitas:fix/web-search-issue

Conversation

@amelitoalcuitas

@amelitoalcuitas amelitoalcuitas commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

Bug Fixes

  • Improved detection of AI model capabilities including reasoning and web search support across all providers
  • Enhanced model identification and selection logic for better multi-provider configuration handling
  • Better support for region-specific model identification in model selection

@coderabbitai

coderabbitai Bot commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR refactors model capability detection for reasoning and web search. A new data contract extends ComboboxModel with optional reasoning and webSearch flags. The mapModels function computes and propagates these capabilities from provider mappings. The chat-page-client is refactored to determine feature support by reading these flags from mapped models instead of provider-mapping lookups.

Changes

Model Capability Flags Propagation

Layer / File(s) Summary
Type Contract
apps/playground/src/lib/types.ts
ComboboxModel interface extended with optional reasoning?: boolean and webSearch?: boolean fields.
Model Mapping Logic
apps/playground/src/lib/mapmodels.ts
mapModels computes root-level capability flags (hasReasoning, hasWebSearch) across provider mappings, includes them in the "Auto" entry, introduces region-aware id construction for per-mapping entries, and propagates reasoning and webSearch from mappings to combobox items.
Client Refactoring
apps/playground/src/components/playground/chat-page-client.tsx
Type imports updated to remove ApiModelProviderMapping; supportsReasoning and supportsWebSearch in both ChatPageClient and ExtraChatPanel refactored to search availableModels by id and read capability flags directly instead of consulting provider mappings.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main fix: enabling the web search button for models with web search capability by refactoring capability checks to use the mapped models.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@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)
apps/playground/src/components/playground/chat-page-client.tsx (1)

344-350: ⚡ Quick win

Consider extracting the model lookup pattern into a helper function.

The same model lookup logic (exact ID match, then endsWith fallback) is repeated 8 times across ChatPageClient and ExtraChatPanel. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1e3b13f and 149716d.

📒 Files selected for processing (3)
  • apps/playground/src/components/playground/chat-page-client.tsx
  • apps/playground/src/lib/mapmodels.ts
  • apps/playground/src/lib/types.ts

@smakosh
smakosh enabled auto-merge May 9, 2026 09:14
@smakosh
smakosh added this pull request to the merge queue May 9, 2026
Merged via the queue into theopenco:main with commit b4438d2 May 9, 2026
8 checks passed
github-merge-queue Bot pushed a commit that referenced this pull request May 9, 2026
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.

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/theopenco/llmgateway/pull/2221)

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

2 participants