fix(macos): gate Web Audio in child frames
Facebook Messenger on your desktop, without the Facebook clutter
Brought to you by:
kristoffer-r
Originally created by: kristofferR
Messenger creates an idle Web Audio context in a cross-origin child frame. Carrier’s idle gate was registered as a main-frame initialization script on macOS, so that context kept WebKit’s audio session active and could retain the Bluetooth route.
This adds a dedicated, origin-scoped all-frame Web Audio bundle for Messenger and fbsbx frames while keeping Carrier’s privileged bridge main-frame-only. Active call state is relayed through the frame tree so call audio stays exempt from idle suspension.
bun run checkcd src-tauri && cargo fmt && cargo clippy --all-targets -- -D warnings && cargo test --libactive audio session not requiredRef [#234]
Added throttled diagnostics for supported Messenger and audio-only frames.
Bug Fixes
Originally posted by: kristofferR
@coderabbitai review
Originally posted by: kristofferR
@codex review
Originally posted by: coderabbitai[bot]
✅ Action performed
Review finished. > Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.Originally posted by: chatgpt-codex-connector[bot]
Codex Review: Didn't find any major issues. 🎉
Reviewed commit:
4ceb25a2e2ℹ️ About Codex in GitHub
[Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Originally posted by: coderabbitai[bot]
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
**Configuration used**: Path: .coderabbit.yaml **Review profile**: ASSERTIVE **Plan**: Pro Plus **Run ID**: `a0485190-723b-4289-9029-aa0ec1ae03a3`📥 Commits
Reviewing files that changed from the base of the PR and between [4ceb25] and 87af473a7d4edd16344b53ae62ca6b3ea76f473c.📒 Files selected for processing (5)
* `inject/src/messenger/features/web-audio-idle.ts` * `inject/src/messenger/lib/web-audio-idle.test.ts` * `inject/src/messenger/lib/web-audio-idle.ts` * `inject/src/web-audio-idle.ts` * `src-tauri/inject/web-audio-idle.js`📝 Walkthrough
## Walkthrough The PR moves Web Audio idle management into a standalone injection bundle. The bundle runs in Messenger and FBSBX frames, manages audio activity, synchronizes call state across frames, reports diagnostics, and keeps privileged Carrier initialization limited to the main frame. ### Changes **Web Audio idle injection** |Layer / File(s)|Summary| |---|---| |**Web Audio gate and call-state propagation**`inject/src/messenger/features/web-audio-idle.ts`, `inject/src/messenger/lib/web-audio-idle.ts`, `src-tauri/inject/web-audio-idle.js`|The feature manages audio context activity, media holds, automatic suspension and resumption, rejected resumes, and cross-frame call state.| |**Standalone entry and diagnostics**
`inject/src/web-audio-idle.ts`, `inject/src/messenger/lib/web-audio-idle.ts`, `inject/src/messenger/lib/web-audio-idle.test.ts`, `src-tauri/inject/web-audio-idle.js`|The standalone entry detects Messenger and FBSBX frames, creates throttled top-level diagnostics, and initializes the Web Audio feature. Tests cover host resolution, trusted origins, and diagnostic formatting.| |**Build and WebView frame wiring**
`inject/build.ts`, `src-tauri/src/lib.rs`, `src-tauri/src/window.rs`|The build creates the `web-audio-idle` bundle. The WebView loads it in every frame and restricts privileged initialization to the main frame. Tests cover origins, event validation, and bridge isolation.| |**Messenger injector migration**
`inject/src/messenger/index.ts`, `src-tauri/inject/messenger.js`|The Messenger injector no longer imports, starts, or contains the Web Audio idle implementation.| **Estimated code review effort:** 4 (Complex) | ~60 minutes **Merge Risk:** _🟡 Moderate_ · up to `87af4` The frame-wide call-state relay can disclose call activity to embedded cross-origin documents, while the diagnostic timing can silently lose counters and obscure feature behavior. These bounded security and observability issues should be fixed or explicitly accepted before merge. ### Sequence Diagram(s) :::mermaid sequenceDiagram participant WebView participant WebAudioIdle participant AudioContext participant ChildFrame WebView->>WebAudioIdle: load standalone injection WebAudioIdle->>AudioContext: wrap lifecycle and activity methods AudioContext->>WebAudioIdle: report activity and state changes WebAudioIdle->>AudioContext: suspend or resume idle contexts ChildFrame->>WebAudioIdle: request or receive call state WebAudioIdle->>AudioContext: apply call-state protection
🚥 Pre-merge checks | ✅ 4 | ❌ 1
### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 56.25% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |✅ Passed checks (4 passed)
| Check name | Status | Explanation | | :------------------------: | :------- | :------------------------------------------------------------------------------------------------------- | | Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. | | Title check | ✅ Passed | The title clearly summarizes the main change: enabling Web Audio idle handling in child frames on macOS. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
- [ ] Create stacked PR - [ ] Commit on current branch🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests - [ ] Commit unit tests in branch `t3code/investigate-issue-234`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.
❤️ Share
- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)Comment
@coderabbitai helpto get the list of available commands.Originally posted by: kristofferR
@coderabbitai review
Originally posted by: kristofferR
@codex review
Originally posted by: coderabbitai[bot]
⚠️ Action not completed
Review rate limited. > Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.Originally posted by: kristofferR
@codex review
Originally posted by: chatgpt-codex-connector[bot]
Codex Review: Didn't find any major issues. Hooray!
Reviewed commit:
87af473a7dℹ️ About Codex in GitHub
[Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Originally posted by: kristofferR
@coderabbitai review
Originally posted by: coderabbitai[bot]
✅ Action performed
Review finished. > Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.Ticket changed by: kristofferR