You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(web): report ChatGPT sign-in returns to removed environments - #39573
Browser ChatGPT sign-in returns waited silently for removed environments. The browser now shows the existing error when the destination is absent from the loaded catalog and platform discovery has resolved the topology, even if an unrelated persistence write fails. Incomplete discovery keeps the callback available for delivery when its environment connects.
Commit 59651c1761 (main). T3 Code opens Welcome for another environment without reporting that the sign-in failed. The cause is at apps/web/src/providerAuthDelivery.ts:33. Ran pnpm scenarios:prove scripts/scenarios/chatgpt-return-reports-removed-environment.e2e.ts --base main with the repro test added: it failed in 2 of 2 runs on a clean checkout, with ChatGPT sign-in couldn't finish in the output.
Evidence
Environment: boat.dev default machine, Linux x64, a fresh checkout of each commit
Steps: A ChatGPT sign-in return reports that it cannot finish on a removed environment: app.open ; expect.not.toHaveURL //pair(?:[?#]|$)/; app.open /welcome#codex-auth=%7B%22environmentId%22%3A%22removed-sign-in-machine%22%2C%22instanceId%22%3A%22codex%22%2C%22flowId%22%3A%22scenario-flow%22%2C%22callbackUrl%22%3A%22http%3A%2F%2F127.0.0.1%3A1455%2Fauth%2Fcallback%3Fstate%3Dscenario-auth-state%26code%3Dscenario-code%22%2C%22returnHash%22%3A%22%23agents%3Aremoved-sign-in-machine%22%7D; expect.toBeVisible getByText("ChatGPT sign-in couldn't finish"); app.screenshot return-to-removed-environment.
import{EnvironmentId,ProviderInstanceId}from"@t3tools/contracts";import{codexAuthDeliveryUrl}from"@t3tools/shared/codexAuthHandoff";import{expect}from"e2e";import{test,WEB}from"./t3.ts";test("A ChatGPT sign-in return reports that it cannot finish on a removed environment",WEB,async({ t3, app, screen })=>{awaitt3.project("demo");constenvironmentId=EnvironmentId.make("removed-sign-in-machine");constinstanceId=ProviderInstanceId.make("codex");constreturnUrl=newURL("/welcome",app.baseUrl);returnUrl.hash=`agents:${environmentId}`;// Start at the helper's return link. The missing machine makes the code unusable,// so this does not contact the identity provider.constcallback=newURL("http://127.0.0.1:1455/auth/callback");callback.searchParams.set("state","scenario-auth-state");constauthorization=newURL("https://auth.openai.com/api/accounts/authorize");authorization.search=newURLSearchParams({state: "scenario-auth-state",redirect_uri: "http://127.0.0.1:1455/auth/callback",response_type: "code",code_challenge_method: "S256",code_challenge: "a".repeat(43),client_id: "dynamic_agent_client",}).toString();callback.searchParams.set("code","scenario-code");constdelivery=newURL(codexAuthDeliveryUrl({authorizationUrl: authorization.href,returnUrl: returnUrl.href,
environmentId,
instanceId,flowId: "scenario-flow",},callback.href,),);awaitt3.open(`${delivery.pathname}${delivery.search}${delivery.hash}`);try{awaitexpect(screen.getByText("ChatGPT sign-in couldn't finish",{exact: true}),).toBeVisible();}finally{awaitapp.screenshot("return-to-removed-environment");}},);
Tests
ecc4522788 adds the failing test, alone, before the fix.
pnpm exec vp run check:changed passed on head.
Not in this change
Saved targets still wait through transient disconnects, and the connection supervisor retains its policies for disabled and unsupported entries.
Removal after callback dispatch follows existing RPC error handling.
Exact environment IDs still select the destination, regardless of duplicate labels, route changes, or provider IDs.
Empty and malformed fragments follow the existing parser and URL cleanup.
Each page consumes one return fragment, and the server still validates flows and orders returns across tabs.
Desktop and native mobile sign-in use separate callback paths.
Configured split-origin primaries use the same discovery gate as same-origin primaries, which the browser scenarios exercise.
Who did the work
Written by GPT 6.2 Sol, in Codex
Review findings fixed by GPT 6.2 Sol, in Codex
Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex, each on its own
Also reviewed by cubic, run locally by a program, with no score
Reproduction, checks and proof run by a program on base and head, not by an agent
Left open after review: should, apps/web/src/providerAuthDelivery.ts:40: On a loopback web client, a return to a removed remote environment can still stay silent if the unrelated primary descriptor request keeps failing. I reproduced the dependency by loading a return for an ID absent from the catalog and aborting two consecutive primary descriptor requests. The error toast appeared only after I let primary discovery succeed. The registry publishes null on every incomplete poll, and this atom waits indefinitely on null. When a target's identity is known, limit discovery uncertainty to the IDs it could affect. For discovery that remains unresolved, give the user feedback after a bounded wait while continuing to accept recovery for a valid callback.; should (cubic), apps/web/src/connection/platform.ts:765: One failing desktop-local backend keeps sign-in returns waiting forever. discoveryComplete goes false whenever any secondary bootstrap is rejected or fails to load, and also when the primary topology read fails. While that is true, entriesAfterPlatformDiscovery emits null. Take a desktop with one broken or rejected secondary backend: every poll reports incomplete, so a ChatGPT return addressed to a removed environment stays AsyncResult.initial() in providerAuthDelivery.ts and never shows the error toast. That is the silent failure this branch is meant to fix. Discovery could count as complete once each target has been tried once, or it could only block when the delivery's own environment might be the unresolved one.
Made in T3 Code by Claude Opus 5.5 and GPT 6.2 Sol
No actionable comments were generated in the recent review.
Walkthrough
Platform connection sources now publish registration snapshots with discovery status. The registry exposes catalog entries after discovery. Provider auth delivery waits for discovery and reports when the destination environment is unavailable.
Changes: Environment discovery and auth delivery
Layer / File(s)
Summary
Platform snapshots and registry state packages/client-runtime/src/platform/source.ts, packages/client-runtime/src/connection/registry.ts, apps/web/src/connection/platform.ts, apps/mobile/src/connection/platform.ts, packages/client-runtime/src/connection/layer.ts, packages/client-runtime/src/connection/registry.test.ts, packages/client-runtime/src/state/threads-atoms.test.ts
Platform sources now publish registrations with a discovery-completion flag. The registry tracks that state and exposes catalog snapshots only after discovery completes. Startup reconciliation and registry test support use the updated contract.
The web app exposes the registry’s discovery stream through an atom. Provider auth delivery waits for discovery and destination connection, and reports when discovery excludes the destination. End-to-end scenarios cover interrupted discovery and removed environments.
This change shows the sign-in failure message when a ChatGPT return targets a removed environment. It keeps waiting while platform discovery is incomplete. No merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title follows conventional commit form and names the main change: the browser now reports ChatGPT sign-in returns that target removed environments. It matches the changeset, which adds discovery-g…
Description check
The description covers the problem, the change, the scope link to issue #39572, and verification. It includes reproduction steps, before/after evidence, and a test commit. It also lists exclusions and…
Linked Issues check
Directly linked issue #39572 requires that a ChatGPT sign-in return for a removed environment shows that sign-in could not finish. At head ae3ff16, apps/web/src/providerAuthDelivery.ts reads entriesAf…
Out of Scope Changes check
The changes in the whole-PR summary (merge base de0466f to head ae3ff16) implement the discovery-gated missing-environment check. They touch apps/web/src/providerAuthDelivery.ts, apps/web/src/connect…
Full details: Title check
Explanation
The title follows conventional commit form and names the main change: the browser now reports ChatGPT sign-in returns that target removed environments. It matches the changeset, which adds discovery-gated error reporting in providerAuthDelivery and related registry and platform changes.
Full details: Description check
Explanation
The description covers the problem, the change, the scope link to issue #39572, and verification. It includes reproduction steps, before/after evidence, and a test commit. It also lists exclusions and author attribution, which go beyond the template but do not conflict with it. The Problem section is merged into the opening paragraph, and the Scope section links the issue, so the required information is present. The verification section gives observed results for the changed behavior, and the description is mostly complete.
Full details: Linked Issues check
Explanation
Directly linked issue #39572 requires that a ChatGPT sign-in return for a removed environment shows that sign-in could not finish. At head ae3ff16, apps/web/src/providerAuthDelivery.ts reads entriesAfterPlatformDiscoveryAtom from apps/web/src/connection/catalog.ts. When discovery is resolved and the destination ID is absent from the catalog, the destination atom yields "missing", and reportUnavailableEnvironment() shows the toast "ChatGPT sign-in couldn't finish". When the presentation is known, the flow waits for the connected phase and does not report an error. The scenario scripts/scenarios/chatgpt-return-reports-removed-environment.e2e.ts fails on base d6cdb4f and passes on head 4b00217, per the PR description. The registry (packages/client-runtime/src/connection/registry.ts) keeps discovery state separate from persistence writes, and the added registry test covers a failed bearer credential save. The issue's stated reproduction is met. Known gap: when discovery stays incomplete (the PR cites a failing loopback primary descriptor request, or a rejected desktop-local secondary backend), the destination atom waits on null and no toast appears. The issue does not define a bounded wait or a timeout, so this gap does not break the issue's stated requirement. Uncertainty: head ae3ff16 is newer than the previously reviewed head 4b00217. I did not read the incremental diff, so I cannot confirm whether the newer commits change the discovery gate or address the open review findings.
Full details: Out of Scope Changes check
Explanation
The changes in the whole-PR summary (merge base de0466f to head ae3ff16) implement the discovery-gated missing-environment check. They touch apps/web/src/providerAuthDelivery.ts, apps/web/src/connection/catalog.ts, apps/web/src/connection/platform.ts, packages/client-runtime/src/connection/{layer,registry,registry.test}.ts, and packages/client-runtime/src/platform/source.ts. The source type change to snapshots requires the mobile source update (apps/mobile/src/connection/platform.ts) and the threads-atoms.test.ts mock update. The scenario files support the change. The summary shows no changes to disconnect policy, fragment parsing, server flow validation, or desktop and native mobile callback paths, which the PR lists as excluded. The uncertainty noted for the linked-issue assessment also applies here: I did not read the incremental diff from 4b00217 to ae3ff16, so the verdict rests on the whole-PR summary and the head file content of providerAuthDelivery.ts.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
Paired a second real environment, confirmed the synthetic ChatGPT callback reports failure while connected, removed that environment, then full-loaded the same return link. Chromium, 1280×800, light theme, fresh isolated state on both commits.
Permanent blocker: real first-party ChatGPT OAuth and the desktop automatic-return handoff require OAuth access unavailable on this VM; the reported synthetic return-link reproduction was verified.
Temporary discovery or connection failures and the failing-primary-descriptor case were not exercised.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:L100-499 changed lines (additions + deletions).takeover:needs-juliusTakeover done; route gate says Julius decidesvouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Browser ChatGPT sign-in returns waited silently for removed environments. The browser now shows the existing error when the destination is absent from the loaded catalog and platform discovery has resolved the topology, even if an unrelated persistence write fails. Incomplete discovery keeps the callback available for delivery when its environment connects.
Fixes #39572
Related: #29125
Reproduction on main
Commit 59651c1761 (main). T3 Code opens Welcome for another environment without reporting that the sign-in failed. The cause is at
apps/web/src/providerAuthDelivery.ts:33. Ranpnpm scenarios:prove scripts/scenarios/chatgpt-return-reports-removed-environment.e2e.ts --base mainwith the repro test added: it failed in 2 of 2 runs on a clean checkout, withChatGPT sign-in couldn't finishin the output.Evidence
Environment: boat.dev default machine, Linux x64, a fresh checkout of each commit
Steps: A ChatGPT sign-in return reports that it cannot finish on a removed environment: app.open ; expect.not.toHaveURL //pair(?:[?#]|$)/; app.open /welcome#codex-auth=%7B%22environmentId%22%3A%22removed-sign-in-machine%22%2C%22instanceId%22%3A%22codex%22%2C%22flowId%22%3A%22scenario-flow%22%2C%22callbackUrl%22%3A%22http%3A%2F%2F127.0.0.1%3A1455%2Fauth%2Fcallback%3Fstate%3Dscenario-auth-state%26code%3Dscenario-code%22%2C%22returnHash%22%3A%22%23agents%3Aremoved-sign-in-machine%22%7D; expect.toBeVisible getByText("ChatGPT sign-in couldn't finish"); app.screenshot return-to-removed-environment.
Proven: the scenario fails on base d6cdb4f161 and passes on head 4b00217a11.
Scenario source:
scripts/scenarios/chatgpt-return-reports-removed-environment.e2e.tsTests
pnpm exec vp run check:changedpassed on head.Not in this change
Who did the work
apps/web/src/providerAuthDelivery.ts:40: On a loopback web client, a return to a removed remote environment can still stay silent if the unrelated primary descriptor request keeps failing. I reproduced the dependency by loading a return for an ID absent from the catalog and aborting two consecutive primary descriptor requests. The error toast appeared only after I let primary discovery succeed. The registry publishes null on every incomplete poll, and this atom waits indefinitely on null. When a target's identity is known, limit discovery uncertainty to the IDs it could affect. For discovery that remains unresolved, give the user feedback after a bounded wait while continuing to accept recovery for a valid callback.; should (cubic),apps/web/src/connection/platform.ts:765: One failing desktop-local backend keeps sign-in returns waiting forever.discoveryCompletegoes false whenever any secondary bootstrap is rejected or fails to load, and also when the primary topology read fails. While that is true,entriesAfterPlatformDiscoveryemitsnull. Take a desktop with one broken or rejected secondary backend: every poll reports incomplete, so a ChatGPT return addressed to a removed environment staysAsyncResult.initial()inproviderAuthDelivery.tsand never shows the error toast. That is the silent failure this branch is meant to fix. Discovery could count as complete once each target has been tried once, or it could only block when the delivery's own environment might be the unresolved one.Made in T3 Code by Claude Opus 5.5 and GPT 6.2 Sol