Skip to content

fix: re-fetch auth providers after setup step 1 authentication#1974

Merged
yottahmd merged 7 commits intomainfrom
fix/setup-codex-provider-unavailable
Apr 8, 2026
Merged

fix: re-fetch auth providers after setup step 1 authentication#1974
yottahmd merged 7 commits intomainfrom
fix/setup-codex-provider-unavailable

Conversation

@yottahmd
Copy link
Copy Markdown
Collaborator

@yottahmd yottahmd commented Apr 8, 2026

Summary

  • The useAgentAuthProviders hook fires its API call on component mount (step 1), before the user has created their admin account. The GET /settings/agent/auth/providers endpoint requires admin auth, so the call fails silently and sets providers to [].
  • When the user completes step 1 and moves to step 2, the hook doesn't re-fetch because the client singleton hasn't changed, so the OpenAI Codex provider card shows "connection status is unavailable."
  • Added a useEffect that calls refreshProviders() when currentStep transitions to 2, ensuring providers are fetched after the JWT from step 1 is available.

Test plan

  • Start a fresh Dagu instance (no existing admin user) to trigger the setup wizard
  • Complete step 1 (create admin account)
  • On step 2, select "OpenAI Codex" as provider
  • Verify the Codex provider auth card renders (connect/disconnect UI) instead of "connection status is unavailable"

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced authentication provider refresh during the setup process to ensure current provider information is properly synchronized at step 2.

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

This change adds auth provider state refresh functionality to the setup flow. The SetupPage component now destructures refreshProviders from the useAgentAuthProviders() hook and triggers a refresh when advancing to step 2, silently catching any errors that occur during the refresh operation.

Changes

Cohort / File(s) Summary
Auth Provider Refresh
ui/src/pages/setup.tsx
Extended useAgentAuthProviders() destructuring to include refreshProviders and added useEffect hook that triggers async provider refresh when currentStep reaches step 2, with error suppression.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: re-fetching auth providers after step 1 of the setup process, which matches the core fix in the changeset.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/setup-codex-provider-unavailable

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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

📥 Commits

Reviewing files that changed from the base of the PR and between c8dae21 and f801db3.

📒 Files selected for processing (1)
  • ui/src/pages/setup.tsx

Comment thread ui/src/pages/setup.tsx
yottahmd added 6 commits April 8, 2026 14:19
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.
@yottahmd yottahmd merged commit 709c98b into main Apr 8, 2026
2 checks passed
@yottahmd yottahmd deleted the fix/setup-codex-provider-unavailable branch April 8, 2026 06: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.

1 participant