mirror of
https://github.com/saphid/frame-control.git
synced 2026-10-06 08:00:32 +02:00
Offer Use now from the finished test's own order
The fix review found Use now could still point the wrong way: the button was worked out from per-address ranks in the devices list while the test was still running (a better-ranked address might yet answer), and the test's successes changed those ranks before the list was reloaded. The test now finishes by publishing the order a reconnect on this network would try, worked out after it has recorded where each address works, together with the network it ran on. The page offers Use now only once the test is done, only for that network, and only on the first address in that order that passed. The ranks in the devices list are gone again. docs/devices.md no longer promises where a reconnect lands: a slow address loses to a later one. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
22548bc42f
commit
0bb2f9eb03
4 files changed
+29
-32
No files matched your search
+5
-6
@@ -4406,12 +4406,11 @@ function renderConnAddrs() {
|
||||
const refocus = cd.refocus ? [cd.refocus, "[data-ed]"]
|
||||
: held ? [held.dataset.host, ["[data-use]", "[data-mv='-1']", "[data-mv='1']", "[data-ed]", "[data-rm]"].find(q => document.activeElement.matches(q))] : null;
|
||||
cd.refocus = null;
|
||||
// A reconnect picks the first-ranked address that answers: offer it when that's a tested
|
||||
// address other than the one in use.
|
||||
const used = d.addresses.find(a => a.host === inUse);
|
||||
const best = used && d.addresses.filter(a => (tested.get(a.host) || {}).ssh === "ok")
|
||||
.reduce((x, a) => !x || a.rank < x.rank ? a : x, null);
|
||||
const switchTo = best && best.rank < used.rank ? best.host : null;
|
||||
// A reconnect tries the addresses in the order the finished test reports for this network
|
||||
// and picks the first that answers: offer Use now on that one, if it isn't the one in use.
|
||||
const test = (s.tests || {})[d.id], order = test && test.done && test.network === (s.network || {}).id && test.order;
|
||||
const pick = order && order.find(h => (tested.get(h) || {}).ssh === "ok");
|
||||
const switchTo = pick && inUse && pick !== inUse && order.indexOf(inUse) > order.indexOf(pick) ? pick : null;
|
||||
list.innerHTML = d.addresses.map((a, i) => {
|
||||
if (cd.editing === a.host && cd.editDev === d.id) return `<div class="item addr"><div class="addr-edit conn-edit">
|
||||
<input type="text" id="ceHost" value="${esc(a.host)}" maxlength="253" aria-label="Address">
|
||||
|
||||
Reference in new issue
Block a user