From 1597d62a976bee23f78d0ca241bf742f814fe367 Mon Sep 17 00:00:00 2001 From: gnacho Date: Sat, 17 Oct 2026 10:11:14 +0200 Subject: [PATCH] fix(wifi): suggest distinct per-band names when unchecking unify Grouping is derived from SSID equality, so unchecking the toggle without renaming left the bands grouped and the toggle re-checked on reopen: a silent no-op that read as a failure (#541). Pre-fill base and base-5g/-6g suggestions when every per-band name is still identical (never over user edits, collision-checked against other networks), and promote the identical-names banner from info to warning. Closes #541 --- app/src/components/WifiEditModal.tsx | 37 ++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/app/src/components/WifiEditModal.tsx b/app/src/components/WifiEditModal.tsx index 2325a433..be60a530 100644 --- a/app/src/components/WifiEditModal.tsx +++ b/app/src/components/WifiEditModal.tsx @@ -22,6 +22,36 @@ function generateKey(): string { return Array.from(buf, (n) => chars[n % chars.length]).join(""); } +const bandSuffix = (band: string) => (band === "5g" ? "-5g" : band === "6g" ? "-6g" : ""); + +/** + * Unchecking the unify toggle only separates the bands when their names end + * up different: grouping is derived from SSID equality (#541). When every + * per-band field still holds the same name, suggest one per band (base for + * 2.4 GHz, base-5g/-6g for the rest), avoiding names already used by other + * networks on the device. Edits made by the user are never touched. + */ +function suggestBandNames( + current: Record, + group: WifiUI[], + main: WifiUI[], +): Record { + if (new Set(Object.values(current).map((v) => v.trim())).size > 1) return current; + const base = (group[0]?.ssid ?? "").trim(); + const taken = new Set( + main.filter((m) => !group.some((g) => g.section === m.section)).map((m) => m.ssid), + ); + const out: Record = { ...current }; + for (const g of group) { + let name = (base + bandSuffix(g.band)).slice(0, 32); + if (name !== base && (taken.has(name) || group.some((o) => o.section !== g.section && (out[o.section] ?? o.ssid) === name))) { + name = (name + "-2").slice(0, 32); + } + out[g.section] = name; + } + return out; +} + /** * Modal de edición WiFi (wifi.md §2): nombre, seguridad segmentada, clave con * generador, red oculta, emisión de la banda y aviso de reinicio. @@ -141,7 +171,10 @@ export function WifiEditModal({ iface, group, main, onClose, onSaved }: { title={t("wifi.unifyBands")} description={t("wifi.unifyBandsDesc")} checked={unify} - onChange={setUnify} + onChange={(checked) => { + setUnify(checked); + if (!checked) setBandSsids((s) => suggestBandNames(s, group, main)); + }} /> )} @@ -165,7 +198,7 @@ export function WifiEditModal({ iface, group, main, onClose, onSaved }: { )} - {sameBandNames && {t("wifi.sameNamesWarn")}} + {sameBandNames && {t("wifi.sameNamesWarn")}}