Skip to content

The open-source app everyone uses to manage agents at work

fix(ui): make adapter test button test only (#8405)

Devin Foleye281095cb4e8
diff --git a/ui/src/components/AgentConfigForm.test.ts b/ui/src/components/AgentConfigForm.test.ts
index 51e2e10759..befe41c340 100644
--- a/ui/src/components/AgentConfigForm.test.ts
+++ b/ui/src/components/AgentConfigForm.test.ts
@@ -1,10 +1,6 @@
-import { describe, expect, it, vi } from "vitest";
-import type { AdapterEnvironmentTestResult, Environment } from "@paperclipai/shared";
-import {
- getAgentConfigTestActionLabel,
- runAgentConfigEnvironmentTest,
- supportsAdapterModelRefresh,
-} from "./AgentConfigForm";
+import { describe, expect, it } from "vitest";
+import type { Environment } from "@paperclipai/shared";
+import { supportsAdapterModelRefresh } from "./AgentConfigForm";
import { resolveForcedKubernetesEnvironment } from "../lib/forced-kubernetes-environment";
describe("supportsAdapterModelRefresh", () => {
@@ -20,61 +16,6 @@ describe("supportsAdapterModelRefresh", () => {
});
});
-describe("agent config test action", () => {
- it("labels dirty edit-mode tests as save-and-test", () => {
- expect(getAgentConfigTestActionLabel({ isCreate: false, isDirty: true })).toBe("Save + Test");
- expect(getAgentConfigTestActionLabel({ isCreate: false, isDirty: false })).toBe("Test");
- expect(getAgentConfigTestActionLabel({ isCreate: true, isDirty: true })).toBe("Test");
- });
-
- it("saves a dirty edit draft before running the environment test", async () => {
- const callOrder: string[] = [];
- const saveDraft = vi.fn(async () => {
- callOrder.push("save");
- });
- const runTest = vi.fn(async (): Promise<AdapterEnvironmentTestResult> => {
- callOrder.push("test");
- return {
- adapterType: "claude_local",
- status: "pass",
- checks: [],
- testedAt: new Date(0).toISOString(),
- };
- });
-
- await runAgentConfigEnvironmentTest({
- isCreate: false,
- isDirty: true,
- saveDraft,
- runTest,
- });
-
- expect(saveDraft).toHaveBeenCalledTimes(1);
- expect(runTest).toHaveBeenCalledTimes(1);
- expect(callOrder).toEqual(["save", "test"]);
- });
-
- it("runs create-mode tests without saving first", async () => {
- const saveDraft = vi.fn(async () => {});
- const runTest = vi.fn(async (): Promise<AdapterEnvironmentTestResult> => ({
- adapterType: "claude_local",
- status: "pass",
- checks: [],
- testedAt: new Date(0).toISOString(),
- }));
-
- await runAgentConfigEnvironmentTest({
- isCreate: true,
- isDirty: true,
- saveDraft,
- runTest,
- });
-
- expect(saveDraft).not.toHaveBeenCalled();
- expect(runTest).toHaveBeenCalledTimes(1);
- });
-});
-
function makeEnvironment(overrides: Partial<Environment>): Environment {
return {
id: "env-1",
diff --git a/ui/src/components/AgentConfigForm.tsx b/ui/src/components/AgentConfigForm.tsx
index 5355d2f1b3..2b2316f2bc 100644
--- a/ui/src/components/AgentConfigForm.tsx
+++ b/ui/src/components/AgentConfigForm.tsx
@@ -116,22 +116,6 @@ export function supportsAdapterModelRefresh(adapterType: string): boolean {
return adapterType === "claude_local" || adapterType === "codex_local" || adapterType === "acpx_local";
}
-export function getAgentConfigTestActionLabel(input: { isCreate: boolean; isDirty: boolean }): string {
- return !input.isCreate && input.isDirty ? "Save + Test" : "Test";
-}
-
-export async function runAgentConfigEnvironmentTest(input: {
- isCreate: boolean;
- isDirty: boolean;
- saveDraft?: () => void | Promise<unknown>;
- runTest: () => Promise<AdapterEnvironmentTestResult>;
-}) {
- if (!input.isCreate && input.isDirty) {
- await input.saveDraft?.();
- }
- return await input.runTest();
-}
-
function isOverlayDirty(o: AgentConfigOverlay): boolean {
return (
Object.keys(o.identity).length > 0 ||
@@ -555,7 +539,7 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
});
const [testActionPending, setTestActionPending] = useState(false);
const [testActionError, setTestActionError] = useState<string | null>(null);
- const testActionLabel = getAgentConfigTestActionLabel({ isCreate, isDirty });
+ const testActionLabel = "Test";
const isSavePending = !isCreate && Boolean(props.isSaving);
const testEnvironmentDisabled = testActionPending || isSavePending || !selectedCompanyId;
const runEnvironmentTest = useCallback(async () => {
@@ -566,19 +550,14 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
setTestActionError(null);
testEnvironment.reset();
try {
- return await runAgentConfigEnvironmentTest({
- isCreate,
- isDirty,
- saveDraft: !isCreate ? handleSave : undefined,
- runTest: () => testEnvironment.mutateAsync(),
- });
+ return await testEnvironment.mutateAsync();
} catch (error) {
setTestActionError(error instanceof Error ? error.message : "Environment test failed");
throw error;
} finally {
setTestActionPending(false);
}
- }, [selectedCompanyId, isCreate, isDirty, handleSave, testEnvironment]);
+ }, [selectedCompanyId, testEnvironment]);
// `runEnvironmentTest` (and `testEnvironmentDisabled`) change identity on every
// render because `useMutation` returns a fresh result object each time. Hold the
// latest behavior in a ref so the trigger handed to the parent stays referentially