refactor(ui): unify branch pickers into searchable BranchCombobox

Rename BaseBranchSelect to BranchCombobox and rebuild it on the shared
Combobox with an include filter, configurable remote prefixing, and
clearing. Add a useRepoBranches hook and migrate the worktree, integrate,
multi-run, and schedule dialogs onto it. Expose id and ARIA listbox/option
roles from Combobox, and add bg-background to the form prompt panels.
This commit is contained in:
Chris Scott committed 2026-10-04 16:34:22 -04:00
1 parent 092add1eb1
commit 27860224dc
12 files changed
+157 -167

No files matched your search

@@ -41,6 +41,17 @@ describe('Combobox', () => {
expect(input).toHaveValue('Built-in Browser')
})
it('filters options as the user types', async () => {
const user = userEvent.setup()
const input = renderCombobox()
await user.clear(input)
await user.type(input, 'ext')
expect(screen.getByRole('option', { name: 'External API' })).toBeInTheDocument()
expect(screen.queryByRole('option', { name: 'Built-in Browser' })).not.toBeInTheDocument()
})
it('calls onOpen each time the options open', async () => {
const user = userEvent.setup()
const onOpen = vi.fn()
+6
View File
@@ -20,6 +20,7 @@ interface ComboboxProps {
showClear?: boolean
ariaLabel?: string
onOpen?: () => void
id?: string
}
function getOptionLabel(options: ComboboxOption[], value: string): string {
@@ -37,6 +38,7 @@ export function Combobox({
showClear = false,
ariaLabel,
onOpen,
id,
}: ComboboxProps) {
const [isOpen, setIsOpen] = useState(false)
const [inputValue, setInputValue] = useState(() => getOptionLabel(options, value))
@@ -185,6 +187,7 @@ export function Combobox({
<div className="relative">
<input
ref={inputRef}
id={id}
type="text"
value={inputValue}
onChange={handleInputChange}
@@ -244,6 +247,7 @@ export function Combobox({
{isOpen && flatFilteredOptions.length > 0 && (
<div
ref={listRef}
role="listbox"
className="absolute z-[150] mt-1 w-full bg-popover border border-border rounded-md shadow-lg max-h-60 overflow-y-auto"
>
{Object.entries(groupedOptions).map(([group, groupOptions]) => (
@@ -263,6 +267,8 @@ export function Combobox({
key={option.value}
data-option
type="button"
role="option"
aria-selected={option.value === value}
onClick={() => handleSelect(option.value)}
className={cn(
'w-full scroll-mt-7 px-3 py-2 text-left text-sm transition-colors',