fix(terminal): add scroll area to worktree dropdown to prevent overflow (#1146)

* fix(terminal): add scroll area to worktree dropdown to prevent overflow

Wrap worktree list in ScrollArea with max-height of 300px to handle
cases with many worktrees without overflowing the screen.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(terminal): keep separator fixed above scrollable worktree list

Move DropdownMenuSeparator outside ScrollArea so it remains visible
when scrolling through many worktrees, maintaining visual distinction
from the "Create New" item.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Andy
2026-01-15 22:26:18 +01:00
committed by GitHub
parent 658f26cb47
commit 200bb3bcae
@@ -20,6 +20,7 @@ import {
AlertDialogTitle,
} from '../ui/alert-dialog';
import { cn } from '../../lib/utils';
import { ScrollArea } from '../ui/scroll-area';
import { useProjectStore } from '../../stores/project-store';
interface WorktreeSelectorProps {
@@ -169,20 +170,20 @@ export function WorktreeSelector({
{t('terminal:worktree.createNew')}
</DropdownMenuItem>
{/* Separator and existing worktrees */}
{isLoading ? (
<>
{/* Fixed separator between "Create New" and scrollable content */}
<DropdownMenuSeparator />
{/* Scrollable content */}
<ScrollArea className="max-h-[300px]">
{isLoading ? (
<div className="flex items-center justify-center py-2">
<Loader2 className="h-4 w-4 animate-spin text-muted-foreground" />
</div>
</>
) : (
<>
{/* Terminal Worktrees Section */}
{worktrees.length > 0 && (
<>
<DropdownMenuSeparator />
<div className="px-2 py-1.5 text-xs text-muted-foreground">
{t('terminal:worktree.existing')}
</div>
@@ -253,6 +254,7 @@ export function WorktreeSelector({
)}
</>
)}
</ScrollArea>
</DropdownMenuContent>
</DropdownMenu>