fix(connect): preserve CLI OAuth parameters through browser sign-in - #6285
Conversation
- Route CLI authorization through the hosted connect page - Return loopback OAuth codes directly to the waiting CLI
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
ApprovabilityVerdict: Needs human review This PR modifies OAuth authentication flow logic (how CLI authorization routes through Clerk), which requires human review regardless of change simplicity. The fix alters how authorization URLs are built and how redirect URIs are determined during CLI sign-in. You can customize Macroscope's approvability policy. Learn more. |
## What's Changed * feat(mobile): add thread title regeneration by @chrisdeeming in pingdotgg/t3code#6253 * chore: add dara to vouched by @maria-rcks in pingdotgg/t3code#6259 * fix(web): align the composer model picker by @t3-code[bot] in pingdotgg/t3code#6252 * fix(mobile): keep ordered lists inside user bubbles by @none23 in pingdotgg/t3code#6154 * feat(web): a better right panel empty state by @StiensWout in pingdotgg/t3code#6258 * fix(web): align mobile onboarding header by @t3-code[bot] in pingdotgg/t3code#6293 * fix(connect): preserve CLI OAuth parameters through browser sign-in by @juliusmarminge in pingdotgg/t3code#6285 ## New Contributors * @none23 made their first contribution in pingdotgg/t3code#6154 **Full Changelog**: pingdotgg/t3code@v0.0.34-nightly.20260812.1072...v0.0.34-nightly.20260812.1076 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.34-nightly.20260812.1076
What Changed
Route the CLI's browser (loopback) OAuth flow through the hosted
/connectpage instead of opening Clerk's/oauth/authorizedirectly. The printed URL now carries the loopback callback port in the URL fragment (/connect#state=…&challenge=…&port=34338); after the page confirms a Clerk session it forwards to/oauth/authorizewith the loopbackredirect_uri, so the authorization code still lands on the waiting CLI athttp://127.0.0.1:34338/callback. The out-of-band (headless) flow is unchanged. Added strict validation + tests for the port parameter, dropped the now-unusedauthorizationEndpointfrom the CLI OAuth config, and updated the Connect internals doc.Why
Fixes #5051.
npx t3 connectsent a possibly signed-out browser straight toclerk.t3.codes/oauth/authorize. Clerk then bounces through its sign-in redirect mid-flow, and that round-trip does not reliably preserve the authorize query parameters — the request comes back with onlyclient_idandredirect_uri, so Clerk redirects to the loopback witherror=unsupported_response_typeand an emptystate. The CLI's callback handler rejects that asInvalid T3 Connect authorization callbackand times out. This is exactly why the reporter found--headlessworking on the same machine/account: the headless flow already signs in onapp.t3.codesbefore touching/oauth/authorize. This PR makes the loopback flow session-first the same way, which also removes the terminal→browser URL-mangling failure class (a truncated copied URL now fails fast with the "incomplete link" page instead of a 10-minute timeout).Related (same surface, not fixed here): #5130 — the
/connectpage not auto-advancing after passkey sign-in.No Clerk dashboard changes needed: both
http://127.0.0.1:34338/callbackandhttps://app.t3.codes/connect/callbackare already registered. Deploy note: the hosted web bundle must ship before/with the CLI release — an older bundle ignores theportfragment and would fall back to showing the paste-code page while the CLI waits on the loopback.UI Changes
The
/connectpage shows "Browser authorization" instead of "Step 1 of 2 · Browser authorization" for loopback requests (there is no browser step 2 in that flow). No screenshots required.Checklist
Note
High Risk
Changes CLI OAuth authorize/redirect behavior and loopback redirect URI selection, which are authentication-critical paths. Invalid port handling or redirect mismatches could break or misroute authorization codes.
Overview
Fixes CLI OAuth failures where opening Clerk
/oauth/authorizewhile signed out dropped PKCE/stateparams across Clerk's sign-in redirect (#5051).The loopback login path now prints a hosted
/connectURL (viabuildConnectAuthorizeRequestUrl) that includes the callbackportin the fragment. After a Clerk session exists, the hosted page forwards to/oauth/authorizewith a loopbackredirect_uriso the code returns to127.0.0.1; out-of-band flows still omit the port and use/connect/callback.CloudCliOAuthConfigdropsauthorizationEndpoint(CLI only hits/oauth/tokendirectly) and exposesloopbackPort. Shared helpers validate the port, and connect UI copy distinguishes the one-step loopback flow from the two-step hosted handoff.Reviewed by Cursor Bugbot for commit 41e519a. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Preserve CLI OAuth parameters through the hosted /connect page during browser sign-in
/connectpage instead of directly to Clerk's/oauth/authorize, carryingstate,code_challenge, andloopbackPortas fragment parameters.loopbackPortfield toConnectAuthorizeRequestin connectAuth.ts; when present, the Clerk authorize URL targets the CLI's local loopback callback (http://127.0.0.1:<port>/callback) instead of the hosted/connect/callback.authorizationEndpointwithloopbackPortinCloudCliOAuthConfigand removesbuildConnectClerkAuthorizeUrlfrom the server-side login flow in CliTokenManager.ts.portfragment parameter inreadConnectAuthorizeRequest; malformed values cause the function to returnnull./connectpage which then redirects to Clerk.Macroscope summarized 41e519a.