Skip to content

Fix instant switching window order - #28

Merged
Focus2321 merged 1 commit into
mainfrom
codex/fix-instant-window-cycle
Jul 22, 2026
Merged

Fix instant switching window order#28
Focus2321 merged 1 commit into
mainfrom
codex/fix-instant-window-cycle

Conversation

@Focus2321

@Focus2321 Focus2321 commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • preserve a stable window-ID order while instant switching
  • reconcile opened and closed windows without adopting Accessibility's reordered front-to-back list
  • retain the existing fallback for windows without Core Graphics IDs
  • add a regression test for a focused window moving to the front of the returned list

Root cause

always mode enumerated windows again on every shortcut press. Raising the selected window changed the Accessibility window order, so [A, B, C] became [B, A, C] and the next press selected A again instead of advancing to C.

Validation

  • git diff --check
  • unsigned macOS xcodebuild test -only-testing:ReefTests (13 tests passed)

This also supplies the follow-up fix for upstream PR gouwsxander/Reef#68.

Summary by CodeRabbit

  • Bug Fixes

    • Improved direct window switching to preserve a stable window order when the focused window moves.
    • Maintains consistent cycling behavior as available windows change.
    • Added fallback handling for incomplete or mismatched window information.
  • Tests

    • Added coverage verifying stable direct-switch ordering across window layout changes.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4ee4abbc-099a-46d5-a5a0-8f6485d54da1

📥 Commits

Reviewing files that changed from the base of the PR and between 6b7680d and 6a98c5a.

📒 Files selected for processing (3)
  • Reef/Models/CyclePanelState.swift
  • Reef/UI/CyclePanel/CyclePanelController.swift
  • ReefTests/InstantSwitchModeTests.swift

📝 Walkthrough

Walkthrough

Changes

Stable direct cycling

Layer / File(s) Summary
Window-ID reconciliation
Reef/Models/CyclePanelState.swift
Adds a helper that preserves existing available IDs, appends new IDs, and removes duplicates.
Direct-cycle state and validation
Reef/UI/CyclePanel/CyclePanelController.swift, ReefTests/InstantSwitchModeTests.swift
Stores direct-cycle application and window IDs, reconciles them during focus selection, handles ID/count mismatches, and tests stable ordering.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CyclePanelController
  participant CyclePanelState
  participant Windows
  CyclePanelController->>Windows: derive availableWindowIDs
  CyclePanelController->>CyclePanelState: reconcile stored and available IDs
  CyclePanelState-->>CyclePanelController: reconciled window IDs
  CyclePanelController->>Windows: focus next matching window
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing instant switching by preserving window order across presses.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-instant-window-cycle

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Focus2321
Focus2321 merged commit aa7e1e6 into main Jul 22, 2026
1 check passed
@Focus2321
Focus2321 deleted the codex/fix-instant-window-cycle branch July 22, 2026 21:38
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.

1 participant