Skip to content

Cycle only running workspaces with Cmd-` (#330) - #331

Merged
scgopi merged 2 commits into
mainfrom
fix/330-cycle-active-only
Sep 9, 2026
Merged

Cycle only running workspaces with Cmd-` (#330)#331
scgopi merged 2 commits into
mainfrom
fix/330-cycle-active-only

Conversation

@scgopi

@scgopi scgopi commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Fixes #330.

What was wrong

cycleRequested in AppFeature+Workspaces.swift walked workspaces.list(), which is every workspace directory on disk, and sent the next one to switchRequested. That action's WorkspaceClient.open raises a live instance if one holds the pid file and launches a new one otherwise. So a workspace someone had just quit was still next in creation order, and ⌘` brought it back.

CycleShortcut's premise (one window per instance, so the system's own ⌘` has nothing to cycle) holds. The walk upstream of it was the bug.

The fix

The walk is narrowed to the current workspace plus workspaceClient.otherOpen(), the same call updateInstallTapped already trusts before swapping the bundle (it checks WorkspaceLock.holder and that the pid is one of ours). The filter runs over known so creation order is kept, and the wrap-around uses the running subset's count. With nothing else running, ⌘` does nothing rather than launching the first dead workspace.

Tests

Three new cases in WorkspaceCycleTests, each red against origin/main's reducer and green with the fix (-only-testing:graphcodeTests/WorkspaceCycleTests, exit 65 → 0):

  • aWorkspaceWithNoWindowIsSteppedOver — on disk and next in order, but not running: skipped, not launched.
  • nothingElseRunningMeansNowhereToGo — every other workspace quit: no switch in either direction.
  • wrappingCountsTheRunningOnesNotTheOnesOnDisk — four on disk, two running: wraps within the running two, both directions.

The five existing cases now state that the others are running, which is what they assumed all along.

Gate (from the worktree, private DerivedData)

Step Result
xcodebuild test (full suite) exit 0, 1702 tests in 181 suites passed, 0 ** TEST FAILED **, 0 Failing tests:
xcodebuild test on origin/main reducer + new tests exit 65, the 3 new tests fail, the 5 old ones pass
swiftlint lint exit 0, 0 errors
swift format lint --strict exit 0

🤖 Generated with Claude Code

https://claude.ai/code/session_012jEwiawXZxVpaKWKBLyzJU

scgopi and others added 2 commits September 8, 2026 13:53
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012jEwiawXZxVpaKWKBLyzJU
cycleRequested walked every workspace on disk and handed the next one to
switchRequested, whose open launches an instance when none holds the pid
file. So the workspace someone had just quit was next in creation order and
Cmd-` brought it back. Filter the walk by the workspaces otherOpen reports,
the same signal the update-install path trusts, and wrap within that subset.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012jEwiawXZxVpaKWKBLyzJU
@scgopi
scgopi merged commit 4f309ff into main Sep 9, 2026
1 check 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.

Cmd+` Should only switch between the active apps and should not boot up the killed one.

1 participant