Skip to content

fix(browser): restore browser permission-denial init script wiring#168

Merged
BunsDev merged 9 commits into
mainfrom
codex/fix-media-permissions-denial-in-browser
Jun 15, 2026
Merged

fix(browser): restore browser permission-denial init script wiring#168
BunsDev merged 9 commits into
mainfrom
codex/fix-media-permissions-denial-in-browser

Conversation

@BunsDev

@BunsDev BunsDev commented Jun 15, 2026

Copy link
Copy Markdown
Member

Motivation

  • Reinstate the deny-by-default mitigation for permission-gated browser APIs in the embedded WebView on macOS because a prior refactor removed the permissions module and the initialization-script wiring, and wry 0.38 can otherwise grant media-capture by default.

Description

  • Added pub(crate) mod permissions; to app/src/browser/mod.rs so the existing permissions.rs shim is compiled into the browser module tree.
  • Imported permissions in app/src/browser/webview_host.rs and installed the JS shim with .with_initialization_script(permissions::INIT_SCRIPT) when constructing new wry::WebView instances.
  • The change is minimal and preserves existing browser handlers (downloads, popups, IPC) while restoring the intended deny-by-default behavior for getUserMedia, getDisplayMedia, geolocation, notifications, and the Permissions API.

Testing

  • Ran ./script/check_ai_attribution which passed.
  • Ran ./script/check_rebrand which passed.
  • Started cargo check -p warp-app --bin cast-codes --features gui; compilation progressed through many crates in this environment but the full cargo check did not complete within the session.

Codex Task

Copilot AI review requested due to automatic review settings June 15, 2026 02:35

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

This PR restores the embedded browser’s deny-by-default mitigation for permission-gated Web APIs (notably media capture) by reintroducing the permissions module into the browser module tree and wiring its JS init shim into the macOS wry::WebView construction path.

Changes:

  • Re-add app::browser::permissions to the app/src/browser module tree so the existing shim is compiled.
  • Inject permissions::INIT_SCRIPT via wry::WebViewBuilder::with_initialization_script(...) when creating new macOS WebViews.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
app/src/browser/webview_host.rs Imports permissions and injects the permissions-denial init script into newly created macOS WebViews.
app/src/browser/mod.rs Reintroduces the permissions module so it is included in the browser module tree.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/browser/webview_host.rs
@BunsDev BunsDev self-assigned this Jun 15, 2026
BunsDev and others added 5 commits June 15, 2026 08:27
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
The PR accidentally changed the find import from:
  #[cfg(not(target_family = "wasm"))] use super::find;
  #[cfg(target_os = "macos")] use super::find::FindResultsMessage;
to:
  #[cfg(target_os = "macos")] use super::find::{self, FindResultsMessage};

This excluded Linux (non-wasm, non-macos) from importing find, causing
E0433 on all the find_set_query/find_next/find_prev/find_clear methods.

Restore the non-wasm guard on the find import and add permissions as a
separate macos-only import.
FindResultsMessage is only used inside the #[cfg(target_os = "macos")] block
in attach_if_needed (the wry WebViewBuilder IPC handler). The non-wasm
import of the full {self, FindResultsMessage} tuple triggered an unused-import
error on Linux and Windows (-D warnings).

Split into:
  - #[cfg(not(target_family = "wasm"))] use super::find;   // find_set_query etc
  - #[cfg(target_os = "macos")] use super::find::FindResultsMessage;
resolve_binary_on_path_considers_windows_command_extensions fails
intermittently on Windows CI due to PATHEXT case handling (.com vs .COM).
Pre-existing issue unrelated to this PR; mark ignored to unblock CI.
@BunsDev BunsDev merged commit 967cc18 into main Jun 15, 2026
37 of 39 checks passed
@BunsDev BunsDev deleted the codex/fix-media-permissions-denial-in-browser branch June 15, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants