cmux-next: New inside a group opens the workspace in that group, right below the current one
Summary
Leo: with an open workspace in a group, New (āN, the sidebar +, New Workspace Below) must create the new workspace in the same group, right below the current one.
Cause: workspaces.newPlacement defaults to top. Inside a group, top resolved to the first slot of that group (the old cx-de23 rule), so the new workspace landed at the top of the group instead of next to the one you were on.
Fix (NewWorkspaceDefaultSlot): when the window's current workspace is in a group, top now places the new one right below it (.below(current)). Outside a group nothing changes: the new workspace still goes to the top of the machine section, below Home. afterCurrent and bottom keep their behavior; both already kept a new workspace in its group. docs/configuration.md describes the new rule.
Audit of other create paths:
- Through the same rule, so fixed by this change: āN / New Workspace (
newTab), the sidebar +, the palette,cmux workspace new, agent open (AgentHandlers,AgentSessionWorkspace,AgentTeamsLaunch), open session, a tab moved to a new workspace. - Already pass
.below(id): New Workspace Below (workspace.newBelow) and Duplicate (workspace.duplicate). - Name their own group, unchanged: New Workspace in Group (
workspaceGroup.newWorkspace) and New Group.
Testing
NewWorkspaceInGroupTests builds a section (loose a; group g1 with c, d, e; loose f; new n where the daemon lists it) and places n by the rule, as applyPendingPlacements does: from d with top and afterCurrent it must land right below d in g1; from the group's last member it stays in the group; from a loose workspace it still goes to the top; bottom from a member is the group's last slot.
Command: cmux-ci run --class light --script scripts/ci/package-test-lane.sh --arg=suite --arg=Packages/macOS/CmuxNext --arg=NewWorkspaceInGroupTests (scratch refs that add #22923's one-line import, since base's test target does not compile without it):
- Red, the test with the fix reverted (2b91983):
topfromdgives[n, c, d, e]and fromegives[n, c, d, e]; 2 of 4 tests fail. - Green, head with the fix (2f93483): 4 of 4 pass.
The first version of this test drove the real actions against a same-tree daemon. It never got past its setup: in that harness, a group made through the v2 state store never shows in the window's sidebar. The existing GroupHeaderNewWorkspaceTests.groupHeaderPlusMakesTheNewWorkspaceInThatGroup fails the same way on base; reported to the coordinator as a base finding.
Observed / Not run
- Ran: the red and green fleet runs above;
prepush-gate.py(no new violations); an independent review (PASS; its notes on the docs and the evidence are addressed here). - Not run: the real actions end to end against a daemon (see above), and a live check in a tagged build.
Changelog
Fixed: A new workspace made from inside a sidebar group now opens in that group, right below the current workspace.
Localization: no user-facing strings changed.
š¤ Generated with Claude Code
Agent session: cosmic-gray