Skip to content

Don't treat Bluetooth Trusted as a completed pairing - #7880

Open
reinierbutot wants to merge 2 commits into
omacom:quattrofrom
reinierbutot:fix/bluetooth-trusted-unpaired
Open

reinierbutot wants to merge 2 commits into
omacom:quattrofrom
reinierbutot:fix/bluetooth-trusted-unpaired

Conversation

@reinierbutot

Copy link
Copy Markdown

Fixes #7879

Problem

If the first Bluetooth pair attempt fails, the panel never pairs that device again.

omarchy-bluetooth-device pair ignored a failed bluetoothctl pair and still trusted the address. The panel treats trusted as already paired (paired || bonded || trusted), so later clicks only connect. BlueZ Trusted is not a bond. After this, bluetoothctl info shows Trusted yes, Paired/Bonded no, and the device sits under PAIRED.

Hit this with a Logitech MX Master 2S (BLE HID). Same trap for any device whose first pair fails.

Fix

  • Trust and connect only after bluetoothctl pair succeeds
  • Group known devices as paired or bonded, not merely trusted — trusted-unpaired stay with discovered devices
  • Clicking an unpaired device pairs it again, even if it is already trusted

Testing

./test/shell.d/bluetooth-test.sh passes, including new coverage that a failed pair does not trust or connect, and that a trusted-only device is discovered rather than known.

./test/all: 184 of 188 test files pass. The four failures (config, launch-about, snapper, unowned-system-paths) fail the same way on quattro without this change — three need an omarchy-pkgs checkout; launch-about wants a live compositor animation.

A failed pair still trusted the address, and the panel treated Trusted as
already paired, so later clicks only connected. Trust only after pairing
succeeds, and retry pair unless the device is paired or bonded.
Copilot AI balanced review requested due to automatic review settings August 23, 2026 12:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes #7879 by distinguishing Bluetooth trust from successful pairing.

Changes:

  • Trusts and connects only after pairing succeeds.
  • Classifies trusted-only devices as discovered.
  • Adds regression coverage for failed pairing and device grouping.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
bin/omarchy-bluetooth-device Gates trust and connect on pairing success.
shell/plugins/panels/bluetooth/Panel.qml Retries pairing for trusted-only devices.
shell/plugins/panels/bluetooth/Model.js Corrects paired-device grouping.
test/shell.d/bluetooth-test.sh Adds pairing-state regression tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at b88af95. The bug is real and this fixes it.

What ran. On a disposable Omarchy worker I wrote a separate reproduction with a stubbed bluetoothctl whose pair fails: on quattro (b18ab49) the script still ran trust and connect, the panel listed a trusted-only device under PAIRED, and clicking it ran connect. On this head, and on this head merged into current quattro, a failed pair stops after pair, a successful one runs pair → trust → connect, and a trusted-only device is listed as available and clicking it pairs. With the three source files reverted, it fails again. ./test/cli and test/shell.d/bluetooth-test.sh pass on the head (56/56), and the shell loads the merged tree cleanly. On the merged tree, ./test/cli has one failure (vscode generated theme references current theme file), and bare quattro fails it too, so it is not caused by this PR. Nothing ran on real Bluetooth hardware.

Second opinion. Codex Medium reviewed it too; independence is not guaranteed. It checked BlueZ 5.80–5.87 source and confirmed the assumption the fix rests on: bluetoothctl pair exits non-zero on every D-Bus error and on the 20s timeout. It also raised three behaviour changes that I checked and agree are real. They are trade-offs for the maintainer to weigh, not defects to push:

  • A device that connects but rejects pairing (for example a BLE peripheral with no security) used to connect anyway through the failed-pair fallback. The panel now sends it through pair every time and never tries connect.
  • A trusted-but-unpaired device, including one left stuck by the old behaviour, moves out of PAIRED. It is hidden when not scanning, and it has no Forget, because Forget only shows on paired and connected rows (Panel.qml:900).
  • Running omarchy-bluetooth-device pair directly on a device that is already bonded now does nothing, because BlueZ returns AlreadyExists. The panel never does this; only direct CLI use hits it.

Codex suggested a narrower alternative: only drop trusted from the click decision in Panel.qml. That fixes the retry trap, stuck devices included, and keeps both the fallback and Forget, but it leaves a failed pair still marking the device trusted.

Next. Labelled verified. It waits on the maintainer to choose between this and the narrower fix. Nothing is needed from you.

@drewdunne

Copy link
Copy Markdown

Tested this PR's bin/omarchy-bluetooth-device (b88af95) on real hardware: AirPods Pro 2 (USB-C), Dell 14S DS14265 (MediaTek MT7925), Omarchy 4.0.4-1, BlueZ 5.87-2.

Gating trust and connect on the exit status relies on bluetoothctl pair returning 0 once a real pairing succeeds, which a stub can't show. It does. Three fresh pairings (forget, pairing mode, then omarchy-bluetooth-device pair), with every bluetoothctl call wrapped to log its exit status and duration:

Run pair trust connect Result
1 exit 0, 792 ms exit 0 exit 0, 562 ms Paired, Bonded, Trusted, Connected; A2DP card up 2 s later
2 exit 0, 829 ms exit 0 exit 0, 545 ms Same
3 exit 0, 718 ms exit 0 exit 0, 567 ms Same

On the same machine the stock script left the AirPods Trusted: yes, Paired: no after a failed pair, as described in #7879.

One thing I noticed: in one attempt, bluetoothctl pair on a device that was already paired did not return until its timeout (exit 124). With this PR that only affects running omarchy-bluetooth-device pair by hand on a paired device, since the panel now sends paired devices to connect.

I only exercised the script. The Model.js and Panel.qml changes were not run on hardware here.

@echennells

Copy link
Copy Markdown

I compared this with #13811 and #14319 on real hardware (ThinkPad T14 Gen 2a, Realtek, BLE mouse), applied onto 4.0.4 at b88af95a. Table and details: #7879 (comment)

For this PR, with the pairing agent stopped, the pair fails as expected. The device is not left trusted, and it goes back under discovered, so it can be retried. That's the fix this issue asks for. But the helper exits 0 and nothing tells the user the pair failed. The panel launches it with Quickshell.execDetached, so the exit code and stderr never reach the UI either way. Of the three, the panel/model change (trusted is not paired) is only in this PR.

Tested with help from Claude Code; every run was on my machine.

The panel launches omarchy-bluetooth-device with Quickshell.execDetached, so it never sees the helper's exit status or stderr: a failed pair now leaves the device retryable, but nothing says it failed. Notify instead, with a fixed message and a distinct one for the 20 second timeout, and exit 1 for anyone running it by hand. The message never carries bluetoothctl's output, which after a timeout is discovery chatter naming other nearby devices.

Folded in from omacom#14319.

Co-Authored-By: David Boulay <david.boulay@lojel.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Stops treating Bluetooth trust as a completed pairing.

  • The Bluetooth panel retries pairing for trusted-only devices.

No actionable issues found. Tests were inspected but not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Click disconnected device] --> B{Paired or bonded?}
  B -->|Yes| C[Connect]
  B -->|No, including trusted-only| D[Pair]
  D --> E{Pair succeeded?}
  E -->|Yes| F[Trust, then connect]
  E -->|No| G[Notify and exit with failure]
Loading

Reviews (1) · Last reviewed commit: "Tell the user when Bluetooth pairing fai..." · Reviewed by Greptile

@omarchybot omarchybot added the ready Good to merge label Oct 16, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Pushed 29d450d to this branch. It folds in the one thing #14319 adds: a failed pair now tells the user.

Why. The panel starts the helper with Quickshell.execDetached (Panel.qml, runDeviceAction), so it never sees an exit status or stderr. With this PR a failed pair leaves the device retryable, but as @echennells found on hardware, nothing says it failed. Now omarchy-bluetooth-device pair sends an Omarchy notification, "Bluetooth pairing failed", writes the same text to stderr, and exits 1. A timeout (exit 124) gets its own message: "Pairing timed out after 20 seconds. Is the device in pairing mode?" The message is fixed text. In #14319 the notification after a timeout carried bluetoothctl's output, which @echennells saw fill with other nearby devices' addresses and colour codes. Connect, disconnect and forget are unchanged. The commit credits @davidboulay as co-author.

What ran. On a disposable Omarchy worker, test/shell.d/bluetooth-test.sh passes 65/65 and ./test/cli passes, both on this head and on this head merged into current quattro. The new tests cover a failed pair with exit 1 and with 124: the helper must exit non-zero, must not trust or connect, must notify, and must say "timed out" for 124. With only the helper change reverted, they fail, and on quattro the suite fails at the panel check. The helper was also run against a failing bluetoothctl stub, and the worker's desktop drew the notification. Nothing ran on real Bluetooth hardware. The successful-pair path is unchanged from b88af95, which @drewdunne confirmed on AirPods Pro 2.

Who checked. I reviewed it (Claude Opus 5.5), and Codex Medium reviewed the new commit as a second opinion. It found no defects, checked every caller of the helper (only the panel, which ignores the exit status, plus the CLI router), and agreed the tests fail without the fix. Its independence is not guaranteed.

Still the maintainer's call. The trade-offs from the first review still apply. A device that connects but rejects pairing no longer gets the connect fallback. A device that is trusted but not paired moves out of PAIRED and has no Forget. #13811, which also starts bt-agent before pairing, is a separate enhancement and is not folded in here.

Next. This waits on the maintainer. Nothing is needed from you.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This no longer merges into quattro, so the verified and ready labels came off. The conflict is only in test/shell.d/bluetooth-test.sh: #16334 removed every Panel.qml source-regex assert from that file, and this branch adds two more of them (connect only paired or bonded devices, never treat trusted as paired). Resolving it means taking quattro's side of that hunk, dropping those two asserts along with the rest. The rest of the merge is clean. The helper, Model.js and Panel.qml changes come through unchanged, and so do the behavioural tests (a failed pair, status 1 or 124, does not trust, connect or exit 0, it notifies, and a trusted-only device is listed as discovered).

I have not pushed that merge. The classification for this head is unsettled: I read it as a bug fix, and Codex Medium, classifying the PR separately, read it as an enhancement. The likely reason is the failed-pair notification folded in at 29d450d, which is new behaviour on top of the fix. Until the two agree, it is not re-verified on a worker or brought back to ready.

Waiting on the maintainer to settle the class, either as a fix or by splitting the notification out. @reinierbutot, you're welcome to merge quattro in yourself and resolve it as above.

@omarchybot omarchybot removed the bug Something isn't working label Oct 31, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Checked the failed Check translation structure run for unchanged head 29d450d5. GitHub still records a failure, but its log returns log not found, and its jobs and check-run endpoints now return no records. I could not recover the failing command or output, or establish whether this PR caused it. The passing Greptile review does not establish that the translation check passed.

A disposable worker was used only to check which translation test files exist at this head; no test suite, visual check or hardware test ran in this follow-up. No code was pushed or CI rerun.

GPT-6 in Codex at high effort checked this evidence. Opus 5.5 High and muse-wonder via pi, thinking high reviewed it too and found no supported code fix from the available evidence; independence is not guaranteed. This waits on the maintainer because the CI investigation could not be completed. The existing classification disagreement and merge conflict remain unresolved.

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.

Bluetooth panel treats trusted-but-unbonded devices as paired and never retries pairing

5 participants