Skip to content

fix(antigravity): start agy chats on the selected account after an older agy wrote its login back - #50703

Merged
AmoabaKelvin merged 2 commits into
mainfrom
fix/antigravity-chats-follow-selected-account
Nov 27, 2026
Merged

AmoabaKelvin merged 2 commits into
mainfrom
fix/antigravity-chats-follow-selected-account

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

agy keeps one login per machine, and every running agy writes its own login back into that slot when it refreshes its token. #50206 made terminal launches put the account you selected back first. Antigravity chats never had that check: a chat opened after an older agy wrote its login back ran on that older account, which might be the one whose quota you just ran out of. Now chats put the selected account back too.

Files Added Deleted Net
Test 0 0 0 0
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​43 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​26

What Changed

Before: with A and B saved and B selected, an agy still running on A wrote A's tokens back within the hour. Every new or resumed Antigravity chat then ran on A's tokens and quota. agy kept B's stored email label, so it even reported b@… while spending A's quota.

After:

  • Chats follow the selection. Host agy chats and Orca-home Google chats put the selected account back right before agy starts, using the same restore terminal launches use since fix(antigravity): restore the selected agy account at launch when another agy refreshes over it #50206. Resumes count too, including idle chats that Orca stops on an account switch.
  • No new failures. The restore is best effort for chats. When it isn't safe (a login Orca hasn't saved, nobody signed in, an in-app sign-in running, a different credential store, Windows), the chat starts on agy's current login exactly as before, and nothing that works today starts failing.
  • The launch check no longer blocks. It read the Linux session bus with statSync, and chats would now reach that on the main process. It uses an async check instead, which also removes the blocking call from the three terminal launch paths (their ratchet baseline rows shrink).

Model listings aren't changed: they only pick which models the chat picker offers.

Why

Chats read agy's login when their agy starts (agy acp at its first session) and keep it in memory, just like terminals. So restoring the slot right before the chat's agy starts is the smallest fix, and the spec's account.prepare hook runs exactly there, for every chat start and resume, never on reads. Chats never had the launch check, so making them refuse would add failures that don't exist today. A design that refused was reviewed and kept finding edge cases (gateway and API-key auth, other HOMEs, Linux session buses). Best effort avoids all of them: a restore only ever writes a saved account over another saved account.

Linked Issue

Fixes #50155

Follow-up to #50100 / #50206.

Visual Proof

N/A: no UI change. Proof is from agy's own logs, below.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

macOS, real agy 1.5.16, dev build of this branch as a headless serve. Scratch HOME with SSH_CONNECTION set so agy and Orca use a token file, not your keychain. A local HTTPS proxy and test CA stand in for Google's token endpoint. Chats were pointed at the scratch HOME with agentDefaultEnv.antigravity, and Orca routed them to the host's agy (chatUsesAgy: true). Setup: saved A and B, selected A, started a long-lived agy on A, selected B, and waited until that agy's refresh wrote A back (account list: A active, B selected).

  • main: a new chat's agy loaded A's token (at-rt-A-1, expiry 09:51:34) and reported email=b@…. The slot held A's tokens with B's id_token_email.
  • this branch: a new chat put B back. Its agy loaded B's snapshot, refreshed with rt-B at the fake Google, and authenticated as b@…. The account list showed B active.
  • [Feature]: Allow existing Antigravity chats to continue working after switching accounts #50155 flow: re-selected B so Orca stopped the idle chat that had started on A's tokens, then sent it a message. It resumed with a new agy on B's token.

Not run live: Linux, Windows (unchanged there), Orca-home Enterprise chats (same call, made before the login copy). No new test: this is launch wiring around the restore that native-account-store.test.ts already covers.

pnpm check:changed passes.

Performance

None, because the restore runs once per chat start or resume. It adds one vault read and native credential read, plus a write and readback only when another saved account holds the login. The credential-store check becomes async, which removes a synchronous stat from the main process on every agy launch.

Risk

The risky part is that chat starts can now write agy's login slot. They write only a saved account over another saved account, through the same path terminals use since #50206, and never during an in-app sign-in. If it misbehaves, a chat starts on the wrong saved account, which is today's behaviour after a flip. Residual, as for terminals: an older agy refreshing in the seconds before the chat's agy reads the slot can still win. A plain revert backs it out.

Level: Low

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…der agy wrote its login back

Chats never passed the launch check, so a chat opened after another running agy refreshed its login over the selected account ran on that account's tokens while agy reported the selected email. Host and Orca-home Google chats now put the selected account back right before agy starts, the same restore terminal launches use. It is best effort: when a restore isn't safe the chat starts on agy's current login, as before.
…re an agy launch

The launch check stat'ed the Linux session bus synchronously; chats now reach it on the main process. It uses an async check instead, which also clears the blocking call from the terminal launch paths, so their baseline rows shrink.
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Chat preparation now attempts to restore the Antigravity account for host-account launches and for Orca home launches using Google OAuth. Account preparation uses asynchronous file-storage-host checks. If preparation fails, it warns that chat will start on the current login. The blocking-helper baseline also removes two entries and lowers two counts.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 8a38b

Antigravity chats now restore the selected account before agy starts, and fall back to the current login if restoration is unsafe. No concrete defect was found, and the blocking-call baseline only improves. Linux and Orca-home Enterprise paths were not manually tested, but nothing indicates a problem there.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: chats now restore the selected Antigravity account after an older agy writes its login back. It matches the changeset, which adds a restore step before chat launches a…
Description check Passed The description follows the repository template and fills in every required section: ELI5, What Changed (before and after), Why, Linked Issue (Fixes #50155), Visual Proof (N/A with reason), Testing, P…
Linked Issues check Passed Issue #50155 asks that existing Antigravity chats and bot Home Chats keep working after the user selects another saved account. The PR adds a call to restoreAntigravityAccountForChat in the host-acc…
Out of Scope Changes check Passed All changed areas connect to the chat restore path or its direct support. native-account-launch.ts adds restoreAntigravityAccountForChat and awaits the async credential-store check. `native-file-c…
Full details: Title check

Explanation

The title names the main change: chats now restore the selected Antigravity account after an older agy writes its login back. It matches the changeset, which adds a restore step before chat launches and resumes. The title uses a conventional fix(antigravity) prefix and is specific.

Full details: Description check

Explanation

The description follows the repository template and fills in every required section: ELI5, What Changed (before and after), Why, Linked Issue (Fixes #50155), Visual Proof (N/A with reason), Testing, Performance, and Risk with level. The AI Disclosure section is left empty, which is acceptable for a StablyAI team member. The Review and Notes sections are present but are template text without author content. Overall the description is mostly complete.

Full details: Linked Issues check

Explanation

Issue #50155 asks that existing Antigravity chats and bot Home Chats keep working after the user selects another saved account. The PR adds a call to restoreAntigravityAccountForChat in the host-account launch spec (antigravity-acp-launch-spec.ts) and in the Orca-home Google OAuth prepare hook (antigravity-agy-orca-home.ts). The restore runs before agy starts for chat starts and resumes, so a resumed chat (including an idle chat that Orca stops on an account switch) starts agy on the selected account. The author reports a live macOS run with agy 1.5.16 showing: a new chat loads the selected account's token (main showed the prior account), and the #50155 flow resumes an idle chat on the newly selected account. The issue's suggested ACP-restart approach is not used literally, but the issue does not require a specific mechanism. Limits: the restore is best effort, so a chat falls back to agy's current login when restore is unsafe (unsaved login, in-app sign-in running, different credential store, Windows). Linux and Orca-home Enterprise chats were not tested live. No automated test was added. The issue does not require tests. A chat that is running and not idle is not described as switched in place.

Full details: Out of Scope Changes check

Explanation

All changed areas connect to the chat restore path or its direct support. native-account-launch.ts adds restoreAntigravityAccountForChat and awaits the async credential-store check. native-file-credentials.ts adds isAntigravityFileStorageHostAsync so the restore does not call statSync on the main process. That helper also serves the existing terminal launch checks, so the three PTY launch paths lose their blocking-helper baseline entries (spawn-env.ts, local-configure.ts, spawn-options.ts, and native-account-launch.ts in config/main-blocking-helper-baseline.txt). The PR states that model listings are unchanged. No unrelated file or feature change appears in the summary.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7942fc9a-7811-4c8e-96c3-068a5b503150
Commits

Reviewing files that changed from the base of the PR and between 0c9aac4 and 8a38b58.

Files selected for processing: 5

  • config/main-blocking-helper-baseline.txt
  • src/main/antigravity/antigravity-acp-launch-spec.ts
  • src/main/antigravity/antigravity-agy-orca-home.ts
  • src/main/antigravity/native-account-launch.ts
  • src/main/antigravity/native-file-credentials.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@AmoabaKelvin
AmoabaKelvin merged commit 2194f55 into main Nov 27, 2026
54 checks passed
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.

[Feature]: Allow existing Antigravity chats to continue working after switching accounts

1 participant