-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Collapse all button for projects sidebar #2308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
942b841
2c31cbe
71f2ffa
3c1b592
82362d4
3e67353
9151a02
36bb93d
705e812
9bc58d9
490c08b
b1e7671
d84ffbc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { | |
| ArchiveIcon, | ||
| ArrowUpDownIcon, | ||
| ChevronRightIcon, | ||
| ChevronsDownUpIcon, | ||
| CloudIcon, | ||
| FolderPlusIcon, | ||
| Globe2Icon, | ||
|
|
@@ -128,6 +129,7 @@ import { Input } from "./ui/input"; | |
| import { | ||
| Menu, | ||
| MenuGroup, | ||
| MenuItem, | ||
| MenuPopup, | ||
| MenuRadioGroup, | ||
| MenuRadioItem, | ||
|
|
@@ -957,6 +959,7 @@ interface SidebarProjectItemProps { | |
| attachThreadListAutoAnimateRef: (node: HTMLElement | null) => void; | ||
| expandThreadListForProject: (projectKey: string) => void; | ||
| collapseThreadListForProject: (projectKey: string) => void; | ||
| collapseAllProjects: () => void; | ||
| dragInProgressRef: React.RefObject<boolean>; | ||
| suppressProjectClickAfterDragRef: React.RefObject<boolean>; | ||
| suppressProjectClickForContextMenuRef: React.RefObject<boolean>; | ||
|
|
@@ -977,6 +980,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec | |
| attachThreadListAutoAnimateRef, | ||
| expandThreadListForProject, | ||
| collapseThreadListForProject, | ||
| collapseAllProjects, | ||
| dragInProgressRef, | ||
| suppressProjectClickAfterDragRef, | ||
| suppressProjectClickForContextMenuRef, | ||
|
|
@@ -1282,10 +1286,15 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec | |
| if (useThreadSelectionStore.getState().hasSelection()) { | ||
| clearSelection(); | ||
| } | ||
| if (event.altKey) { | ||
| collapseAllProjects(); | ||
| return; | ||
| } | ||
| toggleProject(project.projectKey); | ||
| }, | ||
| [ | ||
| clearSelection, | ||
| collapseAllProjects, | ||
| dragInProgressRef, | ||
| project.projectKey, | ||
| suppressProjectClickAfterDragRef, | ||
|
|
@@ -2614,6 +2623,10 @@ interface SidebarProjectsContentProps { | |
| suppressProjectClickForContextMenuRef: React.RefObject<boolean>; | ||
| attachProjectListAutoAnimateRef: (node: HTMLElement | null) => void; | ||
| projectsLength: number; | ||
| allProjectsCollapsed: boolean; | ||
| allThreadListsMinimized: boolean; | ||
| collapseAllProjects: () => void; | ||
| minimizeAllThreadLists: () => void; | ||
| } | ||
|
|
||
| const SidebarProjectsContent = memo(function SidebarProjectsContent( | ||
|
|
@@ -2655,6 +2668,10 @@ const SidebarProjectsContent = memo(function SidebarProjectsContent( | |
| suppressProjectClickForContextMenuRef, | ||
| attachProjectListAutoAnimateRef, | ||
| projectsLength, | ||
| allProjectsCollapsed, | ||
| allThreadListsMinimized, | ||
| collapseAllProjects, | ||
| minimizeAllThreadLists, | ||
| } = props; | ||
|
|
||
| const handleProjectSortOrderChange = useCallback( | ||
|
|
@@ -2746,6 +2763,45 @@ const SidebarProjectsContent = memo(function SidebarProjectsContent( | |
| onProjectGroupingModeChange={handleProjectGroupingModeChange} | ||
| onThreadPreviewCountChange={handleThreadPreviewCountChange} | ||
| /> | ||
| {projectsLength > 0 && ( | ||
| <Menu> | ||
| <Tooltip> | ||
| <TooltipTrigger | ||
| render={ | ||
| <MenuTrigger | ||
| aria-label="Bulk collapse actions" | ||
| data-testid="sidebar-bulk-collapse-menu" | ||
| disabled={allProjectsCollapsed && allThreadListsMinimized} | ||
| className="inline-flex size-5 cursor-pointer items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-muted-foreground/60" | ||
| /> | ||
| } | ||
| > | ||
| <ChevronsDownUpIcon className="size-3.5" /> | ||
| </TooltipTrigger> | ||
| <TooltipPopup side="right">Collapse options</TooltipPopup> | ||
| </Tooltip> | ||
| <MenuPopup align="end" side="bottom" className="min-w-44"> | ||
| <MenuGroup> | ||
| <MenuItem | ||
| disabled={allProjectsCollapsed} | ||
| onClick={collapseAllProjects} | ||
| data-testid="sidebar-collapse-all-projects" | ||
| className="min-h-7 py-1 sm:text-xs" | ||
| > | ||
| Collapse all projects | ||
| </MenuItem> | ||
| <MenuItem | ||
| disabled={allThreadListsMinimized} | ||
| onClick={minimizeAllThreadLists} | ||
| data-testid="sidebar-minimize-all-threads" | ||
| className="min-h-7 py-1 sm:text-xs" | ||
| > | ||
| Minimize all thread lists | ||
| </MenuItem> | ||
| </MenuGroup> | ||
| </MenuPopup> | ||
| </Menu> | ||
| )} | ||
| <Tooltip> | ||
| <TooltipTrigger | ||
| render={ | ||
|
|
@@ -2796,6 +2852,7 @@ const SidebarProjectsContent = memo(function SidebarProjectsContent( | |
| attachThreadListAutoAnimateRef={attachThreadListAutoAnimateRef} | ||
| expandThreadListForProject={expandThreadListForProject} | ||
| collapseThreadListForProject={collapseThreadListForProject} | ||
| collapseAllProjects={collapseAllProjects} | ||
| dragInProgressRef={dragInProgressRef} | ||
| suppressProjectClickAfterDragRef={suppressProjectClickAfterDragRef} | ||
| suppressProjectClickForContextMenuRef={ | ||
|
|
@@ -2828,6 +2885,7 @@ const SidebarProjectsContent = memo(function SidebarProjectsContent( | |
| attachThreadListAutoAnimateRef={attachThreadListAutoAnimateRef} | ||
| expandThreadListForProject={expandThreadListForProject} | ||
| collapseThreadListForProject={collapseThreadListForProject} | ||
| collapseAllProjects={collapseAllProjects} | ||
| dragInProgressRef={dragInProgressRef} | ||
| suppressProjectClickAfterDragRef={suppressProjectClickAfterDragRef} | ||
| suppressProjectClickForContextMenuRef={suppressProjectClickForContextMenuRef} | ||
|
|
@@ -2854,6 +2912,7 @@ export default function Sidebar() { | |
| const projectExpandedById = useUiStateStore((store) => store.projectExpandedById); | ||
| const projectOrder = useUiStateStore((store) => store.projectOrder); | ||
| const reorderProjects = useUiStateStore((store) => store.reorderProjects); | ||
| const collapseAllProjectsAction = useUiStateStore((store) => store.collapseAllProjects); | ||
| const navigate = useNavigate(); | ||
| const pathname = useLocation({ select: (loc) => loc.pathname }); | ||
| const isOnSettings = pathname.startsWith("/settings"); | ||
|
|
@@ -3132,6 +3191,17 @@ export default function Sidebar() { | |
| visibleThreads, | ||
| ]); | ||
| const isManualProjectSorting = sidebarProjectSortOrder === "manual"; | ||
| const handleCollapseAllProjects = useCallback(() => { | ||
| collapseAllProjectsAction(sortedProjects.map((p) => p.projectKey)); | ||
| }, [collapseAllProjectsAction, sortedProjects]); | ||
| const handleMinimizeAllThreadLists = useCallback(() => { | ||
| setExpandedThreadListsByProject((current) => (current.size === 0 ? current : new Set())); | ||
| }, []); | ||
| const allProjectsCollapsed = useMemo( | ||
| () => sortedProjects.every((p) => (projectExpandedById[p.projectKey] ?? true) === false), | ||
| [sortedProjects, projectExpandedById], | ||
| ); | ||
| const allThreadListsMinimized = expandedThreadListsByProject.size === 0; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong minimize-all disabled checkLow Severity
Additional Locations (1)Reviewed by Cursor Bugbot for commit 490c08b. Configure here.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pre-existing, not part of this change |
||
| const visibleSidebarThreadKeys = useMemo( | ||
| () => | ||
| sortedProjects.flatMap((project) => { | ||
|
|
@@ -3518,6 +3588,10 @@ export default function Sidebar() { | |
| suppressProjectClickForContextMenuRef={suppressProjectClickForContextMenuRef} | ||
| attachProjectListAutoAnimateRef={attachProjectListAutoAnimateRef} | ||
| projectsLength={projects.length} | ||
| allProjectsCollapsed={allProjectsCollapsed} | ||
| allThreadListsMinimized={allThreadListsMinimized} | ||
| collapseAllProjects={handleCollapseAllProjects} | ||
| minimizeAllThreadLists={handleMinimizeAllThreadLists} | ||
| /> | ||
|
|
||
| <SidebarSeparator /> | ||
|
|
||


There was a problem hiding this comment.
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
Altheld, the handler always callscollapseAllProjects()and returns without runningtoggleProject. If every visible project is already collapsed,collapseAllProjectsis a no-op, so the click does nothing—unlike a normal click, which would expand that project.Reviewed by Cursor Bugbot for commit b85ccb3. Configure here.
There was a problem hiding this comment.
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