cmux next: a message's More menu opens upward when it does not fit below

Merged
LU
5d ago
+111-7

The More (...) button on a message opened its native menu 2 px under the button and never checked the menu's height. On a message near the bottom of the window, the menu ran past the screen and AppKit shrank it to a scroll arrow, hiding its last rows.

  • Placement (AgentPaneContextMenu.popUpOrigin): if the whole menu fits under the button in the window's visible part, it opens down as before; else it opens up if it fits there; else on the side with more room. It is then kept on the screen, so AppKit never needs the scroll arrow.
  • Both menus: the message More menu and the fork menu share one helper (AgentPaneView+ContextMenu.swift).
  • Short windows: when the menu fits on neither side inside the window, it takes the side that fits on the screen (below first), then the screen's roomier side. Picked by the window's room alone, a short window near the screen's top sent it up past the window, and the screen's edge pushed it back over its button.
  • Displays: the screen is the one holding the button (PopupPlacement.screen(for:fallback:)), so a window across two displays keeps the menu by its button.
  • Unchanged: the menu's items. #26660 changes those items in the same files; the two should merge cleanly but touch nearby lines.

Changelog

  • Fixed: a message's More menu opens upward when it would not fit below, instead of shrinking to a scroll arrow.

Tests

  • Packages/macOS/CmuxNext/Tests/CmuxNextAgentPaneTests/AgentPaneMoreMenuTests.swift: room below, over the composer, no room on either side, kept whole on the screen, and a short window near the screen's top (the menu opens below, clear of the button).

Observed / Not run

  • Observed: compiled in a tagged build (Xcode 26.6). Checked in that build: the last message's menu opens upward with every row, a higher message's opens down. prepush-gate.py passes.
  • Not run: AgentPaneMoreMenuTests (Swift suites run on the fleet or CI only).