import { useState } from 'react' import { GitBranch, Tag, Check, ChevronsUpDown } from 'lucide-react' import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import type { GitRef } from '@/lib/gitApi' import { cn } from '@/lib/utils' interface RefSelectorProps { refs: GitRef[] currentRef: string onSelect: (ref: GitRef) => void } // Branch / tag selector dropdown for the code browser. Shown in two groups // (branches, tags) with an inline search filter. export function RefSelector({ refs, currentRef, onSelect }: RefSelectorProps) { const [open, setOpen] = useState(false) const [filter, setFilter] = useState('') const filtered = refs.filter((r) => r.shortName.toLowerCase().includes(filter.toLowerCase()), ) const branches = filtered.filter((r) => r.type === 'branch') const tags = filtered.filter((r) => r.type === 'tag') return (

Switch branch / tag

setFilter(e.target.value)} autoFocus />
{branches.length > 0 && (

Branches

{branches.map((ref) => ( { onSelect(ref); setOpen(false); setFilter('') }} /> ))}
)} {tags.length > 0 && (

Tags

{tags.map((ref) => ( { onSelect(ref); setOpen(false); setFilter('') }} /> ))}
)} {filtered.length === 0 && (

No results

)}
) } function RefItem({ ref_, active, onSelect, }: { ref_: GitRef active: boolean onSelect: () => void }) { return ( ) }