Skip to content

fix: skip inactive-space windows in discovery fallback path#333

Open
yuukidach wants to merge 2 commits intoacsandmann:mainfrom
yuukidach:fix/space-switch-window-clustering
Open

fix: skip inactive-space windows in discovery fallback path#333
yuukidach wants to merge 2 commits intoacsandmann:mainfrom
yuukidach:fix/space-switch-window-clustering

Conversation

@yuukidach
Copy link
Copy Markdown
Contributor

@yuukidach yuukidach commented Apr 3, 2026

Summary

  • Windows from inactive Spaces were being included in the layout after a Space switch, causing all windows to cluster on one screen and sometimes oscillate
  • Root cause: the AX API returns all windows regardless of Space; the fallback path in emit_layout_events frame-mapped these windows to the active Space on the same display
  • Fix: check visible_windows (authoritatively filtered to active spaces) before including a fallback window, skipping any whose window server ID is not on an active Space

The AX API returns all windows regardless of Space. The fallback path
in emit_layout_events would frame-map these windows to the active Space
on the same display, causing all windows to cluster on one screen after
a Space switch and sometimes oscillate as the layout re-triggered.

Check visible_windows (authoritative, filtered to active spaces) before
including a window from the fallback path.
@acsandmann
Copy link
Copy Markdown
Owner

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ccf05a1d5f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +381 to +383
if let Some(wsid) = state.info.sys_id {
if !reactor.window_manager.visible_windows.contains(&wsid) {
continue;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve fallback when WS snapshot is empty

In emit_layout_events, this new guard drops any fallback window whose sys_id is not present in visible_windows, but the fallback loop is specifically for cases where the WS snapshot can be empty (see the known_visible fallback comment above). When visible_windows is empty after a SpaceChanged/incomplete WS payload, this condition skips nearly all windows, so no windows are assigned to active spaces and layouts can temporarily go blank or stale until another WS refresh arrives. The active-space filter should only run when visible_windows is known-populated/authoritative for that cycle.

Useful? React with 👍 / 👎.

Only filter fallback windows against visible_windows when the set is
non-empty/authoritative. When empty (e.g. after SpaceChanged with an
incomplete WS payload), skip the guard so the fallback path can still
assign windows to active spaces instead of producing a blank layout.
@yuukidach
Copy link
Copy Markdown
Contributor Author

@codex review

code changed

@chatgpt-codex-connector
Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants