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(antigravity): switch saved accounts at once and move each chat at its next message - #50216
agy (Antigravity's CLI) keeps one Google login on the machine. Selecting another saved account in Orca now swaps that login straight away, so new chats use it at once. A chat that is in the middle of a turn finishes that turn on the old account and says so, then moves to the new account with your next message. Its history stays.
Files
Added
Deleted
Net
Test
7
$\color{#1a7f37}{\Huge{\mathbf{+}}}$524
$\color{#cf222e}{\Huge{\mathbf{−}}}$1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$523
Prod
53
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1350
$\color{#cf222e}{\Huge{\mathbf{−}}}$190
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1160
What Changed
Before: selecting another saved account wrote agy's login, then stopped only the chats that were idle at that moment. Chats that were busy or starting kept their old agy acp and the old account indefinitely. Bot Home Chats were hit most, because they are often busy. Nothing recorded which account a chat had run on.
After:
Instant switch.accounts.antigravitySelect writes agy's login right away, as before. New chats launch on it at once.
Every chat moves. Each agy acp launch records the saved account its login was actually put on, as child.accountKey. That is the account the launch's preparation found or restored, not just the selection. If the selection changes between preparation and spawn, the login is prepared once more right before the spawn. Launches that don't use agy's Google login (API key, gcloud) record none. Orca's existing "launched under another account" check now compares that key when the home can't tell accounts apart, which is the case for agy. The same retirement Claude's account switch uses then handles agy:
Idle chats stop now.
A busy chat finishes its turn, and the next send's handover starts it on the new account (agy session/resume, same home, history kept).
This covers bot chats and orchestration workers, which are ordinary sessions on the same host.
A busy chat says so. A quiet line appears in that chat, in the same faint style as Claude's "switched models" line: "Finishing this turn on old@x. Your next message uses new@y." Each running agent has one such line. Switching again revises it, and switching back to the account the turn runs on removes it. Older clients, including phones, print the same sentence as plain text.
A failed move says so, once. When a launch can't put agy's login on the selected account (for example, the keychain would have to ask), the chat records the account it really runs on and shows "Couldn't move this chat to new@y: {reason}". Orca then holds chats where they are for that selection, so nothing relaunches in a loop. Restores happen only where they already did, off the send path: chat launches, listings, the exit-time restore and the switch itself. Each of those that finds agy's login on the selected account lifts the hold, and every held chat moves at its next send. A send only compares in-memory state, with no reads. Selecting another account lifts it too.
Which account a failed launch "really runs on" comes only from fresh evidence that raised no dialog: a no-prompt read made then, or what that restore read itself before it wrote anything. Otherwise it is recorded as unknown, never as the host's default login.
A launch on another home or credential store than the host's own reads a login no saved account names. That includes another session bus on Linux, which is another Secret Service. Orca decides this first, before anything about saved accounts. Such a launch records no saved account, so no switch ever retires it, it never holds the host's selection, and it never delays putting the selected login back when old-account agy processes exit.
Windows puts no account back at launch, but reading agy's login there raises no dialog, so each launch on the host's own home and store reads who holds it. A login on another account records that account and shows the note.
The account survives a restart.record.launchedAccount gains an optional accountId. Older builds ignore it. The stacked usage-limit PR uses it.
Write-back healing. An old-account agy that refreshes its token can write the old login back. The selected account is now put back:
before every chat launch (as main already did);
before every model listing and Enterprise/Orca-home Google launch (newly added);
once more when the last agy Orca started on a previous account exits (new). This one runs unasked, so it never reads a login that only a keychain dialog could name; it leaves that case to the next launch.
All of these use fix(antigravity): list agy accounts without reading its keychain login #51276's capped, latch-guarded reads, so none can raise a keychain dialog.
Sign-in exclusion. A select is refused while an in-app sign-in is writing agy's login.
Toasts. "Switched to {{account}}" (with "New chats use it now. Chats running a turn switch at their next message."), or "Antigravity account update failed." with the reason.
#50155: this PR is the account switch itself. The stacked PR (usage-limit release and the in-chat "Switch account" menu) completes the issue.
Why
Antigravity's saved accounts swap one login inside one home, so Orca's home comparison never saw a switch. The fix records which saved account each launch used and reuses the existing retirement path.
Kelvin chose instant switching over waiting for running turns, and agy behaves in a way that allows it. A running agy keeps its token in memory, so a busy turn finishes on its own account. Anything it writes back on refresh is undone at the next launch, listing, or exit. Persisting accountId means the account a chat ran on is still known after Orca restarts.
An idle agent on another saved account in the same home is stopped, and one on the selected account is kept.
The next send's handover starts it on the new account.
A busy chat keeps its agent and gets one account-switch line, revised in place on a second switch and removed when the selection returns to its account.
agy-account-selection.test.ts:
Only a change of the selected account is announced, and only the latest change stays committed.
A launch reads the vault before recording an account.
The selected login is put back once the last agy on a previous account exits (including one that started on another account than selected), and not when an agy on the selected account exits.
A launch that couldn't move to the selection says so once and stops chats retiring for it, until a later launch reaches it or another account is selected.
acp-launch-account-current.test.ts: a login prepared for a selection replaced before the spawn is prepared once more; one prepared for the current selection is kept, failure included.
native-account-launch-holder.test.ts:
A failed restore names the account it found holding agy's login before it wrote anything.
A restore whose write landed but whose readback failed names nobody.
Where reading raises no dialog (Windows), who holds the login is read directly.
A launch on another home or credential store records no saved account (foreign), never the host's login.
agy-launch-credential-authority.test.ts:
The same home in another spelling is the host's: a trailing slash, a symlink, or a case-only difference on macOS and Windows. A different home, or a removed HOME, is foreign.
The same session bus in another spelling is the host's: guid in any position, doubled or trailing slashes, percent-escapes, the default runtime-folder bus. An address it can't read never makes a launch foreign. Another bus, or another ; fallback list, is foreign.
Buses are compared only when both the launch and the host use the keyring rather than agy's token file.
A launch elsewhere is classified as foreign before Orca reads the selection, even with none selected.
agy-account-selection.test.ts: an agy whose login no saved account names never delays putting the selected login back.
structured-agent-session-account-switch.test.ts: a chat held back by a failed move stays on its account at every send, and moves at the first send after agy's login is known to hold the selected one.
native-account-quiet-restore.test.ts: the exit-time restore never reads agy's login when its keychain item changed since Orca last read it.
agent-session-owner-proof.test.ts: the saved account a launch ran on is recorded in the home it ran in (or the home it moved to), and it reads back through the record validator.
pnpm check:changed passes.
Not run against a real agy login: per repo rules, nothing here touches the real keychain.
Performance
Per send: one synchronous comparison of the child's account key during the handover.
Per agy launch: one vault read, only the first time after Orca starts (an encrypted file; no keychain).
On a switch: one pass over loaded sessions to release idle chats, plus one journal row per chat that is still busy (revised or removed in place on later switches).
On a failed restore: one no-prompt read to name the login agy holds, and one journal row in the chat that launched.
On each agy process exit: a check over the agy processes Orca started.
Listings: each now runs the selected-account restore before it starts. That restore is a no-prompt fingerprint read that settles at once when nothing moved.
Nothing polls.
Risk
Level: Medium
Riskiest part: listings now restore the selected account before they start, where before only chats did. If the selected account doesn't match agy's login and exactly one other saved account does, a listing now switches agy back to the selected account, as a chat launch already would.
launchedAccount on agy chats: agy chats now record launchedAccount, which they never did before, so usage-limit attribution reads it for them too. It names the same home as before, so homes compare equal.
Backing out: a plain revert. The optional accountId field left in records is ignored.
AI Disclosure
Review
One round, Codex and a Claude reviewer. Fixed:
Windows never noted the selected account, so chats there didn't move. The selection is now tracked on every platform.
A select landing between a launch's start and its spawn could stamp the chat with the new account while agy ran on the old login. The account is now read as the process spawns.
The exit-time restore could read agy's login through the keychain when its item had changed. It now skips that case.
Listings didn't restore the selected account for host chats. They do now.
A busy-chat line could reuse an earlier line's id after a restart. Its id now includes the chat's fence.
The very first selection (no previous account) wrote a line naming an empty account. It now writes none.
API-key and gcloud chats were stamped with a saved account they don't use. They record none now.
The success toast's "running chats switch" line showed for WSL accounts, whose chats this doesn't move. It now shows only for host accounts.
A final Codex check found two more, both fixed:
A launch was stamped with the selection at spawn, not the login it got. A switch during an Orca-home launch's preparation, or a failed restore, left a chat recorded on the new account while it ran on the old one, so it never moved. Launches now record the account their preparation verified, and re-prepare once if the selection moved before the spawn. A failed restore records the account the login really holds, shows the chat why, and latches so the chat isn't relaunched for nothing.
Switching A→B→A during a running turn left the "next message uses B" line. Each running agent now has one line that follows the selection and goes away when it returns.
A focused Codex check of those fixes found no P0/P1 and no restart loop, and four P2s, all fixed:
A held-back chat never recovered on its own next message. It now moves at its next send once a launch, listing, restore or the switch finds agy's login on the selected account.
Windows recorded the selection without checking agy's login. It now reads who holds it.
On backends without no-prompt reads (Linux), a restore whose write landed but whose readback failed was recorded on the old account. Holder evidence is now dropped before any write, and only fresh evidence names a holder.
A launch on another home or credential store was recorded on the host's login. It now records no saved account, and no switch retires it. Windows makes the same check before reading the login.
A Codex check of that redesign found no P0/P1 (a send's check stays memory-only) and three P2s, fixed by making the "is this launch foreign?" decision once, first, and using it everywhere:
The check ran after the no-selection early return, so a foreign chat recorded the empty account and was retired when the first account was selected. It now runs first.
A foreign chat's process still counted as an old-account agy and delayed putting the selected login back. It no longer counts.
On Linux, a launch on another session bus (another Secret Service) counted as the host's store. It is now foreign.
A further Codex check found the foreign test too eager in three places, which matters because a normal launch called foreign quietly stops following switches. A launch is now foreign only when the difference is provable:
Session bus addresses are parsed as D-Bus address lists and compared canonically: guid dropped, unix:path normalized, ; fallbacks kept in order. An unreadable address counts as the same bus.
Homes are compared by real path, case-folded on macOS and Windows. Where a real path can't be read, only a clearly different spelling counts.
File-or-keyring storage uses the same full decision as the credential backend (containers included), and buses are compared only when both sides use the keyring.
A first version of the held-chat recovery restored agy's login inside a send. A Codex check showed two P1s in it: an other-home chat restarted at every send, and sends could wait on account work with no overall deadline. It was replaced by the in-memory check above.
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
Windows has no restore at launch (unchanged). Orca tracks the selected account and reads who holds agy's login at each launch (no dialog there), so chats move at their next message, or say why they can't.
Remote: a remote host runs all of this itself.
Mobile: the account-switch line renders on mobile too, and older phones print its text.
Folder workspaces: unaffected.
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)
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
No actionable comments were generated in the recent review.
Walkthrough
The changes add launch-account identity tracking and coordinate Antigravity account switches with active chats and other processes. The runtime exposes switch progress and failure details, and the settings UI refreshes while a switch is active. Session account keys are carried through acquisition and publication for account comparisons. The CLI polls for switch completion and reports progress or failure.
Merge Risk: Moderate · up to c2e04
Account switching for Antigravity chats has several open concerns. A stuck process shutdown can block new chats. A partial credential write can leave stale login state. The CLI can report success for an account that was never selected. Some settings controls can stay locked. These should be resolved or explicitly accepted before merge.
Pre-merge checks: 4
Check name
Status
Explanation
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Title check
The title names the two main behaviors of the PR: switching saved Antigravity accounts at once, and moving each chat to the new account at its next message. It matches the changeset, which adds an ins…
Description check
The description is detailed and covers most required sections. The ELI5, What Changed, Why, Linked Issue (#50155), Visual Proof (screenshots for light and dark themes), Testing, Performance, Risk (Lev…
Full details: Title check
Explanation
The title names the two main behaviors of the PR: switching saved Antigravity accounts at once, and moving each chat to the new account at its next message. It matches the changeset, which adds an instant account select, records a per-launch account key, and retires or hands over chats. The title is in conventional-commit form and is 86 characters, slightly long but readable.
Full details: Description check
Explanation
The description is detailed and covers most required sections. The ELI5, What Changed, Why, Linked Issue (#50155), Visual Proof (screenshots for light and dark themes), Testing, Performance, Risk (Level: Medium, with a backout plan), Review, and Notes are all filled in. The Performance section gives a concrete reasoned answer. The checklist is mostly completed. The required items that are missing or incomplete are: the Linked Issue is cited as #50155 but the author notes the stacked PR completes the issue, which is acceptable; the AI Disclosure section is empty (it is only required for non-StablyAI team members, so the author's status is unclear); the Testing section leaves the manual-testing checkbox unchecked and the 'pnpm lint, typecheck, test, build' checklist item unchecked, so it is unclear whether these checks were run; and the Review section is included but the Agent skill upstream boundary item is checked. The description is mostly complete, so the check passes, with the minor gaps noted below.
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Stability & Availability · Quick win
Do not make the early progress reply wait behind the credential write.
The reply timer can fire while selectAccount() is in its serialized section. listAccounts() and selectAccount() both run through AntigravityAccountService.serialize(), and that helper chains each operation after the previous one. The second service.listAccounts() call on the early reply path therefore waits for the in-flight credential write. This delays the reply past the 5-second reply budget.
Keep the full account state from the initial read near line 100, and use it for the early progress reply. The early reply then no longer waits for serialize(). It returns the account rows read before the switch started, with the switching progress. Keep returning the final rows when done settles first.
Suggested fix
- const active = (await service.listAccounts()).activeAccountId+ const current = await service.listAccounts()+ const active = current.activeAccountId
The reason will be displayed to describe this comment to others. Learn more.
Minor · Stability & Availability · Quick win
Re-check the account switch immediately before starting the sign-in.
The changeAccount path awaits account-store work after the AGY_HOST_ACCOUNT_SWITCH.running() check at line 186. An account switch can start during those awaits. The handler then starts sign-in at line 197 without another check. startAntigravityChatSignIn and runFlow do not check the switch either. The sign-in agy process can therefore start while the switch drains chats. This breaks the sign-in and switch serialization. The switch can then fail its pre-write check.
Move the check so that no await separates it from startAntigravityChatSignIn. The synchronous start then runs without interleaving.
Suggested fix
+ // Re-check after the awaits above: a switch can start while they run.+ if (AGY_HOST_ACCOUNT_SWITCH.running()) {+ throw new Error('Antigravity is switching accounts. Sign in after it finishes.')+ }
return startAntigravityChatSignIn(agySignInHost(ctx.runtime), owner, intent)
Files skipped from review as they are similar to previous changes: 1
src/renderer/src/i18n/locales/en.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Performance & Scalability · Quick win
Cache the initial account rows before publishing the switch.
While the switch waits for its early reply, this.rows remains null. An accounts.antigravityList request then bypasses waitingRows() and calls service.listAccounts(), which reads the native credentials again.
Keep the full result from Line 113 and assign it to this.rows before publishing progress. Clear it when the switch ends, as the code already does. This also covers reads before the early reply; the previous early-reply correction does not cover that interval.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Apply host switch progress only to host account rows.
For a WSL target, signIn.accountSwitch still describes the host. This assignment puts that progress into the distro's account state. AntigravityAgyAccountRows then disables Save, Select and Remove until the unrelated host switch ends. Passing no signInControls does not prevent this assignment.
Gate this overlay and the progress reread key with chats. Host rows will retain progress, and WSL rows will retain their own account state.
Files skipped from review as they are similar to previous changes: 1
src/renderer/src/i18n/locales/en.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
AmoabaKelvin
changed the title
fix(antigravity): move every open chat to the newly selected account, after running turns finish
fix(antigravity): switch saved accounts at once and move each chat at its next message
Nov 28, 2026
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
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.
ELI5
agy (Antigravity's CLI) keeps one Google login on the machine. Selecting another saved account in Orca now swaps that login straight away, so new chats use it at once. A chat that is in the middle of a turn finishes that turn on the old account and says so, then moves to the new account with your next message. Its history stays.
What Changed
Before: selecting another saved account wrote agy's login, then stopped only the chats that were idle at that moment. Chats that were busy or starting kept their old
agy acpand the old account indefinitely. Bot Home Chats were hit most, because they are often busy. Nothing recorded which account a chat had run on.After:
accounts.antigravitySelectwrites agy's login right away, as before. New chats launch on it at once.agy acplaunch records the saved account its login was actually put on, aschild.accountKey. That is the account the launch's preparation found or restored, not just the selection. If the selection changes between preparation and spawn, the login is prepared once more right before the spawn. Launches that don't use agy's Google login (API key, gcloud) record none. Orca's existing "launched under another account" check now compares that key when the home can't tell accounts apart, which is the case for agy. The same retirement Claude's account switch uses then handles agy:session/resume, same home, history kept).record.launchedAccountgains an optionalaccountId. Older builds ignore it. The stacked usage-limit PR uses it.All of these use fix(antigravity): list agy accounts without reading its keychain login #51276's capped, latch-guarded reads, so none can raise a keychain dialog.
#50155: this PR is the account switch itself. The stacked PR (usage-limit release and the in-chat "Switch account" menu) completes the issue.
Why
Antigravity's saved accounts swap one login inside one home, so Orca's home comparison never saw a switch. The fix records which saved account each launch used and reuses the existing retirement path.
Kelvin chose instant switching over waiting for running turns, and agy behaves in a way that allows it. A running agy keeps its token in memory, so a busy turn finishes on its own account. Anything it writes back on refresh is undone at the next launch, listing, or exit. Persisting
accountIdmeans the account a chat ran on is still known after Orca restarts.Linked Issue
#50155
Visual Proof
The line in a chat still running a turn when the account switched (light / dark):
Selecting an account (light / dark):
A select that can't run (light / dark):
A chat that couldn't start on the selected account (light / dark):
All shots are from component fixtures:
NativeChatNoticeRow:accountSwitch,NativeChatNoticeRow:accountNotMovedandAntigravityAccountSwitchToast.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
structured-agent-session-account-switch.test.ts(real host rig):agy-account-selection.test.ts:acp-launch-account-current.test.ts: a login prepared for a selection replaced before the spawn is prepared once more; one prepared for the current selection is kept, failure included.native-account-launch-holder.test.ts:agy-launch-credential-authority.test.ts:HOME, is foreign.;fallback list, is foreign.agy-account-selection.test.ts: an agy whose login no saved account names never delays putting the selected login back.structured-agent-session-account-switch.test.ts: a chat held back by a failed move stays on its account at every send, and moves at the first send after agy's login is known to hold the selected one.native-account-quiet-restore.test.ts: the exit-time restore never reads agy's login when its keychain item changed since Orca last read it.agent-session-owner-proof.test.ts: the saved account a launch ran on is recorded in the home it ran in (or the home it moved to), and it reads back through the record validator.pnpm check:changedpasses.Not run against a real agy login: per repo rules, nothing here touches the real keychain.
Performance
Risk
Level: Medium
launchedAccounton agy chats: agy chats now recordlaunchedAccount, which they never did before, so usage-limit attribution reads it for them too. It names the same home as before, so homes compare equal.accountIdfield left in records is ignored.AI Disclosure
Review
One round, Codex and a Claude reviewer. Fixed:
A final Codex check found two more, both fixed:
A focused Codex check of those fixes found no P0/P1 and no restart loop, and four P2s, all fixed:
A Codex check of that redesign found no P0/P1 (a send's check stays memory-only) and three P2s, fixed by making the "is this launch foreign?" decision once, first, and using it everywhere:
A further Codex check found the foreign test too eager in three places, which matters because a normal launch called foreign quietly stops following switches. A launch is now foreign only when the difference is provable:
unix:pathnormalized,;fallbacks kept in order. An unreadable address counts as the same bus.A first version of the held-chat recovery restored agy's login inside a send. A Codex check showed two P1s in it: an other-home chat restarted at every send, and sends could wait on account work with no overall deadline. It was replaced by the in-memory check above.
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)