Skip to content

Keep the focused workspace visible after monitor changes - #2358

Open
JuanRdBO wants to merge 2 commits into
nikitabobko:mainfrom
JuanRdBO:fix/focused-workspace-display-reconcile
Open

JuanRdBO wants to merge 2 commits into
nikitabobko:mainfrom
JuanRdBO:fix/focused-workspace-display-reconcile

Conversation

@JuanRdBO

@JuanRdBO JuanRdBO commented Oct 28, 2026 •

Copy link
Copy Markdown

Keep the focused workspace visible when display remapping would otherwise hide it. The existing nearest-screen and force-assignment rules still determine its destination.

Six regression cases cover display changes and focus initialization. Two fail with the fix removed. ./test.sh passes with the pinned Swift 6.4.0 toolchain.

PR checklist

  • Explain your changes in the relevant commit messages rather than in the PR description. The PR description must not contain more information than the commit messages (except for images and other media).
  • Each commit must explain what/why/how and motivation in its description. https://cbea.ms/git-commit/
  • Don't forget to link the appropriate issues/discussions in commit messages (if applicable).
  • Each commit must be an atomic change (a PR may contain several commits). Don't introduce new functional changes together with refactorings in the same commit.
  • ./test.sh exits with zero exit code.
  • Avoid merge commits, always rebase and force push.

Reading focus for the first time resolves the main monitor's active
workspace. Reconciliation therefore cannot use that getter to inspect
existing focus: it may itself be running while activeWorkspace is being
initialized.

Keep the same first-read initialization in optional backing storage and
expose a read that returns nil before initialization. Add a test-only
monitor override and focus reset so display transitions and cold focus
initialization can be exercised without NSScreen. Clear monitor mappings
in workspace test setup to keep those fixtures isolated.
@github-actions github-actions Bot added the not-actionable By default, all PRs have this label. If the PR makes sense, the label will be removed. label Oct 28, 2026
When a display disconnects, nearest-screen remapping can hide the focused
workspace. This occurs when two old screens map to the same surviving
screen, or a numeric monitor assignment resolves to a different screen
after the display count changes.

Capture the initialized focused workspace and its resolved destination
before rebuilding the visible-workspace maps. After the existing remap,
restore it only if it is hidden and that destination is still present.
Other workspace mappings and force-assignment resolution stay unchanged.
Do not initialize focus during reconciliation or restore visibility when
there are no monitors.

Add six tests covering a forced-assignment disconnect, a collision, focus
that remains visible, cold initialization, moved monitor origins, and an
empty monitor list. Reverting only this fix makes the disconnect and
collision tests fail; the other four are regression guards.

Validation: ./test.sh passed with the pinned Swift 6.4.0 toolchain. This
includes the warnings-as-errors build, XCTest suite, CLI smoke checks,
formatting, SwiftLint, Periphery, generation and clean-tree checks.
@JuanRdBO
JuanRdBO force-pushed the fix/focused-workspace-display-reconcile branch from c6b9c63 to 7ed6f6b Compare October 28, 2026 03:05

This branch has not been deployed

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

Labels

not-actionable By default, all PRs have this label. If the PR makes sense, the label will be removed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant