Skip to content

feat: improve connection animation, audio auto-connect, battery detection, and tray exit - #261

Closed
aaroncheungzy wants to merge 2 commits into
SpriteOvO:mainfrom
aaroncheungzy:codex/audio-playback-auto-connect
Closed

aaroncheungzy wants to merge 2 commits into
SpriteOvO:mainfrom
aaroncheungzy:codex/audio-playback-auto-connect

Conversation

@aaroncheungzy

@aaroncheungzy aaroncheungzy commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR improves four areas of the connection experience: connection animation and feedback, automatic connection on audio playback, battery detection, and the tray Quit button. Supersedes #253.

1. Connection animation and feedback

  • Replace Windows system notifications with an application-owned card styled consistently with the battery window, with light/dark theme support.
  • Show an animated indeterminate progress indicator while connecting, and reuse the same card for progress and errors.
  • On a successful connection, dismiss the connection card and show battery information without an extra "Connected" notification.
  • Make a single tray click connect when disconnected or show battery information when already connected; remove the dedicated double-click action.
  • Update the setting description and all existing translation catalogs.

2. Automatic connection on audio playback

  • Add Connect automatically when audio starts playing, off by default and independent of the tray-click setting. Both options use the same selected paired Bluetooth audio device.
  • When playback starts, connect only if the selected device is disconnected. Already-connected automatic checks stay silent, and in-flight requests are reused.
  • After a failure, require at least 30 seconds and a new playback start before retrying; do not repeatedly reconnect during continuous playback.
  • Check Windows output audio sessions on a background worker every 250 ms, excluding this application's own audio. Disable monitoring when the setting is off.
  • Running streams count as playback through quiet passages and muted output. A 1.5-second inactive interval recognizes a stop; apps that keep streams running while paused may delay a subsequent start.

The new configuration key is audio_auto_connect_enabled, with a default value of false.

3. Battery detection and source filtering

  • Prevent battery readings from repeatedly jumping between inconsistent values when conflicting advertisement sources are merged.
  • Check overlapping battery reports for consistency, allowing adjacent 10% buckets. An initial partial conflicting report can be replaced by a more complete report with a signal at least 10 dB stronger.
  • Preserve existing latest-available merging, expiry behavior, and genuine battery changes. Broadcast readings retain their existing 10% granularity.
  • Add a regression fixture containing 48 anonymized observations, without Bluetooth addresses or encrypted payloads.

Source selection remains a heuristic; unauthenticated broadcasts alone cannot prove that two advertisements belong to the same pair.

4. Tray Quit button

  • Fix Quit being canceled by the battery window's close-to-tray handler.
  • Queue an explicit QCoreApplication::exit(0) on the GUI thread, preserving normal application destruction and worker cleanup.
  • Keep normal battery-window closing/hiding behavior.
  • Add a child-process regression test that triggers the real tray Quit action with the battery window visible and verifies that the process exits.

No new dependencies are introduced.

Validation

  • Manually tested on Windows 11 25H2 with AirPods 4 with Active Noise Cancellation and the bilibili web player, including playback-triggered connection and the subsequent battery-display and tray-exit fixes.
  • Local x64 RelWithDebInfo build passed with Qt 6.8.3 and MSVC 19.51 (Visual Studio 2026 Build Tools).
  • ctest --test-dir Build -C RelWithDebInfo --output-on-failure: 12/12 test targets passed. The optional native tone smoke test is opt-in and skipped in the standard run.
  • Tests cover independent settings, persistence, playback edges, cooldown, duplicate requests, already-connected behavior, monitor shutdown, concurrent manual clicks, battery-source conflicts in both arrival orders, captured packet replay, and process exit with a visible battery window.
  • UI tests use in-memory settings; production settings were unchanged during the final test run.
  • C++ formatting and git diff --check passed.

Screenshots

Captured by the local UI tests:

Light notification Dark notification
Light connection popup Dark connection popup

Tray and automatic playback connection settings

@aaroncheungzy aaroncheungzy changed the title feat: add playback auto-connect and improve tray reliability feat: improve connection animation, audio auto-connect, battery detection, and tray exit Oct 19, 2026
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