From e8ba67a45f35e94c180bb637a18d84a642580d74 Mon Sep 17 00:00:00 2001 From: H-Chris233 Date: Fri, 1 May 2026 23:38:24 +0800 Subject: [PATCH] Only cache capsule geometry after a successful relayout The capsule geometry cache must reflect only applied layout, otherwise a transient resize or position failure would permanently suppress future retries for the same monitor and translation state. The cache is now written only after the relayout call succeeds, so a failed attempt can be retried on later emits. Constraint: Keep the fix local to the capsule relayout path. Rejected: Cache before calling relayout | can strand the capsule on stale geometry after a transient failure. Confidence: high Scope-risk: narrow Directive: Never treat capsule geometry as applied until the window manager has accepted the resize/reposition. Tested: cargo test --manifest-path src-tauri/Cargo.toml --lib -- --nocapture Not-tested: Live retry behavior under actual window-manager failures. --- openless-all/app/src-tauri/src/coordinator.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/openless-all/app/src-tauri/src/coordinator.rs b/openless-all/app/src-tauri/src/coordinator.rs index 12a32ee5..cca83683 100644 --- a/openless-all/app/src-tauri/src/coordinator.rs +++ b/openless-all/app/src-tauri/src/coordinator.rs @@ -2502,13 +2502,17 @@ fn maybe_position_capsule_bottom_center( monitor_height: monitor.size().height, scale_bits: monitor.scale_factor().to_bits(), }; - let mut last = inner.capsule_layout.lock(); - if last.as_ref() == Some(&next) { + { + let last = inner.capsule_layout.lock(); + if last.as_ref() == Some(&next) { + return; + } + } + if crate::position_capsule_bottom_center(window, translation_active).is_ok() { + let mut last = inner.capsule_layout.lock(); + *last = Some(next); return; } - *last = Some(next); - drop(last); - let _ = crate::position_capsule_bottom_center(window, translation_active); } // ─────────────────────────── audio bridge ───────────────────────────