Skip to content

Right-click on message text shows the message menu on macOS 27 again, and the Swift tests pass - #206

Merged
pitis merged 3 commits into
mainfrom
fix/swift-tests-macos27
Nov 14, 2026
Merged

pitis merged 3 commits into
mainfrom
fix/swift-tests-macos27

Conversation

@pitis

@pitis pitis commented Nov 14, 2026

Copy link
Copy Markdown
Owner

What changed

Right-click on message text (app fix). From macOS 27, SwiftUI draws selectable text (Text(...).textSelection(.enabled)) in its own view, AppKitTextInteractionView, not in an NSTextField. TimelineList.menuAround only recognised NSTextFields, so on macOS 27 right-clicking or control-clicking a message's text showed the text's own menu (Cut, Copy, Paste, Font, Spelling…) and not the message's menu (Reply, React…). menuAround now also takes a view that accessibility reports as static text (the new view's role is AXStaticText; there is no public class for it). The NSTextField path for macOS 26 is unchanged, and editable text still keeps its own menu.

Settings test (test fix only). On macOS 27, removePersistentDomain(forName:) leaves an empty domain behind, so persistentDomain(forName:) returns [:] and not nil (a domain that never existed still returns nil). Legacy.adoptSettings behaves correctly: the old settings are gone, and running it again on the empty domain does nothing. The test now checks that the old domain has no keys left. If the domain isn't emptied, the failure message lists the keys that are still there.

The MessageRowTests helper now finds the message text as either an NSTextField or a static-text view, and clicks into it. A text field goes into the window's field editor, as before. Any other text view becomes first responder.

How it was tested

macOS 27.2.1, Xcode 27.2, unsigned test runs:

  • Before: both tests fail as the issue reports (XCTAssertNil failed: "[:]", and XCTUnwrap failed: … NSTextField).
  • New tests with the old menuAround, and with adoptSettings's removePersistentDomain line commented out: both fail. Legacy fails with ["appearance", "showInMenuBar"] is not equal to []. The message-row test fails on the two menuAround assertions (right-click and control-click), so the app really was wrong on macOS 27.
  • With the fix: LegacyTests and MessageRowTests pass, testEditableTextKeepsItsOwnMenu included.
  • Full Swift suite: 339 tests, 0 failures. make format, make lint and cd core && cargo test -q all pass.
  • A small off-app probe (hosting view, window never shown) confirmed the view tree, the AXStaticText role and the menus. Hush itself was not launched, so no right-click was made by hand in the live app.

Not verified: macOS 26. That path is the same NSTextField code as before, and the tests used to pass there.

Closes #203

@pitis

pitis commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

Review (/pr-review-toolkit:review-pr: code, tests, comments)

There were no Critical findings. Each finding and what was done:

Important

  • The menuAround doc comment still gave "Look Up, Translate…" as the text's own menu (comments). On macOS 27 that menu is Cut, Copy, Paste… Fixed: the comment now says "the text's own menu" and lists no items, so it can't go stale again.

Suggestions, fixed

  • The "text clicked into shows in the window's field editor" comment read as a rule for all text (comments). It now says "a text field clicked into…".
  • The comment on the new branch didn't say why there is no isEditable check (comments). It now says that from macOS 27 selectable text is a private view, not a text field, and that static text is never editable.
  • The test comment left out Cut (comments). It now lists "Cut, Copy, Paste…", like the real menu.
  • The clickInto tuple label editor was wrong on macOS 27 (comments, tests). On 27 the value is the text's own view, not an editor. The label is now view, and the test uses text.
  • The read-only NSTextField path (the macOS 26 case) had no test on this Mac (tests). New test testRightClickOnALabelClickedIntoShowsTheMenuAround: a selectable NSTextField(labelWithString:) under a .contextMenu, clicked into through the field editor. To check that it guards the path, that branch was changed to always return nil: this test failed, and the others passed. The branch was then restored.

Declined

  • "macOS 27 keeps the emptied domain" says more than was measured (comments). It was measured: after removePersistentDomain the domain's plist is still in ~/Library/Preferences, and defaults read prints {}. The comment stays.
  • Add XCTAssertNotNil on the text's own menu (tests, 3/10). Declined: the test is about what menuAround returns. Whether the text has a menu of its own doesn't change that.
  • The makeFirstResponder result is ignored (tests, 2/10). Declined: menuAround doesn't depend on the first responder. The call only stands in for a click.

Noted, outside this PR

  • On macOS 27, removePersistentDomain leaves an empty plist behind. Each run of LegacyTests (and of the suites in FormattingTests) leaves two in ~/Library/Preferences, and there are now about 216 dev.pitis.hush.tests.* files. This is clutter only. It could be its own issue.
  • The code reviewer's probes rebuilt the real timeline layout (ScrollView > LazyVStack > rows with contentShape + contextMenu). In that layout, right-click and control-click on the text give the row's menu, with or without a selection. Every other selectable-text site, plain Text, buttons, TextField, SecureField, TextEditor and the composer behave as before.

After the fixes

  • MessageRowTests and LegacyTests pass: 12 tests, 0 failures.
  • make format and make lint pass, including the new desktop clippy step from main.
  • The branch is merged with main (0a189a0, a Makefile-only change).
  • The full Swift suite (339 tests, 0 failures) ran on cb72868. Since then the app code has changed only in comments, and one test was added. The full suite was not re-run, so on-screen windows open fewer times.

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.

Two Mac app tests pass again, so the Swift gate is clean

1 participant