π OpenHands: AI-Driven Development
fix(automations): stop offering an agent profile to prompt and plugin presets (#18708)
simonrosenberge9563919e18c
diff --git a/.pr/18569-after-draft-saved.png b/.pr/18569-after-draft-saved.pngnew file mode 100644index 0000000000..a9fa8bb1eeBinary files /dev/null and b/.pr/18569-after-draft-saved.png differdiff --git a/.pr/18569-before-main-save-failed.png b/.pr/18569-before-main-save-failed.pngnew file mode 100644index 0000000000..544e5f2605Binary files /dev/null and b/.pr/18569-before-main-save-failed.png differdiff --git a/__tests__/components/automations/automation-setup-panel.test.tsx b/__tests__/components/automations/automation-setup-panel.test.tsxindex 9887997af5..7854d25ee4 100644--- a/__tests__/components/automations/automation-setup-panel.test.tsx+++ b/__tests__/components/automations/automation-setup-panel.test.tsx@@ -499,7 +499,7 @@ describe("AutomationSetupPanel", () => {);});- it("pins an automation agent profile without changing the conversation", async () => {+ it("does not offer or send an agent profile for prompt automations", async () => {vi.mocked(AutomationService.createServerDraft).mockRejectedValue({response: { status: 404 },});@@ -509,38 +509,53 @@ describe("AutomationSetupPanel", () => {});const user = userEvent.setup();- renderPanel();+ renderPanel({+ prompt: "Review every pull request",+ kind: "prompt",+ form: { kind: "prompt", agentProfileId: "agent-reviewer" },+ });- const agentProfile = screen.getByTestId("automation-setup-agent-profile");- const model = screen.getByTestId("automation-setup-model");- expect(agentProfile).toHaveAttribute("aria-label", "default");expect(- agentProfile.compareDocumentPosition(model) &- Node.DOCUMENT_POSITION_FOLLOWING,- ).toBeTruthy();- await user.click(screen.getByTestId("automation-setup-agent-profile"));- await user.click(- screen.getByTestId("automation-setup-agent-profile-option-reviewer"),+ screen.queryByTestId("automation-setup-agent-profile"),+ ).not.toBeInTheDocument();+ expect(screen.getByTestId("automation-setup-model")).toBeInTheDocument();++ await user.click(screen.getByTestId("automation-setup-test"));++ await waitFor(() =>+ expect(AutomationService.validateDraft).toHaveBeenCalled(),);expect(- screen.getByTestId("automation-setup-agent-profile"),- ).toHaveAttribute("aria-label", "reviewer");- expect(screen.getByTestId("automation-setup-model")).toHaveAttribute(- "aria-label",- "claude-opus-4-5-20251101",- );+ vi.mocked(AutomationService.validateDraft).mock.calls[0][0].draft,+ ).not.toHaveProperty("agent_profile_id");+ });- await user.click(screen.getByTestId("automation-setup-test"));+ it("leaves a prompt automation's stored agent profile alone on save", async () => {+ vi.mocked(AutomationService.updateAutomation).mockResolvedValue({+ id: "auto-1",+ } as never);++ const user = userEvent.setup();+ renderPanel({+ prompt: "Review every pull request",+ kind: "prompt",+ editingAutomationId: "auto-1",+ form: {+ kind: "prompt",+ name: "Daily digest",+ prompt: "Review every pull request",+ agentProfileId: "agent-reviewer",+ },+ });++ await user.click(screen.getByTestId("automation-setup-save"));await waitFor(() =>- expect(AutomationService.validateDraft).toHaveBeenCalledWith(- expect.objectContaining({- draft: expect.objectContaining({- agent_profile_id: "agent-reviewer",- }),- }),- ),+ expect(AutomationService.updateAutomation).toHaveBeenCalledTimes(1),);+ expect(+ vi.mocked(AutomationService.updateAutomation).mock.calls[0][1],+ ).not.toHaveProperty("agent_profile_id");});it("sends each comma-separated repository to the automation service", async () => {diff --git a/src/components/features/automations/setup/automation-setup-panel.tsx b/src/components/features/automations/setup/automation-setup-panel.tsxindex 31fd1f504e..d6dbc7143a 100644--- a/src/components/features/automations/setup/automation-setup-panel.tsx+++ b/src/components/features/automations/setup/automation-setup-panel.tsx@@ -1224,7 +1224,6 @@ export function AutomationSetupPanel({body.plugins = configuredPlugins;}if (model.trim()) body.model = model.trim();- if (agentProfileId.trim()) body.agent_profile_id = agentProfileId.trim();return body;};const buildCustomBody = (tarballPath: string): SetupRequestBody =>@@ -1701,11 +1700,12 @@ export function AutomationSetupPanel({name: normalizedName(),trigger: buildTrigger(),model: model.trim() || null,- agent_profile_id: agentProfileId.trim() || null,timeout:showTimeout && timeoutSeconds.trim() ? Number(timeoutSeconds) : null,};- if (kind !== "custom") body.prompt = prompt.trim();+ if (kind === "custom")+ body.agent_profile_id = agentProfileId.trim() || null;+ else body.prompt = prompt.trim();return body as Partial<Automation>;};@@ -2019,10 +2019,6 @@ export function AutomationSetupPanel({}model={model}onModelChange={(value) => updateField("model", value)}- agentProfileId={agentProfileId}- onAgentProfileChange={(value) =>- updateField("agentProfileId", value)- }/>) : hasExistingCustomBundle ? (<ExistingCustomBundleSummarydiff --git a/src/components/features/automations/setup/automation-setup-prompt-stack.tsx b/src/components/features/automations/setup/automation-setup-prompt-stack.tsxindex 0c63c2b64a..a8abe26d8e 100644--- a/src/components/features/automations/setup/automation-setup-prompt-stack.tsx+++ b/src/components/features/automations/setup/automation-setup-prompt-stack.tsx@@ -9,7 +9,6 @@ import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";import { ModalCloseButton } from "#/components/shared/modals/modal-close-button";import { ContextMenuListItem } from "#/components/features/context-menu/context-menu-list-item";import { StyledTooltip } from "#/components/shared/buttons/styled-tooltip";-import { useAgentProfiles } from "#/hooks/query/use-agent-profiles";import { useGitRepositories } from "#/hooks/query/use-git-repositories";import { useLlmProfiles } from "#/hooks/query/use-llm-profiles";import { useClickOutsideElement } from "#/hooks/use-click-outside-element";@@ -165,121 +164,6 @@ function SetupModelPill({);}-function SetupAgentProfilePill({- value,- onChange,-}: {- value: string;- onChange: (profileId: string) => void;-}) {- const { t } = useTranslation("openhands");- const { data, isLoading } = useAgentProfiles();- const profiles = (data?.profiles ?? []).filter(- (profile) => profile.id != null,- );- const activeProfile =- profiles.find((profile) => profile.id === data?.active_agent_profile_id) ??- null;- const [isOpen, setIsOpen] = useState(false);- const triggerRef = useRef<HTMLButtonElement>(null);- const popoverRef = useClickOutsideElement<HTMLUListElement>(- () => setIsOpen(false),- triggerRef,- );- const pinnedProfile =- profiles.find((profile) => profile.id === value.trim()) ?? null;- const displayName = pinnedProfile?.name ?? activeProfile?.name ?? null;- const pillLabel = displayName ?? t(I18nKey.CHAT$AGENT_PROFILE_PLACEHOLDER);- const canOpen = !isLoading && profiles.length > 0;- const tooltip = t(I18nKey.CHAT$AGENT_PROFILE_PLACEHOLDER);-- return (- <div className="relative min-w-0">- <StyledTooltip content={tooltip} placement="top">- <button- ref={triggerRef}- type="button"- className={cn(- chatInputPillButtonClassName,- "max-w-[200px] rounded-lg",- )}- data-testid="automation-setup-agent-profile"- aria-label={displayName ?? pillLabel}- aria-expanded={isOpen}- aria-haspopup="dialog"- onMouseDown={(event) => event.preventDefault()}- onClick={(event) => {- event.preventDefault();- event.stopPropagation();- if (!canOpen) return;- setIsOpen((open) => !open);- }}- >- <span className="truncate">- {displayName ? truncateLabel(pillLabel) : pillLabel}- </span>- <ComboboxCaretInline isOpen={isOpen} />- </button>- </StyledTooltip>- {isOpen && canOpen ? (- <ContextMenu- ref={popoverRef}- testId="automation-setup-agent-profile-popover"- position="top"- alignment="left"- spacing="none"- className="z-[60] mb-2 min-w-[200px] max-w-[320px] max-h-[60vh] overflow-y-auto"- >- <ContextMenuListItem- testId="automation-setup-agent-profile-option-active"- onClick={(event) => {- event.preventDefault();- event.stopPropagation();- onChange("");- setIsOpen(false);- }}- className={cn(- "flex items-center justify-between gap-2",- !pinnedProfile && "bg-[var(--oh-interactive-hover)]",- )}- >- <span className="truncate">{t(I18nKey.COMMON$ACTIVE_PROFILE)}</span>- {!pinnedProfile ? (- <CheckIcon className="size-4 shrink-0" aria-hidden />- ) : null}- </ContextMenuListItem>- {profiles.map((profile) => {- const isSelected = profile.id === pinnedProfile?.id;- return (- <ContextMenuListItem- key={profile.id}- testId={`automation-setup-agent-profile-option-${profile.name}`}- onClick={(event) => {- event.preventDefault();- event.stopPropagation();- if (profile.id) onChange(profile.id);- setIsOpen(false);- }}- className={cn(- "flex flex-col items-stretch gap-0.5",- isSelected && "bg-[var(--oh-interactive-hover)]",- )}- >- <div className="flex min-w-0 items-center justify-between gap-2">- <span className="truncate">{profile.name}</span>- {isSelected ? (- <CheckIcon className="size-4 shrink-0" aria-hidden />- ) : null}- </div>- </ContextMenuListItem>- );- })}- </ContextMenu>- ) : null}- </div>- );-}-function AddRepositoryModal({isOpen,onClose,@@ -361,11 +245,9 @@ export function AutomationSetupPromptStack({titleAction,showTitle = true,model,- agentProfileId,onPromptChange,onRepositoryChange,onModelChange,- onAgentProfileChange,}: {prompt: string;repository: string;@@ -378,11 +260,9 @@ export function AutomationSetupPromptStack({/** The setup form owns the title when the kind toggle stays outside the crossfade. */showTitle?: boolean;model: string;- agentProfileId: string;onPromptChange: (value: string) => void;onRepositoryChange: (value: string) => void;onModelChange: (profileName: string) => void;- onAgentProfileChange: (profileId: string) => void;}) {const { t } = useTranslation("openhands");const textareaRef = useRef<HTMLTextAreaElement>(null);@@ -476,10 +356,6 @@ export function AutomationSetupPromptStack({className="min-h-[120px] w-full resize-none border-0 bg-transparent p-0 text-sm text-content outline-none placeholder:text-tertiary-alt"/><div className="flex min-w-0 items-center gap-2 pt-2">- <SetupAgentProfilePill- value={agentProfileId}- onChange={onAgentProfileChange}- /><SetupModelPill value={model} onChange={onModelChange} /></div><div