Skip to content

Mac tests: no real key tap under UI testing (it raised a prompt over Settings); say what a missed live press did - #451

Merged
alexkroman merged 5 commits into
mainfrom
claude/mac-ui-flakes
Nov 27, 2026
Merged

alexkroman merged 5 commits into
mainfrom
claude/mac-ui-flakes

Conversation

@alexkroman

@alexkroman alexkroman commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

What & why

This follows up the three Mac-side flakes seen in CI between Nov 25 and 27. It fixes one at its cause, makes another diagnosable, and confirms the third is already fixed on main.

1. APIKeySheetUITests/testCancelDiscardsKeyEditAndKeepsRow: the "Connect…" button was covered

On main, a ⌘, fallback (#427) kept this test green. With it removed, the test failed on every run of this PR and on all 3 test-plan attempts. A full-screen screenshot from the result bundle (run 46044674961) shows what covered the button: macOS's "Keystroke Receiving" prompt ("“Blurt” would like to receive keystrokes from any application"), open over Settings.

Cause: under UI testing, AppDelegate calls showOverlay() at launch. That calls DictationKeyTap.ensureRunning(), which runs CGEvent.tapCreate for key events. Without Input Monitoring, macOS raises that prompt; the comment there assumed the call simply failed. The install retry on the permission poll then tried again on every tick.

Fix: under UI testing, ensureRunning() refreshes the key binding and creates no real tap. The suite never used the real tap: it drives the gate through simulatePressForTesting.

With nothing covering the row:

  • openKeyEditor drops the ⌘, fallback.
  • openSettingsWindow waits for Settings to be the front window after its one ⌘,.
  • If the button is still covered, the test fails with the app's state, the windows front to back, and a full-screen screenshot.

2. Make a missed live press diagnosable

LivePerformerTests "every element action lands in the fixture" failed once on #447. That PR touched no Mac code, and the test passed on its next run. The press's answer sat inside #expect, so the log couldn't show what the performer did instead. Each press's answer is now held in a variable before it's checked, so the next miss names it. This is a diagnostic, not a fix, and it adds no retry.

Not changed: already fixed on main

ReadAloudFlowsUITests/testPillShowsAReadAndNeverReplaysAnOldNotice only failed on #439's branch, from a change that was reverted before merging.

How it was tested

Written in a Linux sandbox, which can't build or run the Mac suites, so CI is the first execution. Locally: swift-format, swiftlint lint --strict, the size and lint-lite checks, and scripts/check.sh --portable all pass. The cause came from the CI run's own screenshot.

  • scripts/check.sh passes (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 (doc comments on DictationKeyTap.ensureRunning, AppDelegate and the UI-test helpers)

🤖 Generated with Claude Code

https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP

A CI run of PR #447 (46015518999, live-tests) failed "every element
action lands in the fixture" on its first step: the Reply press answered
something other than "AXPress", and the fixture never recorded a press.
The log couldn't say what the performer did instead — the call sat inside
#expect, which printed no value — so whether AXPress was refused and the
fallback click missed, or something else, is unknown. Each press's answer
is now held before it is checked, so the next miss names it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP
openKeyEditor raised a covered Settings row with a second ⌘, when the
Connect…/Change… button wasn't hittable in 5 s — a fallback added (#427)
after testCancelDiscardsKeyEditAndKeepsRow, first in its run, found the
button present but covered, Settings having opened behind another window.
The cause is in openSettingsWindow, which returned as soon as a Settings
window existed. It now also waits for Settings to be the front window
(`app.windows.firstMatch`, listed front to back), after its one ⌘,, and a
Settings window left behind fails there naming every window front first.
openKeyEditor no longer sends ⌘,: it waits for the button to be hittable
or fails with the same window list. windowFrames moves to the shared
windows file for both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP
PR #451's first run (46025331730) failed testCancelDiscardsKeyEditAndKeepsRow
on the same miss #427's ⌘, fallback had covered: "Connect… is covered", with
Settings ("General") the app's front window and the button inside its frame.
So nothing of Blurt's covers it — another app's window does, or Blurt isn't
the active app; the removed ⌘, raised it because typeKey brings the app
forward first. The failure now names the app's state (4 = in front) and
keeps a full-screen screenshot in the result bundle, so the next run says
which.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP

Copy link
Copy Markdown
Collaborator Author

Status: CI red on 3c89708, blocked on one screenshot.

The only failing test is APIKeySheetUITests/testCancelDiscardsKeyEditAndKeepsRow, in the Mac UI suite's shard a. It fails in the run's first test, on all 3 test-plan attempts:

API key row button (settings.apiKey.connect) is covered (at (636.0, 262.0, 86.0, 24.0)); app state 4 (4 = in front); windows, front first: General (272.0, 118.0, 480.0, 500.0); Blurt …; Blurt UI Test Harness …

  • Blurt is the active app.
  • Settings is its front window.
  • The button sits inside Settings' frame.

Even so, the button isn't hittable, so whatever covers it is a window from another process (a system dialog or a notification). The ⌘, step this PR removes cleared that cover, which is why it passed on main.

Blocked on: run 46044674961's BlurtUITests-xcresult-a artifact has a full-screen screenshot, "screen with settings.apiKey.connect covered". It shows what's on top, but it can't be downloaded from the environment that wrote this PR. Once the cover is known, the fix is to stop it appearing. Everything else on this PR passes, live-tests included.


Generated by Claude Code

…Settings

The result bundle's screenshot from PR #451's run 46044674961 shows what
covered testCancelDiscardsKeyEditAndKeepsRow's Connect… button: macOS's
"Keystroke Receiving" prompt ("Blurt would like to receive keystrokes from
any application"), open over Settings. Under UI testing AppDelegate calls
showOverlay() at launch, which calls the key tap's ensureRunning(), and
CGEvent.tapCreate for key events without Input Monitoring raises that
prompt — the comment there assumed it simply failed. The install retry on
the permission poll tried again every tick.

The suite never uses the real tap: it drives the gate through
simulatePressForTesting. ensureRunning() now refreshes the binding the
simulated presses read and, under UI testing, creates no tap. With nothing
covering the row, openKeyEditor needs no second ⌘, (removed earlier in
this PR) and its comments name the real cause.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP
@alexkroman alexkroman changed the title Mac tests: Settings opens in front without a second ⌘,; say what a missed live press did Mac tests: no real key tap under UI testing (it raised a prompt over Settings); say what a missed live press did Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

Resolved: CI green on 2d3367e.

The screenshot showed macOS's "Keystroke Receiving" prompt open over Settings. The app raised it at launch under UI testing by creating a real key-event tap, which needs Input Monitoring permission. Under UI testing the app now creates no real tap: the suite only ever drove the tap's gate through simulatePressForTesting. With the prompt gone, the "Connect…" button is hittable without the ⌘, fallback.


Generated by Claude Code

@alexkroman
alexkroman added this pull request to the merge queue Nov 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 27, 2026
alexkroman pushed a commit that referenced this pull request Nov 27, 2026
…hange

The audit timeouts ("Audit failed to complete in time", -56) hit the first
test of a shard: testSetupWithKey in #451's queue run (46055375031), and
testConsent and testSetupWithKey in the runs that added the re-run #447
removed. That test pays for the runner installing the app afresh (~20 s
in #451's recording) and the cold first launch after it, and the audit
read the hierarchy while the app was still coming up.

The class's setUp now launches the app once and waits for its screen to
hold still before any test (`warmFirstLaunch`), so no test's screen is the
cold launch; and audit() snapshots until the screen holds still before it
reads it, as auditScrolling already did for every page but the first.
Both are bounded waits for a state, not a re-run: a screen that never
settles still gets audited, and a pass that times out still fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP
@alexkroman
alexkroman added this pull request to the merge queue Nov 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 27, 2026
@alexkroman
alexkroman added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit 12bfacf Nov 27, 2026
23 checks passed
@alexkroman
alexkroman deleted the claude/mac-ui-flakes branch November 27, 2026 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants