Repository navigation
fix(antigravity): protect active account removal - #21797
Conversation
|
Independent verification (2026-09-20):
Verdict: approve stacked on #21784. The active-account guard is verified, including protection before the first refresh; broader platform account backends remain outside the stack. No merge performed. |
ELI5 / evidence / trade-offs auditELI5: Orca refuses to remove an account while another part of Orca still needs it, preventing an accidental sign-out. Proof: Removal-guard tests and CI pass; no independent screenshot is applicable to this guard-path change. User-facing trade-off: A removal can be blocked until the dependent session is closed. This note scopes the claim to the evidence above; it does not claim untested remote, SSH, WSL, or vendor combinations. |
There was a problem hiding this comment.
ℹ️ No blocking issues — the pre-refresh guard is correctly implemented and tested. One durability question and a small rough edge below.
Reviewed changes
removeAccountre-reads the live credential before deleting —src/main/antigravity/native-account-service.ts:111now resolves the active account from the Keychain viaknownActiveAccountbefore filtering the store, so a removal is refused when the target is active even iflistAccountsnever ran. The in-memoryactiveAccountIdcheck stays as a secondary guard.- Regression test for removal before the first refresh —
src/main/antigravity/native-account-service.test.ts:73constructs the service and callsremoveAccountwith no priorlistAccounts; it fails against the pre-PR code, so it genuinely pins the new behavior.
ℹ️ The live-read guard inherits knownActiveAccount's hash-equality contract
The guard is only as strong as the id match underneath it. knownActiveAccount compares accountId(current.contents) — a SHA-256 of the entire Keychain blob — against stored record ids, and nothing in the repo re-syncs a stored record after the live blob changes. Any external byte-level rewrite (an OAuth token refresh, or a CLI-upgrade re-serialization that selectAccount's own comment at line 94 already anticipates) makes the match fail, at which point both this guard and listAccounts' activeAccountId go null and the Remove button reappears on every row. This PR correctly covers the pre-refresh case it targets; the open question is whether it is expected to keep protecting after a rotation.
Technical details
# Active-account id is a hash of the mutable credential blob
## Affected sites
- `src/main/antigravity/native-account-service.ts:36` — `accountId()` hashes the whole `contents`, including `token.access_token`.
- `src/main/antigravity/native-account-service.ts:119` — `knownActiveAccount` re-hashes the live blob and returns `null` on any mismatch.
- `src/main/antigravity/native-account-service.ts:112` — the new guard, and `listAccounts` at line 62, both depend on that match.
- `src/main/antigravity/native-account-service.ts:66` — `addCurrentAccount` is the only writer of stored `credentials`; it appends a new record rather than updating the existing one.
## Required outcome
- Either confirm the `agy` Keychain blob is byte-stable across token refreshes (no change needed), or key the active-account match on a stable identity (e.g. `identity.subject`) instead of a hash of the volatile blob.
## Open questions for the human
- Does `agy` rewrite the `gemini`/`antigravity` Keychain item when it refreshes an OAuth token?
- Is "protect the active account" expected to survive an external credential rewrite, or is the pre-refresh window the whole scope here?ℹ️ Nitpicks
removeAccountnow fails closed on a Keychain read error:readAntigravityMacOSCredentialthrows on asecuritytimeout or unexpected exit, so removing an unrelated account can now fail where it previously succeeded, surfacing the raw backend message as a toast.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

What changed
Protects the active native Antigravity account even when an account removal request arrives before the first Accounts list refresh. The service now resolves the live native credential inside
removeAccountand rejects removal of that account; the existing in-memory active ID guard remains as a second protection.ELI5: the Accounts screen normally tells the service which account is active. If a remove click arrives before that first refresh finishes, the service now checks the keychain itself before deleting anything.
Verification
pnpm tc:nodepassed.pnpm run check:code-quality:changed origin/mainpassed.removeAccountbeforelistAccounts.No UI changed, so visual proof is not applicable. This is stacked on #21784.