feat(web): add file tree expansion toggle#4273
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e8a976f. Configure here.
ApprovabilityVerdict: Needs human review This PR adds a new user-facing feature (expand/collapse all folders toggle) to the file browser. While well-tested and self-contained, new user-facing functionality warrants human review to ensure the UX matches expectations. You can customize Macroscope's approvability policy. Learn more. |

Summary
Rationale
Large workspace trees currently require closing directories one at a time. The state-aware control provides a small, predictable way to reset or inspect the full tree without changing existing per-directory or initial-expansion behavior.
The bulk operation rebuilds the existing path set with the requested expansion set in one model emission, keeping the operation linear for large indexed workspaces. A 2,000-directory regression test asserts one emission and at most two item reads per directory across the precheck and subscribed state update.
Closes #4227.
Validation
vp test run src/components/files/fileTreeExpansion.test.ts(9 tests passed)vp lint --report-unused-disable-directives apps/web/src/components/files/FileBrowserPanel.tsx apps/web/src/components/files/fileTreeExpansion.ts apps/web/src/components/files/fileTreeExpansion.test.tsvp run --filter @t3tools/web typecheckvp fmt apps/web/src/components/files/FileBrowserPanel.tsx apps/web/src/components/files/fileTreeExpansion.ts apps/web/src/components/files/fileTreeExpansion.test.ts --checkgit diff --checkImage
Note
Low Risk
UI-only file explorer behavior with well-tested expansion helpers; no auth, data, or API surface changes.
Overview
Adds Collapse all and Expand all toolbar buttons to the workspace file explorer, wired to a new
fileTreeExpansionhelper that tracks expansion state (expanded,collapsed,mixed,searching,empty) and applies bulk changes via a singleresetPathswithinitialExpandedPathsinstead of per-folder toggles.Button enablement follows that snapshot: both are off while search is open or the tree is empty; collapse/expand only when the action would change anything. Path refreshes now reset with
initialExpansion: "closed"plus explicit depth-oneinitialExpandedPathsso default open folders match the oldinitialExpansion: 1behavior while bulk operations stay batched.Unit tests cover path normalization, parity with the old initial expansion, no-ops when already fully expanded/collapsed, search guardrails, and a 2k-folder regression for a single model emission.
Reviewed by Cursor Bugbot for commit e487f19. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add expand/collapse all folders toggle to file browser panel
FileBrowserPanelheader that expands or collapses all directories at once, using new utilities infileTreeExpansion.ts.ChevronsUpDownorChevronsDownUpbased on current expansion state, which is tracked viauseSyncExternalStoreand classified ascollapsed,expanded,mixed,empty, orsearching.setAllDirectoriesExpanded, which batch-resets expansion viamodel.resetPaths.FileTreeinitial expansion switches from a numeric depth (1) to"closed"with depth-one paths supplied viainitialExpandedPathson reset, preserving the same visual default.Macroscope summarized 1bd7545.