From 5b5647ea346e5759eda056b0ebdad8475ecdc679 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 31 Oct 2026 15:11:29 -0700 Subject: [PATCH] fix(mac): forget the windows that the application reaper removes BEHAVIOUR (registry only). Review finding 4, the part that can be done where a window id is known. Window::observe now registers the windows that are really observed (previous revision), and a window that closes while its application runs left its entry until the application quit. WindowManagerEvent::Destroy carries no window id, but reap_invalid_windows_for_application is where the daemon works out which of the application's windows are gone, and it already removes them from the workspace: it now also forgets them in the registry (tiled and floating alike); the reaper's reap_window did already. What stays: an observed window that closes without passing through either (for example one that was unmanaged and then closed, or whose Destroy was not followed by a reap) keeps its entry (an element, an observer and an inert application) until its application quits; the table is bounded by the number of windows the daemon has observed per running application, and a periodic sweep would cost one Accessibility call per entry under the window manager lock. Hand check H4 measures the Mach ports held (the one unverified cost: whether an AXObserver holds a port). Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified: any run. Verified on the Mini: not yet. --- komorebi-for-mac/komorebi/src/workspace.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/komorebi-for-mac/komorebi/src/workspace.rs b/komorebi-for-mac/komorebi/src/workspace.rs index 4845a177..6dfee80e 100644 --- a/komorebi-for-mac/komorebi/src/workspace.rs +++ b/komorebi-for-mac/komorebi/src/workspace.rs @@ -432,10 +432,12 @@ impl WorkspaceExt for Workspace { for window_id in &invalid_window_ids { // Ignore errors - window may have already been removed by the reaper thread let _ = self.remove_window(*window_id); + crate::ax_registry::forget(*window_id); } for window_id in &invalid_floating_window_ids { self.remove_floating_window(*window_id); + crate::ax_registry::forget(*window_id); } tracing::debug!(