Skip to content

Add a collapse-idle action to the sidebar#1210

Draft
ponbac wants to merge 1 commit intopingdotgg:mainfrom
ponbac:collapse-idle
Draft

Add a collapse-idle action to the sidebar#1210
ponbac wants to merge 1 commit intopingdotgg:mainfrom
ponbac:collapse-idle

Conversation

@ponbac
Copy link
Copy Markdown

@ponbac ponbac commented Mar 19, 2026

What Changed

  • Added a Collapse idle projects action to the sidebar header.
  • The action collapses expanded projects that are idle (not the active project and no thread status or running terminal) while keeping the currently active project open.

Why

The sidebar can accumulate a lot of expanded projects during normal use. This adds a one-click cleanup path without collapsing the project you are currently in or other projects that still have visible thread activity.

UI Changes

Video:

screenrecording-2026-03-19_16-33-08.mp4

Sorry that the mouse cursor is not visible in the recording.

Screenshot:

image

Added this tiny icon. Open for suggestions on a more fitting icon.

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

Note

Add a 'Collapse idle projects' button to the sidebar

Adds a FoldVerticalIcon button to the Projects section header in the sidebar. Clicking it collapses all expanded projects that have no running terminals and no active thread status, while keeping the currently active project and any projects with activity expanded. The logic is extracted into a collectSidebarNonIdleProjectIds utility in Sidebar.logic.ts with corresponding tests in Sidebar.logic.test.ts.

📊 Macroscope summarized 7c33165. 3 files reviewed, 1 issue evaluated, 0 issues filtered, 1 comment posted

🗂️ Filtered Issues


Note

Low Risk
Low risk UI change that adds a new sidebar action and supporting helper logic; main risk is minor behavioral/performance regressions in how project “activity” is detected for collapsing.

Overview
Adds a “Collapse idle projects” button to the sidebar Projects header that collapses currently-expanded projects that have no active signal.

Introduces collectSidebarNonIdleProjectIds (with tests) and sidebar wiring to keep the active project, projects with non-null thread status pills, or projects with running terminal threads from being collapsed; includes minor header spacing tweaks and a new FoldVerticalIcon tooltip button.

Written by Cursor Bugbot for commit 7a62228. This will update automatically on new commits. Configure here.

@github-actions github-actions bot added size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 19, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1831722e98

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 19, 2026

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: 2c1ab72b-2add-4ec0-a2b4-ca11746d0621

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.

@ponbac ponbac force-pushed the collapse-idle branch 5 times, most recently from faa7eed to b3123eb Compare March 20, 2026 20:46
@fire17
Copy link
Copy Markdown

fire17 commented Mar 21, 2026

nice touch , hope they merge

@ponbac ponbac force-pushed the collapse-idle branch 2 times, most recently from 8a5469e to 3480f72 Compare March 24, 2026 07:11
@ponbac ponbac force-pushed the collapse-idle branch 6 times, most recently from 5d423b7 to 4a13273 Compare March 30, 2026 06:31
@github-actions github-actions bot added size:M 30-99 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Mar 30, 2026
runningTerminalThreadIds,
}),
[activeProjectId, runningTerminalThreadIds, threadStatusById, threads],
);
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.

Idle detection considers archived threads the sidebar hides

Medium Severity

The nonIdleProjectIds computation (along with threadStatusById and runningTerminalThreadIds) iterates over threads, which includes archived threads. The rest of the sidebar uses visibleThreads (filtered by archivedAt === null). An archived thread with a stale session status like "Working" would mark its project as non-idle, preventing collapse even though no visible activity exists for that project.

Additional Locations (2)
Fix in Cursor Fix in Web

[toggleProject],
);

const handleCollapseIdleProjects = useCallback(() => {
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.

🔴 Critical components/Sidebar.tsx:1846

In handleCollapseIdleProjects, the loop iterates over projects from useStore, but that array contains raw Project objects without an expanded property. Since project.expanded is always undefined, the condition !project.expanded is always true, so the function calls continue for every project and never collapses anything. The loop should iterate over sidebarProjects (which has the expanded snapshot) or check projectExpandedById[project.id] directly.

🤖 Copy this AI Prompt to have your agent fix this:
In file apps/web/src/components/Sidebar.tsx around line 1846:

In `handleCollapseIdleProjects`, the loop iterates over `projects` from `useStore`, but that array contains raw `Project` objects without an `expanded` property. Since `project.expanded` is always `undefined`, the condition `!project.expanded` is always `true`, so the function calls `continue` for every project and never collapses anything. The loop should iterate over `sidebarProjects` (which has the `expanded` snapshot) or check `projectExpandedById[project.id]` directly.

Evidence trail:
- apps/web/src/components/Sidebar.tsx:441 - `projects` from `useStore((store) => store.projects)`
- apps/web/src/types.ts:81-89 - `Project` interface has no `expanded` property
- apps/web/src/components/Sidebar.tsx:168-170 - `SidebarProjectSnapshot = Project & { expanded: boolean }`
- apps/web/src/components/Sidebar.tsx:514-520 - `sidebarProjects` adds `expanded` property from `projectExpandedById`
- apps/web/src/components/Sidebar.tsx:1846-1852 - `handleCollapseIdleProjects` iterates over `projects` and checks `!project.expanded`

Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

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 and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

}
setProjectExpanded(project.id, false);
}
}, [projects, nonIdleProjectIds, setProjectExpanded]);
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 variable makes collapse button a no-op

High Severity

handleCollapseIdleProjects iterates over projects (raw Project[] from the store) which lacks an expanded property. Since project.expanded is always undefined, !project.expanded is always true, the continue always executes, and setProjectExpanded is never called. The button does nothing. The code needs to iterate over sidebarProjects instead, which is Project & { expanded: boolean }.

Fix in Cursor Fix in Web

@juliusmarminge
Copy link
Copy Markdown
Member

i think more proper filters next to the sorting in this menu would be more useful and generalized
CleanShot 2026-03-30 at 23 52 30@2x

@ponbac
Copy link
Copy Markdown
Author

ponbac commented Mar 31, 2026

i think more proper filters next to the sorting in this menu would be more useful and generalized
CleanShot 2026-03-30 at 23 52 30@2x

I agree. But I think this PR (and filtering) might not be as relevant anymore since the sorting was added.

My issue was that active work could appear at the bottom of the list, pushed down by expanded projects I was not currently working on.

What would be some useful filters? Broad "Unread" filter, and maybe more granular ones like only displaying ready plans, running terminals?

Maybe filtering on a thread level would be more useful than project, or both.

@ponbac ponbac marked this pull request as draft March 31, 2026 07:42
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.

3 participants