fix(mobile): defer background WHOOP init - #2026
Conversation
Reuse activity summary freshness and cap dirty-key batches so analytics cycles do not expand the entire power backlog. Consume precomputed normalized power during refits.
# Conflicts: # docs/production-incident-baseline.md
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
The PR cleanly defers WHOOP BLE connection during initialization when the app is backgrounded, preventing BLE operations while suspended, and correctly connects once the app transitions to active. Test coverage for the background init case is included and verified. Left one minor nit regarding setting the 🤖 Reviewed by codereviewbot.ai - Catch bugs before your team does. |
PR Summary by QodoFix mobile: defer WHOOP BLE init until app is foregrounded
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Mobile PreviewScan to open on device:
To test on device:
|
📝 WalkthroughWalkthroughWHOOP BLE initialization now checks ChangesWHOOP BLE lifecycle
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 1 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Storybook previews for This comment updates automatically on each PR push. |
Code Review by Qodo
Context used✅ Compliance rules (platform):
167 rules✅ Skills:
fix-provider, write-tests, cloudflare 1.
|
|
LGTM 🤖 Reviewed by codereviewbot.ai - Catch bugs before your team does. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/mobile/lib/background-whoop-ble-sync.test.ts`:
- Around line 121-124: Update the test’s vi.waitFor block to include the
assertion that whoopDeps.startImuStreaming was called, keeping the connect and
streaming assertions together while preserving the existing expected call
arguments.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 1cafb9c5-b66c-490f-b758-b7ab4715e98d
📒 Files selected for processing (3)
docs/production-incident-baseline.mdpackages/mobile/lib/background-whoop-ble-sync.test.tspackages/mobile/lib/background-whoop-ble-sync.ts
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
Summary
DOFEK-MOBILE-1Dincident and follow-upRoot cause
initBackgroundWhoopBleSyncunconditionally started its foreground BLE path even whenAppState.currentStatewas not active. The Sentry event came fromwhoop-ble-init-syncwithapp.in_foreground:false, producing a nativeDISCONNECTEDerror.Validation
pnpm exec vitest run packages/mobile/lib/background-whoop-ble-sync.test.ts --project mobile(47 passed)pnpm lintpnpm typecheckpnpm test(13,742 passed, 21 skipped)Summary by cubic
Defers WHOOP BLE init when the app starts in the background, serializes the first sync, and cancels sync if the app backgrounds mid-flow; adds tests that await IMU stream startup. Prevents background BLE attempts, duplicate runs, and dangling connections; the explicit background-refresh path stays unchanged.
Written for commit 8177587. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Documentation