Skip to content

feat(sidebar): add a bindable collapse / expand all projects command - #37718

Closed
Mahdi-Hasan wants to merge 5 commits into
stablyai:mainfrom
Mahdi-Hasan:feat/sidebar-collapse-all-projects
Closed

Mahdi-Hasan wants to merge 5 commits into
stablyai:mainfrom
Mahdi-Hasan:feat/sidebar-collapse-all-projects

Conversation

@Mahdi-Hasan

@Mahdi-Hasan Mahdi-Hasan commented Nov 3, 2026 •

Copy link
Copy Markdown

ELI5

With many projects in the sidebar, you had to click each arrow to fold them. Now one shortcut folds them all, or unfolds them all.

What Changed

  • New command sidebar.projects.toggleCollapseAll, "Collapse / Expand All Projects", listed under Global in Settings → Keyboard Shortcuts. No default binding.
  • If any visible project or project-group header is expanded, it collapses all. Otherwise it expands all and opens the sidebar.
  • Each header goes through toggleCollapsedGroup, the same action as the chevron click, so persistence and sync behave the same.
  • Works from the terminal under "Orca first", like sidebar.left.toggle. Yields while a modal, overlay, or the floating workspace has focus.
  • project-collapse-all-target.ts works out which header keys to flip from the rendered sidebar rows. Pinned and host sections are left alone.
  • The child-workspaces toggle handler moved into sidebar-group-collapse-shortcuts.ts next to the new handler, to keep app-command-handlers.ts under the max-lines limit. No behavior change there.

Why

  • No existing command changes group collapse state; only the chevron click does.
  • Reusing the chevron action avoids a second write path for collapsedGroups.
  • Unbound by default to avoid shortcut conflicts.

Linked Issue

Fixes #37485

Visual Proof

Taken from the real Electron app (Windows, electron-vite build --mode e2e) driven by a throwaway Playwright script, before = main at 312ce09.

Before (main): no command exists; each project only folds from its own chevron.

Before: all projects expanded

After: the command in Settings → Shortcuts, bound here to Ctrl+Alt+K for the demo (unbound by default).

After: shortcut row

After: one press of the shortcut folds every project. Pressing it again expands them all.

After: all projects collapsed

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • New app-command-handlers-project-collapse-all.test.ts (5 tests against the real store) and an unbound/terminal-match case in keybindings-unassigned-actions.test.ts.

  • vitest over app-shell: all pass except 2 in worktree-creation-chat-handoff.test.tsx, which fail the same way on clean main.

  • Full typecheck: pass. oxlint and oxfmt --check on changed files: pass.

  • Tested on Windows only.

Risk

Level: Low

  • Only acts when the sidebar is grouped by project. In status or PR grouping the key passes through.
  • Toggles each header separately, so N projects means N UI-state writes in one tick.
  • Non-English locale strings are machine-translated.
  • Back out: plain revert. Users who bound the command lose the binding.

AI Disclosure

Written with Claude Code (Claude Opus 5.5). I reviewed the diff and the test results.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

Adds the sidebar.projects.toggleCollapseAll global keybinding action with no default platform binding and localized labels. The shortcut resolves eligible project groups, then collapses all when any eligible group is expanded or expands them when none are expanded. Shared shortcut handlers check modal, focus, overlay, and menu conditions and toggle group state. The command handler also delegates child-workspace toggling to the shared handlers. Tests cover toggle behavior, shortcut yielding, persisted state, and terminal notification.

Severity of issue fixed: Medium

Merge Risk: Low · up to 59dca

The shortcut can skip placeholder-only groups or choose the wrong direction. Manual controls remain available; this is suitable for a bounded follow-up.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: adding a bindable command to collapse or expand all sidebar projects.
Linked Issues check Passed Issue #37485 requires a bindable global command for the project-chevron action. The PR adds sidebar.projects.toggleCollapseAll under the Global scope with no default binding. `resolveProjectCollapse…
Out of Scope Changes check Passed The changes stay within issue #37485. Command metadata, localization, shortcut dispatch, target resolution, and automated tests implement the requested command. The child-workspaces handler move is a …
Description check Passed The description is mostly complete. It explains the change, links an issue, provides visual proof, and describes testing and risk. Testing lacks reproducible steps and does not confirm that each added…
Full details: Linked Issues check

Explanation

Issue #37485 requires a bindable global command for the project-chevron action. The PR adds sidebar.projects.toggleCollapseAll under the Global scope with no default binding. resolveProjectCollapseAllToggleKeys selects rendered project and project-group headers, collapses all when any selected header is expanded, and otherwise expands them. toggleSidebarGroups calls store.toggleCollapsedGroup for each key, which reuses the chevron action. The handler supports terminal use through the global keybinding path and yields for modal, overlay, floating-workspace, and owning-menu focus. The added tests cover the collapse, expand, visibility, grouping, and terminal cases.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #37485. Command metadata, localization, shortcut dispatch, target resolution, and automated tests implement the requested command. The child-workspaces handler move is a supporting refactor. Its behavior remains in the shared sidebar shortcut handler, with the existing gating, group toggle, sidebar opening, and scroll-anchor logic preserved. No unrelated functional change is shown.

Full details: Description check

Explanation

The description is mostly complete. It explains the change, links an issue, provides visual proof, and describes testing and risk. Testing lacks reproducible steps and does not confirm that each added test fails without the change.

Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 8 functions across 9 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Mahdi-Hasan and others added 2 commits November 4, 2026 16:28
Adds sidebar.projects.toggleCollapseAll, listed under Global with no
default binding. If any visible project header is expanded it collapses
every project and project-group header; otherwise it expands them all.
It only claims the chord when the sidebar is grouped by project.

Each header flips through toggleCollapsedGroup, the chevron's own action.
The child-workspaces toggle now shares the same guard and toggle code.

Closes stablyai#37485

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Mahdi-Hasan
Mahdi-Hasan force-pushed the feat/sidebar-collapse-all-projects branch from ca04b75 to c5fb807 Compare November 4, 2026 10:30

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 31813b8c-40d6-4526-91ca-7f15c66842dd
Commits

Reviewing files that changed from the base of the PR and between ca04b75 and c5fb807.

Files selected for processing: 16
  • src/renderer/src/app-shell/app-command-handlers-project-collapse-all.test.ts
  • src/renderer/src/app-shell/app-command-handlers.ts
  • src/renderer/src/app-shell/sidebar-group-collapse-shortcuts.ts
  • src/renderer/src/components/settings/shortcuts/keybinding-title-copy.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/project-collapse-all-target.ts
  • src/renderer/src/i18n/locales/de.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/ru.json
  • src/renderer/src/i18n/locales/tr.json
  • src/renderer/src/i18n/locales/zh-Hant.json
  • src/renderer/src/i18n/locales/zh.json
Files with no reviewable changes: 1
  • src/renderer/src/app-shell/app-command-handlers.ts
Files skipped from review as they are similar to previous changes: 11
  • src/renderer/src/i18n/locales/de.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/tr.json
  • src/renderer/src/i18n/locales/zh-Hant.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ru.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

The key pass for collapse / expand all cleared every collapsed group,
host sections included. It could then flip projects hidden under a
collapsed host. Only project and project-group keys are cleared now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 97b4bc25-d42e-4824-ae96-3996c5e2efe8
Commits

Reviewing files that changed from the base of the PR and between c5fb807 and df824f7.

Files selected for processing: 2
  • src/renderer/src/app-shell/app-command-handlers-project-collapse-all.test.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/project-collapse-all-target.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

A collapsed project group shows a global header. Expanding it for the
second planning pass can move that header under a collapsed host, where
it drops out, so expand-all left the visible group collapsed. The target
set now also keeps the keys from the currently visible headers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Include placeholder repos in the target rows. · project-collapse-all-target.ts:17

src/renderer/src/components/sidebar/worktree-list/listing/project-collapse-all-target.ts:17
Minor · Functional Correctness · Quick win

Include placeholder repos in the target rows.

useSidebarSectionRows includes placeholder repos, but computeRenderedSidebarRows omits them. A project group containing only a repo with no visible worktrees therefore has a chevron in the sidebar but a count of zero here. The shortcut ignores that group and can choose the wrong toggle direction. Build target rows with the sidebar’s placeholder inputs. (raw.githubusercontent.com)

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9dc3b9b7-9027-46d0-8280-e78111374ba8
Commits

Reviewing files that changed from the base of the PR and between df824f7 and 59dca58.

Files selected for processing: 2
  • src/renderer/src/app-shell/app-command-handlers-project-collapse-all.test.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/project-collapse-all-target.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

The sidebar builds rows with empty-project placeholders, so a project
group whose projects have no workspaces still gets a chevron. The
collapse-all target rows left them out, gave that group a count of 0,
and skipped it. computeRenderedSidebarRows now takes an opt-in
includeEmptyProjects flag, and the collapse-all target uses it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Mahdi-Hasan

Copy link
Copy Markdown
Author

@coderabbitai Fixed the outside-diff finding (project-collapse-all-target.ts:17, placeholder repos) in e2ce55e.

  • computeRenderedSidebarRows takes an opt-in includeEmptyProjects flag. It builds the same empty-project placeholders as useSidebarSectionRows (host-filtered repos, getEmptyProjectPlaceholderRepoIds).
  • The collapse-all target uses it, so a project group with only empty projects counts and is toggled.
  • The other caller (child-workspace toggle) reads item rows only and keeps the default.

Regression test collapses a project group whose only project has no workspaces fails without the fix. Typecheck, oxlint, oxfmt, and the sidebar + app-shell suites pass.

@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

Analysis chain

Script executed:

#!/bin/bash
set -euo pipefail
fd -t f '^project-collapse-all-target\.ts$' --exec ast-grep outline {}
fd -t f '^project-collapse-all-target\.ts$' --exec sed -n '1,180p' {}
rg -n -C 10 --type ts --type tsx 'includeEmptyProjects|collapses a project group whose only project has no workspaces' src/renderer/src

Length of output: 3263


Script executed:

#!/bin/bash
set -euo pipefail
fd -t f '^rendered-sidebar-worktree-order\.ts$' --exec ast-grep outline {}
fd -t f '^rendered-sidebar-worktree-order\.ts$' --exec sed -n '1,250p' {}
rg -n -C 22 -g '*.ts' -g '*.tsx' 'collapses a project group whose only project has no workspaces' src/renderer/src
rg -n -C 5 -g '*.ts' -g '*.tsx' 'getEmptyProjectPlaceholderRepoIds|computeRenderedSidebarRows\(' src/renderer/src/components/sidebar

Length of output: 41838


@Mahdi-Hasan Thanks for the fix. Source inspection confirms that collapse-all now includes empty-project placeholders from host-filtered repos. The child-workspace toggle retains the default behavior.

The regression test covers the reported case and asserts that the project group collapses. This addresses the placeholder-repo finding. I did not rerun the checks; the passing results are from your report.


Learnings used
Learnt from: Jinwoo-H
Repo: stablyai/orca PR: 28997
File: mobile/src/host-screen/workspace-option-controls.tsx:0-0
Timestamp: 2026-10-15T22:17:27.950Z
Learning: In this TypeScript/React codebase, `src/renderer/src/components/sidebar/worktree-card-option-items.tsx` selects “Branch / folder path” when `projectGroups.length > 0`, independently of the Group by choice. The phone does not receive the project group list. A host lists folder workspaces only under project groups, so `mobile/src/host-screen/workspace-option-controls.tsx` can use the presence of any folder workspace row as a proxy. This proxy cannot detect project groups that contain no folder workspaces.

If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

You are interacting with an AI system.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add a bindable "Collapse / expand all projects" command for the left sidebar

1 participant