From 421ce75733a3d5c8e3ea10c3558622046f10d0d1 Mon Sep 17 00:00:00 2001 From: Brad Harris Date: Mon, 3 Aug 2026 03:05:25 -0600 Subject: [PATCH] Dedupe AgentTypeCombobox into AgentTypeSelect AgentTypeCombobox in automations-form-fields.tsx duplicated ~90 lines of AgentTypeSelect (identical trigger, key handling, and Command dropdown). AgentTypeSelect gains an optional label prop (default "Type") so both automations call sites keep their "Agent type" label; the duplicate is deleted. Co-Authored-By: Claude Fable 5 --- .../src/components/app/agent-type-select.tsx | 4 +- .../app/automations-form-fields.tsx | 121 ++---------------- .../app/automations-launch-dialog.tsx | 16 +-- 3 files changed, 20 insertions(+), 121 deletions(-) diff --git a/apps/web/src/components/app/agent-type-select.tsx b/apps/web/src/components/app/agent-type-select.tsx index 98522651c..dc66fa3b6 100644 --- a/apps/web/src/components/app/agent-type-select.tsx +++ b/apps/web/src/components/app/agent-type-select.tsx @@ -20,6 +20,7 @@ type AgentTypeSelectProps = { onChange: (type: AgentType) => void; agentTypes: AgentType[]; onOpenChange?: (open: boolean) => void; + label?: string; }; export function AgentTypeSelect({ @@ -27,6 +28,7 @@ export function AgentTypeSelect({ onChange, agentTypes, onOpenChange, + label = "Type", }: AgentTypeSelectProps): JSX.Element { const sortedTypes = useMemo(() => sortAgentTypes(agentTypes), [agentTypes]); const [open, setOpen] = useState(false); @@ -46,7 +48,7 @@ export function AgentTypeSelect({ return (
- + - {open ? ( -
- { - if (el) requestAnimationFrame(() => el.focus()); - }} - onKeyDown={(e) => { - if (e.key === "Escape") { - e.preventDefault(); - setOpen(false); - requestAnimationFrame(() => triggerRef.current?.focus()); - } - }} - > - - - {sorted.map((t) => ( - { - onChange(t); - setOpen(false); - requestAnimationFrame(() => triggerRef.current?.focus()); - }} - > - - {AGENT_TYPE_LABELS[t]} - - ))} - - - -
- ) : null} -
- ); -} - export function TemplateWorktreeOption({ checked, cwd, @@ -259,14 +160,12 @@ export function TemplateConfigFields({ return (
-
- - -
+
diff --git a/apps/web/src/components/app/automations-launch-dialog.tsx b/apps/web/src/components/app/automations-launch-dialog.tsx index cc25c4702..e08d0f2d3 100644 --- a/apps/web/src/components/app/automations-launch-dialog.tsx +++ b/apps/web/src/components/app/automations-launch-dialog.tsx @@ -13,7 +13,7 @@ import { toast } from "sonner"; import { ArgInput } from "@/components/app/arg-input"; import { ContextPicker } from "@/components/app/context-picker"; import { startupFileKey } from "@/components/app/create-agent-dialog-clipboard"; -import { AgentTypeCombobox } from "@/components/app/automations-form-fields"; +import { AgentTypeSelect } from "@/components/app/agent-type-select"; import { ActivityBars } from "@/components/ui/activity-bars"; import { Button } from "@/components/ui/button"; import { @@ -247,14 +247,12 @@ function LaunchTemplateDialogContent({ onDrop={showMedia ? handleDrop : undefined} > {!isTerminal ? ( -
- - -
+ ) : null} {args.length > 0 ? (