Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(automations): show Default when the agent profile field is empty (#18111)

fengyue-xve3dfe0ac8f276
diff --git a/__tests__/components/manifest/manifest-setup-dialog.test.tsx b/__tests__/components/manifest/manifest-setup-dialog.test.tsx
index 11bd4d5643..d3767bbc3b 100644
--- a/__tests__/components/manifest/manifest-setup-dialog.test.tsx
+++ b/__tests__/components/manifest/manifest-setup-dialog.test.tsx
@@ -6,6 +6,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
import AutomationService from "#/api/automation-service/automation-service.api";
import { SetupDialog } from "#/components/features/manifest/manifest-setup-dialog";
import { SUPER_ADMIN_SETUP_STEP_EVENT } from "#/components/features/setup-guide/super-admin-setup-step-event";
+import { I18nKey } from "#/i18n/declaration";
import type { SetupPrerequisitesResult } from "#/hooks/query/use-manifest-prerequisites";
import type { DeploymentCapabilities, SetupEntry } from "#/manifests/types";
import {
@@ -298,6 +299,75 @@ describe("SetupDialog", () => {
});
});
+ it("shows Default after a pass through Prompt and back to Upload tarball", async () => {
+ mocks.capabilities.mockReturnValue({
+ capabilities: ACTION_CAPABILITIES,
+ supported: true,
+ unmet: [],
+ isLoading: false,
+ });
+ const { user } = renderDialog(CUSTOM_AUTOMATION_ENTRY);
+
+ await waitFor(() =>
+ expect(screen.getByTestId("setup-action-kind")).toBeInTheDocument(),
+ );
+ await user.click(screen.getByTestId("setup-action-kind"));
+ await user.click(await screen.findByText("Upload tarball"));
+ await screen.findByTestId("automation-agent-profile");
+
+ // The pass through Prompt clears the profile; back on Upload tarball the
+ // field must read Default rather than blank.
+ await user.click(screen.getByTestId("setup-action-kind"));
+ await user.click(await screen.findByText("Prompt"));
+ await waitFor(() =>
+ expect(
+ screen.queryByTestId("automation-agent-profile"),
+ ).not.toBeInTheDocument(),
+ );
+ await user.click(screen.getByTestId("setup-action-kind"));
+ await user.click(await screen.findByText("Upload tarball"));
+
+ const selector = await screen.findByTestId("automation-agent-profile");
+ await waitFor(() =>
+ expect(selector).toHaveValue(I18nKey.SETTINGS$PROFILE_DEFAULT),
+ );
+ await user.click(selector);
+ expect(
+ await screen.findByRole("option", {
+ name: I18nKey.SETTINGS$PROFILE_DEFAULT,
+ }),
+ ).toHaveAttribute("aria-selected", "true");
+ });
+
+ it("keeps Default selected after choosing it from the list", async () => {
+ mocks.capabilities.mockReturnValue({
+ capabilities: ACTION_CAPABILITIES,
+ supported: true,
+ unmet: [],
+ isLoading: false,
+ });
+ const { user } = renderDialog(CUSTOM_AUTOMATION_ENTRY);
+
+ await waitFor(() =>
+ expect(screen.getByTestId("setup-action-kind")).toBeInTheDocument(),
+ );
+ await user.click(screen.getByTestId("setup-action-kind"));
+ await user.click(await screen.findByText("Upload tarball"));
+
+ // Choose a saved profile first, so the return to Default is a real
+ // selection change rather than the form's initial state.
+ const selector = await screen.findByTestId("automation-agent-profile");
+ await user.click(selector);
+ await user.click(await screen.findByText("Reviewer"));
+ await waitFor(() => expect(selector).toHaveValue("Reviewer"));
+
+ await user.click(selector);
+ await user.click(await screen.findByText(I18nKey.SETTINGS$PROFILE_DEFAULT));
+ await waitFor(() =>
+ expect(selector).toHaveValue(I18nKey.SETTINGS$PROFILE_DEFAULT),
+ );
+ });
+
it("asks about an unconnected integration before it asks anything else", async () => {
// Arrange β€” an advisory integration, which is shown but does not block.
mocks.prerequisites.mockReturnValue({
diff --git a/src/components/features/manifest/manifest-setup-dialog.tsx b/src/components/features/manifest/manifest-setup-dialog.tsx
index 52188359ef..d4db1d5808 100644
--- a/src/components/features/manifest/manifest-setup-dialog.tsx
+++ b/src/components/features/manifest/manifest-setup-dialog.tsx
@@ -548,8 +548,11 @@ export function SetupDialog({ entry, onClose }: SetupDialogProps) {
)}
{canSelectAgentProfile && (
<AutomationAgentProfileSelector
+ // The form stores "no profile" as "", but the selector only
+ // reads null/undefined as Default; "" would render it blank.
value={
- typeof values.agent_profile_id === "string"
+ typeof values.agent_profile_id === "string" &&
+ values.agent_profile_id !== ""
? values.agent_profile_id
: null
}