Database governance built for humans and agents — controlling changes and access across every major database.
BYT-9432 — Stop wiping user-scoped localStorage on logout
- Status: Approved (design)
- Linear: BYT-9432
- Date: 2026-05-09
Problem
On logout, both the Vue store (frontend/src/store/modules/v1/auth.ts) and the React store (frontend/src/react/stores/app/auth.ts) scan localStorage and remove every key whose suffix matches .${currentUserEmail}. This wipes SQL Editor tabs/current-tab pointers, worksheet UI state, recent visits, quick access, and other productivity state that users rely on persisting across sessions.
Keys are already user-scoped by email, so different users on the same browser cannot read each other's data — there is no cross-user contamination problem to solve by wiping. Closing the browser does not wipe localStorage; logout being more destructive than that is surprising. The wipe was introduced in PR #19218 alongside the storage-key registry refactor without an explicit rationale.
Goal
Remove the broad *.<email> cleanup from both logout paths so user-scoped state survives a logout/login round-trip on the same browser.
Non-goals
- No changes to
storage-keys.tsorstorage-migrate.ts. The keys themselves are correct. - No new "Sign out and clear local data" opt-in action. If shared-machine privacy becomes a real ask, that's a separate spec.
- No new tests pinning negative behavior (logout-must-not-touch-localStorage). Manual verification only.
Changes
1. frontend/src/store/modules/v1/auth.ts (Vue store)
- Delete the
cleanupUserStoragehelper (defined ~line 186, 11 lines). It has no other callers in the codebase (verified by grep). - Delete its invocation inside
logout()'sfinallyblock (~line 204). - Preserve the rest of
finallyunchanged:unauthenticatedOccurred.value = falseand the redirect to the signin route viawindow.location.href.
2. frontend/src/react/stores/app/auth.ts (React store)
- Delete the inlined cleanup block in
logout()(the loop populatingkeysToRemoveand the subsequentforEach(localStorage.removeItem)). - Drop the
emailcapture on line 29 since it becomes unused. - Drop the
getCurrentUserEmailimport from./utilsif it has no remaining uses in this file. - Keep the
try/catcharoundauthServiceClientConnect.logout({})and thewindow.location.href = signinUrlredirect.
What stays untouched
frontend/src/utils/storage-keys.ts— unchanged.frontend/src/utils/storage-migrate.ts— unchanged.- All callers and key builders — unchanged.
Behavior after fix
| Scenario | Before | After |
|---|---|---|
| Logout, log back in as same email | User-scoped keys wiped; SQL Editor tabs gone | Keys persist; tabs and unsaved statements restore |
| Logout, log in as different email on same browser | Previous user's keys wiped | Previous user's keys remain in storage, inaccessible to the new email (different suffix). Consistent with how every other browser-persisted UI state already behaves. |
| Closing browser without logout | Keys persist (already true) | Keys persist (unchanged) |
Risk
Low. Two small deletions in two files. No API, proto, or schema changes. The only observable behavior change is that user-scoped keys persist across logout — the change being asked for.
The minor consideration is that ephemeral auth-flow nudges keyed by email (e.g., bb.iam-remind.<email>, bb.reset-password.<email>) will also persist. On a single-user browser this is harmless: the same email re-login should see the same nudge state. If this turns out to be a problem in practice, those specific keys can be cleared at the points where they're produced/consumed rather than via a blanket logout sweep.
Testing
Manual
- Sign in to the app.
- Open SQL Editor, create 2–3 tabs with unsaved SQL.
- Open DevTools → Application → Local Storage; note keys with the
.<email>suffix (bb.sql-editor.tabs.<project>.<email>,bb.sql-editor.current-tab.<project>.<email>, etc.). - Sign out via the app menu.
- Confirm those keys are still present in Local Storage after the redirect to the signin page.
- Sign back in as the same user.
- Confirm SQL Editor tabs, current tab, and the unsaved SQL within them all restore.
Automated gates
pnpm --dir frontend fixpnpm --dir frontend checkpnpm --dir frontend type-checkpnpm --dir frontend test
No new unit tests planned — the change is a pure deletion, and there is no covering test today. A test asserting "logout does not call localStorage.removeItem" would be a low-value negative-behavior pin.
Rollout
Standard frontend deploy. No feature flag needed — the behavior change is small and clearly an improvement.