import { HarnessSelector } from '@/client/features/harness/harness-selector' import { type ReactNode, useEffect } from 'react' import { Button } from '@/client/components/ui/button' import { DialogDescription, DialogTitle } from '@/client/components/ui/dialog' import { Skeleton } from '@/client/components/ui/skeleton' import type { WorkspaceType } from '@/lib/types' import { resolveWorkspaceAgentSelection, type WorkspaceAgentOption } from './workspace-agent-options' const WORKSPACE_AGENT_DESCRIPTION = 'Choose the agent to build the workspace' type WorkspaceAgentSelectorProps = { title: string selectedType: WorkspaceType options: WorkspaceAgentOption[] isLoading?: boolean isPending: boolean errorMessage?: string emptyMessage?: string secondaryAction: ReactNode primaryLabel: string pendingLabel?: string onTypeChange: (type: WorkspaceType) => void onSubmit: () => void } export function WorkspaceAgentSelector({ title, selectedType, options, isLoading = false, isPending, errorMessage, emptyMessage, secondaryAction, primaryLabel, pendingLabel, onTypeChange, onSubmit }: WorkspaceAgentSelectorProps) { const selectableType = resolveWorkspaceAgentSelection(options, selectedType) const selectedUnavailable = selectableType !== selectedType useEffect(() => { if (!isPending && selectableType && selectedUnavailable) onTypeChange(selectableType) }, [isPending, onTypeChange, selectableType, selectedUnavailable]) return (
{errorMessage}
)} {emptyMessage && !selectableType && !isPending && !errorMessage && ({emptyMessage}
)}