Skip to content

feat(model-selector): add region selection feature to model entries - #2751

Merged
smakosh merged 10 commits into
theopenco:mainfrom
amelitoalcuitas:feat/models-selector-region
Jun 23, 2026
Merged

smakosh merged 10 commits into
theopenco:mainfrom
amelitoalcuitas:feat/models-selector-region

Conversation

@amelitoalcuitas

@amelitoalcuitas amelitoalcuitas commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor
  • Removed region display from disabled model entries.
  • Implemented region filtering for model mappings in the ModelSelector component.
  • Added UI elements to display available regions for selected models in both the ChatPageClient and ExtraChatPanel components.
  • Enhanced ChatUI to allow users to select a region from available options.

This update improves user experience by providing clearer region options for model selection.

Summary by CodeRabbit

  • New Features
    • Added regional model selection capability. Users can now view and select from available regional variants of models when applicable.
    • New "Available Regions" section displays supported regions as badges for the currently selected model.
    • New region selector added to the toolbar, enabling easy switching between regions with a "Default" option.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds regional model variant support to the playground. ModelSelector gains a showRegionalVariants prop controlling whether region-specific entries appear in the dropdown, and adds "Available Regions" badge displays in the preview panel and model details dialog. ChatUI adds a region Select in the prompt toolbar. chat-page-client derives and wires region state for primary and extra chat panels.

Changes

Region Selection Feature

Layer / File(s) Summary
ModelSelector: filter regional entries and display Available Regions
apps/playground/src/components/model-selector.tsx, apps/playground/src/components/playground/group-chat-client.tsx
Adds showRegionalVariants?: boolean prop (default false) to ModelSelectorProps; skips mappings with a region in allEntries when disabled; removes region suffix from per-provider row subtitle; adds "Available Regions" badge blocks to both the desktop preview panel and the model details dialog. Group chat selector passes showRegionalVariants.
ChatUI: region Select in prompt toolbar
apps/playground/src/components/playground/chat-ui.tsx
Extends ChatUIProps with availableRegions, selectedRegion, and onRegionChange; defaults availableRegions to []; conditionally renders a MapPin-labeled region Select with a "Default" option and per-region items in the prompt toolbar. Also adjusts reasoning-effort SelectTrigger sizing.
chat-page-client: derive and wire region state
apps/playground/src/components/playground/chat-page-client.tsx, apps/playground/src/components/playground/chat-header.tsx
Parses selectedModel into providerId, modelId, and region; computes availableRegions from model provider-region mappings; defines handleRegionChange to rebuild provider/model:region strings via handleSelectModel. Wires region props into both comparison and non-comparison ChatUI instances. Mirrors derivation and handler for ExtraChatPanel, fixes handleModelChange to strip trailing :region segments, and updates layout constraints in ChatHeader and ExtraChatPanel.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • theopenco/llmgateway#2224: Both PRs refactor chat-page-client.tsx's selectedModel parsing and mapping lookup logic, with this PR adding region-aware parsing and availableRegions derivation.
  • theopenco/llmgateway#2344: Both PRs update the playground model selector to support region-suffixed model identifiers (provider/model:region) and region-aware mapping/value parsing.
  • theopenco/llmgateway#2412: Both PRs modify model-selector.tsx to handle regional model mappings and selection more accurately when a region suffix is present or absent.

Suggested reviewers

  • steebchen
  • smakosh
🚥 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 PR title accurately describes the main feature added: region selection functionality for model entries in the model selector component.
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.

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@apps/playground/src/components/model-selector.tsx`:
- Around line 960-962: The code filters out regional mappings from allEntries by
skipping entries with mp.region at lines 960-962, but the selection and preview
state matching logic still uses region-qualified values like
provider/model:region. Normalize the selected-entry matching throughout the
component wherever allEntries is used for highlighting or preview to work at the
provider level only, removing the region portion from the active value before
comparison, so it matches the provider-only entries that remain in the filtered
allEntries list.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 824a43cb-fae1-4df4-9625-12f59e906928

📥 Commits

Reviewing files that changed from the base of the PR and between 07154f0 and 126cf4b.

📒 Files selected for processing (3)
  • apps/playground/src/components/model-selector.tsx
  • apps/playground/src/components/playground/chat-page-client.tsx
  • apps/playground/src/components/playground/chat-ui.tsx

Comment thread apps/playground/src/components/model-selector.tsx Outdated

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/playground/src/components/playground/chat-page-client.tsx (1)

2487-2493: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Region changes can bypass video/audio model gating in ExtraChatPanel.

Line 2492 now passes provider/model:region into handleModelChange, but handleModelChange parses model id with model.split("/")[1] and never removes :region. That makes models.find(...) miss on regional values, so video/audio reroute checks are skipped on region updates.

Proposed fix
-	const handleModelChange = useCallback(
-		(model: string) => {
-			const modelId = model.includes("/")
-				? (model.split("/")[1] ?? model)
-				: model;
+	const handleModelChange = useCallback(
+		(model: string) => {
+			const { modelId } = parseModelSelectorValue(model);
 			const def = models.find((m) => m.id === modelId);
 			if (def?.output?.includes("video")) {
 				onVideoModelSelected?.(modelId);
 				return;
 			}
🤖 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
2487 - 2493, The handlePanelRegionChange function constructs a string with the
region appended as `provider/model:region` and passes it to handleModelChange,
but handleModelChange does not strip the `:region` suffix when parsing the model
ID, causing models.find() lookups to fail and skip video/audio gating checks.
Modify handlePanelRegionChange to either pass only the base model identifier
`provider/model` to handleModelChange without the region suffix, or ensure the
region is handled separately from the model ID so that handleModelChange can
correctly match against the models array without the regional suffix interfering
with the lookup.
🤖 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.

Inline comments:
In `@apps/playground/src/components/ui/button-group.tsx`:
- Line 2: Update the import statement in button-group.tsx to import Slot from
"`@radix-ui/react-slot`" instead of "radix-ui" to match the established pattern
used throughout the codebase. Additionally, locate where Slot.Root is being used
(around line 47) and replace it with Slot directly, as Slot.Root is not the
correct API and the Slot component should be used as a direct JSX element.

---

Outside diff comments:
In `@apps/playground/src/components/playground/chat-page-client.tsx`:
- Around line 2487-2493: The handlePanelRegionChange function constructs a
string with the region appended as `provider/model:region` and passes it to
handleModelChange, but handleModelChange does not strip the `:region` suffix
when parsing the model ID, causing models.find() lookups to fail and skip
video/audio gating checks. Modify handlePanelRegionChange to either pass only
the base model identifier `provider/model` to handleModelChange without the
region suffix, or ensure the region is handled separately from the model ID so
that handleModelChange can correctly match against the models array without the
regional suffix interfering with the lookup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5541ce14-55b2-4df3-9b3e-79af885d296b

📥 Commits

Reviewing files that changed from the base of the PR and between 126cf4b and 40002ee.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • apps/playground/package.json
  • apps/playground/src/components/model-selector.tsx
  • apps/playground/src/components/playground/chat-header.tsx
  • apps/playground/src/components/playground/chat-page-client.tsx
  • apps/playground/src/components/playground/group-chat-client.tsx
  • apps/playground/src/components/playground/region-selector.tsx
  • apps/playground/src/components/ui/button-group.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/playground/src/components/model-selector.tsx

Comment thread apps/playground/src/components/ui/button-group.tsx Outdated

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@apps/playground/src/components/playground/chat-ui.tsx`:
- Around line 1723-1727: The SelectTrigger components render only icons on small
screens since the text content is hidden with sm:contents, creating unnamed
controls for assistive technology. Add an aria-label attribute to both
SelectTrigger components mentioned in the review (the one with MapPin icon at
lines 1723-1727 and the other trigger at lines 1751-1755) to provide descriptive
accessible names that screen readers can announce, even when the visual text is
hidden on mobile views.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 16dbfcb8-82ca-4f8e-be41-abcb5eda858c

📥 Commits

Reviewing files that changed from the base of the PR and between 6e7c709 and d5ac6d3.

📒 Files selected for processing (3)
  • apps/playground/src/components/playground/chat-header.tsx
  • apps/playground/src/components/playground/chat-page-client.tsx
  • apps/playground/src/components/playground/chat-ui.tsx
✅ Files skipped from review due to trivial changes (1)
  • apps/playground/src/components/playground/chat-header.tsx

Comment thread apps/playground/src/components/playground/chat-ui.tsx Outdated
Comment thread apps/playground/src/components/playground/chat-page-client.tsx Outdated
Comment thread apps/playground/src/components/playground/chat-page-client.tsx Outdated
- Removed region display from disabled model entries.
- Implemented region filtering for model mappings in the ModelSelector component.
- Added UI elements to display available regions for selected models in both the ChatPageClient and ExtraChatPanel components.
- Enhanced ChatUI to allow users to select a region from available options.

This update improves user experience by providing clearer region options for model selection.
@amelitoalcuitas
amelitoalcuitas force-pushed the feat/models-selector-region branch from d5ac6d3 to 8e25c6f Compare June 21, 2026 04:16
@smakosh
smakosh added this pull request to the merge queue Jun 23, 2026
Merged via the queue into theopenco:main with commit 3d769e1 Jun 23, 2026
24 checks passed
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