(
nodes: BranchTreeNode[],
depth: number,
isRemote: boolean
)
| 640 | // typeahead can reach them by keyboard; `onSelect` preventDefault keeps the |
| 641 | // menu open while toggling. Collapsed children simply aren't rendered. |
| 642 | function renderDropdownTree( |
| 643 | nodes: BranchTreeNode[], |
| 644 | depth: number, |
| 645 | isRemote: boolean |
| 646 | ): React.ReactNode[] { |
| 647 | return nodes.flatMap((node) => { |
| 648 | if (node.type === "leaf") { |
| 649 | return [renderBranchItem(node, isRemote, depth)] |
| 650 | } |
| 651 | const groupOpen = isExpanded(node.key) |
| 652 | return [ |
| 653 | <DropdownMenuItem |
| 654 | key={node.key} |
| 655 | aria-expanded={groupOpen} |
| 656 | onSelect={(e) => { |
| 657 | e.preventDefault() |
| 658 | toggle(node.key) |
| 659 | }} |
| 660 | style={{ paddingLeft: branchRowPaddingLeft("dropdown", depth) }} |
| 661 | > |
| 662 | <ChevronRight |
| 663 | className={cn( |
| 664 | "h-3.5 w-3.5 shrink-0 transition-transform", |
| 665 | groupOpen && "rotate-90" |
| 666 | )} |
| 667 | /> |
| 668 | <span className="min-w-0 flex-1 truncate">{node.label}</span> |
| 669 | <span className="shrink-0 pl-2 text-xs text-muted-foreground/70"> |
| 670 | {node.count} |
| 671 | </span> |
| 672 | </DropdownMenuItem>, |
| 673 | ...(groupOpen |
| 674 | ? renderDropdownTree(node.children, depth + 1, isRemote) |
| 675 | : []), |
| 676 | ] |
| 677 | }) |
| 678 | } |
| 679 | |
| 680 | // Folderless chat conversations have no git branch — hide the top-bar |
| 681 | // selector entirely (covers both the mobile and desktop title-bar instances). |
no test coverage detected