Skip to content

Cmd+W on the last surface in the last workspace does not close the window on CI #222

Description

@arzafran

What happens

testCmdWClosesWindowWhenClosingLastSurfaceInLastWorkspace presses Cmd+W on the last surface in the last workspace and expects the window to close. On CI the window never closes.

programaTests/AppDelegateShortcutRoutingTests.swift:1463: failed - Timed out waiting for
  Cmd+W on the last surface to close the window
programaTests/AppDelegateShortcutRoutingTests.swift:1465: XCTAssertNil failed: "<NSWindow: 0x9d684d180>"

This test has been skipped in scripts/ci-run-unit-tests.sh for months with no recorded reason. #221 un-skipped it to find out why, got the above, and restored the skip with the reason documented.

Why this is not just a flaky test

Three things establish that:

  1. Not a timing race. test: replace fixed 50ms spins with condition waits in shortcut routing tests #218 replaced the test's single fixed 0.05s run-loop spin with a 2-second condition wait. It now waits the full two seconds and the window is still there. More time does not help.
  2. The shortcut dispatches correctly. The XCTAssertTrue(appDelegate.debugHandleCustomShortcut(event:)) immediately above the failing assertion passes. Routing works; the close it should trigger does not complete.
  3. Headless window closing works in general. testCmdCtrlWPromptsBeforeClosingWindow and testCmdCtrlWClosesWindowAfterConfirmation both close real NSWindows on the same runner and are not skipped.

So this is specific to the cascade the test exercises: close last surface → close last workspace → close window. Cmd+Ctrl+W, which closes the window directly, is fine.

Steps to reproduce

  1. Remove the -skip-testing:${STATEFUL_TEST_SKIP} lines from scripts/ci-run-unit-tests.sh (both the stateful and serial arms)
  2. Push and let the unit-tests job run
  3. The stateful pass fails with the two errors above

Reproduced twice in the same run — the retry hit it identically.

What is not known

Whether this is a headless-only limitation of the test host or a real bug in a path users rely on. Nobody has reproduced it outside CI, and the behaviour is presumably fine in the shipping app, since closing the last surface with Cmd+W is an ordinary thing to do.

Both possibilities are worth resolving, and they need opposite fixes:

  • Headless limitation → document it in the test, and consider whether the assertion can be rewritten against something observable in that environment.
  • Real bug → the cascade drops the window close somewhere, and that is worth finding regardless of the test.

Verify

With the skip removed, testCmdWClosesWindowWhenClosingLastSurfaceInLastWorkspace passes in the stateful pass of scripts/ci-run-unit-tests.sh, and the skip can be deleted for good.

Context

Found while working #186. The skip's full reasoning is now written into scripts/ci-run-unit-tests.sh above STATEFUL_TEST_SKIP — it explicitly warns against reading it as flakiness.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions