[Bug] 6-second undo-delete timer silently deletes a freshly re-imported account with the same email
发生了什么 / 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
- On the Accounts page, click Delete on an account (
[email protected]). The row disappears locally and the 6-second undo toast appears. - Immediately (within 6 seconds) open Add account -> Paste cookies (or Chrome import / Browser login) and import
[email protected]with fresh cookies. - The import task runs
upsertAccount->updateImportedAccounton the backend (sinceDELETEhas not been sent yet) and completes. - Once the 6-second timer fires,
commitDelete()executesDELETE /api/accounts/user%40example.comand silently deletes the newly updated account.
Root Cause Pointer
web/src/console.ts(deleteAccounts,commitDelete):deleteAccountshides the account invisibleAccountsand schedulessetTimeout(() => void commitDelete(), 6000).- Account creation/import/login actions do not flush
commitDelete()beforehand, andcommitDelete()unconditionally deletespending.accountseven if an account with thatidwas added/updated afterdeleteAccountswas 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