fix: Settings refuses an endpoint URL whose network changed before it was stored (closes #663) #684

Merged
clawbot merged 1 commits from issue-663-rpc-save-follow into next 2026-10-27 07:27:17 +01:00
Collaborator

The RPC and Blockscout "Save" buttons in Settings take the network that Settings was last drawn for. A follow of a switch saved elsewhere sets state to the new network first. Settings is drawn again only once the follow's write returns. So a "Save" tapped in between still belongs to the network on screen.

The URL is set in state inside the save, holding the lock. So the popup cannot follow a switch between setting the URL and writing it. The save is refused if the network that Settings showed is no longer active, on the page or in the stored record. The flash message then reads "The URL was not saved because the network changed." "Saved." appears only for a stored URL.

The Blockscout URL save had the same fault and is fixed the same way.

The RPC check compares the node's chain id with the network that Settings showed at the tap. A follow that lands while the check waits does not change that network.

Before, a save that took the lock before the follow could also store the previous network's URL as the new network's endpoint. The tests cover that order too.

Judgement call: Settings has no error line of its own. The refusal goes on the flash message line, like the URL check's other errors.

Model: opus-5-5

The RPC and Blockscout "Save" buttons in Settings take the network that Settings was last drawn for. A follow of a switch saved elsewhere sets `state` to the new network first. Settings is drawn again only once the follow's write returns. So a "Save" tapped in between still belongs to the network on screen. The URL is set in `state` inside the save, holding the lock. So the popup cannot follow a switch between setting the URL and writing it. The save is refused if the network that Settings showed is no longer active, on the page or in the stored record. The flash message then reads "The URL was not saved because the network changed." "Saved." appears only for a stored URL. The Blockscout URL save had the same fault and is fixed the same way. The RPC check compares the node's chain id with the network that Settings showed at the tap. A follow that lands while the check waits does not change that network. Before, a save that took the lock before the follow could also store the previous network's URL as the new network's endpoint. The tests cover that order too. Judgement call: Settings has no error line of its own. The refusal goes on the flash message line, like the URL check's other errors. Model: opus-5-5
clawbot added the needs-review label 2026-10-27 04:44:18 +01:00
clawbot self-assigned this 2026-10-27 04:44:18 +01:00
Author
Collaborator

Review: FAIL (needs-rework)

  1. A Blockscout URL can still be stored for a network Settings did not show. Suppose another window saves a switch from Ethereum Mainnet to Sepolia. followStoredSettings() in src/popup/index.js sets state to Sepolia inside its save. It redraws Settings only after that save's write returns. The Blockscout "Save" handler in src/popup/views/settings.js reads state.networkId at the tap. A tap during that write therefore takes Sepolia while Settings still shows Ethereum Mainnet. The URL the user typed for Ethereum Mainnet is stored as Sepolia's Blockscout endpoint, and "Saved." is shown. Acceptable: a "Save" tapped while Settings still shows the previous network stores nothing for the new one. A test holds the follow's write, taps "Save" and checks the stored record.

  2. Nothing tests the move of the RPC chain-id check to the tap. With currentNetwork() read again after the answer, every test still passes. In that version, a follow to Sepolia can land during the check of a Sepolia node tapped on Ethereum Mainnet. The node is then stored as Sepolia's endpoint, and "Saved." is shown. Acceptable: a test in which the follow lands while the check waits for its answer, and the answer names Sepolia's chain id. Nothing is stored, and the flash reads "Wrong network: expected Ethereum Mainnet."

Judgement call: finding 1 also happens on next. It fails this PR because the PR says the Blockscout save is fixed. The issue also asks that an edit made while a follow lands be stored for its network or refused.

Model: opus-5-5

**Review: FAIL (needs-rework)** 1. A Blockscout URL can still be stored for a network Settings did not show. Suppose another window saves a switch from Ethereum Mainnet to Sepolia. `followStoredSettings()` in `src/popup/index.js` sets `state` to Sepolia inside its save. It redraws Settings only after that save's write returns. The Blockscout "Save" handler in `src/popup/views/settings.js` reads `state.networkId` at the tap. A tap during that write therefore takes Sepolia while Settings still shows Ethereum Mainnet. The URL the user typed for Ethereum Mainnet is stored as Sepolia's Blockscout endpoint, and "Saved." is shown. Acceptable: a "Save" tapped while Settings still shows the previous network stores nothing for the new one. A test holds the follow's write, taps "Save" and checks the stored record. 2. Nothing tests the move of the RPC chain-id check to the tap. With `currentNetwork()` read again after the answer, every test still passes. In that version, a follow to Sepolia can land during the check of a Sepolia node tapped on Ethereum Mainnet. The node is then stored as Sepolia's endpoint, and "Saved." is shown. Acceptable: a test in which the follow lands while the check waits for its answer, and the answer names Sepolia's chain id. Nothing is stored, and the flash reads "Wrong network: expected Ethereum Mainnet." Judgement call: finding 1 also happens on `next`. It fails this PR because the PR says the Blockscout save is fixed. The issue also asks that an edit made while a follow lands be stored for its network or refused. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-27 05:24:58 +01:00
clawbot force-pushed issue-663-rpc-save-follow from bccc86b6ea to 15eea79b77 2026-10-27 05:54:08 +01:00 Compare
Author
Collaborator

Rework:

  1. Fixed: both "Save" buttons take the network Settings was last drawn for. The new test holds the follow's write and taps "Save".
  2. Added the test. It fails against a version that reads currentNetwork() again after the answer.

Model: opus-5-5

Rework: 1. Fixed: both "Save" buttons take the network Settings was last drawn for. The new test holds the follow's write and taps "Save". 2. Added the test. It fails against a version that reads `currentNetwork()` again after the answer. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-27 05:54:23 +01:00
Author
Collaborator

Review: FAIL (needs-rework)

  1. Two checks this PR adds in src/popup/views/settings.js can be removed with every test still passing:

    • shownNetwork = currentNetwork(); in showNewSettings(). Without it, after a switch to Sepolia with Settings open, no URL can be saved for Sepolia. The RPC "Save" says "Wrong network: expected Ethereum Mainnet." The Blockscout "Save" says the network changed.
    • state.networkId !== networkId in saveEndpoint(). Without it, suppose a switch to Sepolia in Settings fails to write. The page is then on Sepolia, but both "Save" buttons still take Ethereum Mainnet. A Mainnet node saved next is stored as Sepolia's RPC endpoint, and "Saved." is shown.

    Acceptable: a test that switches to Sepolia with Settings open (a follow, or the network selector), then saves each URL and finds it stored for Sepolia with "Saved.". A second test makes a switch in Settings fail to write, and a "Save" after it stores nothing.

  2. Two comments in src/popup/views/settings.js read as "network settings" at first: "The network Settings was last drawn for." (above shownNetwork) and "The URL is for the network Settings shows when "Save" is tapped." (in the RPC "Save" handler). Acceptable: "The network that Settings was last drawn for." and "The URL is for the network that Settings shows when "Save" is tapped."

Follow-up note: the PR body and commit message use the same phrase ("the network Settings was last drawn for", "the network Settings showed"); adding "that" fixes it there too.

Model: opus-5-5

**Review: FAIL (needs-rework)** 1. Two checks this PR adds in `src/popup/views/settings.js` can be removed with every test still passing: - `shownNetwork = currentNetwork();` in `showNewSettings()`. Without it, after a switch to Sepolia with Settings open, no URL can be saved for Sepolia. The RPC "Save" says "Wrong network: expected Ethereum Mainnet." The Blockscout "Save" says the network changed. - `state.networkId !== networkId` in `saveEndpoint()`. Without it, suppose a switch to Sepolia in Settings fails to write. The page is then on Sepolia, but both "Save" buttons still take Ethereum Mainnet. A Mainnet node saved next is stored as Sepolia's RPC endpoint, and "Saved." is shown. Acceptable: a test that switches to Sepolia with Settings open (a follow, or the network selector), then saves each URL and finds it stored for Sepolia with "Saved.". A second test makes a switch in Settings fail to write, and a "Save" after it stores nothing. 2. Two comments in `src/popup/views/settings.js` read as "network settings" at first: "The network Settings was last drawn for." (above `shownNetwork`) and "The URL is for the network Settings shows when "Save" is tapped." (in the RPC "Save" handler). Acceptable: "The network that Settings was last drawn for." and "The URL is for the network that Settings shows when "Save" is tapped." Follow-up note: the PR body and commit message use the same phrase ("the network Settings was last drawn for", "the network Settings showed"); adding "that" fixes it there too. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-27 06:24:48 +01:00
clawbot force-pushed issue-663-rpc-save-follow from 15eea79b77 to 3add1a158b 2026-10-27 06:42:11 +01:00 Compare
Author
Collaborator

Rework:

  1. Added both tests. In the first, Settings is open when the network switches to Sepolia, once by a follow and once by the network selector; each URL then saves for Sepolia with "Saved.". In the second, a switch in Settings fails to write, and a "Save" after it stores nothing. I also added a test that the Blockscout "Save" keeps the network shown at the tap while its check waits; no test covered that before. Each new test fails when its check is removed.
  2. Added "that" in both comments, in the saveEndpoint() comment, and in the PR body and commit message.

Model: opus-5-5

Rework: 1. Added both tests. In the first, Settings is open when the network switches to Sepolia, once by a follow and once by the network selector; each URL then saves for Sepolia with "Saved.". In the second, a switch in Settings fails to write, and a "Save" after it stores nothing. I also added a test that the Blockscout "Save" keeps the network shown at the tap while its check waits; no test covered that before. Each new test fails when its check is removed. 2. Added "that" in both comments, in the `saveEndpoint()` comment, and in the PR body and commit message. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-27 06:42:21 +01:00
clawbot added 1 commit 2026-10-27 07:06:32 +01:00
fix: Settings refuses an endpoint URL whose network changed before it was stored (closes #663)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run
f2059261f0
The RPC and Blockscout "Save" buttons in Settings take the network that
Settings was last drawn for. A follow of a switch saved elsewhere sets
`state` first. Settings is drawn again only once the follow's write
returns.

The URL is set in `state` inside the save, holding the lock. The save is
refused if the network that Settings showed is no longer active, on the
page or in the stored record. The flash message then says that the
network changed, and "Saved." is shown only for a stored URL.

Before, a popup that followed a switch saved elsewhere could replace the
URL before the write and still show "Saved.". It could also store a URL
for a network that Settings did not show.

Model: opus-5-5
clawbot force-pushed issue-663-rpc-save-follow from 3add1a158b to f2059261f0 2026-10-27 07:06:32 +01:00 Compare
Author
Collaborator

Review: PASS

Both "Save" buttons now store a URL only for the network that Settings showed at the tap, and show "Saved." only when it was stored.

Judgement call: I read the claim that "Saved." appears only for a stored URL as covering the network changes this PR handles. A separate case, also on next, is outside #663: after another page saves a different RPC URL for the same network, saving the URL this page loaded shows "Saved." while the other page's URL stays stored.

Model: opus-5-5

**Review: PASS** Both "Save" buttons now store a URL only for the network that Settings showed at the tap, and show "Saved." only when it was stored. Judgement call: I read the claim that "Saved." appears only for a stored URL as covering the network changes this PR handles. A separate case, also on `next`, is outside https://git.eeqj.de/sneak/AutistMask/issues/663: after another page saves a different RPC URL for the same network, saving the URL this page loaded shows "Saved." while the other page's URL stays stored. Model: opus-5-5
clawbot merged commit 5615b08760 into next 2026-10-27 07:27:17 +01:00
clawbot deleted branch issue-663-rpc-save-follow 2026-10-27 07:27:17 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#684