Repository navigation
Commit 8e0666c
fix(desktop): canonicalize relay pins before ranking Welcome starters
Review follow-up on PR #6037.
relayPinRank compared pins normalized only by trimming whitespace and trailing
slashes, so backend-equivalent spellings ranked as different communities:
ws://localhost:3000 vs ws://127.0.0.1:3000
wss://RELAY.EXAMPLE:443/ vs wss://relay.example
ws://relay.example:80 vs ws://relay.example
The backend's pair key already folds host case, loopback aliases and default
ports, so a record pinned to one spelling of the active community was ranked
"pinned elsewhere". On an install that already carries duplicate Welcome
records -- the exact population this PR exists to stop growing -- that can
reuse the wrong identity.
normalizeRelayUrl now delegates to the existing canonicalRelayUrl
(features/agents/managedAgentRuntimeStatus.ts) rather than hand-rolling a
second normalization. canonicalRelayUrl returns null for anything that is not
a ws/wss URL, so a legacy or malformed pin falls back to a stable lowercased
form: two records carrying the same bad pin still rank as one community
instead of each becoming its own. An unbound pin ("") stays null and keeps its
eligible-everywhere rank.
Tests cover loopback aliases, host case, both default ports and a trailing
slash, plus a malformed pin, and a guard that canonicalization does not fold
two genuinely distinct hosts together.
A note on how those tests are written: pickAgentForRelay walks every rank and
returns the last candidate standing rather than reporting a starter missing,
so a single-agent assertion passes with or without canonicalization. My first
draft did exactly that and was vacuous -- it passed against the unfixed
source. Each case now lists a decoy pinned elsewhere FIRST, so the assertion
only holds if the equivalent spelling is actually recognised as rank 0.
Verified: reverting welcomeGuide.ts alone takes the file to 25 pass / 2 fail.
Full desktop unit suite 4961/4962; the one failure is the pre-existing timing
flake in shared/lib/useDocumentVisible.test.mjs, which this branch does not
touch. tsc --noEmit and biome clean.
Co-authored-by: Michael Feth <[email protected]>
Signed-off-by: Michael Feth <[email protected]>1 parent f05ecea commit 8e0666c
2 files changed
Lines changed: 102 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
130 | 211 | | |
131 | 212 | | |
132 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
54 | 72 | | |
55 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
56 | 76 | | |
57 | 77 | | |
58 | 78 | | |
| |||
0 commit comments