When refreshing the browser on the Credits or API ...
# proj-agent-canvas
r
When refreshing the browser on the Credits or API Keys pages under Settings, the interface returns to the User Settings page.
@nutritious-balloon-65098, please make it so that hitting refresh on https://app.all-hands.dev/settings/billing or https://app.all-hands.dev/settings/api-keys no longer returns the user back to https://app.all-hands.dev/settings/user
Whoops, need to configure things before I can do that. Lemme try...
n
Uh oh! There was an unexpected error starting the job :(
r
Hrmm...
@nutritious-balloon-65098, please make it so that hitting refresh on https://app.all-hands.dev/settings/billing or https://app.all-hands.dev/settings/api-keys no longer returns the user back to https://app.all-hands.dev/settings/user
n
Uh oh! There was an unexpected error starting the job :(
r
I'll have to read the docs in a bit because this isn't working:
Be back later...
❤️ 1
@nutritious-balloon-65098, please make it so that hitting refresh on https://app.all-hands.dev/settings/billing or https://app.all-hands.dev/settings/api-keys no longer returns the user back to https://app.all-hands.dev/settings/user
n
I'm on it! Kent Johnson can track my progress here.
🙌 1
Summary I successfully fixed the issue where refreshing the billing (
/settings/billing
) or API keys (
/settings/api-keys
) pages would redirect users back to the user settings page (
/settings/user
). Root Cause The problem was in the
settings.tsx
component where the navigation logic was running immediately when the component mounted, before the app configuration was loaded. Since
config?.APP_MODE
was initially
undefined
(falsy), the
else
block would execute and redirect users away from SaaS-only routes like billing and API keys. Solution I added a simple guard clause to prevent the navigation logic from running until the config is actually loaded:
Copy code
React.useEffect(() => {
  // Only run navigation logic when config is loaded
  if (config?.APP_MODE === undefined) return;
  
  // ... rest of navigation logic
}, [isSaas, pathname, config?.APP_MODE]);
Changes Made 1. Fixed the navigation logic in
frontend/src/routes/settings.tsx
with a 2-line guard clause 2. Updated useEffect dependencies to include
config?.APP_MODE
for proper reactivity 3. Updated tests to account for the async config loading behavior Verification • All existing tests pass • Frontend builds successfully • Pre-commit hooks pass (linting, formatting, type checking) • The fix maintains existing functionality while solving the refresh redirect issue Now users can refresh the billing and API keys pages without being unexpectedly redirected to the user settings page.
r
Wait, maybe this was intended?
Some questions for a maintainer: 1. Why are
/billing
and
/api-keys
treated differently than
/integrations
,
/app
, and
/secrets
? 2. Why are both
/billing
and
/credits
listed? The Credits tab actually goes to
/billing
and
/credits
gives a 404.
f
Thanks from bringing this issue up. We render different settings options for users using OpenHands on the cloud or locally. The logic in your screenshot is meant to redirect the user to appropriate pages. The issue is we get the app mode from cache after page renders, causing the sudden change in view permissions Issue is fixed here: https://github.com/All-Hands-AI/OpenHands/pull/9596
r
Opened a comment about #2 above.