A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.
TypeScript
fix(desktop): end each call's capture exclusion with the call
Marcelito57e6f65a7209
diff --git a/apps/desktop/src-tauri/src/computer/app.rs b/apps/desktop/src-tauri/src/computer/app.rsindex 860931f..0743aaa 100644--- a/apps/desktop/src-tauri/src/computer/app.rs+++ b/apps/desktop/src-tauri/src/computer/app.rs@@ -142,12 +142,6 @@ pub fn show_without_focus(window: &tauri::WebviewWindow) -> Result<(), String> {Ok(())}-// Both sides bypass tao so its visibility flag continues to represent the user's choice.-#[cfg(windows)]-pub fn hide_for_call(window: &tauri::WebviewWindow) -> Result<(), String> {- super::win::hide_for_call(window.hwnd().map_err(|e| e.to_string())?.0)-}-/// A window of Gentle Dot is shown or hidden through tao (the panel, the Dot) while the returned/// change lives: a computer-control capture overlapping it is not returned.#[cfg(windows)]diff --git a/apps/desktop/src-tauri/src/computer/mod.rs b/apps/desktop/src-tauri/src/computer/mod.rsindex 48b2d01..4f5267e 100644--- a/apps/desktop/src-tauri/src/computer/mod.rs+++ b/apps/desktop/src-tauri/src/computer/mod.rs@@ -54,11 +54,60 @@ mod capture_order {restore();}+ /// Match only the process-lifetime handles recorded at window creation. No resolver or+ /// main-thread dispatch is permitted here: callers may hold the affinity lock on a worker.+ pub(super) fn current_window(saved: &[(Option<u64>, (super::working::Part, u32))], hwnd: usize,+ handles: [Option<usize>; 2]) -> Option<usize> {+ saved.iter().position(|(_, (window, _))| handles[*window as usize] == Some(hwnd))+ }++ /// End call ownership, retaining an ownerless recovery value if native restoration fails.+ /// Callers keep at most one entry per window and adopt it on a later hide.+ pub(super) fn release<T: Copy>(saved: &mut Vec<(Option<u64>, T)>, operation: u64, mut restore: impl FnMut(T) -> bool) {+ saved.retain_mut(|(owner, entry)| {+ if *owner != Some(operation) { return true; }+ *owner = None;+ !restore(*entry)+ });+ }+#[cfg(test)]mod tests {use super::*;use std::cell::RefCell;+ #[test]+ fn matching_under_the_affinity_lock_never_dispatches_a_window_query() {+ let saved = std::sync::Mutex::new(vec![(Some(1), (super::super::working::Part::Dot, 7))]);+ let guard = saved.lock().unwrap();+ // The API accepts only recorded values, so querying Tauri is not an option.+ assert_eq!(current_window(&guard, 101, [Some(101), Some(102)]), Some(0));+ assert_eq!(current_window(&guard, 201, [Some(101), Some(102)]), None);+ assert_eq!(current_window(&guard, 101, [None, None]), None);+ }++ #[test]+ fn release_restores_original_values_and_leaves_no_stale_entry_for_the_next_call() {+ let mut saved = vec![(Some(10), (1, 7)), (Some(10), (2, 0)), (Some(11), (3, 9))];+ let mut restored = Vec::new();+ release(&mut saved, 10, |entry| { restored.push(entry); true });+ assert_eq!(restored, [(1, 7), (2, 0)]);+ assert_eq!(saved, [(Some(11), (3, 9))]);+ release(&mut saved, 11, |_| true);+ assert!(saved.is_empty());+ // The next hide can save a different current affinity for the same window.+ saved.push((Some(12), (1, 9)));+ release(&mut saved, 12, |entry| { restored.push(entry); true });+ assert_eq!(restored.last(), Some(&(1, 9)));+ assert!(saved.is_empty());+ // Native failure ends call ownership but must not discard the true original.+ saved.push((Some(12), (1, 9)));+ release(&mut saved, 12, |_| false);+ assert_eq!(saved, [(None, (1, 9))]);+ release(&mut saved, 12, |_| panic!("an old call cannot touch recovery state"));+ assert_eq!(saved, [(None, (1, 9))]);+ }+#[test]fn capture_waits_even_without_new_exclusions() {let events = RefCell::new(Vec::new());diff --git a/apps/desktop/src-tauri/src/computer/win.rs b/apps/desktop/src-tauri/src/computer/win.rsindex 842fea0..109da18 100644--- a/apps/desktop/src-tauri/src/computer/win.rs+++ b/apps/desktop/src-tauri/src/computer/win.rs@@ -521,6 +521,7 @@ fn is_excluded(hwnd: HWND) -> bool {/// Wait even when no visible windows needed exclusion: a just-hidden panel may still be composed.fn wait_for_composition() -> Result<(), String> {+ // No timeout: if DwmFlush stalls, it holds the tool call open with no ceiling.// SAFETY: a plain call; it waits for the next composition.let result = unsafe { DwmFlush() };if result < 0 {@@ -617,9 +618,9 @@ fn restore_affinity(changed: &[(HWND, u32)]) {let mut saved = CALL_AFFINITIES.lock().unwrap_or_else(|error| error.into_inner());for &(hwnd, previous) in changed {// A hide may have taken ownership since enumeration. Hand it the original affinity- // instead of undoing its exclusion; it will restore only after showing the window.- if let Some((_, original)) = saved.iter_mut().find(|(window, _)| *window == hwnd as usize) {- *original = previous;+ // instead of undoing its exclusion; it restores after showing, or at call end if left hidden.+ if let Some(index) = super::capture_order::current_window(&saved, hwnd as usize, call_handles()) {+ saved[index].1.1 = previous;continue;}let _change = WindowChange::begin();@@ -1542,19 +1543,42 @@ pub fn show_overlay(hwnd: *mut c_void, visible: bool) {}// Main-thread show/hide callers serialize these entries. Keep the original value, including-// WDA_MONITOR, rather than assuming every window started at WDA_NONE. A user-hidden Dot retains-// its entry only until it is next shown; no visible window stays excluded for the session.-static CALL_AFFINITIES: std::sync::Mutex<Vec<(usize, u32)>> = std::sync::Mutex::new(Vec::new());+// WDA_MONITOR, rather than assuming every window started at WDA_NONE. Showing releases an entry;+// the owning call's restore phase releases its remainder, including a user-hidden Dot.+// A newer hide takes ownership without losing the original affinity; delayed older restores+// cannot release it. Failed dispatch restores affinity directly without showing the window.+// If native restoration fails, owner None retains the original for the next show (after showing)+// or hide (adopt, never read the still-excluded value). Logical keys bound this to one record+// per Dot/panel for the process lifetime, never per recyclable HWND or failed call.+static CALL_AFFINITIES: std::sync::Mutex<Vec<(Option<u64>, (super::working::Part, u32))>> = std::sync::Mutex::new(Vec::new());+// The Dot and panel are created once and live until process exit. Record their handles on+// the main thread at creation; worker cleanup must never query Tauri while holding our lock.+static CALL_WINDOWS: [std::sync::OnceLock<usize>; 2] = [std::sync::OnceLock::new(), std::sync::OnceLock::new()];++pub fn record_call_window(part: super::working::Part, hwnd: HWND) {+ CALL_WINDOWS[part as usize].set(hwnd as usize).expect("call window is created only once");+}++fn call_window(part: super::working::Part) -> Option<usize> {+ CALL_WINDOWS[part as usize].get().copied()+}++fn call_handles() -> [Option<usize>; 2] {+ [call_window(super::working::Part::Dot), call_window(super::working::Part::Panel)]+}/// Exclude before hiding. If exclusion fails, still hide, then put this window back and fail/// preparation: Working has not yet recorded it as hidden and cannot restore it on that error./// The failed call therefore never reaches capture, and no persistent failure poisons later calls.-pub fn hide_for_call(hwnd: *mut c_void) -> Result<(), String> {+pub fn hide_for_call(part: super::working::Part, operation: u64) -> Result<(), String> {+ let hwnd = call_window(part).ok_or_else(|| format!("window {part:?} is missing"))? as HWND;let _change = WindowChange::begin();let mut saved = CALL_AFFINITIES.lock().unwrap_or_else(|error| error.into_inner());let result = super::capture_order::hide(|| {- if saved.iter().any(|&(window, _)| window == hwnd as usize) {- return set_capture_excluded(hwnd, true);+ if let Some((owner, _)) = saved.iter_mut().find(|(_, (window, _))| *window == part) {+ set_capture_excluded(hwnd, true)?;+ *owner = Some(operation);+ return Ok(());}let mut previous = 0;// SAFETY: a query on our window with a valid out-pointer.@@ -1562,7 +1586,7 @@ pub fn hide_for_call(hwnd: *mut c_void) -> Result<(), String> {return Err(format!("cannot read its capture affinity: {}", std::io::Error::last_os_error()));}set_capture_excluded(hwnd, true)?;- saved.push((hwnd as usize, previous));+ saved.push((Some(operation), (part, previous)));Ok(())}, || {// SAFETY: a call on this process's window.@@ -1578,8 +1602,8 @@ pub fn hide_for_call(hwnd: *mut c_void) -> Result<(), String> {fn restore_call_affinity(hwnd: HWND) {let mut saved = CALL_AFFINITIES.lock().unwrap_or_else(|error| error.into_inner());- let Some(index) = saved.iter().position(|&(window, _)| window == hwnd as usize) else { return };- let previous = saved[index].1;+ let Some(index) = super::capture_order::current_window(&saved, hwnd as usize, call_handles()) else { return };+ let previous = saved[index].1.1;// This function is called only inside the showing WindowChange, after ShowWindow. Restoring// even a nonzero affinity must count as a change, so an overlapping capture cannot be accepted.// SAFETY: a call on this process's window, restoring the value read before the call.@@ -1590,6 +1614,30 @@ fn restore_call_affinity(hwnd: HWND) {}}+/// End the serialized call's affinity ownership after its eligible windows have been shown.+/// Remaining windows were left hidden by the user (or their show/affinity restore failed).+/// Read the recorded handles only; native failures retain ownerless recovery values.+pub fn finish_call_affinities(operation: u64) {+ let _change = WindowChange::begin();+ let mut saved = CALL_AFFINITIES.lock().unwrap_or_else(|error| error.into_inner());+ super::capture_order::release(&mut saved, operation, |(part, previous)| {+ let Some(hwnd) = call_window(part) else { return true };+ // SAFETY: the current handle of our logical window. This API requires process+ // ownership, not the window's thread, so dispatch failure can restore it directly.+ let restored = unsafe { SetWindowDisplayAffinity(hwnd as HWND, previous) } != 0;+ if !restored {+ eprintln!("gentle-dot: a window may stay out of screenshots: {}", std::io::Error::last_os_error());+ }+ restored+ });+}++/// Main-thread dispatch failed: leave windows hidden but restore their original affinity+/// inside WindowChange. The owner filter protects a newer hide; failures keep recovery values.+pub fn abandon_call_affinities(operation: u64) {+ finish_call_affinities(operation);+}+pub fn show_without_activating(hwnd: *mut c_void) {let _change = WindowChange::begin();super::capture_order::show(|| {diff --git a/apps/desktop/src-tauri/src/computer/working.rs b/apps/desktop/src-tauri/src/computer/working.rsindex f19dc8b..f11c467 100644--- a/apps/desktop/src-tauri/src/computer/working.rs+++ b/apps/desktop/src-tauri/src/computer/working.rs@@ -70,8 +70,17 @@ pub fn to_restore(hidden: Visibility, now: Visibility, rose_hidden: bool) -> Vispub trait Windows: Send + Sync {fn is_visible(&self, part: Part) -> bool;fn hide(&self, part: Part) -> Result<(), String>;+ fn hide_for_operation(&self, part: Part, _operation: u64) -> Result<(), String> {+ self.hide(part)+ }/// Orders the window in without focusing it or activating the app.fn show(&self, part: Part);+ /// Release call-owned state after all eligible windows have been shown, including state+ /// for windows the user chose to keep hidden. Main thread only.+ fn finish_restore(&self, _operation: u64) {}+ /// Dispatch failed: restore this call's capture affinities without showing its windows.+ /// May run off the main thread; failed native restores retain ownerless recovery values.+ fn abandon_restore(&self, _operation: u64) {}/// The user's "Hide the rose" choice, as it is now.fn rose_hidden(&self) -> bool;}@@ -116,8 +125,8 @@ impl Preparation for NoPreparation {struct State {last: u64,current: Option<Op>,- /// What operations hid that has not been shown again yet.- hidden: Visibility,+ /// Each part belongs to its latest successful hide, never to a delayed older restore.+ hidden: Vec<(Part, u64)>,}struct Op {@@ -227,14 +236,17 @@ impl Inner {}let mut outcome = Ok(());for part in PARTS {- if !self.windows.is_visible(part) {+ // A previous restore may still be queued. Inherit its hidden windows too,+ // so it cannot show them during this call even without a user reopen.+ if !self.windows.is_visible(part) && !state.hidden.iter().any(|&(saved, _)| saved == part) {continue;}- if let Err(error) = self.windows.hide(part) {+ if let Err(error) = self.windows.hide_for_operation(part, operation) {outcome = Err(error);break;}- state.hidden.set(part, true);+ state.hidden.retain(|(saved, _)| *saved != part);+ state.hidden.push((part, operation));}if let Some(op) = state.current.as_mut() {op.hid = Some(outcome);@@ -243,13 +255,20 @@ impl Inner {}/// On the main thread: shows again what operations hid, as the user left things meanwhile.- fn restore(&self) {- let hidden = std::mem::take(&mut self.lock().hidden);+ fn restore(&self, operation: u64) {+ let mut state = self.lock();+ let mut hidden = Visibility::default();+ state.hidden.retain(|&(part, owner)| {+ if owner != operation { return true; }+ hidden.set(part, true);+ false+ });let now = Visibility { dot: self.windows.is_visible(Part::Dot), panel: self.windows.is_visible(Part::Panel) };let show = to_restore(hidden, now, self.windows.rose_hidden());for part in PARTS.into_iter().filter(|part| show.get(*part)) {self.windows.show(part);}+ self.windows.finish_restore(operation);}}@@ -305,7 +324,12 @@ impl Preparation for Working {self.0.changed.notify_all();self.0.rings.end(operation);let inner = self.0.clone();- if let Err(error) = self.0.main.run(Box::new(move || inner.restore())) {+ if let Err(error) = self.0.main.run(Box::new(move || inner.restore(operation))) {+ // Showing must stay on the main thread, but affinity restoration need not.+ // End only this call's ownership; preserve recovery values on native failure.+ let mut state = self.0.lock();+ state.hidden.retain(|&(_, owner)| owner != operation);+ self.0.windows.abandon_restore(operation);eprintln!("gentle-dot: cannot show the Dot and the panel again: {error}");}}@@ -343,6 +367,12 @@ mod tests {visible: Mutex<Visibility>,rose_hidden: AtomicBool,fails: Mutex<Option<Part>>,+ call_affinities: Mutex<Vec<(Option<u64>, (Part, u32))>>,+ affinities: Mutex<[u32; 2]>,+ handles: Mutex<[Option<usize>; 2]>,+ unrelated_affinity: Mutex<u32>,+ restore_fails: AtomicBool,+ restored: Mutex<Vec<(Part, u32, bool)>>,}fn name(part: Part) -> &'static str {@@ -352,6 +382,26 @@ mod tests {}}+ impl FakeWindows {+ fn restore_affinity(&self, part: Part, previous: u32) -> bool {+ if self.restore_fails.load(Ordering::SeqCst) { return false; }+ self.affinities.lock().unwrap()[part as usize] = previous;+ self.restored.lock().unwrap().push((part, previous, self.is_visible(part)));+ true+ }+ }++ impl FakeWindows {+ fn restore_unrelated_capture(&self, hwnd: usize, previous: u32) {+ let mut saved = self.call_affinities.lock().unwrap();+ if let Some(index) = super::super::capture_order::current_window(&saved, hwnd, *self.handles.lock().unwrap()) {+ saved[index].1.1 = previous;+ return;+ }+ *self.unrelated_affinity.lock().unwrap() = previous;+ }+ }+impl Windows for FakeWindows {fn is_visible(&self, part: Part) -> bool {self.visible.lock().unwrap().get(part)@@ -366,9 +416,34 @@ mod tests {Ok(())}+ fn hide_for_operation(&self, part: Part, operation: u64) -> Result<(), String> {+ self.hide(part)?;+ let mut saved = self.call_affinities.lock().unwrap();+ let previous = saved.iter().find(|(_, (window, _))| *window == part)+ .map(|(_, (_, previous))| *previous)+ .unwrap_or(self.affinities.lock().unwrap()[part as usize]);+ self.affinities.lock().unwrap()[part as usize] = 0x11;+ saved.retain(|&(_, (window, _))| window != part);+ saved.push((Some(operation), (part, previous)));+ Ok(())+ }+fn show(&self, part: Part) {self.visible.lock().unwrap().set(part, true);self.log.lock().unwrap().push(format!("show {}", name(part)));+ self.call_affinities.lock().unwrap().retain(|&(_, (window, previous))| {+ window != part || !self.restore_affinity(window, previous)+ });+ }++ fn finish_restore(&self, operation: u64) {+ let mut saved = self.call_affinities.lock().unwrap();+ super::super::capture_order::release(&mut saved, operation,+ |(part, previous)| self.restore_affinity(part, previous));+ }++ fn abandon_restore(&self, operation: u64) {+ self.finish_restore(operation);}fn rose_hidden(&self) -> bool {@@ -404,12 +479,16 @@ mod tests {/// once, after the first task is queued).struct FakeMain {deferred: AtomicBool,+ fails: AtomicBool,queue: Mutex<Vec<Task>>,after_queue: Mutex<Option<Box<dyn Fn() + Send + Sync>>>,}impl MainThread for FakeMain {fn run(&self, task: Task) -> Result<(), String> {+ if self.fails.load(Ordering::SeqCst) {+ return Err("dispatch failed".into());+ }if !self.deferred.load(Ordering::SeqCst) {task();return Ok(());@@ -447,10 +526,16 @@ mod tests {visible: Mutex::new(visible),rose_hidden: AtomicBool::new(!visible.dot),fails: Mutex::new(None),+ call_affinities: Mutex::new(Vec::new()),+ affinities: Mutex::new([1, 0]),+ handles: Mutex::new([Some(101), Some(102)]),+ unrelated_affinity: Mutex::new(0x11),+ restore_fails: AtomicBool::new(false),+ restored: Mutex::new(Vec::new()),});let rings = Arc::new(FakeRings { log: log.clone(), fails: AtomicBool::new(false), on_show: Mutex::new(None) });let main =- Arc::new(FakeMain { deferred: AtomicBool::new(false), queue: Mutex::new(Vec::new()), after_queue: Mutex::new(None) });+ Arc::new(FakeMain { deferred: AtomicBool::new(false), fails: AtomicBool::new(false), queue: Mutex::new(Vec::new()), after_queue: Mutex::new(None) });let working = Arc::new(Working::new(windows.clone(), rings.clone(), main.clone(), timeout));let rig = Rig { working, windows, rings, main, log };rig.on_show(|working, operation| {@@ -510,6 +595,99 @@ mod tests {assert_eq!(rig.log(), ["rings on 1", "rings off 1"]);}+ #[test]+ fn delayed_restore_cannot_touch_a_later_calls_windows_or_affinities() {+ for reopen in [false, true] {+ let rig = rig();+ let a = rig.working.begin().unwrap();+ rig.main.deferred.store(true, Ordering::SeqCst);+ rig.working.finish(a);+ rig.main.deferred.store(false, Ordering::SeqCst);+ // B owns either inherited hides or windows the user reopened meanwhile.+ if reopen { *rig.windows.visible.lock().unwrap() = BOTH; }+ let b = rig.working.begin().unwrap();+ rig.main.drain();+ assert_eq!(rig.visible(), Visibility::default(), "A must not show B's windows");+ assert_eq!(*rig.windows.call_affinities.lock().unwrap(), [(Some(b), (Part::Dot, 1)), (Some(b), (Part::Panel, 0))],+ "A must not release B's affinities");+ rig.working.finish(b);+ assert_eq!(rig.visible(), BOTH);+ assert!(rig.windows.call_affinities.lock().unwrap().is_empty());+ }+ }++ #[test]+ fn unrecorded_handle_does_not_intercept_an_unrelated_windows_capture_restore() {+ let rig = rig();+ let operation = rig.working.begin().unwrap();+ rig.main.fails.store(true, Ordering::SeqCst);+ rig.windows.restore_fails.store(true, Ordering::SeqCst);+ rig.working.finish(operation);+ // Dot/panel handles live for the process. An unrelated (possibly recycled) handle+ // outside that recorded pair must be restored natively, not handed to their records.+ rig.windows.restore_unrelated_capture(201, 7);+ assert_eq!(*rig.windows.unrelated_affinity.lock().unwrap(), 7);+ }++ #[test]+ fn failed_dispatch_restores_native_affinity_values_while_hidden() {+ let rig = rig();+ let operation = rig.working.begin().unwrap();+ assert_eq!(*rig.windows.affinities.lock().unwrap(), [0x11, 0x11]);+ rig.main.fails.store(true, Ordering::SeqCst);+ rig.working.finish(operation);+ assert_eq!(*rig.windows.affinities.lock().unwrap(), [1, 0]);+ assert_eq!(*rig.windows.restored.lock().unwrap(), [(Part::Dot, 1, false), (Part::Panel, 0, false)]);+ }++ #[test]+ fn failed_native_restore_keeps_the_original_for_next_show_or_hide() {+ for show_first in [true, false] {+ let rig = rig();+ let operation = rig.working.begin().unwrap();+ rig.main.fails.store(true, Ordering::SeqCst);+ rig.windows.restore_fails.store(true, Ordering::SeqCst);+ rig.working.finish(operation);+ assert_eq!(*rig.windows.affinities.lock().unwrap(), [0x11, 0x11]);+ assert_eq!(*rig.windows.call_affinities.lock().unwrap(), [(None, (Part::Dot, 1)), (None, (Part::Panel, 0))]);+ rig.windows.restore_fails.store(false, Ordering::SeqCst);+ if show_first {+ rig.windows.show(Part::Dot);+ rig.windows.show(Part::Panel);+ assert_eq!(*rig.windows.affinities.lock().unwrap(), [1, 0]);+ assert_eq!(*rig.windows.restored.lock().unwrap(), [(Part::Dot, 1, true), (Part::Panel, 0, true)]);+ }+ // Also exercise a new hide before any successful show: adopt the saved original.+ rig.windows.hide_for_operation(Part::Dot, operation + 1).unwrap();+ rig.windows.hide_for_operation(Part::Panel, operation + 1).unwrap();+ rig.windows.finish_restore(operation + 1);+ assert_eq!(*rig.windows.affinities.lock().unwrap(), [1, 0]);+ assert!(rig.windows.call_affinities.lock().unwrap().is_empty());+ }+ }++ #[test]+ fn failed_restore_dispatch_releases_call_affinities_without_showing() {+ let rig = rig();+ let operation = rig.working.begin().unwrap();+ rig.main.fails.store(true, Ordering::SeqCst);+ rig.working.finish(operation);+ assert_eq!(rig.visible(), Visibility::default());+ assert!(rig.windows.call_affinities.lock().unwrap().is_empty(), "failed dispatch must release ownership");+ }++ #[test]+ fn restore_releases_call_affinities_even_when_the_user_hid_the_rose() {+ let rig = rig();+ let operation = rig.working.begin().unwrap();+ assert_eq!(*rig.windows.call_affinities.lock().unwrap(), [(Some(operation), (Part::Dot, 1)), (Some(operation), (Part::Panel, 0))]);+ rig.windows.rose_hidden.store(true, Ordering::SeqCst);+ rig.working.finish(operation);+ assert_eq!(rig.visible(), Visibility { dot: false, panel: true });+ assert!(rig.windows.call_affinities.lock().unwrap().is_empty(),+ "the hidden Dot's affinity must be restored and released when its call ends");+ }+#[test]fn restoring_keeps_what_the_user_changed_meanwhile() {let hidden = BOTH;@@ -527,6 +705,7 @@ mod tests {rig.working.finish(operation);assert_eq!(rig.log(), ["rings on 1", "hide dot", "hide panel", "rings off 1"]);assert_eq!(rig.visible(), Visibility { dot: false, panel: true });+ assert!(rig.windows.call_affinities.lock().unwrap().is_empty());}#[test]diff --git a/apps/desktop/src-tauri/src/shell.rs b/apps/desktop/src-tauri/src/shell.rsindex 5e8af2b..4f8e2f8 100644--- a/apps/desktop/src-tauri/src/shell.rs+++ b/apps/desktop/src-tauri/src/shell.rs@@ -92,12 +92,15 @@ impl working::Windows for ShellWindows {fn hide(&self, part: Part) -> Result<(), String> {let window = self.get(part).ok_or_else(|| format!("window {part:?} is missing"))?;- #[cfg(windows)]- return computer::hide_for_call(&window);- #[cfg(not(windows))]window.hide().map_err(err)}+ #[cfg(windows)]+ fn hide_for_operation(&self, part: Part, operation: u64) -> Result<(), String> {+ // Bypass tao so its visibility flag continues to represent the user's choice.+ crate::computer::win::hide_for_call(part, operation)+ }+fn show(&self, part: Part) {let Some(window) = self.get(part) else { return };#[cfg(any(target_os = "macos", windows))]@@ -109,6 +112,16 @@ impl working::Windows for ShellWindows {}}+ #[cfg(windows)]+ fn finish_restore(&self, operation: u64) {+ crate::computer::win::finish_call_affinities(operation);+ }++ #[cfg(windows)]+ fn abandon_restore(&self, operation: u64) {+ crate::computer::win::abandon_call_affinities(operation);+ }+fn rose_hidden(&self) -> bool {self.0.try_state::<Shell>().is_some_and(|shell| shell.rose_hidden.load(Ordering::SeqCst))}@@ -584,6 +597,8 @@ fn build_windows(#[cfg(windows)]let dot = dot.minimizable(false);let dot = dot.build()?;+ #[cfg(windows)]+ crate::computer::win::record_call_window(Part::Dot, dot.hwnd()?.0);// Linux has no window effects; the panel URL tells the UI to paint an opaque background.let panel = WebviewWindowBuilder::new(app, PANEL, WebviewUrl::App(platform::panel_url(Os::CURRENT).into())).title(PANEL_TITLE)@@ -601,6 +616,12 @@ fn build_windows(#[cfg(target_os = "macos")]let panel = panel.effects(EffectsBuilder::new().effect(Effect::HudWindow).state(EffectState::Active).radius(20.0).build());+ #[cfg(windows)]+ {+ let panel = panel.build()?;+ crate::computer::win::record_call_window(Part::Panel, panel.hwnd()?.0);+ }+ #[cfg(not(windows))]panel.build()?;if !places_windows {