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
feat(antigravity): ask, restart or keep agy running in terminals when you switch accounts - #51652
agy keeps one Google login per computer. When you switch your Antigravity account in Orca, any agy already running in a terminal keeps working on the old account until you restart it. Now Orca deals with those terminals the same way it does for Claude: it asks you (by default), restarts them for you, or leaves them alone, depending on a new setting.
Files
Added
Deleted
Net
Test
5
$\color{#1a7f37}{\Huge{\mathbf{+}}}$479
$\color{#cf222e}{\Huge{\mathbf{−}}}$10
$\color{#1a7f37}{\Huge{\mathbf{+}}}$469
Prod
56
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1987
$\color{#cf222e}{\Huge{\mathbf{−}}}$392
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1595
What Changed
Before: after #50216, picking another saved Antigravity account switched new chats and new agy launches right away, but agy already running in Orca terminals stayed on the old account. Its hourly token refresh could even write the old login back over the switch until the next launch put the selected account back.
After, with the new setting When you switch accounts while agy is running in terminals (Settings → AI Provider Accounts → Antigravity):
Ask (default): a switch made in this window opens the same "Switched to {account}" dialog Claude uses, listing every terminal still running agy on the old account, with checkboxes, Keep as is and Restart N sessions. Terminals on some other earlier account are listed unticked under "Not on {account}".
Always restart: those terminals restart at once and a toast says so ("Restarting 2 Antigravity sessions on {account}", with Review when others were left).
A restart stops that terminal's agy, waits for it to exit, and relaunches agy --conversation <id> with the conversation its hooks reported. A terminal whose conversation Orca doesn't know restarts fresh, and the dialog says so on its row and in its text. WSL and SSH terminals are never touched, since the switch only changes this host's login.
Switches made somewhere else follow the setting too. A switch from the CLI on a desktop host goes to the desktop window, where Ask restarts instead of opening a dialog nobody at the CLI can answer (as Claude does since #41064). Terminals the window shows no pane for (an agy started in the background in a workspace it never opened) are moved by the host by the window's rule. A server with no window restarts by the switching client's own setting, fresh where it doesn't know the conversation; under Ask it leaves them and the switching client gets a toast with Restart, which answers it.
Mechanism:
Main owns which terminals run agy and on which account (antigravity-running-pane-account-move.ts). At each switch it lists the host's own terminals with agy in front (status row, saved record or launch, checked by a foreground read), skipping SSH, WSL, other servers' and chat-owned panes, and terminals whose spawn environment gives agy another credential authority (the same agyLaunchIsForeign decision chat launches use, noted per pane as each terminal spawns and dropped when that terminal exits), and notes the account each agy invocation runs on, so switching back to it moves nothing. The note ends when the terminal's command finishes or exits, or its hooks report another conversation.
accounts.antigravitySelect takes movesRunningSessions (this desktop window restarts its own), runningSessions (another client's choice) and answersAsk; the previous selection is read inside the same serialized select. Clients send the new params only to hosts that advertise accounts.antigravity-running-terminals.v1, since older hosts reject unknown params. accounts.antigravityMoveUnheldTerminals takes the terminals the window can't show.
The window restarts through the existing per-pane restart queue (AccountRestartAgent now includes antigravity), which already handles mounted and unmounted tabs. The host uses restartAgentPaneInPlace, which now also starts an agent afresh when it is given no conversation.
Claude's dialog, session tree, toasts and setting are now shared by agent (account-switch-copy.ts, account-switch-prompt.ts, account-switch-toasts.ts, AccountSwitchPromptDialog, RunningSessionSwitchSetting). Claude's copy and behaviour are unchanged. The window notice is one accountSelectedElsewhere(agent, change) for both.
Mobile: Claude's running-session switch has no phone surface (the phone only switches; the host follows its policy), and the phone can't switch Antigravity accounts at all, so nothing changes on mobile.
Why
The product call was to match Claude: a setting with Ask / Always restart / Keep, the same dialog and toasts. agy has a single login per host, so unlike Claude there are no per-pane account folders to read; the only reliable record of which account a running agy is on is the selection when it started, which main notes at every switch. Main does the listing because it owns the PTYs, their foreground reads and the selection, and it is the only place a windowless server can act. The window still runs its own restarts so its panes keep their xterm and focus, and so a terminal without a known conversation can restart fresh, which the in-place restart can't.
Linked Issue
Builds on #50216 (merged; Antigravity chats follow an account switch). Part of #50155.
Visual Proof
Component fixtures from the production components, light and dark:
No before shots: none of these existed for Antigravity. Claude's dialog is included to show it is unchanged by the shared component.
Ask, several terminals (light)
Ask, several terminals (dark)
One terminal, conversation unknown
Review from the restart toast
Setting (light)
Setting (dark)
Always restart toast
Server left them under Ask
Claude's dialog, same component
Testing
I manually tested these changes locally (not in the running app: see below)
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
antigravity-running-pane-account-move.test.ts (main, real runtime with a fake PTY controller): a restart stops the terminal, waits for its exit, then relaunches agy --conversation conv; Keep never restarts; a windowless host under Ask leaves terminals until answersAsk; the client's choice overrides the host setting; a CLI switch on a desktop host goes to the window and restarts nothing in main; SSH and WSL terminals are skipped; a kept terminal is listed on its own account, so switching back lists nothing; agy run again in a kept terminal is listed on the account selected as it started; an unknown conversation restarts as a new agy and the reply says so; the host moves terminals the window lacks.
antigravity-account-switch-sessions.test.ts (renderer store): a switch made elsewhere under Ask queues restarts with no dialog; a switch made here under Ask opens the dialog and restarts what the answer picks; a switch back drops a queued restart; Keep never queues.
Fixture screenshots above. I didn't run agy against a real login (it would read and write the real keychain item), so the end-to-end check is the tests at the owner plus the fixtures.
pnpm check:changed passes. macOS only.
Performance
None that matters, because the work runs only when a saved Antigravity account is switched: main reads the foreground of each terminal with agy evidence, one at a time, and skips the process scan when the cached foreground is a shell. Nothing new runs on any hot path, timer or render. The account map holds one string per live agy terminal and is pruned at each switch.
Risk
The riskiest part is the shared restart queue and the generalized Claude dialog: a mistake there would change what a Claude account switch restarts. Claude's queue rules are kept as they were (agent !== 'codex' where the code said agent === 'claude'), and its copy is the same keys and strings. An older desktop talking to a new host sends no new params and gets the host's own setting; a new desktop talking to an older host sends none and gets today's behaviour. Back out with a plain revert; the new setting key is ignored afterwards.
Level: Medium
Review
One review round (Codex and a Claude reviewer with a performance pass). No P0. Fixed from it:
A terminal where agy was quit and run again kept the old invocation's account. Main now forgets the note when the terminal's command finishes or exits, and when its hooks report a different conversation.
Terminals the window shows no pane for (a background agy in a workspace it never opened) were dropped. The window now hands those to the host (accounts.antigravityMoveUnheldTerminals), which moves them by the window's rule, as Claude's unheld sessions are.
A queued restart survived a switch back to its terminal's account; each switch now drops queued agy restarts the host no longer lists. Every switch also clears a dialog left open by an earlier one.
A fresh restart could replace a pane that had since left agy; it now requires the pane to still show agy.
Concurrent selections could read the same previous account; the previous selection is now read inside the serialized select.
Foreground checks run one at a time and skip the process scan when the cached foreground is a shell; an unreadable foreground keeps its note.
A server with no window now restarts agy with an unknown conversation fresh, as the desktop does, and its toast says how many started a new conversation.
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 host: the switch writes the host default credential, so running agy terminals there are listed and restarted the same way. WSL terminals are skipped.
Remote: a paired server moves its own terminals; SSH panes are never touched.
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)
No actionable comments were generated in the recent review.
Walkthrough
The change adds Antigravity account-switch handling for running terminals, including terminal credential tracking, host-side move policies, and renderer prompts and settings. It extends account-selection RPCs and notifications to carry terminal-move results. Claude and Antigravity now share account-switch prompt, session-tree, setting, and toast components. Restart handling supports fresh Antigravity sessions when no conversation is available.
Merge Risk: Moderate · up to 8bc5b · assessed changes only
Path filters excluded changed files. This rating applies only to the assessed changes.
This adds Ask, restart or keep handling for running agy terminals when you switch accounts. Several race and attribution cases remain open: a stale or superseded choice could stop a terminal that should have been left alone, and some terminals could be restarted or listed incorrectly. These are limited to opted-in agy terminals and can be avoided with Keep, but they should be resolved or explicitly accepted before merge.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: Antigravity (agy) terminals running under the old account can now be asked about, restarted, or kept when the user switches accounts. The raw summary and objectives co…
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.
Description check
The description follows the repository template closely. It has all required sections: ELI5, What Changed (before/after plus mechanism), Why (product rationale and alternatives), Linked Issue (referen…
Full details: Title check
Explanation
The title names the main change: Antigravity (agy) terminals running under the old account can now be asked about, restarted, or kept when the user switches accounts. The raw summary and objectives confirm a new setting with Ask, Always restart, and Never restart options, plus the dialog, restart queue, and host-side terminal tracking. The title is specific and matches the changeset. It is one sentence, though long at 89 characters.
Full details: Description check
Explanation
The description follows the repository template closely. It has all required sections: ELI5, What Changed (before/after plus mechanism), Why (product rationale and alternatives), Linked Issue (references #50216 as a builds-on link and #50155 as part of, but does not use a 'Fixes #' issue link), Visual Proof (fixture screenshots for light and dark modes, with the Claude comparison), Testing (automated tests listed with specific cases; manual testing explicitly not done in the running app), Performance (explained), Risk (level Medium, with rollback guidance), Review, Agent skill boundary (checked), Notes, and Checklist. The Linked Issue section does not contain a real issue that the template requires for outside contributors, and the manual-testing checkbox is left unchecked with an explanation. The AI Disclosure section is left blank with no statement about AI use, though the template says to omit it only for StablyAI team members. These gaps are minor, so the description is mostly complete.
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.
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; 5 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Heavy lift
Restore the credential-authority verdict when a daemon terminal is reattached.
The verdict is kept only in authorityByPaneKey. That map starts empty and gains an entry only from noteAgyTerminalAuthority, which runs when a new host terminal is prepared. A daemon terminal that survives an application restart is reattached without that preparation. Its pane has no entry, so agyTerminalIsForeign returns false. The terminal then counts as host-owned and can be listed and restarted under a saved account. If the terminal was spawned with another HOME, its agy reads a different login, which the switch contract excludes.
Required behavior: a reattached terminal must keep the authority it was spawned with. Until that authority is known, the terminal must not be treated as host-owned in account-switch moves. Choose the restore mechanism and the exclusion rule for unknown authority in the implementation.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Quick win
Handle saved-account changes even when the native login needs no write.
If an A terminal is still running and agy's native login already holds B, selecting B saves the change from A to B without calling switched. The RPC then skips terminal handling, so neither Ask nor Always restart applies. A retry can reach the same state if the first attempt wrote B but failed to save the selection.
After a verified login and successful vault save, notify the terminal handler when the saved selection changes. Keep a repeated selection with no saved change and no native write as a no-op.
The reason will be displayed to describe this comment to others. Learn more.
Major · Stability & Availability · Quick win
An Ask answer can stop agy terminals after a later switch selected Keep.
answerAntigravityAsk checks the selected account once, before it awaits listAgyTerminals. A switch that commits during that await changes the selection. The answer then still calls restartAgyTerminals. Its restart guard, agyTerminalStillMoves, compares only the terminal's noted account with the current selection. A terminal noted to the previous account passes that comparison, so restartAgentPaneInPlace can stop it and relaunch it on the newly selected account, even though that switch chose Keep.
The check that runs before the stop needs to confirm that the selection still equals the account the answer was given for. Apply that check after the last await and before the stop.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Heavy lift
Reject unheld-terminal requests from earlier switches to the same account.
An A→B handoff with restart can arrive after B→A and a new A→B switch with Keep. The account check still matches B. If the terminal is still on A, the old handoff can stop it despite the newer Keep choice.
Include a switch ID in runningTerminals and require it in the handoff. Validate the ID before applying the request's policy, including after the asynchronous scan.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Quick win
Limit Ask replies to the terminals the toast offered.
If P is restartable and Q's foreground is unreadable, the toast can offer one restart while Q retains its earlier account note. If Q becomes readable before the reply, the headless answer scans both terminals and can restart both. The window handoff also stores the full requested set rather than the subset that qualified.
Store the PTY IDs that qualify when you build the offer. On reply, recheck only those IDs. This still allows P to restart and lets the final guard reject P if it is no longer eligible.
The reason will be displayed to describe this comment to others. Learn more.
Major · Stability & Availability · Heavy lift
Do not attribute a post-switch invocation to the outgoing account.
If the scan waits on one PTY, a user can start agy on B in another shell already in the scan snapshot. When the loop reaches that shell, it can see the new invocation but has no account note for it. The fallback records A, so Always restart can stop a session that already uses B.
Use invocation-level launch evidence to establish that an unnoted invocation predates the switch before attributing it to A. Keep pre-switch A invocations eligible. Do not stop a newly discovered invocation automatically when its account cannot be established.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Data Integrity & Integration · Heavy lift
Clear or scope the saved Antigravity session before it resolves a new invocation.
The resolver falls back to the saved pane record when the live row has no providerSession. Nothing in the inspected paths removes that record when an agy invocation exits. A new invocation that has not yet reported its conversation can therefore inherit the previous conversation. A restart on account switch then resumes that conversation instead of starting fresh, which the PR describes as the behavior for an unknown conversation.
The fix needs a rule for invocation identity, such as clearing the record on invocation exit or accepting the fallback only for the invocation that wrote it. The inspected code does not establish which rule the design requires, so this comment does not propose a patch.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Show a fresh-start warning for ticked elsewhere terminals.
Elsewhere terminals never get the new-conversation reason. This is because only onAccount terminals run the resume check. A terminal on a third account whose conversation is unknown restarts fresh when ticked, but the dialog does not say so. The body and the fresh count cover only onAccount. The restart button still counts the ticked elsewhere terminals.
Apply the same resume check to elsewhere terminals. Mark each one that cannot resume with the same fresh-start reason that onAccount terminals get. Derive the fresh-start count from the ticked sessions, not from onAccount alone, so the body text and the restart button both reflect every terminal that will restart without its conversation.
The reason will be displayed to describe this comment to others. Learn more.
Major · Stability & Availability · Heavy lift
Bind each Antigravity Ask answer to the Ask it answers.
An Ask answer carries only accountId. The host accepts it whenever the latest Ask targets that account and the account is still selected. An answer from an older toast therefore acts on a newer Ask for the same account. After host B→C→B, a stale B answer restarts the terminals that the C→B Ask captured. The stale toast never listed those terminals, and busy agent turns stop without the user answering that prompt.
Claude avoids this with an Ask ID. The Antigravity contract needs the same guarantee. Assign each Ask an ID when the host records it. Pass that ID with the answer. Reject the answer when the IDs differ, as the Claude path does at claude-host-account-switch.ts:96.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Do not dismiss the host Ask after a WSL account selection.
If this owner already has a host-terminal Ask, selecting a WSL account removes that toast. The WSL result has no terminal move, but this call still evaluates replaceHostAsk(owner). No replacement action appears, so the client loses its host-terminal restart action.
Return 'show-confirmation' for non-host targets before replacing the host Ask. Keep replacement enabled for later host selections.
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 keeps one Google login per computer. When you switch your Antigravity account in Orca, any agy already running in a terminal keeps working on the old account until you restart it. Now Orca deals with those terminals the same way it does for Claude: it asks you (by default), restarts them for you, or leaves them alone, depending on a new setting.
What Changed
Before: after #50216, picking another saved Antigravity account switched new chats and new agy launches right away, but agy already running in Orca terminals stayed on the old account. Its hourly token refresh could even write the old login back over the switch until the next launch put the selected account back.
After, with the new setting When you switch accounts while agy is running in terminals (Settings → AI Provider Accounts → Antigravity):
A restart stops that terminal's agy, waits for it to exit, and relaunches
agy --conversation <id>with the conversation its hooks reported. A terminal whose conversation Orca doesn't know restarts fresh, and the dialog says so on its row and in its text. WSL and SSH terminals are never touched, since the switch only changes this host's login.Switches made somewhere else follow the setting too. A switch from the CLI on a desktop host goes to the desktop window, where Ask restarts instead of opening a dialog nobody at the CLI can answer (as Claude does since #41064). Terminals the window shows no pane for (an agy started in the background in a workspace it never opened) are moved by the host by the window's rule. A server with no window restarts by the switching client's own setting, fresh where it doesn't know the conversation; under Ask it leaves them and the switching client gets a toast with Restart, which answers it.
Mechanism:
antigravity-running-pane-account-move.ts). At each switch it lists the host's own terminals with agy in front (status row, saved record or launch, checked by a foreground read), skipping SSH, WSL, other servers' and chat-owned panes, and terminals whose spawn environment gives agy another credential authority (the sameagyLaunchIsForeigndecision chat launches use, noted per pane as each terminal spawns and dropped when that terminal exits), and notes the account each agy invocation runs on, so switching back to it moves nothing. The note ends when the terminal's command finishes or exits, or its hooks report another conversation.accounts.antigravitySelecttakesmovesRunningSessions(this desktop window restarts its own),runningSessions(another client's choice) andanswersAsk; the previous selection is read inside the same serialized select. Clients send the new params only to hosts that advertiseaccounts.antigravity-running-terminals.v1, since older hosts reject unknown params.accounts.antigravityMoveUnheldTerminalstakes the terminals the window can't show.AccountRestartAgentnow includesantigravity), which already handles mounted and unmounted tabs. The host usesrestartAgentPaneInPlace, which now also starts an agent afresh when it is given no conversation.account-switch-copy.ts,account-switch-prompt.ts,account-switch-toasts.ts,AccountSwitchPromptDialog,RunningSessionSwitchSetting). Claude's copy and behaviour are unchanged. The window notice is oneaccountSelectedElsewhere(agent, change)for both.Mobile: Claude's running-session switch has no phone surface (the phone only switches; the host follows its policy), and the phone can't switch Antigravity accounts at all, so nothing changes on mobile.
Why
The product call was to match Claude: a setting with Ask / Always restart / Keep, the same dialog and toasts. agy has a single login per host, so unlike Claude there are no per-pane account folders to read; the only reliable record of which account a running agy is on is the selection when it started, which main notes at every switch. Main does the listing because it owns the PTYs, their foreground reads and the selection, and it is the only place a windowless server can act. The window still runs its own restarts so its panes keep their xterm and focus, and so a terminal without a known conversation can restart fresh, which the in-place restart can't.
Linked Issue
Builds on #50216 (merged; Antigravity chats follow an account switch). Part of #50155.
Visual Proof
Component fixtures from the production components, light and dark:
No before shots: none of these existed for Antigravity. Claude's dialog is included to show it is unchanged by the shared component.
Testing
I manually tested these changes locally (not in the running app: see below)
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
antigravity-running-pane-account-move.test.ts(main, real runtime with a fake PTY controller): a restart stops the terminal, waits for its exit, then relaunchesagy --conversation conv; Keep never restarts; a windowless host under Ask leaves terminals untilanswersAsk; the client's choice overrides the host setting; a CLI switch on a desktop host goes to the window and restarts nothing in main; SSH and WSL terminals are skipped; a kept terminal is listed on its own account, so switching back lists nothing; agy run again in a kept terminal is listed on the account selected as it started; an unknown conversation restarts as a new agy and the reply says so; the host moves terminals the window lacks.antigravity-account-switch-sessions.test.ts(renderer store): a switch made elsewhere under Ask queues restarts with no dialog; a switch made here under Ask opens the dialog and restarts what the answer picks; a switch back drops a queued restart; Keep never queues.Fixture screenshots above. I didn't run agy against a real login (it would read and write the real keychain item), so the end-to-end check is the tests at the owner plus the fixtures.
pnpm check:changedpasses. macOS only.Performance
None that matters, because the work runs only when a saved Antigravity account is switched: main reads the foreground of each terminal with agy evidence, one at a time, and skips the process scan when the cached foreground is a shell. Nothing new runs on any hot path, timer or render. The account map holds one string per live agy terminal and is pruned at each switch.
Risk
The riskiest part is the shared restart queue and the generalized Claude dialog: a mistake there would change what a Claude account switch restarts. Claude's queue rules are kept as they were (
agent !== 'codex'where the code saidagent === 'claude'), and its copy is the same keys and strings. An older desktop talking to a new host sends no new params and gets the host's own setting; a new desktop talking to an older host sends none and gets today's behaviour. Back out with a plain revert; the new setting key is ignored afterwards.Level: Medium
Review
One review round (Codex and a Claude reviewer with a performance pass). No P0. Fixed from it:
accounts.antigravityMoveUnheldTerminals), which moves them by the window's rule, as Claude's unheld sessions are.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)