Skip to content

fix: skip persist on cross-tab recency prune to prevent ping-pong#333

Merged
danshapiro merged 2 commits into
mainfrom
fix/tab-recency-cross-tab-ping-pong
May 18, 2026
Merged

fix: skip persist on cross-tab recency prune to prevent ping-pong#333
danshapiro merged 2 commits into
mainfrom
fix/tab-recency-cross-tab-ping-pong

Conversation

@danshapiro
Copy link
Copy Markdown
Owner

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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +490 to +492
const persistedTabRecency = tabRecencyPruneDirty
? nextTabRecency
: mergeTabRecencyStatesByMax(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Dan Shapiro added 2 commits May 18, 2026 14:58
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.
@danshapiro danshapiro force-pushed the fix/tab-recency-cross-tab-ping-pong branch from 62c6f39 to a4c1b6e Compare May 18, 2026 21:59
@danshapiro danshapiro merged commit 9561cc3 into main May 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant