Repository navigation
Keep a collapsed sidebar group folded when the workspace below it closes - #10169
teamleaderleo merged 3 commits into
Conversation
Closing the last workspace walks selection backwards into the tail of the preceding group's member run. `tabs[]` holds every workspace, including members a collapsed group hides, so the fallback can select a workspace that has no sidebar row. That fires the selection auto-expand and unfolds a group the user deliberately collapsed. Lift the fallback out of TabManager.closeWorkspace into WorkspacesModel.selectionTargetAfterClose with its behavior unchanged, so the rule is reachable from the package's tests, and cover it. closingLastWorkspaceSelectsAnchorNotHiddenMemberOfCollapsedGroup and closingLastWorkspaceKeepsPrecedingGroupCollapsed fail on this commit; the expanded-group and non-last-close tests pin the behavior that must not change. CmuxWorkspacesTests was not a CI gate — the package is absent from the swift-test allowlist in ci.yml, so the whole suite never ran. Add it; its dependencies are already headless-resolvable there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Resolve the close-path selection slot to a row the sidebar renders: a non-anchor member of a collapsed group now hands off to its group's anchor instead of being selected directly, so the selection auto-expand no longer unfolds the group. Members of an expanded group have their own rows and are still selected as before. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 1 minute. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: manaflow-ai/cmux/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughWorkspace closing now calculates replacement selection in ChangesWorkspace close selection
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Merge Risk: ⚪ Minimal · up to This PR localizes workspace-close selection to visible sidebar rows and adds regression coverage plus CI inclusion; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 25✅ Passed checks (25 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The swift test package list moved from ci.yml to ci-macos.yml on main, so take main's ci.yml as is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
All contributors have signed the CLA ✍️ ✅ |
|
Merged main in and resolved the ci.yml conflict so this can land (main moved the package test list out of ci.yml, so that line is dropped here and we'll add CmuxWorkspaces to CI separately). One last thing: the CLA check needs your signature, the CLA Assistant comment has the link. Thanks for the really clear write-up :) |
|
I have read the CLA Document v2.2 and I hereby sign the CLA |
|
Merged, thanks @AvoChang :) |
|
Merge receipt for |
2123231 fix(cloud): offer Pi in the cloud agent menu and vm.cloud_agent_open (manaflow-ai#14819) 909fcc7 fix(settings): stop promising a Tailscale QR the pairing window no longer shows (manaflow-ai#14817) 5d2bc04 fix(custom-sidebar): render Menu nodes so context-menu submenus appear (manaflow-ai#14808) 45815f7 Keep a collapsed sidebar group folded when the workspace below it closes (manaflow-ai#10169) 4bf0ea0 perf(shell): stop spawning tmux and rm on every prompt when idle (manaflow-ai#14833) 443d050 perf: skip the per-flush stat and mkdir in the event log writer (manaflow-ai#14828)
Problem
A collapsed sidebar group force-expands when the workspace sitting directly below it is closed.
Cause
The close path's selection fallback indexes into the flat
tabs[]array:tabs[]holds every workspace, including members a collapsed group hides. The sidebar's actual rows are group anchors plus ungrouped workspaces (sidebarTopLevelWorkspaceIds()), so this can select a workspace that has no row.That assignment then runs
selectedTabId'sdidSet→selectedWorkspaceIdDidChange→expandWorkspaceGroupForSelectionIfNeeded(), which sees the selection inside a collapsed group it is not the anchor of, and clearsisCollapsed. The auto-expand is correct in itself — "a selected row must be visible". The defect is selecting an invisible row in the first place.Why it needs the workspace to be last
newIndex = min(index, count - 1):anchorFirst), and the anchor is exempt from the auto-expand — no bug.Since the ordering invariant puts groups above ungrouped-unpinned workspaces, a lone ungrouped workspace under a collapsed group is exactly this shape.
Fix
Resolve the slot's occupant to a row the sidebar renders. A non-anchor member of a collapsed group hands off to its group's anchor; members of an expanded group have their own rows and are selected as before.
This mirrors
toggleWorkspaceGroupCollapsed, which already moves focus to the anchor when collapsing would hide the selected member, andSidebarState.scrollTargetWorkspaceId, which already maps hidden members to the anchor for scrolling.The fallback moved to
WorkspacesModel.selectionTargetAfterClose(closedIndex:)so it is reachable from the package's tests.Commits
Per the regression policy, the test lands first so CI proves it catches the bug:
closingLastWorkspaceSelectsAnchorNotHiddenMemberOfCollapsedGroupclosingLastWorkspaceKeepsPrecedingGroupCollapsed(end-to-end)closingLastWorkspaceSelectsAdjacentMemberOfExpandedGroup(guards over-correction)closingNonLastWorkspaceSelectsTheWorkspaceThatMovedUpAlso:
CmuxWorkspacesTestswas not running in CICmuxWorkspacesis absent from theswift testallowlist in.github/workflows/ci.yml, so that whole suite — including the existing group/reorder coordinator tests — has never been a CI gate. Without adding it, commit 1 could not go red and the regression policy would be vacuous. Its dependencies (CmuxSettings, bonsplit, CMUXDebugLog, CmuxTestSupport) already resolve headlessly in that job.Out of scope
indexis captured beforepromoteAnchorOrRemoveGroupsAnchoredBy, which callsnormalizeWorkspaceGroupContiguityand can reordertabs. On an anchor close the index may not match the post-reorder array. That is pre-existing and untouched here, though the anchor hand-off softens its symptom.Notes
No user-facing strings changed, so there is nothing to localize.
I could not build locally (no Swift toolchain available in my environment), so compilation and the test results rest on CI. Happy to fix up whatever it reports.
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Keeps a collapsed sidebar group folded when the workspace beneath it closes by fixing the close-path selection fallback. Previously, closing the last workspace selected a hidden group member and auto-expanded the group; now it selects the group anchor so the group stays collapsed.
WorkspacesModel.selectionTargetAfterClose(closedIndex:)(inWorkspacesModel+CloseSelection.swift) and calls it fromTabManager's close path.CmuxWorkspacesTestsand adds the package to theswift testallowlist so they run in CI; the list now lives inci-macos.ymlafter merging main.Written for commit 16af016. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests