From a91be6535440d5d9d6554a8d9759dca490c93c22 Mon Sep 17 00:00:00 2001 From: Michael Chihlas Date: Fri, 8 May 2026 17:55:25 -0400 Subject: [PATCH] docs(plan): add set_window_opacity Rust command Tauri 2 JS WebviewWindow does not expose setOpacity (only the Rust side has set_opacity), so the JS layer routes through a custom command. Surfaced during Task 9 implementation; updates Tasks 16 and 17 to register the command. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../plans/2026-05-08-browserlay-mvp.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/superpowers/plans/2026-05-08-browserlay-mvp.md b/docs/superpowers/plans/2026-05-08-browserlay-mvp.md index c4e5689..2a1ceea 100644 --- a/docs/superpowers/plans/2026-05-08-browserlay-mvp.md +++ b/docs/superpowers/plans/2026-05-08-browserlay-mvp.md @@ -1881,6 +1881,20 @@ pub fn get_hotkey_status(app: AppHandle) -> Result let guard = state.hotkey_status.lock().map_err(|_| "poisoned".to_string())?; Ok(guard.clone()) } + +/// Set window opacity. Tauri 2's JS WebviewWindow does NOT expose setOpacity +/// (only the Rust side does), so the JS layer routes through this command. +#[tauri::command] +pub fn set_window_opacity( + app: AppHandle, + label: String, + opacity: f32, +) -> Result<(), String> { + let Some(window) = app.get_webview_window(&label) else { + return Err(format!("window not found: {label}")); + }; + window.set_opacity(opacity).map_err(|e| e.to_string()) +} ``` > **Note on the design:** Tauri 2 doesn't expose a getter for `ignore_cursor_events` / `opacity` on `WebviewWindow`. Rather than rely on getters, we keep a tiny Rust-side cache (`AppState.click_through`) that the JS side keeps in sync via `sync_click_through_cache`. The global shortcut handler reads this cache, computes the inverse, calls `apply_state`. The JS-driven toggle path uses `toggle_click_through(current)` and skips the cache. @@ -1994,6 +2008,7 @@ pub fn run() { commands::overlay::toggle_click_through, commands::overlay::sync_click_through_cache, commands::overlay::get_hotkey_status, + commands::overlay::set_window_opacity, ]) .run(tauri::generate_context!()) .expect("error while running tauri application");