Skip to content

Fix window management and dock state leaking across virtual desktops - #318

Merged
AllTerrainDeveloper merged 4 commits into
WordPress:trunkfrom
KarunyaChavan:fix/dock-peek-active-space-filter
Jul 8, 2026
Merged

Fix window management and dock state leaking across virtual desktops#318
AllTerrainDeveloper merged 4 commits into
WordPress:trunkfrom
KarunyaChavan:fix/dock-peek-active-space-filter

Conversation

@KarunyaChavan

@KarunyaChavan KarunyaChavan commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Closes #316

This PR fixes cross-desktop state leakage where window management operations, dock hover previews, and app badges were incorrectly applying to windows located on non-active virtual desktops (Spaces).

What has Changed?

  • Core Window Manager: Added winDesktop === activeDesktopId guard checks to core methods (isActive, minimizeAll, restoreFrom, toggleShowDesktop).
  • Active-Desktop APIs: Introduced getAllByBaseIdOnActiveDesktop() and isActiveByBaseId() helper methods to WindowManager.
  • Dock Hover Peek: Updated the dock's getInstances data source to use the new getAllByBaseIdOnActiveDesktop() method.
  • Recycle Bin Badge: Changed the badge logic to watch for window lifecycle events across all Recycle Bin instances (using a base ID prefix check), and updated isBinWindowActive to use the new isActiveByBaseId() method.
  • Tests: Updated vitest mocks in dock-badge.test.ts and dock-peek-instance-fanout.test.ts to support the new WindowManager methods.

Why?

Previously, the framework assumed that multi-instance window collections returned by getAllByBaseId() and direct getById() checks were valid across all virtual desktops.
This assumption breaks down in a multi-desktop environment.

Examples of the resulting issues:

  1. Dock Hover Peek: Hovering over a dock icon on Desktop 1 displayed preview cards for windows opened on Desktop 2, resulting in ghost preview cards that could not be interacted with.
  2. Recycle Bin Badge: The Recycle Bin badge would disappear on Desktop 1 after hovering over a preview card, even though the active Recycle Bin window was actually on Desktop 2.
  3. Window Management: Global operations such as Show Desktop attempted to minimize or restore windows belonging to other virtual desktops.

How it fixes

The fix scopes window state queries and window management operations to the currently active virtual desktop.

  1. Dock Hover Peek: The dock now retrieves only window instances that belong to the active desktop. As a result, preview cards are shown only for windows on the current desktop, eliminating cross-desktop ghost previews.
  2. Recycle Bin Badge: Badge suppression now checks whether a Recycle Bin window is active on the current desktop using isActiveByBaseId(). This prevents the badge from being hidden due to windows on other desktops.
  3. Window Management: Operations such as toggleShowDesktop, minimizeAll, and related window state changes now affect only windows on the active desktop, preserving the state of windows on other virtual desktops.
Open WordPress Playground Preview

- Add `getAllByBaseIdOnActiveDesktop` and `isActiveByBaseId` to WindowManager.
- Filter `minimizeAll`, `restoreFrom`, and `toggleShowDesktop` to the active desktop.
- Update Dock hover peek to only show instances from the current desktop.
- Update Vitest mocks to satisfy the new active-desktop methods.
- Check for any active bin window by base ID instead of exact target ID.
- Attach lifecycle listeners to all bin instances, not just the first one.
- Prevent the dock badge from hiding when looking at a bin on another desktop.
@KarunyaChavan
KarunyaChavan marked this pull request as ready for review July 6, 2026 13:54
@AllTerrainDeveloper

Copy link
Copy Markdown
Collaborator

Again, thank you for your contributions @KarunyaChavan! We will test and release those changes too!

@AllTerrainDeveloper

Copy link
Copy Markdown
Collaborator

I have updated the docs and added new tests :)

@AllTerrainDeveloper
AllTerrainDeveloper merged commit 35bf29d into WordPress:trunk Jul 8, 2026
5 checks passed
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.

Virtual Desktops: Dock Hover Peek Shows Windows from Other Spaces

2 participants