agent: fix — auto-grant microphone permission on WebKitGTK/Linux
WebKitGTK denies getUserMedia by default with no permission prompt. Connect to the permission-request signal and auto-allow, plus enable media-stream and media-capabilities in WebKit settings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -36,4 +36,7 @@ serde_json = "1"
|
|||||||
tokio = { version = "1", features = ["rt", "sync"] }
|
tokio = { version = "1", features = ["rt", "sync"] }
|
||||||
arboard = "3.6.1"
|
arboard = "3.6.1"
|
||||||
tauri-plugin-mcp = "0.7.1"
|
tauri-plugin-mcp = "0.7.1"
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
|
webkit2gtk = "2.0"
|
||||||
sqlx = { version = "0.8", features = ["sqlite", "runtime-tokio"] }
|
sqlx = { version = "0.8", features = ["sqlite", "runtime-tokio"] }
|
||||||
|
|||||||
@@ -94,6 +94,34 @@ pub fn run() {
|
|||||||
let _ = main_window.eval(&init_script);
|
let _ = main_window.eval(&init_script);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto-grant microphone permission on Linux (WebKitGTK).
|
||||||
|
// WebKitGTK doesn't show a permission dialog — it just denies
|
||||||
|
// getUserMedia by default. We connect to the permission-request
|
||||||
|
// signal and grant audio capture requests automatically.
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
main_window.with_webview(|webview| {
|
||||||
|
use webkit2gtk::{
|
||||||
|
PermissionRequest, PermissionRequestExt,
|
||||||
|
SettingsExt, WebViewExt,
|
||||||
|
};
|
||||||
|
|
||||||
|
let wv: webkit2gtk::WebView = webview.inner().clone();
|
||||||
|
|
||||||
|
// Enable media stream in WebKit settings
|
||||||
|
if let Some(settings) = WebViewExt::settings(&wv) {
|
||||||
|
settings.set_enable_media_stream(true);
|
||||||
|
settings.set_enable_media_capabilities(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Auto-grant all permission requests (audio/video capture)
|
||||||
|
WebViewExt::connect_permission_request(&wv, |_wv, request: &PermissionRequest| {
|
||||||
|
request.allow();
|
||||||
|
true
|
||||||
|
});
|
||||||
|
}).expect("Failed to configure webview media permissions");
|
||||||
|
}
|
||||||
|
|
||||||
// Close-to-tray: hide window instead of exiting
|
// Close-to-tray: hide window instead of exiting
|
||||||
let win = main_window.clone();
|
let win = main_window.clone();
|
||||||
main_window.on_window_event(move |event| {
|
main_window.on_window_event(move |event| {
|
||||||
|
|||||||
Reference in New Issue
Block a user