Skip to content

feat(web): add file tree expansion toggle#4273

Open
StiensWout wants to merge 5 commits into
pingdotgg:mainfrom
StiensWout:feat/collapse-expand-file-tree
Open

feat(web): add file tree expansion toggle#4273
StiensWout wants to merge 5 commits into
pingdotgg:mainfrom
StiensWout:feat/collapse-expand-file-tree

Conversation

@StiensWout

@StiensWout StiensWout commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add one compact, state-aware expand/collapse control to the workspace file explorer
  • keep the control synchronized with individual directory expansion state
  • apply bulk expansion in one tree-model reset instead of emitting once per folder
  • disable the bulk action while file search owns temporary expansion state
  • avoid resets for empty trees and folders already in the requested state

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.ts
  • vp run --filter @t3tools/web typecheck
  • vp fmt apps/web/src/components/files/FileBrowserPanel.tsx apps/web/src/components/files/fileTreeExpansion.ts apps/web/src/components/files/fileTreeExpansion.test.ts --check
  • git diff --check
  • integrated web verification: paired successfully, confirmed one toggle, and exercised Collapse → Expand → Collapse on a populated workspace tree

Image

image image

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 fileTreeExpansion helper that tracks expansion state (expanded, collapsed, mixed, searching, empty) and applies bulk changes via a single resetPaths with initialExpandedPaths instead 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-one initialExpandedPaths so default open folders match the old initialExpansion: 1 behavior 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

  • Adds a toggle button in the FileBrowserPanel header that expands or collapses all directories at once, using new utilities in fileTreeExpansion.ts.
  • The button renders ChevronsUpDown or ChevronsDownUp based on current expansion state, which is tracked via useSyncExternalStore and classified as collapsed, expanded, mixed, empty, or searching.
  • The button is disabled when the tree is empty or a search is active; clicking calls setAllDirectoriesExpanded, which batch-resets expansion via model.resetPaths.
  • Behavioral Change: FileTree initial expansion switches from a numeric depth (1) to "closed" with depth-one paths supplied via initialExpandedPaths on reset, preserving the same visual default.

Macroscope summarized 1bd7545.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: aafa1717-b3f1-44b2-8c4a-f0c3c093816d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jul 22, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/web/src/components/files/fileTreeExpansion.ts
@macroscopeapp

macroscopeapp Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

@StiensWout
StiensWout marked this pull request as draft July 22, 2026 14:45
@StiensWout StiensWout changed the title feat(web): add file tree expansion controls feat(web): add file tree expansion toggle Jul 22, 2026
@StiensWout
StiensWout marked this pull request as ready for review July 22, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Button to expand/collapse folders in the file surface

1 participant