Skip to content

🤖 fix: disable gateway when onboarding credits are depleted#2789

Merged
ibetitsmike merged 4 commits intomainfrom
mike/onboarding-9ejn
Mar 4, 2026
Merged

🤖 fix: disable gateway when onboarding credits are depleted#2789
ibetitsmike merged 4 commits intomainfrom
mike/onboarding-9ejn

Conversation

@ibetitsmike
Copy link
Contributor

Summary

Auto-disable Mux Gateway routing and show a warning when a user logs in during onboarding with a $0 balance, preventing a broken experience with an unusable provider.

Closes #1964

Background

The onboarding wizard already displays the gateway balance after login, but there was no handling for depleted credits — the gateway stayed enabled even at $0, leading users to a dead end.

Implementation

  • refresh() in useMuxGatewayAccountStatus now returns Promise<MuxGatewayAccountStatus | null> so callers can act on the result immediately.
  • Both the desktop and browser/server login flows in OnboardingWizardSplash now await the balance check after login. When credits are $0: default gateway models are not applied, and gateway.toggleEnabled() disables routing.
  • A warning banner appears in the logged-in account section when balance is zero, with a link to add credits.
  • Missing account status (null) is treated as permissive — gateway isn't disabled when the balance lookup fails.

Generated with mux • Model: anthropic:claude-opus-4-6 • Thinking: xhigh • Cost: $2.91

@ibetitsmike
Copy link
Contributor Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a58d2d4d3b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
Copy link
Contributor Author

@codex review

Addressed feedback: added a 5-second timeout to the balance refresh calls in both desktop and browser flows. If the gateway endpoint stalls, the timeout resolves to null (permissive), so default models are applied as before — no regression.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0c0563346e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
Copy link
Contributor Author

@codex review

Addressed slow-response bypass: the refresh promise is now stored and, when the timeout wins the race, a .then() on the original promise still disables gateway if the late response returns $0 balance. This handles high-latency connections without blocking onboarding defaults.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c367db970e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
Copy link
Contributor Author

@codex review

Added login-attempt guard (muxGatewayLoginAttemptRef.current !== attempt) to both late balance callback .then() handlers, preventing stale responses from earlier login attempts from disabling gateway on newer logins.

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike ibetitsmike added this pull request to the merge queue Mar 4, 2026
Merged via the queue into main with commit 288e516 Mar 4, 2026
23 checks passed
@ibetitsmike ibetitsmike deleted the mike/onboarding-9ejn branch March 4, 2026 17:11
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.

Getting started wizard shows up on broken workspaces

1 participant