From f510948280f95e5c77cb40af696414385fa0231e Mon Sep 17 00:00:00 2001 From: user Date: Fri, 28 Aug 2026 06:38:43 +0800 Subject: [PATCH] fix(desktop): scope webview builder mutability The browser_webview_create helper declared its WebviewBuilder as mut unconditionally, but the only mutating call (enabling devtools) is compiled solely under #[cfg(any(debug_assertions, feature = "devtools"))]. In release builds without the devtools feature the mut requirement disappears and the compiler flags the binding as unused_mut. Move the mutation into the cfg block by shadowing: the outer binding is immutable, and the devtools block rebinds a local mut copy, applies the devtools flag, and returns it. Builder construction and the final add_child consumer are unchanged, so behavior is identical on every build configuration while the mutability now exactly matches the consumer surface. Test: cargo check --release -p bitfun-desktop --jobs 4 (browser_api unused_mut gone; lib compiles 0 warnings) Test: cargo check -p bitfun-desktop (dev profile, cfg block active, 0 errors 0 warnings) AI: This commit was authored with AI assistance; checks were run locally on Windows (release + dev profiles) and non-Windows compilation surfaces are to be confirmed by the upstream multi-OS CI matrix. --- src/apps/desktop/src/api/browser_api.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/apps/desktop/src/api/browser_api.rs b/src/apps/desktop/src/api/browser_api.rs index 2bfe51b87b..dc71f08087 100644 --- a/src/apps/desktop/src/api/browser_api.rs +++ b/src/apps/desktop/src/api/browser_api.rs @@ -142,16 +142,18 @@ pub async fn browser_webview_create( let window = app .get_window("main") .ok_or_else(|| "main window not found".to_string())?; - let mut builder = + let builder = tauri::webview::WebviewBuilder::new(request.label, tauri::WebviewUrl::External(url)) .initialization_script(video_decoder_compatibility_script()) .transparent(false) .background_color(tauri::window::Color(0, 0, 0, 255)); #[cfg(any(debug_assertions, feature = "devtools"))] - { + let builder = { + let mut builder = builder; builder = builder.devtools(true); - } + builder + }; let webview = window .add_child(