Admit focused untracked standard windows before non-managed fallback#388
Admit focused untracked standard windows before non-managed fallback#388biswadip-paul wants to merge 2 commits into
Conversation
…rd windows before non-managed fallback When OmniWM receives an app activation event before the window has been tracked, the focus path falls through to non-managed fallback. This fix checks if the focused window is a valid managed candidate and admits it into WorkspaceManager before entering the non-managed path. Fixes #387 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAXEventHandler now attempts to admit a focused untracked standard window into the managed model before falling back to non-managed focus handling; a new helper performs admission or defers via delayed replacement, and a regression test verifies the admission and resulting focus/subscription behavior. ChangesWindow Admission Before Non-Managed Fallback
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Tests/OmniWMTests/AXEventHandlerTests.swift (1)
1783-1803: ⚡ Quick winAssert fallback trace is never entered (not just final state).
This test checks final state (
isNonManagedFocusActive == false), but it can still miss a transient fallback entry. Add a trace assertion to ensure.nonManagedFallbackEnterednever occurred for this activation.Proposed assertion hardening
controller.axEventHandler.handleAppActivation( pid: getpid(), source: .focusedWindowChanged ) await controller.layoutRefreshController.waitForRefreshWorkForTests() + let trace = createFocusTraceEvents(on: controller) @@ `#expect`(controller.focusBridge.focusedTarget?.token == observedToken) `#expect`(controller.focusBridge.focusedTarget?.isManaged == true) `#expect`(subscriptions == [[observedWindowId]]) `#expect`(relayoutReasons.contains(.axWindowCreated)) + `#expect`(!trace.contains { event in + if case let .nonManagedFallbackEntered(pid, source) = event.kind { + return pid == getpid() && source == .focusedWindowChanged + } + return false + })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Tests/OmniWMTests/AXEventHandlerTests.swift` around lines 1783 - 1803, Add an assertion after awaiting layout refresh and before the existing guards to ensure the transient fallback trace was never entered: use the test's expectation style (e.g. `#expect`) to assert that the trace collection on the controller/workspace manager does not contain the .nonManagedFallbackEntered event (for example: `#expect`(!controller.workspaceManager.traces.contains(.nonManagedFallbackEntered))). Insert this immediately after await controller.layoutRefreshController.waitForRefreshWorkForTests() and before checking the admitted entry.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@Tests/OmniWMTests/AXEventHandlerTests.swift`:
- Around line 1783-1803: Add an assertion after awaiting layout refresh and
before the existing guards to ensure the transient fallback trace was never
entered: use the test's expectation style (e.g. `#expect`) to assert that the
trace collection on the controller/workspace manager does not contain the
.nonManagedFallbackEntered event (for example:
`#expect`(!controller.workspaceManager.traces.contains(.nonManagedFallbackEntered))).
Insert this immediately after await
controller.layoutRefreshController.waitForRefreshWorkForTests() and before
checking the admitted entry.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2abc0c11-a650-4250-80af-de26a4990ff3
📒 Files selected for processing (2)
Sources/OmniWM/Core/Controller/AXEventHandler.swiftTests/OmniWMTests/AXEventHandlerTests.swift
…back trace assertion Hardens test to verify .nonManagedFallbackEntered is never entered transiently, not just checking final state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Actionable comments posted: 0 |
|
Closing — v0.4.9.6 independently implemented this fix via |
Summary
WorkspaceManageradmitFocusedUntrackedWindowIfNeededto the activation path — checks if the focused AX window is a valid managed candidate and admits it before falling through to the non-managed focus fallbackshouldDelayManagedReplacementCreate)Fixes #387
Test plan
focusedUntrackedStandardWindowIsAdmittedBeforeNonManagedFallbackthat verifies:.axWindowCreatedrelayout is triggered🤖 Generated with Claude Code
Summary by CodeRabbit