Two pages on one network: a save drops the tracked token the other page just added #717

Closed
opened 2026-11-02 23:14:16 +01:00 by clawbot · 1 comment
Collaborator

Where

The tracked-token save in saveStateOnce() in src/shared/state.js, with two popup pages open on one network.

What happens

A save writes trackedTokens whole. Page A and page B are open on one network. B adds a token, and B's "Added SYMBOL" shows. A has not read that save. A then adds or removes a token, and A's save writes A's list over the stored one, so B's token is gone from the stored list. A token B removed comes back the same way. Read from the code; not run in a browser.

Found by the fourth review of #704, outside its scope. It is the same on next without that PR.

What should happen

No tracked token is lost and none comes back, whichever page saves last. README's text for a successful add stays true.

Severity: minor

Definition of done

  • A save merges this page's change into the stored trackedTokens by contract address, as takeStoredTrackedTokens() does for a switch, so another page's add or removal stays.
  • A test for an add and a test for a removal on the other page, each failing on next.

Model: opus-5-5

## Where The tracked-token save in `saveStateOnce()` in `src/shared/state.js`, with two popup pages open on one network. ## What happens A save writes `trackedTokens` whole. Page A and page B are open on one network. B adds a token, and B's "Added SYMBOL" shows. A has not read that save. A then adds or removes a token, and A's save writes A's list over the stored one, so B's token is gone from the stored list. A token B removed comes back the same way. Read from the code; not run in a browser. Found by the fourth review of https://git.eeqj.de/sneak/AutistMask/pulls/704, outside its scope. It is the same on `next` without that PR. ## What should happen No tracked token is lost and none comes back, whichever page saves last. README's text for a successful add stays true. Severity: minor ## Definition of done - [ ] A save merges this page's change into the stored `trackedTokens` by contract address, as `takeStoredTrackedTokens()` does for a switch, so another page's add or removal stays. - [ ] A test for an add and a test for a removal on the other page, each failing on `next`. Model: opus-5-5
clawbot self-assigned this 2026-11-02 23:14:16 +01:00
Author
Collaborator

Plan: one PR to next, in saveStateOnce() in src/shared/state.js. When the save leaves the network as it was and the page's trackedTokens differs from baseline, merged.trackedTokens is mergeListByIdentity() of baseline.trackedTokens, current.trackedTokens and fresh.trackedTokens, by contract address, with this page's record winning for a token both hold. A save that switches networks stays as it is. The save's comment and README's Stored data sentence on what is merged entry by entry say so. Tests in tests/trackedTokensPerNetwork.test.js, each failing on next: the other page's add stays, and the other page's removal stays removed.

Model: opus-5-5

Plan: one PR to `next`, in `saveStateOnce()` in `src/shared/state.js`. When the save leaves the network as it was and the page's `trackedTokens` differs from `baseline`, `merged.trackedTokens` is `mergeListByIdentity()` of `baseline.trackedTokens`, `current.trackedTokens` and `fresh.trackedTokens`, by contract address, with this page's record winning for a token both hold. A save that switches networks stays as it is. The save's comment and README's Stored data sentence on what is merged entry by entry say so. Tests in `tests/trackedTokensPerNetwork.test.js`, each failing on `next`: the other page's add stays, and the other page's removal stays removed. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#717