fix: re-fetch auth providers after setup step 1 authentication#1974
fix: re-fetch auth providers after setup step 1 authentication#1974
Conversation
The useAgentAuthProviders hook fires on mount (step 1) before the user has authenticated, so the admin-gated provider endpoint fails silently. When step 2 renders the providers array is empty and the Codex card shows "connection status is unavailable." Re-fetch after step 1 stores the JWT so the provider list is populated correctly.
📝 WalkthroughWalkthroughThis change adds auth provider state refresh functionality to the setup flow. The Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ui/src/pages/setup.tsx`:
- Around line 101-106: The useEffect calls refreshProviders() without ensuring
it exists, which can throw if refreshProviders is undefined; update the effect
in the useEffect for currentStep to guard before invoking refreshProviders
(e.g., check refreshProviders is truthy or use optional chaining) and only call
.catch on a real Promise so the hook won't attempt to call .catch on
undefined—apply this change where refreshProviders is referenced in the
useEffect that watches currentStep.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 15781acb-ce31-432d-99e2-c2c25028c5ee
📒 Files selected for processing (1)
ui/src/pages/setup.tsx
Add truthiness check before calling refreshProviders() to handle cases where the hook mock does not provide the function. Update the test mock to return a resolved promise so the async .catch() chain works correctly.
In compact mode (used by setup wizard), keep the header layout stacked vertically instead of switching to flex-row at the sm breakpoint. The setup container is max-w-sm so the side-by-side layout overflows.
Rewrite the dialog copy to explain the manual OAuth flow: sign in, expect the localhost:1455 page to not load, copy the full URL, and paste it back. Rename fields to "Login URL" and "Callback URL" for clarity, and tuck the raw authorization code input behind a disclosure toggle.
Change max-w-sm (384px) to max-w-md (448px) so long model names in the dropdown and the provider auth card fit without overflowing.
Summary
useAgentAuthProvidershook fires its API call on component mount (step 1), before the user has created their admin account. TheGET /settings/agent/auth/providersendpoint requires admin auth, so the call fails silently and sets providers to[].clientsingleton hasn't changed, so the OpenAI Codex provider card shows "connection status is unavailable."useEffectthat callsrefreshProviders()whencurrentSteptransitions to2, ensuring providers are fetched after the JWT from step 1 is available.Test plan
Summary by CodeRabbit