Skip to content

fix(wifi): show Disconnect on a connected saved network without a bound MAC#152

Merged
andrescera merged 1 commit into
mainfrom
fix/wifi-connect-button-and-reliability
Jul 16, 2026
Merged

fix(wifi): show Disconnect on a connected saved network without a bound MAC#152
andrescera merged 1 commit into
mainfrom
fix/wifi-connect-button-and-reliability

Conversation

@andrescera

Copy link
Copy Markdown
Member

What

The currently-connected WiFi network showed a Connect button instead of Disconnect (confirmed on real hardware — SSID "SOMOS - 701": green checkmark, "Connected" status, yet a yellow "Connect" button).

Backend fix in wifiUpdateSavedConns (apps/backend/src/modules/wifi/wifi.ts): register a saved WiFi profile in an interface's saved map even when its 802-11-wireless.mac-address is unbound or no longer matches a present adapter. Extracted the keying step into the pure, unit-tested helper registerSavedWifiConnection.

Why

WifiNetworkList.svelte only renders the Disconnect/Connect toggle inside {:else if uuid}; a falsy uuid falls through to the "new/unsaved network" branch that always shows "Connect". getWifiUUID (frontend) is a faithful SSID→UUID lookup over iface.saved — it returned undefined because the backend had dropped the active network from saved.

Root cause: a saved profile was added to saved[ssid] only when its bound MAC matched a currently-present adapter. Profiles created outside CeraUI's own connect flow (nmtui, nmcli device wifi connect, baked image profiles) have no bound MAC, and MAC randomization / swapped adapters make a bound MAC stop matching — so those profiles were silently dropped. Meanwhile the scan path (wifiUpdateScanResult) marks every scanned SSID active from nmcli's IN-USE column with no MAC requirement. The asymmetry produced an active network that resolved no UUID.

The fix keeps precise per-adapter attribution when the bound MAC matches (multi-adapter disambiguation unchanged), and otherwise registers the profile on every present adapter — mirroring the scan path where all interfaces already see all networks.

How to verify

  • apps/backend/src/tests/wifi-saved-connection.test.ts (new, 3 cases):
    • unbound profile (empty MAC) → saved[ssid] resolves the UUID (pre-fix this was undefined — the exact bug; commented in the test);
    • bound MAC matching no present adapter (stale/randomized) → registered on all adapters;
    • bound MAC matching one adapter → attributed to that adapter only, not the other.
  • cd apps/backend && bun tsc --noEmit — clean.
  • biome check on the changed files — clean.
  • bun test (wifi suites) — wifi-saved-connection + wifi-migration + wifi-mock-seam = 12 pass / 0 fail.

Risks

  • Low, backend-only. On a multi-adapter device an unbound profile now shows as saved on every adapter (previously on none). That is the correct semantic — an unbound profile can be used by any adapter — and disconnect/forget already work by UUID across all interfaces. A MAC-bound profile that matches a present adapter is still attributed to that adapter alone, so the common precise case is unchanged.

Notes

Investigated the related "periodic MAC-randomize-then-scan cycling" report at the same time: it is stock NetworkManager background-scan behaviour (wifi.scan-rand-mac-address), the ~35-min idle is NM autoconnect-retry policy, and there is no CeraUI boot-time station-connect code path (nmcli con up is only called from the explicit wifi.connect RPC and hotspot paths) — so the service-restart correlation was coincidental. No change made there; not a defect.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 61edaf18-5bff-49ce-a77f-ffbac2f8d53b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/wifi-connect-button-and-reliability

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…nd MAC

A saved WiFi profile was only recorded in an interface's `saved` map when its
802-11-wireless.mac-address matched a present adapter. Profiles created outside
CeraUI (nmtui, `nmcli device wifi connect`, baked image profiles) have no bound
MAC, and MAC-randomized/swapped adapters no longer match, so those profiles were
dropped from `saved` entirely. The scan path still marked them active, so the UI
resolved no UUID and offered "Connect" on the already-connected network.

Register such profiles on every present adapter (mirroring the scan path where
all interfaces see all networks); keep precise per-adapter attribution when the
bound MAC matches. Extracted into the pure `registerSavedWifiConnection` helper.
@andrescera
andrescera force-pushed the fix/wifi-connect-button-and-reliability branch from 7a542f1 to a27d03b Compare July 16, 2026 21:03
@andrescera
andrescera merged commit f11308e into main Jul 16, 2026
12 checks passed
@andrescera
andrescera deleted the fix/wifi-connect-button-and-reliability branch July 16, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant