Skip to content

Fix SkyFi OAuth Connection flow and Settings connection states#754

Open
ngoiyaeric wants to merge 1 commit into
mainfrom
jules-13021459091643289234-0b233a20
Open

Fix SkyFi OAuth Connection flow and Settings connection states#754
ngoiyaeric wants to merge 1 commit into
mainfrom
jules-13021459091643289234-0b233a20

Conversation

@ngoiyaeric

Copy link
Copy Markdown
Collaborator

This PR implements a robust set of fixes to resolve the core bug where the 'Connect SkyFi Account' button fails to route users to SkyFi's login/authorize page, alongside improvements to token exchange consistency and Settings UI states:

  1. Redirect URI derivation: Updated getRedirectUri() in lib/actions/skyfi.ts to prefer the explicitly configured NEXT_PUBLIC_APP_URL over dynamic request header parsing. In case of headers, added proxy-header parsing for x-forwarded-host and x-forwarded-proto.
  2. Client registration reuse: Checked and validated matching registered redirect URIs and client IDs prior to reuse or re-registration.
  3. Decoupled Auth & Database Resolution Errors: Correctly throwing exceptions in resolveClerkUserToDbUser to prevent misreporting authenticated sessions as authRequired.
  4. Header Alignment & Conservative Expiry: Unified MCP connections and server action status checks on the standardized Authorization: Bearer <token> header and conservatively treated missing expiry as expired/refreshable.
  5. Connection & State Recovery UI: Enhanced the Settings form UI to capture and render expired/unauthorized states with callouts, reset connecting states on error, and support direct "Reconnect" and "Disconnect" flows.

PR created automatically by Jules for task 13021459091643289234 started by @ngoiyaeric

…ttings UI state recovery

Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
qcx Ready Ready Preview, Comment Jul 24, 2026 1:43pm

@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@ngoiyaeric, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 33 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a05ed468-cf24-42c8-a783-1009be8ac12c

📥 Commits

Reviewing files that changed from the base of the PR and between 04755dd and af8407c.

⛔ Files ignored due to path filters (6)
  • server.log is excluded by !**/*.log
  • verification/screenshots/verification.png is excluded by !**/*.png
  • verification/videos/4b3c21fc8a1eaf98287b63d128862a1a.webm is excluded by !**/*.webm
  • verification/videos/6c291f358382cf59561e02b7ca4e017b.webm is excluded by !**/*.webm
  • verification/videos/a2dc584b8ae1e9c7c7a7976bef136e61.webm is excluded by !**/*.webm
  • verification/videos/d201cea3d13586ac718a0107d918d876.webm is excluded by !**/*.webm
📒 Files selected for processing (11)
  • components/settings/components/tool-selection-form.tsx
  • drizzle/migrations/0011_motionless_banshee.sql
  • drizzle/migrations/meta/0010_snapshot.json
  • drizzle/migrations/meta/0011_snapshot.json
  • drizzle/migrations/meta/_journal.json
  • lib/actions/skyfi.ts
  • lib/agents/tools/skyfi.tsx
  • lib/auth/get-current-user.ts
  • lib/db/schema.ts
  • lib/skyfi/provider.ts
  • verify_settings.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jules-13021459091643289234-0b233a20

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.

@ngoiyaeric

Copy link
Copy Markdown
Collaborator Author

The resolution search is not responsive

@charliecreates charliecreates Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Request changes

I found three issues that should be addressed before merge.

  1. The migration journal references a missing SQL migration. _journal.json adds 0010_tough_the_professor, but the PR contains no drizzle/migrations/0010_tough_the_professor.sql; it only adds the snapshot. The migration runner uses Drizzle's journal tags to read <tag>.sql, so deployments will fail while loading migrations before 0011_motionless_banshee.sql can add redirect_uri. Please add the missing SQL migration or remove/reconcile the journal/snapshot entry.

  2. Changing redirect URIs replaces the client registration but preserves tokens issued to the old client. saveClientInformation updates clientId/redirectUri without clearing token columns, while tokens() later refreshes with the stored clientId. If a user with an existing connection starts a reconnect after the redirect URI changes and abandons it, the old refresh token can subsequently be sent with the new client ID and the connection becomes unable to refresh. Clear the old access/refresh tokens when replacing the registration, or keep the old registration until the new authorization callback successfully saves new tokens.

  3. The fallback redirect URI trusts request-supplied proxy headers. When NEXT_PUBLIC_APP_URL is absent, x-forwarded-host and x-forwarded-proto directly control the OAuth redirect URI. Unless the ingress is guaranteed to strip and overwrite these headers, a caller can influence the registered callback/authorization redirect. Use an allowlisted canonical URL or explicitly validate that these headers came from a trusted proxy, and enforce/document the production NEXT_PUBLIC_APP_URL invariant.

Checks observed for this head: GitGuardian and Vercel Preview Comments passed; CodeRabbit reported success but was rate-limited; Supabase Preview was skipped; the Vercel deployment status was still pending. I did not run tests, lint, or builds during this read-only review.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants