base red: four window-opening suites close their windows (.closesItsWindows)

TE
5d ago
+28-19

The desk's ask: "Add .closesItsWindows to the @Suite of PaletteLargeTextTests, SidebarFoldKeyboardTests, WorkspaceTabHoverCardContrastTests and PageWebViewFocusViewChangeTests. Make sure each suite really closes what it opens; if one leaks on purpose, fix the leak instead."

Summary

This PR fixes a base red. WindowCleanupCoverageTests.everySuiteThatOpensAWindowClosesWhatItLeaves fails on feat-cmux-next. It names four suites, all landed 2026-10-31, that open windows without .closesItsWindows:

  • CmuxNextPaletteTests/PaletteLargeTextTests (#26621)
  • CmuxNextAppTests/SidebarFoldKeyboardTests (#27961)
  • CmuxNextAppTests/WorkspaceTabHoverCardContrastTests (#29458)
  • CmuxNextPagesTests/PageWebViewFocusViewChangeTests (#29272)

The failure is in run 41219252754, job 124604477110 (#28605, which changes no Swift, so its Swift suites are the base's). The test failed at WindowCleanupCoverageTests.swift:33 with those four offenders.

Changes

  • Each suite gets .closesItsWindows (and import CmuxNextTestSupport).
  • PaletteLargeTextTests: it really leaked. PaletteController.hide() only orders the panel out, so each test left its palette panels open. The test now uses the target's closeForTest() (hide, then close the panel), as the other palette suites do. Its host windows use closeAfterTest().
  • The other three: their windows are closed in a defer, so a failed #require no longer leaves one open. WorkspaceTabHoverCardContrastTests resolves its theme before it makes the window, so a throw there leaves nothing open.

Why it matters: the cut-short swift test

The cmux-next swift test broad pass is cut short at its 1500 s whole-run limit (exit 143). That is main-thread starvation in the one shared test process, from windows piling up. In run 41219252754:

  • Throughput fell from about 1,000 to 2,500 tests a minute (16:45 to 16:51) to about 100 to 400, and about 45 at the end.
  • From 17:00 the log has 15 to 45 s gaps, and unrelated suites report "passed after 270 to 1440 s".
  • At 1500 s the hang sample shows a 7.4 GB process footprint. 2043 of 2452 main-thread samples are in CA::Transaction::flush, then NSDisplayCycleFlush, then -[NSWindow layoutIfNeeded], deep in sidebar view layout (SidebarIconButton.layout).
  • 32 tests started and never finished.

This is a partial fix. It stops these four suites from adding windows, and the trait now fails any of them by name if it leaves one. The structural fix is #29490 (carry of #26809): it runs the main-thread-heavy suites in their own processes and shards the broad pass. Until #29490 lands, this PR's own swift test may still be cut short at 1500 s.

Testing

  • python3 scripts/cmux-next/prepush-gate.py: no new violations.
  • Not run locally: no Swift build or test on this host. This PR's cmux-next swift test job is the check: WindowCleanupCoverageTests should pass, and each changed suite should report no window leak.

Changelog

none

Agent session: agent session

🤖 Generated with Claude Code


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


Summary by cubic

Makes the four window-opening test suites on feat-cmux-next declare .closesItsWindows and actually close what they open, fixing the WindowCleanupCoverageTests failure.

  • PaletteLargeTextTests genuinely leaked: hide() only orders the palette panel out, so it now uses closeForTest() like the other palette suites.
  • The other three closed their windows in a defer, but a failed #require could leave one open; they now close via closeAfterTest().

This is also a partial fix for the cmux-next swift test run being cut short at its 1500 s limit, since the window pile-up starved the main thread.