feat(medium): Fix Bluetooth Auto-Connect Race Condition and Overlapping Connections#9551
feat(medium): Fix Bluetooth Auto-Connect Race Condition and Overlapping Connections#9551
Conversation
…nnection attempts - Added a check for `hrm_device_id` cookie before triggering auto-connect in `ConnectPage`. - Implemented an `isConnecting` ref guard in `useBluetoothHRM` hook to prevent concurrent connection handshakes. - Updated `connectAndStream` to return gracefully on silent connection failures. - Added `role="status"` and `aria-live="polite"` to Bluetooth status elements for improved accessibility. - Updated unit tests to reflect the new guarded connection behavior. Co-authored-by: arii <342438+arii@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
👋 Welcome to HRM!Thanks for your contribution. This repository uses Gemini AI for automated triage, code review, and generation. 🤖 Gemini Manual Trigger Quick Reference
For more details and GitHub CLI examples, see the Manual Trigger Guide. |
ℹ️ Gemini Review DisabledAutomatic review is currently disabled via Via Comment: Via GitHub Actions:
Via GitHub CLI: gh workflow run reusable-gemini-review.yml -f pr_number=9551🤖 Manual Trigger Quick Reference
Full reference: Manual Trigger Guide To re-enable: Set repository variable |
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Manual Trigger Quick Reference
|
- Added a check for `hrm_device_id` cookie before triggering auto-connect in `ConnectPage`. - Implemented an `isConnecting` ref guard in `useBluetoothHRM` hook to prevent concurrent connection handshakes. - Updated `connectAndStream` to return gracefully on silent connection failures. - Added `role="status"` and `aria-live="polite"` to Bluetooth status elements for improved accessibility. - Updated unit tests to reflect the new guarded connection behavior. - Fixed Prettier formatting in `hooks/useBluetoothHRM.ts`. Co-authored-by: arii <342438+arii@users.noreply.github.com>
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Manual Trigger Quick Reference
|
This PR effectively addresses the Bluetooth auto-connect race condition and overlapping connections, significantly improving the stability of the connection process. The addition of Key Changes & Improvements:
Minor Issue Identified: While the Recommendation: Move Overall, this is a well-executed PR that delivers important fixes and improvements.
🤖 Gemini Manual Trigger Quick Reference
|
… feedback - Moved `isConnecting.current = true` before the `try` block in `connectAndStream` to ensure the entire connection path is guarded. - Maintained all previous fixes for auto-connect race conditions and accessibility. - Verified with unit tests and linting. Co-authored-by: arii <342438+arii@users.noreply.github.com>
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Manual Trigger Quick Reference
|
- Added a check for `hrm_device_id` cookie before triggering auto-connect in `ConnectPage`. - Implemented an `isConnecting` ref guard in `useBluetoothHRM` hook to prevent concurrent connection handshakes. - Moved `isConnecting.current = true` before the `try` block in `connectAndStream` to ensure entire path is guarded. - Fixed a scoping issue with `silent` variable in `connectAndStream` that caused CI type check failure. - Added `role="status"` and `aria-live="polite"` to Bluetooth status elements for improved accessibility. - Updated unit tests to reflect the new guarded connection behavior. - Verified with unit tests, linting, and type checking. Co-authored-by: arii <342438+arii@users.noreply.github.com>
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Manual Trigger Quick Reference
|
… feedback - Added a check for `hrm_device_id` cookie before triggering auto-connect in `ConnectPage`. - Implemented an `isConnecting` ref guard in `useBluetoothHRM` hook to prevent concurrent connection handshakes. - Moved `isConnecting.current = true` before the `try` block in `connectAndStream` to ensure entire path is guarded, as recommended in code review. - Fixed a scoping issue with `silent` variable in `connectAndStream` that caused CI type check failure. - Added `role="status"` and `aria-live="polite"` to Bluetooth status elements for improved accessibility. - Updated unit tests to reflect the new guarded connection behavior. - Verified with unit tests, linting, and type checking. - Analyzed and confirmed VRT failures are unrelated to these changes. Co-authored-by: arii <342438+arii@users.noreply.github.com>
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Manual Trigger Quick Reference
|
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Gemini Manual Trigger Guide |
🤖 AI Technical AuditArchitectural ImpactThe introduction of File-by-File Analysis
|
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Gemini Manual Trigger Guide |
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: arii <342438+arii@users.noreply.github.com>
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Gemini Manual Trigger Guide |
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Gemini Manual Trigger Guide |
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: arii <342438+arii@users.noreply.github.com>
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Gemini Manual Trigger Guide |
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Gemini Manual Trigger Guide |
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Gemini Manual Trigger Guide |
Description
This PR addresses a race condition in the Bluetooth connection flow by implementing several guards and improvements to ensure stable and accessible connections.
Fixes #9303
Changes Made
useAutoConnectlogic now checks for a saved device ID before attempting a silent connection, preventing unnecessary error logs.isConnecting) was added touseBluetoothHRMto ensure that manual and auto-connect attempts do not overlap, which previously causedAbortControllertriggers and potential radio blocking.Testing
Verified with unit tests and manual frontend verification.
Change Type: 🐛 Bug fix (non-breaking change fixing an issue)
Related Issues
Closes #9303
Original PR Body
This PR addresses a race condition in the Bluetooth connection flow. Specifically:
useAutoConnectlogic now checks for a saved device ID before attempting a silent connection, preventing unnecessary error logs.isConnecting) was added touseBluetoothHRMto ensure that manual and auto-connect attempts do not overlap, which previously causedAbortControllertriggers and potential radio blocking.Verified with unit tests and manual frontend verification.
Fixes #9303
PR created automatically by Jules for task 17974409934683189531 started by @arii