test: ignore NSTextView's own delegate reads during init on macOS 27

Merged
TE
1mo ago
+28-0

Summary

Four app-host tests fail on every macOS 27.0.1 mini and pass on the macOS 15/26 Blacksmith runners:

  • CmuxWebViewKeyEquivalentTests/testWindowFirstResponderGuardAvoidsTextViewDelegateLookupForWebViewResolution
  • CmuxWebViewKeyEquivalentTests/testWindowFirstResponderGuardResolvesTrackedWebViewForFieldEditorResponder
  • CommandPaletteFocusStealerClassificationTests/testDoesNotReadTextViewDelegateForFocusStealerClassification
  • GhosttyResponderResolutionTests/testDoesNotReadTextViewDelegateForGhosttyResponderResolution

All four fail with XCTAssertEqual failed: ("4") is not equal to ("0"). The Ghostty and command-palette tests only construct the probe text view and call one cmux helper, so the four reads come from NSTextView's own initializer on macOS 27, not from cmux. That is AppKit reading its own property, which the unsafe-unretained rule does not cover.

Each probe now resets its counter right after construction, so it counts only reads made by the code under test. No product code changes.

Evidence

Recent ci.yml runs (since 2026-10-10 20:14Z): each test failed 0/4 on the 27 minis and passed 10/10 (CmuxWebView) and 5-6/6 (others) on blacksmith macos-26, plus 2/2 on blacksmith macos-15.

Changelog

none

Test plan

  • Targeted rerun on a macOS 27.0.1 mini (cmux8s-mac-mini-glaeda-3), 5 iterations x 2 passes: all four tests passed 10/10. https://github.com/manaflow-ai/cmux/actions/runs/38106496571
  • Before this change the same four failed 0/4 on the 27 minis in recent ci.yml runs, and passed on these same minis on 2026-10-07 before the upgrade (run 37700242931).
  • Full CI dispatch on this branch: https://github.com/manaflow-ai/cmux/actions/runs/38104342596. Routing put it on Blacksmith macos-26; the four tests pass there. Its red shards are unrelated: the Cloud Cmd-Y/Cmd-N tests (#19152), the quit-census deadline test, and RemoteTmuxMirrorSplitRoutingTests.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Fixes four app-host tests that failed on macOS 27 because NSTextView's initializer reads its own delegate four times, which the test probes counted as cmux reads.

  • Adds a resetDelegateReadCount() to each NSTextView probe, called right after construction so only reads made by the code under test are counted.
  • No product code changes.

[!NOTE]
Low Risk
Test-only changes to counter reset timing; no app behavior or security-sensitive paths modified.

Overview
Fixes four app-host tests that fail on macOS 27 because NSTextView’s initializer reads delegate during construction, so probe subclasses were reporting 4 reads before any cmux code ran.

Adds resetDelegateReadCount() on the delegate-tracking probe NSTextView types in BrowserConfigTests, ShortcutAndCommandPaletteTests, and TerminalAndGhosttyTests, and calls it immediately after creating each probe so assertions still enforce zero delegate reads from first-responder / focus-stealer / Ghostty resolution paths. No production code changes.

Reviewed by Cursor Bugbot for commit 5426df763458985b93c675ec67ab2f32ace226ca. Bugbot is set up for automated code reviews on this repo. Configure here.