fix(credentials): restore reliable OAuth connections - #6753
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryHigh Risk Overview Draft lifecycle: Better Auth: Draft binding is captured in Idempotency & UX: Duplicate workspace+account inserts are handled as reconnect (bump Reviewed by Cursor Bugbot for commit 25f6ba9. Bugbot is set up for automated code reviews on this repo. Configure here. |
44eb3c1 to
5139056
Compare
Greptile SummaryThis PR carries exact credential-draft state through browser and desktop OAuth flows, lets newer launches supersede stale drafts, and verifies idempotent account connections. The new timestamp-based verification can still attribute an unrelated credential update to the current OAuth attempt.
Confidence Score: 4/5The PR should not merge until OAuth return verification can distinguish the current authorization from unrelated credential timestamp updates. The return path currently treats any post-launch updatedAt change on a same-provider credential as proof of this OAuth attempt, so concurrent edits or authorizations can produce a verified success for a failed or abandoned flow. Files Needing Attention: apps/sim/hooks/use-oauth-return.ts
|
| Filename | Overview |
|---|---|
| apps/sim/hooks/use-oauth-return.ts | Adds structured success/error reporting and baseline verification, but a mutable updatedAt delta can falsely verify an unrelated operation as this attempt’s success. |
| apps/sim/lib/credentials/draft-hooks.ts | Handles the exact workspace/account conflict idempotently and updates the existing credential timestamp used by return verification. |
| apps/sim/lib/credentials/draft-processor.ts | Preserves request-scoped draft binding across Better Auth account hooks and consumes exact draft IDs. |
| apps/sim/hooks/queries/oauth/oauth-connections.ts | Propagates draft IDs through special-provider, desktop, and browser OAuth launch paths. |
| apps/desktop/src/main/handoff.ts | Carries the validated exact draft ID through the single-use desktop OAuth handoff. |
Sequence Diagram
sequenceDiagram
participant UI as Workspace UI
participant OAuth as OAuth Provider
participant Auth as Better Auth Callback
participant DB as Credential Store
UI->>UI: Snapshot credential IDs/account IDs/updatedAt
UI->>OAuth: Launch OAuth with exact draft ID
OAuth->>Auth: Provider callback
Auth->>DB: Create, reconnect, or bump existing credential
Auth-->>UI: Return to application
UI->>DB: Reload workspace credentials
UI->>UI: Infer outcome from count/accountId/updatedAt delta
Reviews (4): Last reviewed commit: "fix(credentials): preserve reauthorizati..." | Re-trigger Greptile
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2403a8d. Configure here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 25f6ba9. Configure here.

Summary
Type of Change
Testing
Checklist