fix: skip persist on cross-tab recency prune to prevent ping-pong#333
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e5bf9c21f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const persistedTabRecency = tabRecencyPruneDirty | ||
| ? nextTabRecency | ||
| : mergeTabRecencyStatesByMax( |
There was a problem hiding this comment.
Preserve remote pane recency when pruning local sidecar
When tabRecencyPruneDirty is true, this branch writes nextTabRecency directly instead of merging with the existing TAB_RECENCY_STORAGE_KEY, which means a local pane-topology prune can delete recency entries that belong to another open browser window (same-origin localStorage is shared). In multi-window scenarios with non-overlapping live pane IDs, one window’s prune will erase the other window’s recency until new activity happens, so recency-based sorting/sync can silently regress after reloads.
Useful? React with 👍 / 👎.
The prune dispatch in handleIncomingRaw lacked skipPersist, causing each tab to write its pane set back to localStorage after receiving remote recency data. Since non-overlapping tabs have different pane IDs, the raw values alternate and the dedupe mechanism (overwritten by onPersistBroadcast each iteration) never catches them, creating an infinite cross-tab localStorage write loop.
62c6f39 to
a4c1b6e
Compare
Supersedes #332. Carries the same feat commit plus a one-line fix: the cross-tab recency prune dispatch lacked skipPersist, causing an infinite localStorage write loop across browser tabs with non-overlapping pane IDs. Adding skipPersist: true eliminates the redundant write-back without regressing behavior — each tab independently persists its own recency state via the normal persistMiddleware path.