cmux NEXT: a launch window is ordered in with its content installed (no white first frame)

Merged
TE
14d ago
+37-1

In a restore launch, the window's first composited frame (1830 ms after process start) was solid white: the window backdrop with nothing on it. It's the first finding of the launch recording in #23680 (see the strip there). Leo's never-blank first launch frame: the first frame paints the snapshot, then goes live.

Cause: WindowManager.makeController orders the window in during the turn it creates the controller. WindowController installs its workspace (the launch snapshot's provisional workspace, else the connecting state) only from its ObservationStream task, a main-actor hop later. So AppKit's first draw of the window had no content view in it.

Change: makeController calls controller.showWorkspace(requested:) before deciding to present, so the content is already in when the window is ordered in. The observer's first emission repeats it and does nothing: show returns early for the same workspace, and the connecting view is reused. A window whose content went in that way is presented even if its workspace isn't counted as mirrored, so it never waits for a contentDidAppear that already ran.

Test: LaunchWindowContentFirstTests. When the launch window is presented (the onPresent hook, before AppKit draws), it already holds its workspace content or its connecting view. It needs no daemon.

Red, then green: the first commit is the test alone, and it fails on it. The second commit is the fix.

What visibly changes: the first frame of a launch window draws its content or the connecting state, not a white window.

No capture: this removes the white first frame of a restore launch, gone before the window settles; a capture tour shows the settled window, which looks the same before and after. LaunchWindowContentFirstTests pins that the window holds its content or connecting view when it is ordered in.

Next, from the same recording, each in its own PR: the sidebar dropping out during restore, the cold-launch layout settling in pieces, and the too-old daemon notice while connecting (#23692).

Agent session: huge-blue

🤖 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

Fixes the solid white first frame of a restore launch window: the window was ordered in before its content (the launch snapshot's workspace, else the connecting state) was installed, so AppKit drew a frame of the backdrop alone.

  • makeController now installs the workspace before presenting, and presents any window that already has content instead of waiting for contentDidAppear.
  • Adds LaunchWindowContentFirstTests, which fails on the old behavior.