Bug: network module shows a saved/preferred SSID (stale Wi-Fi name) when Wi-Fi is off on macOS
- Dominant language
- Shell
- Stars
- 856
- Forks
- 368
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
## Description
On macOS, `scripts/network.sh` derives the candidate Wi-Fi name (`wifi_network`) via:
```bash
networksetup -listpreferredwirelessnetworks "$ifname" | awk 'NR==2 && sub("\t","") { print; exit }'
```
`listpreferredwirelessnetworks` lists the **saved / preferred** networks — not the currently associated one. The first saved entry (`NR==2`) is then used as the fallback whenever `networksetup -getairportnetwork` reports *"You are not associated with an AirPort network."*
As a result, when **Wi-Fi is OFF but the machine is online via Ethernet**, the host ping succeeds, `getairportnetwork` correctly reports "not associated", and the module falls back to the first **saved** network — displaying a stale SSID (e.g. an old phone hotspot) the machine is not actually connected to.
## Steps to reproduce (macOS 15+ / 26)
1. Have at least one saved Wi-Fi network (e.g. a phone hotspot used previously).
2. Turn **Wi-Fi off**.
3. Stay online via **Ethernet**.
4. The `network` module shows the first *saved* network name instead of `Ethernet`.
## Root cause
`networksetup -listpreferredwirelessnetworks` != current association. It was introduced in #370 as a workaround for `ipconfig getsummary` returning `` on Darwin >= 25, but it reflects *saved* networks, so it yields a name even when Wi-Fi is not connected.
## Environment
- macOS 26.3, tmux 3.6a
- dracula/tmux @ current master
## Suggested fix
Gate the Wi-Fi branch on the interface actually being associated (`ifconfig "$ifname"` -> `status: active`) before consulting any SSID source. A not-associated interface then reports `Ethernet`/`Offline` instead of a saved name. This leaves the #370 connected-Wi-Fi SSID resolution untouched, so there's no regression risk for users currently on Wi-Fi. PR incoming.
Contributor guide
Research direction
Start in scripts/network.sh and inspect the Wi-Fi branch around getairportnetwork and listpreferredwirelessnetworks. Reproduce on macOS with Wi-Fi off and Ethernet online, then verify the module reports Ethernet or Offline rather than a saved SSID while connected Wi-Fi name resolution remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100