Repository navigation
fix(url): Hand focus back when a second link beats the launch activation - #139
Conversation
On cold launch, a passive link that arrived after the launch link settled but before the launch activation landed replaced the deferred decision without taking over its claim to the activation, so Annotate stayed frontmost. The newer link's burst now carries the launch on, keeping the original deadline so later links can't stretch the window.
Three launch focus tests asserted right after the launch activation, before any settle it could start had run. They now check that nothing is settling, drive the manual scheduler through the settle, and then assert.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Carry the deferred launch deadline Annotate/LinkFocusHandoff.swift |
A later link takes over a deferred launch decision only if its deadline has not passed. The burst carries that deadline forward when it settles. |
Enforce the deadline during activation Annotate/LinkFocusHandoff.swift, AnnotateTests/LinkFocusHandoffTests.swift, AnnotateTests/URLCommandTests.swift |
Activation is captured only by the carried deadline, and a burst recreated from deferred activation retains the deadline. Tests cover handoff timing, color-link behavior, and settling state. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Possibly related PRs
- epilande/Annotate#137: Introduced the deferred launch-handoff behavior that this change updates.
Merge Risk: 
Minimal · up to 2b9b0
-
No merge-blocking issue is established for the launch-focus deadline change. Merge after normal checks pass.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title names the main change: a second passive link that arrives while a launch activation is pending now takes over the launch decision and hands focus back. The raw summary and objectives describe this same handoff change in LinkFocusHandoff.swift, with matching tests. The title uses the conventional fix(url) prefix and is specific, so it passes.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 3 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Live verificationAt 2b9b0a2 on macOS 27.2 (Mac mini), with a Debug build under its own bundle ID ( Build and tests
Focus handoff (a small test app frontmost before each run, frontmost app polled every ~50 ms)
Notes
Not tested
|
Follow-ups from the #137 review, both in the link focus handoff.
Cold launch with a second passive link
Say a color link launches Annotate. The launch link settles before the launch activation lands, so the handoff defers the decision until it does. If a second passive link (color, toolbar, fade) arrived in that gap,
linksDidRundropped the deferred decision and started a plain, non-launch burst. That burst never took the launch activation and had nolaunchPreviousAppto fall back to, so Annotate stayed frontmost.Now a new burst that replaces a live deferred launch decision takes it over:
launchActivationWindowfrom when the launch links settled), so a chain of later links can't stretch the window, and an activation past it is left alone even mid-settleUnchanged:
keepsFocusis asked at settle.Tests that asserted before the settle
testALateLaunchActivationIsLeftAlone,testLaunchLinksThatOpenTheOverlayKeepFocus, andURLCommandTests.testAToolLinkThatLaunchesTheAppKeepsFocusasserted right after the launch activation. A settle started by that activation wouldn't have run yet, so the "nothing handed back" checks passed no matter what. Each one now assertsisSettlingis false, advances theManualSchedulerthroughsettleDelay, and then asserts. No sleeps or run-loop waits. I fixed all three since they share the pattern.Testing
New tests:
testAPassiveLinkBeforeTheLaunchActivationStillHandsBack(activation lands after the second link settled)testAPassiveLinkSettlingWhenTheLaunchActivationLandsHandsBack(activation lands while it settles)URLCommandTests.testAColorLinkBeforeTheLaunchActivationStillHandsFocusBack(same throughapplication(_:open:))testPassiveLinksAfterLaunchDoNotExtendTheLaunchActivationWindowtestALaunchActivationPastTheWindowIsLeftAloneWhileALaterLinkSettlesThe first three fail on main (496f58c):
The two deadline tests pass on main, since main never carries the launch over. They guard the deadline handling: with the deadline checks removed from the fix, both fail.
swift test: 941 tests, 0 failuresI didn't do a live cold-launch check. All of this is covered with the injected clock and scheduler.
Summary by CodeRabbit