Skip to content

Collapse all button for projects sidebar#2308

Open
kyziq wants to merge 12 commits into
pingdotgg:mainfrom
kyziq:feat/sidebar-collapse-all-projects
Open

Collapse all button for projects sidebar#2308
kyziq wants to merge 12 commits into
pingdotgg:mainfrom
kyziq:feat/sidebar-collapse-all-projects

Conversation

@kyziq

@kyziq kyziq commented Apr 23, 2026

Copy link
Copy Markdown

What Changed

  • Added "Collapse all" button (ChevronsDownUpIcon) to the Projects section header, alongside the existing sort and add-project buttons
  • Button hidden when no projects exist
  • Button disabled (dimmed) when all projects are already collapsed — visual feedback that the action is a no-op
  • New pure function collapseAllProjects(state, projectIds[]) in uiStateStore — only targets currently visible projects, not stale state entries
  • No-op guard returns same state reference when nothing changes, preventing unnecessary re-renders
  • Three unit tests covering collapse behavior and no-op case

Why

With multiple projects open in the sidebar, collapsing each one individually is tedious. This adds a single-click way to reset the sidebar to a clean state.

UI Changes

Screenshots

Before After
Before After

No project

Will not show the button
CleanShot 2026-04-23 at 23 02 15@2x

Video

Zen.mp4

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Closes #2306


Note

Low Risk
Sidebar-only UI and persisted expand/collapse preferences; no auth, API, or data-model changes beyond local UI state.

Overview
Adds bulk collapse controls to the Projects sidebar header when at least one project is visible.

A new ChevronsDownUp menu offers Collapse all projects (persisted via collapseAllProjects in uiStateStore for currently sorted/visible project keys) and Minimize all thread lists (clears local expandedThreadListsByProject). The trigger and individual items disable when there is nothing left to collapse.

Alt+click on a project header now collapses all projects instead of toggling that row only.

collapseAllProjects is a pure store helper with a no-op when every listed project is already collapsed, plus unit tests for partial and full no-op behavior.

Reviewed by Cursor Bugbot for commit b1e7671. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add collapse-all button to projects sidebar

  • Adds a bulk-collapse menu to Sidebar.tsx that appears when at least one project exists, with two actions: collapse all projects and minimize all thread lists.
  • Menu items are disabled when the corresponding state is already fully collapsed/minimized, derived from projectExpandedById and expandedThreadListsByProject in the UI store.
  • Adds a collapseAllProjects action to uiStateStore.ts that sets specified project IDs to collapsed, returning the original state unchanged if there is nothing to update.
  • Alt+clicking a project header now collapses all projects instead of toggling only that project.

Macroscope summarized b1e7671.

@coderabbitai

coderabbitai Bot commented Apr 23, 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: c2c41f8a-22e4-4f2a-8f0d-6032744eb652

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 and usage tips.

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 23, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Apr 23, 2026
@macroscopeapp

macroscopeapp Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces a new user-facing feature (collapse all menu and alt-click shortcut) rather than a simple fix or refactor. Additionally, there's an unresolved review comment identifying a bug in the alt-click behavior where clicks become no-ops when all projects are already collapsed.

You can customize Macroscope's approvability policy. Learn more.

@juliusmarminge

Copy link
Copy Markdown
Member

what do you tihnk of making this 3 states:

  • minimize all - collapses every project down to the "show less" state
  • collapse all - collapses every project completely
  • disabled - when everything's collapsed

@kyziq

kyziq commented May 5, 2026

Copy link
Copy Markdown
Author

thanks for your reply julius!

looked at vscode, jetbrains, github. all have collapse-all only, no minimize. so my first thought was to keep it simple. but you have a point, minimize-all is actually useful here since projects can hold many threads with overflow, lets you reset it without losing your place

If we want both, I think a dropdown trigger (single header slot) feels cleaner than two adjacent buttons or one single button that does all. what do you think?

@kyziq

kyziq commented May 5, 2026

Copy link
Copy Markdown
Author

prototyped the dropdown:

t3code-05052026.mp4
  • collapse-all enabled when any project is expanded
  • minimize-all enabled when any thread list is expanded
  • trigger enabled when either applies

happy either way. can revert to collapse-all only if you prefer minimal.

@macroscopeapp macroscopeapp Bot dismissed their stale review May 16, 2026 09:15

Dismissing prior approval to re-evaluate 9151a02

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes May 16, 2026
@macroscopeapp macroscopeapp Bot dismissed their stale review June 11, 2026 22:17

Dismissing prior approval to re-evaluate b85ccb3

if (event.altKey) {
collapseAllProjects();
return;
}

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.

Alt-click blocks project toggle

Medium Severity

When a project header is clicked with Alt held, the handler always calls collapseAllProjects() and returns without running toggleProject. If every visible project is already collapsed, collapseAllProjects is a no-op, so the click does nothing—unlike a normal click, which would expand that project.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b85ccb3. Configure here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

intentional, the Alt+click is strictly a collapse-all shortcut, not a toggle

Port collapse-all shortcut from PR pingdotgg#2307 per maintainer request.

Co-authored-by: Bas Milius <978257+basmilius@users.noreply.github.com>
@kyziq kyziq force-pushed the feat/sidebar-collapse-all-projects branch from b85ccb3 to 490c08b Compare June 11, 2026 22:22
() => sortedProjects.every((p) => (projectExpandedById[p.projectKey] ?? true) === false),
[sortedProjects, projectExpandedById],
);
const allThreadListsMinimized = expandedThreadListsByProject.size === 0;

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.

Wrong minimize-all disabled check

Low Severity

allThreadListsMinimized is defined as an empty expandedThreadListsByProject set, but that set can still contain keys when no sidebar row shows “Show less” (for example after raising sidebarThreadPreviewCount, archiving threads, or removing a grouped project). The bulk menu and “Minimize all thread lists” then stay enabled even though no visible thread list is expanded.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 490c08b. Configure here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

pre-existing, not part of this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 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]: Collapse all projects button in sidebar

2 participants