Repository navigation
fix(antigravity): start agy chats on the selected account after an older agy wrote its login back - #50703
Conversation
…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.
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
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.
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:
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 acpat 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'saccount.preparehook 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
macOS, real agy 1.5.16, dev build of this branch as a headless serve. Scratch HOME with
SSH_CONNECTIONset 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 withagentDefaultEnv.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).at-rt-A-1, expiry 09:51:34) and reportedemail=b@…. The slot held A's tokens with B'sid_token_email.rt-Bat the fake Google, and authenticated asb@…. The account list showed B active.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.tsalready covers.pnpm check:changedpasses.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
statfrom 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
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)