mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +00:00
fix(antigravity): guard active account removal (#21797)
This commit is contained in:
@@ -69,4 +69,15 @@ describe('AntigravityAccountService', () => {
|
||||
await expect(service.removeAccount(account.id)).rejects.toThrow('active account')
|
||||
await expect(service.selectAccount('missing')).rejects.toThrow('was not found')
|
||||
})
|
||||
|
||||
it('protects the active account even before the first list refresh', async () => {
|
||||
const active = backend(first)
|
||||
const account = createSyntheticAntigravityAccount(first)
|
||||
const service = new AntigravityAccountService(
|
||||
createMemoryAntigravityAccountStore([account]),
|
||||
active
|
||||
)
|
||||
|
||||
await expect(service.removeAccount(account.id)).rejects.toThrow('active account')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -107,7 +107,9 @@ export class AntigravityAccountService {
|
||||
if (!accounts.some((account) => account.id === id)) {
|
||||
throw new Error('Antigravity account was not found.')
|
||||
}
|
||||
if (this.activeAccountId === id) {
|
||||
// Resolve the native credential here too; callers may remove before the first list refresh.
|
||||
const active = await this.knownActiveAccount(accounts)
|
||||
if (active?.id === id || this.activeAccountId === id) {
|
||||
throw new Error('Select another Antigravity account before removing the active account.')
|
||||
}
|
||||
this.store.write(accounts.filter((account) => account.id !== id))
|
||||
|
||||
Reference in New Issue
Block a user