Lay out standalone quit confirmation before display

Merged
AU
3mo ago
+9-0

Closes #9595

Summary

  • force NSAlert to resolve its lazy layout before the standalone raw window is shown
  • preserve the asynchronous presenter and the no-nested-modal-loop invariant from #6461
  • add behavior-level coverage for the malformed placeholder button geometry

Root cause

The no-host-window fallback orders alert.window front while NSAlert still has its lazy placeholder layout. On macOS 26.4.1 that left the standalone panel at 260×328, with vertically stacked full-width buttons. NSAlert.layout() is the AppKit API that forces immediate layout; using runModal() here would reintroduce the nested modal-loop hang that #6461 removed.

The normal host-window path is unchanged and still uses beginSheetModal(for:).

Regression proof

  • Test-only commit 533bbb47e9 adds the standalone button-alignment assertion.
  • Local before fix: focused suite reported 4 passes and 1 failure; the two buttons were separated by 80 points vertically.
  • CI on the test-only SHA reproduced the failure with a 71-point separation at the new assertion: run 30969717154, shard job 92191739399. The app-host wrapper currently tolerates ordinary Swift Testing failures and printed All failures are expected, treating as pass, so the GitHub job is marked successful despite the recorded test failure.
  • Fix commit c98c6708a0 adds alert.layout() before standalone presentation.
  • Local after fix: all 5 focused tests pass, including both sheet and standalone assertions that runModal() is never called.

Validation

  • Tagged Debug build succeeded on pushed HEAD c98c6708a0: dogfood build.
  • Hidden-host repro: confirmed zero on-screen tagged windows, sent Ctrl+D to the sole terminal, and captured the standalone alert at 260×250, modal layer 8, alpha 1.0.
  • Escape dismissed the standalone panel and ran the cancellation recovery path, respawning the sole terminal.
  • git diff --check passes; the PR contains exactly the presenter and its existing test file.
  • ./scripts/lint-pbxproj-test-wiring.sh passes for all 652 test files.

Visual evidence

A trustworthy screenshot/video could not be recorded. The cloud Mac run 30968244690 reached its SSH hold but never appeared in Tailscale or the Admin API. Local Sky CUA lacks its executable/app-server, the alternate CUA daemon is unavailable, and macOS Screen Recording is denied for the available helper. Runtime geometry and window-layer metadata were captured directly instead.

Localization

No user-facing strings changed. The changed Swift diff was audited for added English literals; no localization catalog updates are needed.


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 the standalone quit confirmation dialog on macOS by calling NSAlert.layout() before the window is shown. Prevents stacked, full-width buttons and keeps the async presenter (no nested modal loops). Addresses #9595.

  • Bug Fixes
    • Call alert.layout() in the standalone path before ordering the window front to avoid placeholder button geometry.
    • Add a behavior test asserting the two buttons have the same midY (no vertical stack).

Summary by CodeRabbit

  • Bug Fixes

    • Improved the quit confirmation alert’s presentation so its buttons are correctly aligned when displayed.
    • Ensured the alert layout is fully resolved before the window becomes visible.
  • Tests

    • Added coverage confirming the quit confirmation alert’s buttons appear horizontally aligned.