Keep pinned workspace groups when their last workspace closes
Merged
AU
3mo ago+2583+2583+0123456789012345678901234567890123456789-372-372-012345678901234567890123456789
Closes #10560
Root cause
Workspace groups were lifecycle-owned by a real member workspace. The close-path anchor fixup removed the group when that member was the last one, and session persistence/sidebar rendering had no representation for a memberless group.
Fix
- Give group anchors an explicit live/empty state with a stable header identity.
- Keep pinned groups as header-only groups when their last workspace closes; unpinned groups retain their existing dissolve behavior.
- Render and reorder empty pinned headers, promote the first workspace added or dropped into one, and keep explicit Delete Group as the destructive removal path (including confirmation in the sidebar).
- Persist and restore pinned empty groups, including crash-pruning and autosave fingerprint coverage.
- Add an empty-group drop resolver path.
Verification
- Regression test commit first:
0bcc843762(fails on the parent). - Fix commit:
fdab2a91ad. swift test --package-path Packages/macOS/CmuxWorkspaces(210 tests passed).- Focused
swift test --package-path Packages/macOS/CmuxFoundation --filter droppingWorkspaceOnEmptyGroupHeaderProducesExplicitGroupPlanpassed. python3 scripts/check-package-resolved-policy.py,./scripts/lint-pbxproj-test-wiring.sh, and./scripts/check-pbxproj.shpassed.
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Keeps pinned workspace groups when their last workspace closes by introducing an explicit live/empty anchor. Previously the last member closing dissolved the group; now pinned groups persist as header-only until explicitly deleted, while unpinned groups still dissolve.
- Introduces
WorkspaceGroupAnchorand addsWorkspaceGroup.isEmptyandliveAnchorWorkspaceId.anchorWorkspaceIdremains as a stable header identity. - Sidebar renders and reorders empty pinned group headers. Dropping a workspace on an empty header assigns it to that group and promotes it to anchor.
- Ungroup does not remove an empty pinned group; use Delete Group (with confirmation) or unpin then ungroup.
- Session and crash persistence keep empty pinned groups (
anchorIsEmptyin snapshots). Older snapshots still load, and autosave/crash-prune paths preserve these headers. - Selection, unread, and notification actions no-op on empty anchors. Ordering keeps empty headers in place; anchor-close promotes a member or transitions pinned groups to empty.
- Updates span
CmuxWorkspaces(model, coordinators, rendering, persistence) andCmuxFoundation(sidebar drop planning/tests).
Migration
- When you need a live anchor, use
liveAnchorWorkspaceIdand handlenil. Build anchor-id sets withcompactMap. - Guard read/unread/notification actions behind
liveAnchorWorkspaceIdpresence. - Emit
isEmptyinSidebarWorkspaceReorderGroupSnapshotand expect an explicit-group reorder plan when dropping onto an empty header.
Summary by CodeRabbit
-
New Features
- Pinned workspace groups remain visible as header-only groups after their last workspace closes.
- Empty groups can be restored, displayed, reordered, and populated with new workspaces.
- Empty group headers support drag-and-drop reordering across sidebar views.
- Empty-group state is preserved across mobile synchronization and session restoration.
- Empty pinned groups can be deleted without closing workspaces.
-
Bug Fixes
- Improved handling of stale or missing group anchors.
- Prevented ungrouping pinned empty groups; use Delete Group instead.
- Added localized guidance for this restriction.
-
Tests
- Added coverage for persistence, rendering, restoration, and drag-and-drop behavior.