mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat(frontend): add mobile composer tools menu and base branch select
This commit is contained in:
1 parent
fac23b1f1a
commit
4a2e695ec2
21 files changed
+819
-158
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { GitBranch } from 'lucide-react'
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
|
||||
import { listBranches } from '@/api/repos'
|
||||
import { getOriginOnlyBranchNames } from '@/lib/utils'
|
||||
|
||||
interface BaseBranchSelectProps {
|
||||
repoId: number
|
||||
value: string
|
||||
onValueChange: (value: string) => void
|
||||
id?: string
|
||||
placeholder: string
|
||||
}
|
||||
|
||||
export function BaseBranchSelect({ repoId, value, onValueChange, id, placeholder }: BaseBranchSelectProps) {
|
||||
const { data: branchesData, isLoading } = useQuery({
|
||||
queryKey: ['branches', repoId],
|
||||
queryFn: () => listBranches(repoId),
|
||||
staleTime: 30000,
|
||||
})
|
||||
|
||||
const localBranches = (branchesData?.branches ?? []).filter((b) => b.type === 'local')
|
||||
const remoteBranchNames = getOriginOnlyBranchNames(branchesData?.branches ?? [])
|
||||
|
||||
return (
|
||||
<Select value={value} onValueChange={onValueChange} disabled={isLoading}>
|
||||
<SelectTrigger id={id} className="bg-background border-border text-foreground">
|
||||
<SelectValue placeholder={isLoading ? 'Loading branches...' : placeholder} />
|
||||
</SelectTrigger>
|
||||
<SelectContent className="bg-popover border-border">
|
||||
{localBranches.map((branch) => (
|
||||
<SelectItem key={`local-${branch.name}`} value={branch.name}>
|
||||
<div className="flex items-center gap-2">
|
||||
<GitBranch className="w-3.5 h-3.5" />
|
||||
<span>{branch.name}</span>
|
||||
{branch.current && (
|
||||
<span className="text-xs text-muted-foreground">(current)</span>
|
||||
)}
|
||||
</div>
|
||||
</SelectItem>
|
||||
))}
|
||||
{remoteBranchNames.map((name) => (
|
||||
<SelectItem key={`remote-${name}`} value={`origin/${name}`}>
|
||||
<div className="flex items-center gap-2">
|
||||
<GitBranch className="w-3.5 h-3.5 text-info" />
|
||||
<span>{name}</span>
|
||||
<span className="text-xs text-muted-foreground">(remote)</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)
|
||||
}
|
||||
@@ -8,6 +8,8 @@ import { AlertCircle, GitBranch, Loader2 } from 'lucide-react'
|
||||
import { createRepo, listBranches, type CreateRepoOptions } from '@/api/repos'
|
||||
import { showToast } from '@/lib/toast'
|
||||
import { invalidateRepoGitCaches } from '@/lib/queryInvalidation'
|
||||
import { getOriginOnlyBranchNames } from '@/lib/utils'
|
||||
import { BaseBranchSelect } from './BaseBranchSelect'
|
||||
|
||||
interface CreateWorktreeDialogProps {
|
||||
open: boolean
|
||||
@@ -51,28 +53,18 @@ export function CreateWorktreeDialog({
|
||||
|
||||
const localBranches = (branchesData?.branches ?? []).filter((b) => b.type === 'local')
|
||||
|
||||
const seenRemoteNames = new Set<string>()
|
||||
const remoteBranches = (branchesData?.branches ?? [])
|
||||
.filter((b) => b.type === 'remote' && b.name.startsWith('remotes/origin/'))
|
||||
.map((b) => ({ ...b, shortName: b.name.slice('remotes/origin/'.length) }))
|
||||
.filter((b) => b.shortName.length > 0)
|
||||
.filter((b) => !localBranches.some((lb) => lb.name === b.shortName))
|
||||
.filter((b) => {
|
||||
if (seenRemoteNames.has(b.shortName)) return false
|
||||
seenRemoteNames.add(b.shortName)
|
||||
return true
|
||||
})
|
||||
const remoteBranchNames = getOriginOnlyBranchNames(branchesData?.branches ?? [])
|
||||
|
||||
const checkoutCandidates = [
|
||||
...localBranches
|
||||
.filter((b) => !b.current && !b.isWorktree)
|
||||
.map((b) => ({ name: b.name, remote: false })),
|
||||
...remoteBranches.map((b) => ({ name: b.shortName, remote: true })),
|
||||
...remoteBranchNames.map((name) => ({ name, remote: true })),
|
||||
]
|
||||
|
||||
const existingBranchNames = new Set([
|
||||
...localBranches.map((b) => b.name),
|
||||
...remoteBranches.map((b) => b.shortName),
|
||||
...remoteBranchNames,
|
||||
])
|
||||
|
||||
const trimmedBranchName = branchName.trim()
|
||||
@@ -219,37 +211,12 @@ export function CreateWorktreeDialog({
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-sm font-medium">Base branch</label>
|
||||
<Select value={baseBranch} onValueChange={setBaseBranch} disabled={branchesLoading}>
|
||||
<SelectTrigger className="bg-background border-border text-foreground">
|
||||
<SelectValue placeholder={branchesLoading ? 'Loading branches...' : 'Select a base branch'} />
|
||||
</SelectTrigger>
|
||||
<SelectContent className="bg-popover border-border">
|
||||
{localBranches.length > 0 && (
|
||||
<>
|
||||
{localBranches.map((branch) => (
|
||||
<SelectItem key={`local-${branch.name}`} value={branch.name}>
|
||||
<div className="flex items-center gap-2">
|
||||
<GitBranch className="w-3.5 h-3.5" />
|
||||
<span>{branch.name}</span>
|
||||
{branch.current && (
|
||||
<span className="text-xs text-muted-foreground">(current)</span>
|
||||
)}
|
||||
</div>
|
||||
</SelectItem>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
{remoteBranches.map((branch) => (
|
||||
<SelectItem key={`remote-${branch.name}`} value={`origin/${branch.shortName}`}>
|
||||
<div className="flex items-center gap-2">
|
||||
<GitBranch className="w-3.5 h-3.5 text-info" />
|
||||
<span>{branch.shortName}</span>
|
||||
<span className="text-xs text-muted-foreground">(remote)</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<BaseBranchSelect
|
||||
repoId={repoId}
|
||||
value={baseBranch}
|
||||
onValueChange={setBaseBranch}
|
||||
placeholder="Select a base branch"
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
The new branch will be created from this branch.
|
||||
</p>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { describe, it, expect, vi, beforeAll, beforeEach } from 'vitest'
|
||||
import { render, screen, waitFor, within } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
@@ -11,6 +11,8 @@ const mocks = vi.hoisted(() => ({
|
||||
launchMultiRun: vi.fn(),
|
||||
discardMultiRunEntry: vi.fn(),
|
||||
useProvidersWithModels: vi.fn(),
|
||||
useOpenCodeModelState: vi.fn(),
|
||||
listBranches: vi.fn(),
|
||||
}))
|
||||
|
||||
const mockNavigate = vi.fn()
|
||||
@@ -30,6 +32,14 @@ vi.mock('@/hooks/useProvidersWithModels', () => ({
|
||||
useProvidersWithModels: mocks.useProvidersWithModels,
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useModelSelection', () => ({
|
||||
useOpenCodeModelState: mocks.useOpenCodeModelState,
|
||||
}))
|
||||
|
||||
vi.mock('@/api/repos', () => ({
|
||||
listBranches: mocks.listBranches,
|
||||
}))
|
||||
|
||||
vi.mock('@/lib/toast', () => ({
|
||||
showToast: {
|
||||
success: vi.fn(),
|
||||
@@ -120,13 +130,141 @@ function renderDialog(overrides: Partial<React.ComponentProps<typeof MultiRunDia
|
||||
)
|
||||
}
|
||||
|
||||
function checkboxLabels() {
|
||||
return screen.getAllByRole('checkbox').map((checkbox) => checkbox.getAttribute('aria-label'))
|
||||
}
|
||||
|
||||
async function fillLaunchForm(user: ReturnType<typeof userEvent.setup>) {
|
||||
await user.type(screen.getByLabelText('Group name'), 'Sweep')
|
||||
await user.type(screen.getByLabelText('Prompt'), 'go')
|
||||
await user.click(screen.getByRole('checkbox', { name: 'GPT-4o' }))
|
||||
}
|
||||
|
||||
describe('MultiRunDialog', () => {
|
||||
beforeAll(() => {
|
||||
Element.prototype.hasPointerCapture ??= () => false
|
||||
Element.prototype.setPointerCapture ??= () => {}
|
||||
Element.prototype.releasePointerCapture ??= () => {}
|
||||
Element.prototype.scrollIntoView ??= () => {}
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
mocks.useProvidersWithModels.mockReturnValue({ data: providers, isLoading: false })
|
||||
mocks.useOpenCodeModelState.mockReturnValue({ data: { recent: [], favorite: [], variant: {} } })
|
||||
mocks.listBranches.mockResolvedValue({
|
||||
branches: [
|
||||
{ name: 'main', type: 'local', current: true },
|
||||
{ name: 'remotes/origin/HEAD', type: 'remote', current: false },
|
||||
{ name: 'remotes/origin/release', type: 'remote', current: false },
|
||||
],
|
||||
status: { ahead: 0, behind: 0 },
|
||||
})
|
||||
mocks.listMultiRuns.mockResolvedValue([])
|
||||
})
|
||||
|
||||
it('lists favorite then recent models before provider groups without duplicates', () => {
|
||||
mocks.useOpenCodeModelState.mockReturnValue({
|
||||
data: {
|
||||
favorite: [{ providerID: 'anthropic', modelID: 'claude-sonnet' }],
|
||||
recent: [
|
||||
{ providerID: 'openai', modelID: 'gpt-4.1' },
|
||||
{ providerID: 'anthropic', modelID: 'claude-sonnet' },
|
||||
{ providerID: 'missing', modelID: 'gone' },
|
||||
],
|
||||
variant: {},
|
||||
},
|
||||
})
|
||||
renderDialog()
|
||||
|
||||
expect(screen.getByText('Favorites')).toBeInTheDocument()
|
||||
expect(screen.getByText('Recent')).toBeInTheDocument()
|
||||
expect(checkboxLabels()).toEqual([
|
||||
'Claude Sonnet',
|
||||
'GPT-4.1',
|
||||
'GPT-4o',
|
||||
'GPT-4o mini',
|
||||
'Claude Opus',
|
||||
'Claude Haiku',
|
||||
'Claude Sonnet 4.5',
|
||||
])
|
||||
})
|
||||
|
||||
it('filters models by every search term and keeps favorites first', async () => {
|
||||
const user = userEvent.setup()
|
||||
mocks.useOpenCodeModelState.mockReturnValue({
|
||||
data: { favorite: [{ providerID: 'anthropic', modelID: 'claude-sonnet-4.5' }], recent: [], variant: {} },
|
||||
})
|
||||
renderDialog()
|
||||
|
||||
await user.type(screen.getByLabelText('Search models'), 'sonnet')
|
||||
await waitFor(() => expect(checkboxLabels()).toEqual(['Claude Sonnet 4.5', 'Claude Sonnet']))
|
||||
|
||||
await user.clear(screen.getByLabelText('Search models'))
|
||||
await user.type(screen.getByLabelText('Search models'), 'anthropic haiku')
|
||||
await waitFor(() => expect(checkboxLabels()).toEqual(['Claude Haiku']))
|
||||
|
||||
await user.type(screen.getByLabelText('Search models'), 'zzz')
|
||||
expect(await screen.findByText('No models match your search.')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps selections that are hidden by the search filter', async () => {
|
||||
const user = userEvent.setup()
|
||||
renderDialog()
|
||||
|
||||
await user.click(screen.getByRole('checkbox', { name: 'GPT-4o' }))
|
||||
await user.type(screen.getByLabelText('Search models'), 'claude')
|
||||
|
||||
await waitFor(() => expect(screen.queryByRole('checkbox', { name: 'GPT-4o' })).not.toBeInTheDocument())
|
||||
expect(screen.getByText('1/5 selected')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('submits the selected remote branch as the base ref', async () => {
|
||||
const user = userEvent.setup()
|
||||
mocks.launchMultiRun.mockResolvedValue(startedRun)
|
||||
renderDialog()
|
||||
|
||||
await fillLaunchForm(user)
|
||||
const branchSelect = screen.getByRole('combobox', { name: 'Start from' })
|
||||
await waitFor(() => expect(branchSelect).toBeEnabled())
|
||||
await user.click(branchSelect)
|
||||
expect(screen.queryByRole('option', { name: /HEAD/ })).not.toBeInTheDocument()
|
||||
await user.click(screen.getByRole('option', { name: /release/ }))
|
||||
await user.click(screen.getByRole('button', { name: 'Launch' }))
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mocks.launchMultiRun).toHaveBeenCalledWith({
|
||||
repoId: 7,
|
||||
name: 'Sweep',
|
||||
prompt: 'go',
|
||||
models: ['openai/gpt-4o'],
|
||||
isolate: true,
|
||||
baseRef: 'origin/release',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('hides the base branch and omits it when runs are not isolated', async () => {
|
||||
const user = userEvent.setup()
|
||||
mocks.launchMultiRun.mockResolvedValue(startedRun)
|
||||
renderDialog()
|
||||
|
||||
await fillLaunchForm(user)
|
||||
await user.click(screen.getByRole('switch', { name: 'Isolate runs' }))
|
||||
expect(screen.queryByRole('combobox', { name: 'Start from' })).not.toBeInTheDocument()
|
||||
await user.click(screen.getByRole('button', { name: 'Launch' }))
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mocks.launchMultiRun).toHaveBeenCalledWith({
|
||||
repoId: 7,
|
||||
name: 'Sweep',
|
||||
prompt: 'go',
|
||||
models: ['openai/gpt-4o'],
|
||||
isolate: false,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('caps model selection at five', async () => {
|
||||
const user = userEvent.setup()
|
||||
renderDialog()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { memo, useCallback, useDeferredValue, useEffect, useMemo, useState, type ReactNode } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { Loader2, Trash2, ArrowUpRight } from 'lucide-react'
|
||||
import { Loader2, Trash2, ArrowUpRight, Clock, Search, Star } from 'lucide-react'
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog'
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
||||
import { Button } from '@/components/ui/button'
|
||||
@@ -12,9 +12,18 @@ import { Badge } from '@/components/ui/badge'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { ConfirmDestructiveDialog } from '@/components/ui/confirm-destructive-dialog'
|
||||
import { SessionStatusIndicator } from '@/components/ui/session-status-indicator'
|
||||
import { BaseBranchSelect } from '@/components/repo/BaseBranchSelect'
|
||||
import { useProvidersWithModels } from '@/hooks/useProvidersWithModels'
|
||||
import { useOpenCodeModelState } from '@/hooks/useModelSelection'
|
||||
import { useDiscardMultiRunEntry, useLaunchMultiRun, useMultiRuns } from '@/hooks/useMultiRuns'
|
||||
import { formatModelName, formatProviderName, providerModelRef, type ProviderWithModels } from '@/api/providers'
|
||||
import {
|
||||
formatModelName,
|
||||
formatProviderName,
|
||||
providerModelRef,
|
||||
type ModelSelection,
|
||||
type OpenCodeModelState,
|
||||
type ProviderWithModels,
|
||||
} from '@/api/providers'
|
||||
import { buildSessionPath } from '@opencode-manager/shared/utils'
|
||||
import {
|
||||
MULTI_RUN_MAX_MODELS,
|
||||
@@ -38,6 +47,21 @@ interface PendingDiscard {
|
||||
isolated: boolean
|
||||
}
|
||||
|
||||
interface ModelOption {
|
||||
value: string
|
||||
label: string
|
||||
providerName: string
|
||||
searchText: string
|
||||
}
|
||||
|
||||
interface ModelSection {
|
||||
key: string
|
||||
title: string
|
||||
icon?: ReactNode
|
||||
pinned: boolean
|
||||
options: ModelOption[]
|
||||
}
|
||||
|
||||
const STATUS_LABELS: Record<MultiRunEntryStatus, string> = {
|
||||
starting: 'Starting',
|
||||
started: 'Started',
|
||||
@@ -45,6 +69,54 @@ const STATUS_LABELS: Record<MultiRunEntryStatus, string> = {
|
||||
discarded: 'Discarded',
|
||||
}
|
||||
|
||||
function buildModelSections(providers: ProviderWithModels[], modelState: OpenCodeModelState | undefined): ModelSection[] {
|
||||
const optionsByValue = new Map<string, ModelOption>()
|
||||
const providerSections = providers.map((provider): ModelSection => {
|
||||
const providerName = formatProviderName(provider)
|
||||
const options = provider.models.map((model) => {
|
||||
const label = formatModelName(model)
|
||||
const value = providerModelRef(provider, model)
|
||||
const option = { value, label, providerName, searchText: `${label} ${value} ${providerName}`.toLowerCase() }
|
||||
optionsByValue.set(value, option)
|
||||
return option
|
||||
})
|
||||
return { key: `provider:${provider.id}`, title: providerName, pinned: false, options }
|
||||
})
|
||||
|
||||
const pinnedValues = new Set<string>()
|
||||
const pinOptions = (selections: ModelSelection[] = []) =>
|
||||
selections.flatMap((selection) => {
|
||||
const option = optionsByValue.get(providerModelRef({ id: selection.providerID }, { id: selection.modelID }))
|
||||
if (!option || pinnedValues.has(option.value)) return []
|
||||
pinnedValues.add(option.value)
|
||||
return [option]
|
||||
})
|
||||
|
||||
const favoriteOptions = pinOptions(modelState?.favorite)
|
||||
const recentOptions = pinOptions(modelState?.recent)
|
||||
const sections: ModelSection[] = [
|
||||
{ key: 'favorites', title: 'Favorites', icon: <Star className="h-3.5 w-3.5" />, pinned: true, options: favoriteOptions },
|
||||
{ key: 'recent', title: 'Recent', icon: <Clock className="h-3.5 w-3.5" />, pinned: true, options: recentOptions },
|
||||
...providerSections.map((section) => ({
|
||||
...section,
|
||||
options: section.options.filter((option) => !pinnedValues.has(option.value)),
|
||||
})),
|
||||
]
|
||||
return sections.filter((section) => section.options.length > 0)
|
||||
}
|
||||
|
||||
function filterModelSections(sections: ModelSection[], query: string): ModelSection[] {
|
||||
const terms = query.toLowerCase().split(/\s+/).filter(Boolean)
|
||||
if (terms.length === 0) return sections
|
||||
|
||||
return sections
|
||||
.map((section) => ({
|
||||
...section,
|
||||
options: section.options.filter((option) => terms.every((term) => option.searchText.includes(term))),
|
||||
}))
|
||||
.filter((section) => section.options.length > 0)
|
||||
}
|
||||
|
||||
export function MultiRunDialog({
|
||||
repoId,
|
||||
directory,
|
||||
@@ -59,9 +131,12 @@ export function MultiRunDialog({
|
||||
const [selectedModels, setSelectedModels] = useState<string[]>([])
|
||||
const [isolate, setIsolate] = useState(true)
|
||||
const [baseRef, setBaseRef] = useState('')
|
||||
const [modelSearch, setModelSearch] = useState('')
|
||||
const deferredModelSearch = useDeferredValue(modelSearch)
|
||||
const [pendingDiscard, setPendingDiscard] = useState<PendingDiscard | null>(null)
|
||||
|
||||
const { data: providers } = useProvidersWithModels({ enabled: open, directory })
|
||||
const { data: modelState } = useOpenCodeModelState(directory, open)
|
||||
const runsQuery = useMultiRuns(repoId, open)
|
||||
const launch = useLaunchMultiRun(repoId)
|
||||
const discard = useDiscardMultiRunEntry(repoId)
|
||||
@@ -74,11 +149,13 @@ export function MultiRunDialog({
|
||||
setSelectedModels([])
|
||||
setIsolate(true)
|
||||
setBaseRef(defaultBaseRef ?? '')
|
||||
setModelSearch('')
|
||||
}, [open, defaultBaseRef])
|
||||
|
||||
const modelGroups = useMemo(
|
||||
() => providers.filter((provider) => provider.models.length > 0),
|
||||
[providers],
|
||||
const modelSections = useMemo(() => buildModelSections(providers, modelState), [providers, modelState])
|
||||
const visibleModelSections = useMemo(
|
||||
() => filterModelSections(modelSections, deferredModelSearch),
|
||||
[modelSections, deferredModelSearch],
|
||||
)
|
||||
|
||||
const toggleModel = useCallback((value: string, checked: boolean) => {
|
||||
@@ -101,7 +178,7 @@ export function MultiRunDialog({
|
||||
prompt: prompt.trim(),
|
||||
models: selectedModels,
|
||||
isolate,
|
||||
...(baseRef.trim() ? { baseRef: baseRef.trim() } : {}),
|
||||
...(isolate && baseRef ? { baseRef } : {}),
|
||||
}
|
||||
launch.mutate(request, { onSuccess: () => setActiveTab('runs') })
|
||||
}
|
||||
@@ -170,11 +247,23 @@ export function MultiRunDialog({
|
||||
{selectedModels.length}/{MULTI_RUN_MAX_MODELS} selected
|
||||
</span>
|
||||
</div>
|
||||
<div className="relative">
|
||||
<Search className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
||||
<Input
|
||||
value={modelSearch}
|
||||
onChange={(event) => setModelSearch(event.target.value)}
|
||||
placeholder="Search models..."
|
||||
aria-label="Search models"
|
||||
autoComplete="off"
|
||||
className="pl-9"
|
||||
/>
|
||||
</div>
|
||||
<div className="max-h-56 overflow-y-auto rounded-md border border-border divide-y divide-border">
|
||||
<ModelCheckboxList
|
||||
providers={modelGroups}
|
||||
sections={visibleModelSections}
|
||||
selectedModels={selectedModels}
|
||||
onToggle={toggleModel}
|
||||
emptyLabel={modelSections.length === 0 ? 'No models available.' : 'No models match your search.'}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -187,16 +276,19 @@ export function MultiRunDialog({
|
||||
<Switch id="multi-run-isolate" checked={isolate} onCheckedChange={setIsolate} />
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="multi-run-base-ref">Start from</Label>
|
||||
<Input
|
||||
id="multi-run-base-ref"
|
||||
value={baseRef}
|
||||
onChange={(event) => setBaseRef(event.target.value)}
|
||||
placeholder="Current HEAD"
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">Branch or ref. Empty starts from the current HEAD.</p>
|
||||
</div>
|
||||
{isolate && (
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="multi-run-base-ref">Start from</Label>
|
||||
<BaseBranchSelect
|
||||
id="multi-run-base-ref"
|
||||
repoId={repoId}
|
||||
value={baseRef}
|
||||
onValueChange={setBaseRef}
|
||||
placeholder="Current HEAD"
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">Each isolated workspace starts from this branch.</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex justify-end">
|
||||
<Button onClick={handleLaunch} disabled={!canSubmit}>
|
||||
@@ -300,38 +392,45 @@ export function MultiRunDialog({
|
||||
}
|
||||
|
||||
interface ModelCheckboxListProps {
|
||||
providers: ProviderWithModels[]
|
||||
sections: ModelSection[]
|
||||
selectedModels: string[]
|
||||
onToggle: (value: string, checked: boolean) => void
|
||||
emptyLabel: string
|
||||
}
|
||||
|
||||
const ModelCheckboxList = memo(function ModelCheckboxList({
|
||||
providers,
|
||||
sections,
|
||||
selectedModels,
|
||||
onToggle,
|
||||
emptyLabel,
|
||||
}: ModelCheckboxListProps) {
|
||||
if (providers.length === 0) {
|
||||
return <p className="p-3 text-sm text-muted-foreground">No models available.</p>
|
||||
if (sections.length === 0) {
|
||||
return <p className="p-3 text-sm text-muted-foreground">{emptyLabel}</p>
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{providers.map((provider) => (
|
||||
<div key={provider.id} className="p-3 space-y-2">
|
||||
<p className="text-xs font-medium text-muted-foreground">{formatProviderName(provider)}</p>
|
||||
{provider.models.map((model) => {
|
||||
const value = providerModelRef(provider, model)
|
||||
const checked = selectedModels.includes(value)
|
||||
{sections.map((section) => (
|
||||
<div key={section.key} className="p-3 space-y-2">
|
||||
<p className="flex items-center gap-1.5 text-xs font-medium text-muted-foreground">
|
||||
{section.icon}
|
||||
{section.title}
|
||||
</p>
|
||||
{section.options.map((option) => {
|
||||
const checked = selectedModels.includes(option.value)
|
||||
const atCapacity = selectedModels.length >= MULTI_RUN_MAX_MODELS && !checked
|
||||
return (
|
||||
<label key={value} className="flex items-center gap-2 text-sm">
|
||||
<label key={option.value} className="flex items-center gap-2 text-sm">
|
||||
<Checkbox
|
||||
aria-label={formatModelName(model)}
|
||||
aria-label={option.label}
|
||||
checked={checked}
|
||||
disabled={atCapacity}
|
||||
onCheckedChange={(next) => onToggle(value, next === true)}
|
||||
onCheckedChange={(next) => onToggle(option.value, next === true)}
|
||||
/>
|
||||
<span className="truncate">{formatModelName(model)}</span>
|
||||
<span className="truncate">{option.label}</span>
|
||||
{section.pinned ? (
|
||||
<span className="ml-auto shrink-0 text-xs text-muted-foreground">{option.providerName}</span>
|
||||
) : null}
|
||||
</label>
|
||||
)
|
||||
})}
|
||||
|
||||
Reference in new issue
Block a user