Skip to content

feat(desktop): ⌘⇧E collapses / expands all sidebar projects - #89487

Closed
leighton-tidwell wants to merge 2 commits into
NousResearch:mainfrom
leighton-tidwell:feat/desktop-collapse-projects-shortcut
Closed

leighton-tidwell wants to merge 2 commits into
NousResearch:mainfrom
leighton-tidwell:feat/desktop-collapse-projects-shortcut

Conversation

@leighton-tidwell

@leighton-tidwell leighton-tidwell commented Aug 18, 2026 •

Copy link
Copy Markdown

What

Binds the sidebar's Collapse all / Expand all to ⌘⇧E (Ctrl+Shift+E off macOS), and surfaces the hint on the menu row that already runs it.

Today that action is mouse-only: open the filter menu, then click the row. With more projects than fit on screen it's the action you reach for most often and the slowest one to get to.

The chord

⌘⇧E is the explorer mnemonic — VS Code's ⌘⇧E focuses the explorer tree — and it was unclaimed in KEYBIND_ACTIONS. A test asserts nothing else ships the same default, since a duplicate would read as a permanent conflict in the keybinds panel and make one of the two actions unreachable.

It's a normal rebindable action: it appears in the shortcuts panel under View, and the menu hint reads from useKeybindHint so a rebind is reflected there rather than hardcoding ⌘⇧E.

Shape

The toggle moves into toggleAllProjectsCollapsed in the projects store, so the menu row and the hotkey run the same code instead of drifting. It keeps every rule the menu already had:

  • only the project rows fold — sweeping Pinned and Cron shut alongside them is not what "collapse all" means here;
  • the lanes underneath keep their own state, so re-opening a project shows it as you left it;
  • it's a no-op under a grouping that puts no project rows on screen, so the key can't write state you can't see.

No new core tool, no new env var, no new config surface — one row in the existing keybind registry, one handler, one shared store function.

Proof

Real running desktop (npm run dev, driven over CDP), not a mock.

The menu row with its live hint:

Filter menu showing "Collapse all ⌘⇧E"

Before ⌘⇧E / after ⌘⇧E — and pressing it again restored the expanded state:

Expanded After ⌘⇧E
Projects expanded Projects collapsed

Tests

Behavior contracts, not snapshots — store/projects.test.ts covers collapse, expand-back, nested lanes surviving the fold, and the non-project-grouping no-op; lib/keybinds/actions.test.ts covers registration, the English label, and the no-collision invariant.

npx vitest run                 # 629 files, 6264 passed | 2 skipped
npx tsc -p . --noEmit          # clean
npx eslint <changed files>     # clean

Related open PRs

I checked for duplicates before opening this: no issue requests it, and no PR (open, merged, or closed) implements a collapse/expand shortcut. Three open PRs touch filter-menu.tsx, none overlapping in purpose — #86196 (saved sidebar views) and #88123 (manual session ordering) are independent.

One merge-order note: #85952 (i18n for the filter menu) edits the same line this PR does, swapping the literals for f.expandAll / f.collapseAll. The changes are complementary — that PR localizes the label, this one appends a shortcut hint beside it — but whichever merges second takes a one-line conflict. Resolution is to keep their localized label AND the <DropdownMenuShortcut> sibling:

{projectsCollapsed ? f.expandAll : f.collapseAll}
{collapseHint && <DropdownMenuShortcut>{collapseHint}</DropdownMenuShortcut>}

Happy to rebase onto whichever lands first.

AI was used for the purposes of this PR

@alt-glitch alt-glitch added type/feature New feature or request comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have labels Aug 18, 2026
@Enough1122

Copy link
Copy Markdown

AI code review — automated review for reference; please use your judgment.

No blocking issues found.

  • nit: the menu row still renders hardcoded 'Expand all' : 'Collapse all' literals while the shortcut hint is keybind-driven — already flagged by the author as the fix(desktop): localize sidebar filter menu strings (i18n) #85952 (filter-menu i18n) merge-order conflict; resolution described there looks right.
  • nit: view.toggleProjects gets an English label in en.ts only; confirm missing keys fall back to en in other locales so the shortcuts panel doesn't render a raw id.
  • Behavior contracts in both test files are the right shape (collapse/expand round-trip, lane state preservation, grouping no-op, chord-collision invariant) — no snapshot or source-reading antipatterns.

@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 70c8fff to dabd151 Compare August 24, 2026 15:05
@leighton-tidwell

Copy link
Copy Markdown
Author

AI was used to generate the below response and fixes that corresponds

Rebased onto current main (057dcdf23). The conflict is resolved and the PR is mergeable again. Both review nits are addressed below.

Valid, fixed — view.toggleProjects had no label outside en (dabd151c5)

This one was a real bug, so I checked it rather than assuming the fallback covered it.

keybind-settings.tsx:203 resolves labels with k.actions[action.id] ?? action.label ?? action.id, and keybinds.actions is typed Record<string, string> (i18n/types.ts:306), so a missing key is invisible to tsc. The view.toggleProjects entry carries no label of its own (keybinds/actions.ts:138), so the raw id is the last rung. ar.ts, ja.ts and zh-hant.ts are built with defineLocale, which merges overrides over en (define-locale.ts:39), so they inherited the English string. zh.ts is a full Translations literal and inherited nothing.

Enumerating TRANSLATIONS at runtime confirmed it:

en       -> Collapse / expand all projects
zh       -> *** UNDEFINED (renders raw id) ***
zh-hant  -> Collapse / expand all projects
ja       -> Collapse / expand all projects
ar       -> Collapse / expand all projects

Chinese users would have seen the literal string view.toggleProjects in the shortcuts panel. Added the zh label, plus a contract test asserting every shipped locale resolves the key to real text rather than the action id. Removing the zh line again fails it with zh is missing a view.toggleProjects label, so it covers the next locale too.

Design decision — deferring the hardcoded label to the author

The 'Expand all' : 'Collapse all' literals at filter-menu.tsx:403 are unchanged. That line belongs to #85952's i18n pass, and merge order between these two PRs is the author's call, not something to settle here. The rebase left the resolution exactly as described in the PR description: localized label plus the <DropdownMenuShortcut> sibling.

Verification (worktree on 057dcdf23 + these two commits)

npx vitest run          # 710 files, 7375 passed | 3 skipped
npx tsc -p . --noEmit   # clean
npx eslint <8 changed files>   # clean

@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from dabd151 to 4130c46 Compare August 24, 2026 17:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 4130c46 to 99658ba Compare August 24, 2026 18:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 99658ba to 15a0d96 Compare August 24, 2026 19:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 15a0d96 to e5ec889 Compare August 24, 2026 20:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch 2 times, most recently from 82f88d5 to b7817ee Compare August 24, 2026 22:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from b7817ee to 937f5e1 Compare August 24, 2026 23:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 937f5e1 to 9bc193d Compare August 25, 2026 02:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch 2 times, most recently from 7a20c1c to 21eb102 Compare August 25, 2026 04:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 21eb102 to b6af47e Compare August 25, 2026 05:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from b6af47e to 3677b1f Compare August 25, 2026 07:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 596c1c0 to e1f717e Compare August 25, 2026 20:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from e1f717e to 529730f Compare August 25, 2026 21:11
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 529730f to 50d7dac Compare August 25, 2026 22:02
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 50d7dac to 4691d30 Compare August 25, 2026 23:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 4691d30 to 8014a50 Compare August 26, 2026 00:02
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 8014a50 to 9834a1a Compare August 26, 2026 04:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch 2 times, most recently from 056ed55 to 17c2575 Compare August 26, 2026 06:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 17c2575 to 35668c4 Compare August 26, 2026 07:02
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 35668c4 to 01395d4 Compare August 26, 2026 08:02
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch 2 times, most recently from bd43247 to 2738a29 Compare August 26, 2026 11:02
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 2738a29 to 6d9d0c0 Compare August 26, 2026 12:01
@leighton-tidwell
leighton-tidwell force-pushed the feat/desktop-collapse-projects-shortcut branch from 6d9d0c0 to a5817b2 Compare August 26, 2026 13:02
leighton-tidwell and others added 2 commits August 31, 2026 10:00
The sidebar's "Collapse all" / "Expand all" was mouse-only: open the
filter menu, then click the row. With more projects than fit on screen
that's the one action you want most often and the slowest one to reach.

Bind it to ⌘⇧E — the explorer mnemonic (VS Code's ⌘⇧E focuses the
explorer tree), and an unclaimed chord here; a test asserts no other
action ships the same default, since a duplicate would read as a
permanent conflict in the keybinds panel and make one of the two
unreachable.

The toggle itself moves into `toggleAllProjectsCollapsed` in the
projects store so the menu row and the hotkey run the same code rather
than drifting. It keeps the menu's existing rules: only the project rows
fold (Pinned and Cron are not what "collapse all" means here), their
lanes underneath keep their own state, and it is a no-op under a
grouping that puts no project rows on screen — so the key can't write
state the user cannot see.

The menu row now renders the live keybind hint beside it, so the
shortcut is discoverable from the place people already use, and it
tracks a rebind instead of hardcoding ⌘⇧E.
Review nit on NousResearch#89487: `view.toggleProjects` shipped an English label in
`en.ts` only, and the shortcuts panel resolves labels through
`k.actions[action.id] ?? action.id`.

Locales built with `defineLocale` merge over `en`, so ar, ja and zh-hant
inherited the English string. `zh.ts` is a full `Translations` literal
rather than a `defineLocale` call, so it inherited nothing and the panel
rendered the raw id `view.toggleProjects` to Chinese users. The
`actions` map is typed `Record<string, string>`, so the missing key was
invisible to `tsc`.

Add the zh string, and cover every shipped locale with a contract test
that asserts the label resolves to real text rather than the action id —
which is the failure a future locale would reproduce.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants