AIStudio2API icon indicating copy to clipboard operation
AIStudio2API copied to clipboard

[Bug] 6-second undo-delete timer silently deletes a freshly re-imported account with the same email

Open photobrand opened this issue 1 week ago • 0 comments

发生了什么 / What happened

Summary

Deleting an account in the Web UI starts a 6-second client-side undo timer (pendingDelete) before actually sending DELETE /api/accounts/{id}. If the user re-adds or re-imports the same account email within those 6 seconds (e.g., via Paste cookies, Browser login, or Import from Chrome), the import succeeds against the still-present backend account, and then the expired 6-second timer runs commitDelete() and deletes the newly imported account.

Minimal Reproduction

  1. On the Accounts page, click Delete on an account ([email protected]). The row disappears locally and the 6-second undo toast appears.
  2. Immediately (within 6 seconds) open Add account -> Paste cookies (or Chrome import / Browser login) and import [email protected] with fresh cookies.
  3. The import task runs upsertAccount -> updateImportedAccount on the backend (since DELETE has not been sent yet) and completes.
  4. Once the 6-second timer fires, commitDelete() executes DELETE /api/accounts/user%40example.com and silently deletes the newly updated account.

Root Cause Pointer

  • web/src/console.ts (deleteAccounts, commitDelete):
    • deleteAccounts hides the account in visibleAccounts and schedules setTimeout(() => void commitDelete(), 6000).
    • Account creation/import/login actions do not flush commitDelete() beforehand, and commitDelete() unconditionally deletes pending.accounts even if an account with that id was added/updated after deleteAccounts was triggered.

Suggested Fix

Call commitDelete() immediately (and await completion) before starting createAccount, importCookieAccounts, importChromeAccounts, or loginAccount—or cancel/remove any ID from pendingDelete when it is re-imported (though flushing the pending delete before starting the import ensures clean deletion semantics if the user intended a fresh delete + re-add).

版本 / Version

No response

photobrand avatar Nov 21 '26 10:11 photobrand