Repository navigation
Report a cancelled app-activation wait as a cancel, not a failure - #423
Merged
Merged
Conversation
`KeyInjector.poll` answered `false` both when its budget ran out and when its sleep was cancelled, so every caller had to tell the two apart itself. `performInsert` did, with a `Task.checkCancellation()` in its activation catch; `SystemVoiceCommandPerformer.open` did not, so a command abandoned while the app it opened came forward was reported and logged as failing to "bring <app> to the front". `poll` now throws `CancellationError` when cancelled before its check held, including during the last read past the deadline, so `false` only ever means the budget ran out. `waitUntilFrontmost` and the injector's `waitForTargetActivation` seam throw with it; `performInsert` lets a `CancellationError` through without the copy fallback and drops the re-check. The open-app wait moves into `waitForFront`, which lets the cancel propagate, and the router's existing handling ends the command as abandoned rather than failed. Tests: `poll` throws when cancelled mid-wait and at the last read; a command cancelled while its app comes forward is abandoned with no failure and no step error, while one whose app never comes forward still fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
The test compares against localizedDescription, which needs Foundation imported in the file itself under MemberImportVisibility. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
alexkroman
enabled auto-merge
November 25, 2026 21:11
alexkroman
pushed a commit
that referenced
this pull request
Nov 25, 2026
… CI run Recent multi-commit PRs (#410, #413, #414, #416, #420, #422, #423, #425, #426) mostly spent their extra ~37-minute runs on things nothing caught before CI: - scripts/check-swift-lint-lite.sh: a toolchain-free text match for the opt-in SwiftLint/swift-format rules it can see (modifier_order, no_empty_block, NoBlockComments, swift-format's `catch where`). Run by check.sh (so --portable and --lint-only) and the swift-budgets edit hook; would have flagged the pre-fix files of #414, #422 and #425. - .claude/hooks/push-gate.sh: a PreToolUse hook that runs `check.sh --portable` (~20 s) before any `git push` and blocks a red one — jscpd clones (#420, #422) and post-merge size overruns (#363, #378) were pushes that skipped the documented portable run. - AGENTS.md / CLAUDE.md: a "Rules only CI catches" list for the rest (variable_shadowing, one_declaration_per_file, type_contents_order, multiline_function_chains, MemberImportVisibility, one argument per line), and the new hook and script in the hooks table and permissions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1UDUZXyuF6g7GUmmNu
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 25, 2026
2 of 3 tasks
alexkroman
pushed a commit
that referenced
this pull request
Nov 25, 2026
One conflict, in .claude/hooks/swift-budgets.sh: #428 added the lint-lite rules inside the per-script scope cases this PR removed. The size and clock checks still narrow their own arguments; check-swift-lint- lite.sh scans what it's given, so the hook keeps one scope case for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
KeyInjector.pollreturnedfalseboth when its time budget ran out and when it was cancelled, so each caller had to work out which one happened.performInserthandled it with aTask.checkCancellation()in its activationcatch(9ab98e8).SystemVoiceCommandPerformer.opendid not, so a command cancelled while its app was coming forward was shown and logged ascouldNotPerform("bring <app> to the front").pollnow throwsCancellationErrorwhen it is cancelled before its check succeeds, including a cancel during the last check after the deadline. Sofalsenow only means the budget ran out.KeyInjector:waitUntilFrontmostand thewaitForTargetActivationseam are nowasync throws, andactivateTargetAppdrops its typedthrows(BlurtError).performInsertrethrows aCancellationErrorahead of the copy-fallbackcatch, replacing theTask.checkCancellation()workaround.SystemVoiceCommandPerformer: the end ofopen(the poll, then the "frontmost is enough" check) moves into a testable@MainActor static func waitForFront(_:clock:look:frontmost:). It lets the cancel through, and the router already handles that:SelectionSpeechRouter.executetreats a cancellation error on a cancelled task as an abandoned command.pollcallers areKeyInjector.waitUntilFrontmostandSystemVoiceCommandPerformer.open, plus tests.Behaviour change: a voice command cancelled while waiting for an app it opened to come forward now ends as abandoned instead of failing with "Couldn't bring to the front". There is no failure state on the pill and no
errors.jsonlentry; thecommands.jsonloutcome isabandonedinstead offailed, and the step carries no error.The paste path behaves the same for every cancel that lands during the frontmost wait. One edge differs: a cancel landing during the synchronous
isTerminated/activate()check, if activation then fails, now takes the.targetAppLostcopy fallback, where before the catch'scheckCancellation()aborted it. That window has no suspension point, so the outcome there already depended on timing.How it was tested
Written in a Linux sandbox with no Swift toolchain:
scripts/check.sh --portablepasses, as docheck-swift-size.shandcheck-test-clock.sh. CI on macOS verifies the build, every test, swiftlint, swift-format and periphery.New tests, all on
TestClockwith no wall-clock waits:KeyInjectorSystemActionsTests:pollthrowsCancellationErrorwhen cancelled mid-wait; with a zero budget and an already-cancelled task it still throws at the last check.SystemVoiceCommandPerformerFrontTests, throughSelectionSpeechRouter.execute:VoiceCommandError.couldNotPerform;falsewithout throwing.Adjusted: the existing poll and
waitUntilFrontmosttests addtry.KeyInjectorFallbackTests' "cancel during frontmost wait" now goes through the throwing seam and still asserts no ⌘V and an untouched clipboard.Size margins are thin:
KeyInjector.swiftis at 390/400 lines andSystemVoiceCommandPerformer's type body at about 235/250.scripts/check.shpasses (or CI will, if I'm not on a Mac)I read AGENTS.md and this doesn't reintroduce anything
deliberately removed
Docs updated if behavior changed
Generated by Claude Code