Skip to content

Speed up menu bar UI test clicks - #79

Open
robin-liquidium wants to merge 1 commit into
mainfrom
codex/faster-menu-ui-tests
Open

Speed up menu bar UI test clicks#79
robin-liquidium wants to merge 1 commit into
mainfrom
codex/faster-menu-ui-tests

Conversation

@robin-liquidium

@robin-liquidium robin-liquidium commented Sep 12, 2026

Copy link
Copy Markdown
Owner

XCTest waits five seconds for a mouse-up acknowledgement after menu-bar clicks, even when the panel is already ready. Scope its private event-confirmation timeout to menu toggles and restore the previous value immediately afterward. Existing idle and content-readiness checks remain enabled, with explicit failures if a future Xcode removes the required API.

Four focused UI tests passed, covering 14 menu toggles, creation flows, issue details, and Settings. Median menu-click time fell from 5.53s to 0.68s; the Settings test fell from 21.4s to 11.4s. System logs confirmed the normal five-second timeout is restored for subsequent actions. The pre-commit autoreview completed without actionable findings.

Only the UI-test harness and its documentation change. No app release is needed.

Summary by CodeRabbit

  • Tests

    • Improved automated coverage and reliability for menu bar panel interactions, including calendar event creation and menu opening.
    • Added safeguards to ensure UI checks continue validating app-idle and panel-readiness states.
  • Documentation

    • Updated development guidance with details about the menu bar interaction testing behavior and failure handling.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
dayline-website 97ac226 Sep 12 2026, 01:51 AM

@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 5a83edd4-2392-4bba-abda-7b10bfdc0bc5

📥 Commits

Reviewing files that changed from the base of the PR and between 6d7f431 and 97ac226.

📒 Files selected for processing (2)
  • README.md
  • UITests/DaylineUITests/DaylineUITests.swift

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The UI tests now use a shared helper for menu-bar clicks. The helper temporarily sets XCTest event confirmation to 0.1 seconds, performs the click, restores the previous value, and fails when the required private API is unavailable. The README documents this behavior.

Changes

Menu-bar click handling

Layer / File(s) Summary
Scoped menu-bar click helper
UITests/DaylineUITests/DaylineUITests.swift, README.md
Menu-bar panel clicks use clickMenuBarItem. The helper validates the private XCTest API, changes the confirmation interval for the click, restores the prior interval, and documents the behavior.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 97ac2

The UI-test-only timeout adjustment is scoped to menu-bar clicks and restores normal behavior afterward, with no active merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: speeding up menu bar UI test clicks.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/faster-menu-ui-tests

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.

@opencode-agent

Copy link
Copy Markdown

Review: PR #79 — Speed up menu bar UI test clicks

Verdict: Approve. This is a well-scoped, test-harness-only change with explicit failure modes if Apple removes the private API. The speedup (5.53s → 0.68s median per click) is significant and the mechanism is sound. I reviewed the diff statically (can't build a macOS XCTest target here), and the call-site plumbing checks out: both testCreatesLinearGitHubAndAppleReminder() and openMenu() are throws, and all ~20 try openMenu() call sites are compatible.

What's done well

  • Correct scoping and restoration. The defer is registered after the previous value is read but before any mutation, so a failure in the XCTUnwrap chain can't leave the session in a modified state, and the restore always runs after the click — including if the activity throws.
  • Defensive guards. responds(to:) is checked before every KVC access, so value(forKey:) can't hit an NSUnknownKeyException crash; failures become explicit XCTFail/XCTUnwrap messages naming the missing API, which is exactly what you want when a future Xcode breaks this.
  • Consistency of the setter. Using the ...WithoutSideEffects variant for both set and restore (per the comment about the ordinary setter deferring restoration to teardown) is coherent and matches the README's claim that "the normal timeout is restored after each toggle."
  • takeUnretainedValue() is appropriate for a singleton accessor, and assigning to a strong local retains it safely.

Potential bugs / risks (all low)

  1. 0.1s floor on shared/CI runners. If a heavily loaded GitHub-hosted runner ever takes >100ms to confirm a legitimate mouse-up, the click could flake where the 5s default previously absorbed it. The measured numbers suggest this isn't happening today, and the failure mode is a test failure rather than a hang, so it's self-limiting. If flakes ever appear, bumping to 0.250.5 would retain ~90% of the speedup with more headroom. Not blocking.

  2. Silent no-op after XCTFail. In the two guard … else { XCTFail(…); return } branches, the test continues after the failure, so the click never happens and the next assertion (waitForExistenceIfNeeded on the panel) fails too — producing cascading, noisier failures. Since the function is already throws, using try XCTUnwrap(...) there (as done for the class and session lookups) would abort immediately with one clean error. Minor consistency point:

    _ = try XCTUnwrap(session.responds(to: ...) ? session : nil,
                      "This Xcode version no longer supports the scoped menu click confirmation timeout")

    (or just make the guard conditions throwing). Take or leave it.

Suggestions (optional)

  • Hoist the session lookup. The reflection + KVC dance runs on every one of the ~14 menu toggles. It's cheap, but a small private lazy var uiAutomationSession: NSObject (resolved once in setUpWithError or on first use) would shrink clickMenuBarItem to just the save/set/click/restore. Purely cosmetic given the measured timings.
  • The comment // The ordinary setter restores only at test teardown… documents behavior of a private API that can't be verified from headers — consider noting the Xcode version this was observed on, so a future maintainer knows the baseline when re-validating.

Documentation

The README addition accurately describes the mechanism, the restoration guarantee, and the explicit-failure behavior. No app code, entitlements, or release artifacts change — correct call that no release is needed.

Nice work; the pre-commit autoreview's clean result is consistent with what I see.

New%20session%20-%202026-09-12T01%3A51%3A21.331Z
opencode session  |  github run

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