fix(airplane): correct radio presence and Bluetooth settle behavior#396
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refines nmrs airplane-mode behavior so hosts without certain radios (notably Bluetooth/WWAN) don’t get “stuck” in a non-airplane state and so BlueZ toggles are less prone to read-after-write races.
Changes:
- Add
RadioState::present(+with_presence) and update airplane-mode aggregation helpers to ignore absent radios. - Treat missing/absent BlueZ as “not present” for aggregation and downgrade
BluezUnavailableduringset_airplane_modeto avoid failing the overall toggle. - After setting BlueZ
Powered, wait (bounded) for the property to reflect the change to reduce transient stale reads.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
nmrs/src/types/constants.rs |
Adds NM device type constant for modem/WWAN detection. |
nmrs/src/core/airplane.rs |
Implements radio presence detection, BlueZ Powered settling wait, and set_airplane_mode behavior change for missing BlueZ. |
nmrs/src/api/network_manager.rs |
Updates public API docs to describe presence semantics and BlueZ no-op behavior. |
nmrs/src/api/models/radio.rs |
Extends RadioState with present, updates AirplaneModeState logic, and adds unit tests. |
nmrs/CHANGELOG.md |
Documents the new present field and airplane-mode fixes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2feb100 to
8e38775
Compare
5be3a0a to
2a0d89b
Compare
2a0d89b to
f3cb9e6
Compare
…Powered to settle so toggling airplane mode no longer leaves wifi soft-killed on hosts without bluetooth
…, and log swallowed BlueZ errors
f3cb9e6 to
f2b5051
Compare
Copilot stopped work on behalf of
cachebag due to an error
May 8, 2026 20:08
…Bluetooth toggle vs stack-unavailable errors
…ch, and fix Powered read on settle
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
nmrs/src/core/airplane.rs:176
set_bluetooth_radio_enabledwraps any error fromenumerate_bluetooth_adaptersinto a newConnectionError::BluezUnavailable. Sinceenumerate_bluetooth_adaptersalready returnsConnectionError(often alreadyBluezUnavailable), this will double-prefix the error message (e.g. "bluetooth stack unavailable: failed to enumerate adapters: bluetooth stack unavailable: …") and can discard the original error variant/context. Prefer propagating the original error (?) or adding context without re-wrapping an existingConnectionError.
let adapter_paths = enumerate_bluetooth_adapters(conn).await.map_err(|e| {
ConnectionError::BluezUnavailable(format!("failed to enumerate adapters: {e}"))
})?;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a bug where turning airplane mode on could shut off Wi‑Fi (and Bluetooth) while clients still saw “airplane off”: failures or missing BlueZ were surfaced as errors after Wi‑Fi had already been soft‑blocked, read‑after‑write could catch Bluetooth’s
Poweredbefore it updated, and absent Wi‑Fi/WWAN/Bluetooth hardware was still folded intoAirplaneModeState, sois_airplane_modenever matched what the user expected.This change treats absent radios as not present, treats unavailable Bluetooth as a no‑op when turning airplane on so the call still succeeds for Wi‑Fi/WWAN, waits for BlueZ power state with bounded latency (one device pass plus a single overall settle timeout), and reduces redundant D‑Bus work by enumerating NM devices once for the combined state. When Bluetooth is skipped because BlueZ is unavailable, a warning is logged so “silent” failures are still diagnosable.