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): free quota-limited chats when another saved account is selected, and switch it from the chat - #51498
When an Antigravity chat runs out of quota, switching to another saved Google account now frees it straight away. It continues on its own, or Continue works at once. The chat's usage-limit row also has a "Switch account" menu. If the account you switch to is itself out of quota, the row says so and waits for that account instead.
Files
Added
Deleted
Net
Test
3
$\color{#1a7f37}{\Huge{\mathbf{+}}}$241
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$241
Prod
42
$\color{#1a7f37}{\Huge{\mathbf{+}}}$793
$\color{#cf222e}{\Huge{\mathbf{−}}}$80
$\color{#1a7f37}{\Huge{\mathbf{+}}}$713
What Changed
Builds on #50216 (merged), which records the saved account each agy launch ran on (launchedAccount.accountId).
Usage-limited chats move with the selection.
Release on a new selection. The usage-limit hold compared only account homes, and all of agy's saved accounts share one home. It now also checks the saved account the cut's launch ran on against the one a start would use now (new host dep launchAccountId). That launch account comes from the persisted record, so this also works after an Orca restart. A different account releases the chat at the moment of the switch. While a launch is known to fail to move agy's login to the selected account (fix(antigravity): switch saved accounts at once and move each chat at its next message #50216's latch), nothing is released, since the chat would only restart on the same spent login.
Accounts known to be out of quota. Each saved account's latest known reset is remembered. Switching to an account that is still out of quota doesn't release the chat. The hold waits for that account's reset, and the row says "personal@x is out of quota until 3:40 PM" ("That account is out of quota until 3:40 PM" when the saved account has no email). The phone waits for that later time too. The memory is per account and per cut, so the chat doesn't loop between two spent accounts.
Immediate re-check. The selection is part of the attribution witness. A committed switch wakes the auto-continue sweep at once instead of on its next 10-second tick.
Bot looks (generic, for any agent with saved accounts in one home):
A look cut short by a usage limit records the account it hit (usageLimited.accountId).
Selecting another saved account lifts the hold.
A switch wakes the look scheduler at once.
"Switch account" in an Antigravity chat's usage-limit row (desktop).
When the menu shows. A new host option field, canSwitchAntigravityAccount, controls it. All of these must hold:
the chat is a host Antigravity chat (not WSL);
it runs on agy's Google login (agy's own home, or an Orca home whose method is Google or Enterprise; not an API key or gcloud);
there are two or more saved accounts, including one other than the selected account;
no in-app sign-in is under way.
It is computed from Orca's saved-accounts vault only; agy's keychain is never read. It is a separate field from canSwitchAccount because older phones show "Switch Account" for any agent that sets that field.
Menu contents. It lists the saved accounts by email with the selected one checked, plus "Manage Accounts…". It re-checks eligibility before switching, then shows the existing toast.
#50155: with #50216 this covers chats following an account switch and quota-limited chats moving to another account. The phone's "Switch account" menu is a separate PR.
Why
agy's saved accounts share one home, so "moved to another account" can only be decided by which saved account a launch ran on. Persisting that account (in #50216) means the hold still knows it after a restart. Remembering each account's reset is what stops a switch onto a spent account from releasing the chat just to hit the limit again.
A fresh hold (as after a restart) reads the cut's account from the persisted record and frees the chat when another saved account is selected.
A switch onto an account still out of quota waits for that account's reset and names it.
bot-look-around-saved-account.test.ts: a look's usage-limit hold survives the store round-trip with its account, and selecting another account lifts it.
antigravity-chat-can-switch-account.test.ts:
Each eligibility condition flips the answer.
Agy's credential backend is never read.
pnpm check:changed: everything passes except one unit test, agent-cli-update-timeout.test.ts ("expected 87 to be less than 30"). It also fails when run on its own. I haven't checked whether it fails on main.
Performance
Per sweep pass: one in-memory selection read per held agy chat.
On a switch: one immediate auto-continue sweep and one look-scheduler tick.
Eligibility check: reads the vault file (no keychain), and only for usage-limited Antigravity chats when their options are read.
Nothing new polls.
Risk
Level: Medium
Riskiest part: the hold's new saved-account comparison. If it is wrong, a held agy chat could release too early: it would continue on a spent account, hit the limit again, and then wait for that account.
Older clients and hosts: an older client or phone ignores limitedAccount and shows the earlier time. Older hosts never send canSwitchAntigravityAccount, so no button appears.
A saved account with no email left the row without the "out of quota" line. It now says "That account is out of quota until …".
The phone took the earlier of the two times, so it offered Continue before the account it moved to had reset. It now waits for that account.
Left as is: after an Orca restart the selection is unknown until the first vault read, so the first sweep pass can miss a switch. The next pass (at most 10 s) catches it.
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
Remote hosts: the menu calls accounts.antigravitySelect on the chat's own host.
Mobile: the phone waits for the moved-to account's reset. The host option is a plain boolean, so the phone's menu can use it.
Windows: has no chats on agy, so nothing changes there.
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)
The changes add saved-account identity to bot usage-limit scheduling and native-chat quota attribution. Eligible Antigravity chats can switch to another saved account. Desktop and mobile usage-limit views can identify a destination account that remains out of quota and use its account-specific continuation time.
Merge Risk: Low · up to a40a3
The feature works for the main flows, but several edge cases remain. A scheduled bot look can start on an account that is still out of quota after the user switches back to it. The usage-limit row can show stale account or reset text for a few seconds after a switch. The account switcher can stay disabled after one failed load. On mobile, manual Continue can be missing in a narrow case. These are minor, bounded issues worth fixing before or soon after merge.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the two main changes: releasing quota-limited Antigravity chats when another saved account is selected, and adding an account switch from the chat. The changeset covers both, including…
Description check
The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (#50155), Visual Proof with images, Testing with checkboxes and specific tests, a Performance section…
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.
Full details: Title check
Explanation
The title names the two main changes: releasing quota-limited Antigravity chats when another saved account is selected, and adding an account switch from the chat. The changeset covers both, including the hold logic, the bot look hold, and the desktop switcher menu. The title is specific and follows the conventional prefix format. The title is 110 characters, which is long, but it stays readable.
Full details: Description check
Explanation
The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (#50155), Visual Proof with images, Testing with checkboxes and specific tests, a Performance section, a Risk section with level and backout plan, a Review section, and Notes. The description is detailed and covers the mechanism, the scope, and the known test failure. Gaps: the Performance line is filled in, but the 'None, because' sentence is not finished as the template asks. The AI Disclosure section is empty. The 'Fixes #' line is replaced by 'Linked Issue #50155', which does not use the closing keyword. The manual testing box is unchecked, and the lint/typecheck/test/build box is unchecked. The Review section lists a fix from a prior round, so it is not empty. The description is mostly complete, so the check passes.
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; 4 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Select the reset for Continue from the published continue state, not the failure fact.
MobileNativeChatUsageLimitStatus reads resetsAt from failure.usageLimit?.resetsAt. The usage-limit type documents that this value can be absent. When the host supplies a reset through an account move or relaunch, the published continue summary carries the effective reset. When the failure has no reset and the chat moved to a limited saved account, resetPassed stays false. The Continue action then stays hidden after that reset passes. Auto-continuation still sends the message, so this affects only manual continuation from mobile.
Derive the reset that useResetPassed and the continueNow gate use from the published continue state. Use the failure reset only as a fallback. The exact published field must be confirmed in the mobile usage-limit contract before the change is made.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Retain the selected account's earlier quota hold.
If A hits quota until 12:00 and B then hits quota until 13:00, selecting A again returns 0. findLast chooses B, and this branch ignores A's earlier limit. An otherwise-due scheduled look can then start before A's reset.
Resolve outstanding limits per account. Returning to A must retain A's reset; selecting a fresh account must still release the hold.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Preserve selection-triggered ticks while a tick is active.
If a tick has already checked a limited bot and then awaits another bot's hadConversation, an account change calls tick() while ticking is true. That call returns immediately. The active tick does not revisit the limited bot, so the account change waits for the next scheduler tick.
Record one pending rerun and process it after the active tick. Keep the existing guard against concurrent ticks.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Publish the updated schedule after account attribution.
This callback runs tick, but tick publishes schedules before it updates account attribution. If the selected account has a future quota reset, no send follows and the pass publishes no updated status. The row can show the previous account and reset until the next 10-second sweep.
Publish the affected status after attribution so the account-change pass exposes the new account and deadline.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Provide a retry after the initial account-list failure.
If the first List request fails, state remains null. The shared control then disables the trigger because loaded is false. The user cannot open the menu to start another load(), and the mount effect does not retry.
Provide an error-state retry action or a bounded automatic retry. Keep the trigger disabled while a request is pending, not permanently after a temporary failure.
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
When an Antigravity chat runs out of quota, switching to another saved Google account now frees it straight away. It continues on its own, or Continue works at once. The chat's usage-limit row also has a "Switch account" menu. If the account you switch to is itself out of quota, the row says so and waits for that account instead.
What Changed
Builds on #50216 (merged), which records the saved account each agy launch ran on (
launchedAccount.accountId).Usage-limited chats move with the selection.
launchAccountId). That launch account comes from the persisted record, so this also works after an Orca restart. A different account releases the chat at the moment of the switch. While a launch is known to fail to move agy's login to the selected account (fix(antigravity): switch saved accounts at once and move each chat at its next message #50216's latch), nothing is released, since the chat would only restart on the same spent login.Bot looks (generic, for any agent with saved accounts in one home):
usageLimited.accountId)."Switch account" in an Antigravity chat's usage-limit row (desktop).
canSwitchAntigravityAccount, controls it. All of these must hold:It is computed from Orca's saved-accounts vault only; agy's keychain is never read. It is a separate field from
canSwitchAccountbecause older phones show "Switch Account" for any agent that sets that field.#50155: with #50216 this covers chats following an account switch and quota-limited chats moving to another account. The phone's "Switch account" menu is a separate PR.
Why
agy's saved accounts share one home, so "moved to another account" can only be decided by which saved account a launch ran on. Persisting that account (in #50216) means the hold still knows it after a restart. Remembering each account's reset is what stops a switch onto a spent account from releasing the chat just to hit the limit again.
Linked Issue
#50155
Visual Proof
The row after a switch onto an account that is itself out of quota (light / dark):
The same, when that saved account has no email (light / dark):
The "Switch account" button in the row, closed (light / dark):
Open, with the selected account checked (light / dark):
An account with no email (light / dark):
Only one saved account (light / dark):
All shots are from component fixtures:
NativeChatUsageLimitRow:antigravityAccountOutOfQuotaandAntigravityChatSwitcherMenu:*.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-usage-limit-saved-accounts.test.ts:bot-look-around-saved-account.test.ts: a look's usage-limit hold survives the store round-trip with its account, and selecting another account lifts it.antigravity-chat-can-switch-account.test.ts:pnpm check:changed: everything passes except one unit test,agent-cli-update-timeout.test.ts("expected 87 to be less than 30"). It also fails when run on its own. I haven't checked whether it fails on main.Performance
Risk
Level: Medium
limitedAccountand shows the earlier time. Older hosts never sendcanSwitchAntigravityAccount, so no button appears.AI Disclosure
Review
One round, Codex and a Claude reviewer. Fixed:
Left as is: after an Orca restart the selection is unknown until the first vault read, so the first sweep pass can miss a switch. The next pass (at most 10 s) catches it.
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
accounts.antigravitySelecton the chat's own host.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)