Scope Channels (bluebird) browser tabs to the signed-in user#3164
Scope Channels (bluebird) browser tabs to the signed-in user#3164adamleithp wants to merge 1 commit into
Conversation
Tab strips were stored machine-wide, so every account on a machine shared one set of tabs and logout left the previous user's tabs behind. Persist them per (cloudRegion, accountKey) instead: each login restores that user's tabs, switching accounts swaps snapshots, and signed-out sessions are memory-only so no account's saved tabs get overwritten. Pre-account rows are adopted by the first login so existing users keep their tabs. Generated-By: PostHog Code Task-Id: b06ce1b6-aef9-4164-8274-0ae6374ca8c1
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
| @@ -0,0 +1,2 @@ | |||
| ALTER TABLE `browser_windows` ADD `account_scope` text;--> statement-breakpoint | |||
| CREATE INDEX `browser_windows_account_scope_idx` ON `browser_windows` (`account_scope`); No newline at end of file | |||
There was a problem hiding this comment.
The file is missing a trailing newline, which can cause issues with some SQL tools and shows as a diff noise marker (
\ No newline at end of file) in git diff.
| CREATE INDEX `browser_windows_account_scope_idx` ON `browser_windows` (`account_scope`); | |
| CREATE INDEX `browser_windows_account_scope_idx` ON `browser_windows` (`account_scope`); |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Problem
Channels/canvas browser tabs are persisted machine-wide, not per user. Everyone who logs into the app on the same machine shares one tab strip: logging out leaves the previous user's tabs behind, and switching accounts doesn't restore that user's own tabs.
Why
Tabs should follow the login, not the install — logging into an account should bring back that account's tabs, and switching users should restore theirs (raised for PostHog Code / project bluebird).
Changes
browser_windowsrows now carry anaccount_scope(<cloudRegion>:<accountKey>, migration 0017); tabs inherit scope through their window FK. Load/save inBrowserTabsRepositoryonly touch the active account's rows.BrowserTabsServicegetssetAccountScope(): login loads that account's persisted snapshot and fans it out to all windows; logout swaps to a blank memory-only strip (nothing persisted while signed out, so no account's saved tabs are overwritten).AuthStatenow exposesaccountKey, with agetAccountScopeKey()helper; the Electron main process wires auth state changes to the tabs service (skipping the transientrestoringstatus so a slow session restore doesn't flash a signed-out strip).How did you test this?
browser-tabs-repository.test.ts(scope isolation, round-trip, legacy-row adoption) andservice.test.ts(per-account restore on user switch, memory-only signed-out behavior, scope-change emissions) — 12 tests passing.auth.test.tsfor the newaccountKeyfield — 43 tests passing.pnpm typecheckclean across all 22 packages; Biome clean on changed files.Automatic notifications
Created with PostHog Code