Offer Use now only where a reconnect goes, and keep newer edits and headsets apart

From the second independent review of this PR:

- Use now sends a plain reconnect, which picks the first-ranked address that
  answers, but it was offered on every tested address listed above the one in
  use. The devices list now carries each address's rank on the current network
  (frame_devices.order_addresses), and only the address a reconnect would pick
  gets the button.
- Saving one address, cancelling, then editing another: the first save's answer
  closed the second editor and lost what was typed. Each edit now has its own
  session, and a late answer leaves a newer one alone.
- Switching headsets with the dialog open drew the address offer from the
  previous headset's status before it was cleared, so Add could save its IP to
  the new headset. The dialog now renders after the old status is cleared.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
saphidandClaude Opus 5.5 committed 2026-10-01 21:03:13 +10:00
1 parent 0520082586
commit 22bb9c6469
4 files changed
+44 -14

No files matched your search

+13
View File
@@ -304,6 +304,19 @@ class Connecting(unittest.TestCase):
self.assertEqual(self.link.active_device()["alias"], "frame-bare")
self.assertEqual(self.routes[-1][0], "frame-bare")
def test_devices_view_ranks_addresses_for_the_current_network(self):
# The page offers Use now only on the address a reconnect would pick: rank says which.
d = self.device("frame.tail1234.ts.net")
self.reg.add_address(d["id"], "192.168.1.40", kind="lan", first=True)
self.reg.record_success(d["id"], "frame.tail1234.ts.net", "n-home", 6.0)
self.link.state["network"] = {"id": "n-home", "name": "Home", "tailscale": {"up": True}}
view = next(x for x in fl.devices_view(self.link)["devices"] if x["id"] == d["id"])
self.assertEqual({a["host"]: a["rank"] for a in view["addresses"]},
{"192.168.1.40": 1, "frame.tail1234.ts.net": 0}) # only Tailscale worked here so far
self.reg.record_success(d["id"], "192.168.1.40", "n-home", 1.0)
view = next(x for x in fl.devices_view(self.link)["devices"] if x["id"] == d["id"])
self.assertEqual([a["rank"] for a in view["addresses"]], [0, 1]) # now the user's order decides
def test_removing_the_headset_frame_alias_named_doesnt_bring_it_back_bare(self):
d = self.device("localhost")
self.link.override = self.link.session_alias = "frame-t"