KeySelector: disambiguate zones served by multiple keys - #63
Conversation
The zone dropdown lists availableZones (a de-duped union across all keys), so a
zone name served by more than one key (e.g. split-horizon internal vs external)
appeared once and selectZone auto-picked a key arbitrarily. Until a key is
chosen, expand such a zone into one option per serving key
("zone — keyName (server)") so the user picks the exact key/view; selecting one
sets key and zone together. Single-key zones are unchanged, and once a key is
selected the list is already narrowed to that key's zones (no splitting). The
same splitting applies inside the reverse-zone sub-dropdown, and the helper text
hints when multi-key zones are present.
KeyContext gains selectKeyAndZone(key, zone) to set both atomically — calling
selectKey then selectZone would read stale state and re-run the auto-pick,
clobbering the chosen key.
Composite option value is `zone|keyId` (| can't appear in a DNS name or in our
key IDs). Known edge: a persisted zone-only selection (no keyId) for a multi-key
zone shows nothing selected until the user picks a per-key entry.
Tests: KeySelector suite extended (multi-key zone splits per key; single-key
unchanged; per-key selection sets both key and zone; no split once a key is
selected; reverse grouping still works). Frontend 252/252 + typecheck + build clean.
Code reviewFound 1 issue:
snap-dns/src/components/KeySelector.tsx Lines 212 to 216 in 8da26f8 (root cause is the split in snap-dns/src/components/KeySelector.tsx Lines 93 to 96 in 8da26f8 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
… key Code review found a regression: after selecting a multi-key zone and then clearing the Key dropdown (or reloading a persisted zone-only selection), selectedZone is set with selectedKey null. In that state renderZoneMenuItems emits only the per-key composite options, so the plain zone name is not a selectable value — the controlled Select bound to it rendered blank and logged a MUI "out-of-range value" warning while the helper text still said "Managing X". That state is genuinely ambiguous (no view chosen), so bind the Select to '' when !selectedKey and the selected zone is served by >1 key (ambiguousZoneOnly), and have the helper text prompt for a key/view instead of claiming "Managing". Covers both triggers at the render layer (no KeyContext change). The per-key options remain available to disambiguate. Test: new case asserting the field shows no committed zone and prompts for a view in that state. Frontend 253/253 + typecheck clean.
|
Fixed in 69f590a: when no key is selected and the chosen zone is served by multiple keys, the Select now binds to '' (not the unselectable plain zone name) and the helper text prompts for a key/view — no more blank field / out-of-range warning / contradictory "Managing" text. Covers both the deselect-key and persisted-reload paths at the render layer. Added a regression test; frontend 253/253 + typecheck clean. |
Why
KeySelector's zone dropdown listsavailableZones— a de-duped union across all keys. So a zone name served by more than one key (e.g. a split-horizon internal vs external view) shows up once, andselectZonesilently auto-picks a key. The user can neither tell the zone is multi-key nor choose which key/view. (This only matters in the zone-first flow; picking a key first already narrows the list to that key.)What
zone — keyName (server)— and selecting one sets the key and zone together. Single-key zones are unchanged.KeyContext.selectKeyAndZone(key, zone)added to set both atomically — callingselectKeythenselectZonewould read stale React state and re-run the auto-pick, clobbering the chosen key.zone|keyId(|can't appear in a DNS name or ourkey_<ts>_<hex>IDs).Known edge (documented): a persisted zone-only selection (no
keyId) for a multi-key zone shows nothing selected until the user picks a per-key entry — rare, from older persisted state.The backend already enforces the explicit
keyId(3.2.0); this makes the UI express it unambiguously.Tests
Extended the
KeySelectorsuite: multi-key zone splits per key; single-key unchanged; per-key selection sets both key and zone; no split once a key is selected; reverse-zone grouping still works. Frontend 252/252 +tsc --noEmit+ build clean.No version/CHANGELOG bump — kept version-neutral so the pending batch (#60/#61/#62 + this) can share one consolidated release.
🤖 Generated with Claude Code