fix(antigravity): replay auth state to late subscribers #9643
main fromrefs/pull/9643/head·opened View on GitHubProblem#
Antigravity can emit and T3 can retain the Google authorization URL while the provider-auth WebSocket subscription is being mounted or reconnected. The existing subscription only listened for future changes, so a late subscriber never received the retained waiting state. In the desktop client this leaves sign-in stuck without the link controls, even though the runtime has already produced the URL.
Change#
- Replay the current ownership-filtered auth snapshot when provider.auth.subscribe starts.
- Keep the existing ownership rules: other clients still receive neither lowId nor uthorizationUrl.
- Add a regression test for a subscriber connecting after the flow has reached waiting.
This addresses #9624 and complements #9425 without changing the browser helper or OAuth validation.
Verification#
- git diff --check passes.
- Added focused server regression coverage.
- The repository test runner could not be executed in this environment because the checkout dependency installation is incomplete: pnpm stopped on uncached packages (@dnd-kit/core and @typescript/native-preview).
Implemented with Codex (GPT-5) in Codex Desktop on Windows 11.
Note
Low Risk Narrow subscription bootstrap change with existing visibility rules; adds regression coverage only.
Overview Fixes desktop Antigravity sign-in getting stuck when the provider.auth.subscribe WebSocket connects after the runtime has already moved to waiting with a Google authorization URL. Previously the stream only forwarded SubscriptionRef updates, so reconnecting or late-mounting clients never saw the retained state and the UI stayed without link controls.
subscribe in AntigravityAuth now emits the current ownership-filtered snapshot (via existing visibleSnapshot rules) before listening for further changes, so the owning client immediately gets flowId and authorizationUrl while other clients still get neither. A server regression test covers subscribing after the flow is already in waiting.
Note
Fix AntigravityAuth to replay current auth state to late subscribers#
Subscribers that joined after authentication had entered the waiting phase missed the current state and only received later changes. The subscription stream in AntigravityAuth.ts now concatenates an effect that emits the current owner-visible auth state before consuming subsequent SubscriptionRef changes. A test in AntigravityAuth.test.ts verifies a late subscriber receives the waiting snapshot immediately.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
- @@ -513,5 +513,4 @@513513 return yield* Fiber.await(worker).pipe(Effect.flatMap((result) => result));514514 }),515515 subscribe: (ownerSessionId) =>516- SubscriptionRef.changes(snapshot).pipe(517- Stream.map((value) => visibleSnapshot(value, ownerSessionId)),516+ Stream.concat(
🟠 High
provider/AntigravityAuth.ts:516The subscription can remain stale after the initial state is emitted, so a client may stay in
waitingor retain anauthorizationUrlafter the flow has finished until another update occurs.Stream.concatdelays subscribing toSubscriptionRef.changes(snapshot)untilcurrentState(ownerSessionId)completes, allowing the PubSub-backed change to be missed; establish the change subscription before reading the initial state, using an atomic/current-state stream primitive if available.🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/provider/AntigravityAuth.ts around line 516: The subscription can remain stale after the initial state is emitted, so a client may stay in `waiting` or retain an `authorizationUrl` after the flow has finished until another update occurs. `Stream.concat` delays subscribing to `SubscriptionRef.changes(snapshot)` until `currentState(ownerSessionId)` completes, allowing the PubSub-backed change to be missed; establish the change subscription before reading the initial state, using an atomic/current-state stream primitive if available. Follow-up: simplified the regression assertion and force-pushed commit 9c75dbb6. git diff --check passes.
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This small, tested change modifies production authentication-state streaming, including replay of authorization-flow state to late subscribers. An unresolved high-severity finding also identifies a race that may leave subscribers stale after the initial replay, so human review is warranted.
Not approved because:
- 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
Correction after reviewing the blocking Macroscope finding: this PR's Stream.concat is not safe here because it delays subscribing to SubscriptionRef.changes. Effect's SubscriptionRef.changes already emits the current value and future updates atomically, so this proposal would add a real race. I have reset the PR branch to the base and am closing this PR rather than asking maintainers to review an invalid fix. Issue #9624 remains open for a validated fix.
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed