-
Notifications
You must be signed in to change notification settings - Fork 28
🤖 feat: add Mux Gateway toggle with cleaner API #950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
f4390cd to
5dbda60
Compare
- Add whitespace-nowrap to ProviderWithIcon to prevent line breaks - Create useGatewayModels hook for managing gateway preferences - Add cloud icon toggle to ModelRow in settings - Add cloud icon toggle to ModelSelector dropdown - Transform model to gateway format when sending messages Users can now click the cloud icon on any model to route it through Mux Gateway. The preference is stored per-model and the transformation happens transparently when sending messages. _Generated with mux_
- Track gateway availability (couponCodeSet) in localStorage - Only transform to gateway format when gateway is both enabled AND available - Hide cloud icon toggle when gateway provider is not configured - Cloud icon only shows in model selector when gateway is actually active
- Filter out mux-gateway provider from custom models list in settings - Filter out mux-gateway models from model LRU list - Only show cloud icon for providers that gateway supports (anthropic, openai, google) - Add isGatewaySupported() check in toGatewayModel for extra robustness
Add forward compatibility for users who have directly specified mux-gateway models in their config: - migrateGatewayModel(): converts 'mux-gateway:provider/model' to 'provider:model' and auto-enables gateway toggle for that model - Applied in useSendMessageOptions, getSendOptionsFromStorage - useModelLRU: migrates LRU list and default model on load - Malformed gateway entries are filtered out Example: 'mux-gateway:anthropic/claude-opus-4-5' becomes 'anthropic:claude-opus-4-5' with gateway toggle enabled
Add xai and bedrock to supported providers list. The Vercel AI Gateway supports OpenAI, Anthropic, Google, xAI, Amazon Bedrock, and others. Excluded providers: - ollama: Local-only, not routable through cloud gateway - openrouter: Already a gateway/aggregator
Remove bedrock from supported gateway providers due to its complex AWS credential-based authentication, which doesn't fit the simple API key routing model of the gateway.
5cbc854 to
c655e18
Compare
Replace generic Cloud icon with a dedicated gateway icon showing data flowing through a central hub (hexagon with arrows). More distinctive and semantically meaningful for the gateway feature.
6cd7b1c to
d75244f
Compare
- Add global gateway enabled state to localStorage (defaults to true) - Add toggle switch in Mux Gateway provider section when coupon is set - Respect global enabled state across all gateway UI elements - Simplify GatewayIcon to diamond relay symbol This allows users to disable gateway routing without removing their coupon code, useful for testing or debugging.
Rename useGatewayModels → useGateway with cleaner interface: - isActive: gateway configured AND enabled (ready to use) - isConfigured: coupon code set - isEnabled: global master switch on - canToggleModel(id): whether to show gateway toggle for model - modelUsesGateway(id): model is toggled for gateway - isModelRoutingThroughGateway(id): active + uses (for display) - toggleEnabled(): toggle global switch - toggleModelGateway(id): toggle per-model Consolidates scattered checks like: gatewayGloballyEnabled && gatewayAvailable && isGatewaySupported(model) Into single semantic calls: gateway.canToggleModel(model) Also renames isGatewaySupported → isProviderSupported for clarity.
d4af5fa to
9392cad
Compare
Use a circle (portal) with an arrow passing through instead of a diamond relay. More visually balanced at small sizes.
Concentric rings with a sparkle/cross at center for a more magical portal appearance.
- Circle with M logo for clear Mux branding - Active state shows outer glow ring instead of fill - Cleaner visual distinction between enabled/disabled
usePersistedState batches localStorage writes in microtask, which can cause race conditions when toggling gateway and immediately sending a message. Now we also call updatePersistedState directly to ensure toGatewayModel() sees the change immediately.
The hook now subscribes to useGateway() so it re-renders when the user toggles gateway on/off for a model. This fixes the bug where disabling gateway in the model selector didn't take effect immediately when sending a message.
The thinking policy regex patterns expect canonical model format
(e.g., 'gpt-5-pro'), not gateway format ('openai/gpt-5-pro').
Run enforceThinkingPolicy before gateway transform to ensure
correct policy detection.
useSendMessageOptions now returns both: - model: gateway-transformed for API calls - baseModel: canonical format for UI/policy (e.g., codex-max reasoning levels) This ensures ThinkingSlider shows correct options (xhigh for codex-max) even when model is routed through gateway.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add a cloud icon toggle for routing models through Mux Gateway, with a cleaner API design and reactive state management.
Key Changes
useGateway()hook with clean interface:isActive: gateway configured AND enabledcanToggleModel(id): whether to show toggleisModelRoutingThroughGateway(id): for display badgetoggleModelGateway(id): toggle per-modelmux-gateway:provider/modelformat auto-migrates to canonical form with gateway enabledBug Fixes
useSendMessageOptions)Generated with
mux