mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-30 17:14:54 +01:00
Revert "Fix default model adapter test config" (#9363)
Reverts paperclipai/paperclip#9361
This commit is contained in:
1 parent
ebd62ca5ae
commit
e84731af70
4 files changed
+9
-141
No files matched your search
@@ -6,10 +6,7 @@ description: >
|
||||
checkbox confirmations, ask_user_questions, or suggest_tasks.
|
||||
---
|
||||
|
||||
# Create a new issue-thread interaction UI (Developer/maintainer skill)
|
||||
|
||||
Do NOT install this on production Paperclip agents. This is a developer/maintainer
|
||||
skill for contributors changing Paperclip source code.
|
||||
# Create a new issue-thread interaction UI (developer skill)
|
||||
|
||||
This skill walks a Paperclip contributor through introducing a new issue-thread
|
||||
interaction kind from shared contract to issue-detail wiring, helpers, and
|
||||
|
||||
@@ -7,7 +7,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { Agent, Environment } from "@paperclipai/shared";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
import { AgentConfigForm } from "./AgentConfigForm";
|
||||
import { defaultCreateValues } from "./agent-config-defaults";
|
||||
|
||||
const mockAgentsApi = vi.hoisted(() => ({
|
||||
adapterModelProfiles: vi.fn(),
|
||||
@@ -69,9 +68,7 @@ vi.mock("../adapters", () => ({
|
||||
adapterType === "hermes_gateway"
|
||||
? <div data-testid="hermes-gateway-config-fields">Hermes Gateway fields</div>
|
||||
: null,
|
||||
buildAdapterConfig: (values: { model?: string }) => ({
|
||||
model: values.model || undefined,
|
||||
}),
|
||||
buildAdapterConfig: () => ({}),
|
||||
parseStdoutLine: () => [],
|
||||
}),
|
||||
}));
|
||||
@@ -226,51 +223,6 @@ async function renderForm(
|
||||
return { container, root };
|
||||
}
|
||||
|
||||
async function renderCreateForm(
|
||||
environments: Environment[],
|
||||
valueOverrides: Partial<typeof defaultCreateValues> = {},
|
||||
options: { showAdapterTestEnvironmentButton?: boolean } = {},
|
||||
) {
|
||||
mockEnvironmentsApi.list.mockResolvedValue(environments);
|
||||
|
||||
const container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
const root = createRoot(container);
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: { retry: false },
|
||||
mutations: { retry: false },
|
||||
},
|
||||
});
|
||||
|
||||
const values = {
|
||||
...defaultCreateValues,
|
||||
adapterType: "codex_local",
|
||||
...valueOverrides,
|
||||
};
|
||||
const onChange = vi.fn();
|
||||
|
||||
await act(async () => {
|
||||
root.render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<TooltipProvider>
|
||||
<AgentConfigForm
|
||||
mode="create"
|
||||
values={values}
|
||||
onChange={onChange}
|
||||
hidePromptTemplate
|
||||
showAdapterTypeField={false}
|
||||
showAdapterTestEnvironmentButton={options.showAdapterTestEnvironmentButton ?? false}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
});
|
||||
|
||||
await flushReact();
|
||||
return { container, root, onChange };
|
||||
}
|
||||
|
||||
describe("AgentConfigForm environment selector", () => {
|
||||
let roots: Root[] = [];
|
||||
|
||||
@@ -443,87 +395,6 @@ describe("AgentConfigForm environment selector", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("tests a Codex agent after clearing the primary model to the adapter default", async () => {
|
||||
const result = await renderForm([
|
||||
makeEnvironment({ id: "local-1", name: "Local", driver: "local" }),
|
||||
], {
|
||||
adapterConfig: { model: "gpt-5.4" },
|
||||
}, {
|
||||
showAdapterTestEnvironmentButton: true,
|
||||
});
|
||||
roots.push(result.root);
|
||||
|
||||
const modelButton = Array.from(result.container.querySelectorAll("button")).find(
|
||||
(button) => button.textContent?.trim() === "gpt-5.4",
|
||||
);
|
||||
expect(modelButton).toBeTruthy();
|
||||
|
||||
await act(async () => {
|
||||
modelButton?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
||||
});
|
||||
await flushReact();
|
||||
|
||||
const defaultButton = Array.from(document.body.querySelectorAll("button")).find(
|
||||
(button) => button.textContent?.trim() === "Default",
|
||||
);
|
||||
expect(defaultButton).toBeTruthy();
|
||||
|
||||
await act(async () => {
|
||||
defaultButton?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
||||
});
|
||||
await flushReact();
|
||||
|
||||
const testButton = Array.from(result.container.querySelectorAll("button")).find(
|
||||
(button) => button.textContent?.trim() === "Test",
|
||||
);
|
||||
expect(testButton).toBeTruthy();
|
||||
|
||||
await act(async () => {
|
||||
testButton?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
||||
});
|
||||
await flushReact();
|
||||
|
||||
expect(mockAgentsApi.testEnvironment).toHaveBeenCalledTimes(1);
|
||||
expect(mockAgentsApi.testEnvironment.mock.calls[0]?.[2]).toMatchObject({
|
||||
adapterConfig: {},
|
||||
});
|
||||
const adapterConfig = (mockAgentsApi.testEnvironment.mock.calls[0]?.[2] as {
|
||||
adapterConfig: Record<string, unknown>;
|
||||
}).adapterConfig;
|
||||
expect(adapterConfig).not.toHaveProperty("model");
|
||||
expect(result.container.textContent).not.toContain("Cannot read properties of undefined");
|
||||
});
|
||||
|
||||
it("omits undefined adapter config entries when testing a create form with the default model", async () => {
|
||||
const result = await renderCreateForm([
|
||||
makeEnvironment({ id: "local-1", name: "Local", driver: "local" }),
|
||||
], {
|
||||
model: "",
|
||||
}, {
|
||||
showAdapterTestEnvironmentButton: true,
|
||||
});
|
||||
roots.push(result.root);
|
||||
|
||||
const testButton = Array.from(result.container.querySelectorAll("button")).find(
|
||||
(button) => button.textContent?.trim() === "Test",
|
||||
);
|
||||
expect(testButton).toBeTruthy();
|
||||
|
||||
await act(async () => {
|
||||
testButton?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
||||
});
|
||||
await flushReact();
|
||||
|
||||
expect(mockAgentsApi.testEnvironment).toHaveBeenCalledTimes(1);
|
||||
expect(mockAgentsApi.testEnvironment.mock.calls[0]?.[2]).toMatchObject({
|
||||
adapterConfig: {},
|
||||
});
|
||||
const adapterConfig = (mockAgentsApi.testEnvironment.mock.calls[0]?.[2] as {
|
||||
adapterConfig: Record<string, unknown>;
|
||||
}).adapterConfig;
|
||||
expect(adapterConfig).not.toHaveProperty("model");
|
||||
});
|
||||
|
||||
it("flushes pending environment variable edits before testing adapter config", async () => {
|
||||
const result = await renderForm([
|
||||
makeEnvironment({ id: "local-1", name: "Local", driver: "local" }),
|
||||
|
||||
@@ -55,7 +55,7 @@ import { shouldShowLegacyWorkingDirectoryField } from "../lib/legacy-agent-confi
|
||||
import { listAdapterOptions, listVisibleAdapterTypes } from "../adapters/metadata";
|
||||
import { getAdapterDisplay, getAdapterLabel } from "../adapters/adapter-display-registry";
|
||||
import { useDisabledAdaptersSync } from "../adapters/use-disabled-adapters";
|
||||
import { buildAgentUpdatePatch, omitUndefinedEntries, type AgentConfigOverlay } from "../lib/agent-config-patch";
|
||||
import { buildAgentUpdatePatch, type AgentConfigOverlay } from "../lib/agent-config-patch";
|
||||
import { useAdapterCapabilities } from "../adapters/use-adapter-capabilities";
|
||||
import { resolveForcedKubernetesEnvironment } from "../lib/forced-kubernetes-environment";
|
||||
|
||||
@@ -195,6 +195,7 @@ function clampDelayMsFromSeconds(value: number) {
|
||||
return clampInteger(value, 0, MAX_TURN_CONTINUATION_MAX_DELAY_SEC) * 1000;
|
||||
}
|
||||
|
||||
|
||||
/* ---- Form ---- */
|
||||
|
||||
export function AgentConfigForm(props: AgentConfigFormProps) {
|
||||
@@ -537,14 +538,14 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
||||
if (adapterConfigPatch) {
|
||||
Object.assign(next, adapterConfigPatch);
|
||||
}
|
||||
return omitUndefinedEntries(next);
|
||||
return next;
|
||||
}
|
||||
const base = config as Record<string, unknown>;
|
||||
const next = { ...base, ...overlay.adapterConfig };
|
||||
if (adapterConfigPatch) {
|
||||
Object.assign(next, adapterConfigPatch);
|
||||
}
|
||||
return omitUndefinedEntries(next);
|
||||
return next;
|
||||
}
|
||||
|
||||
function buildCheapAdapterConfigForTest(adapterConfigPatch?: Record<string, unknown>): Record<string, unknown> {
|
||||
@@ -746,10 +747,9 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
||||
}, [props.onTestFeedbackChange, testActionError, testEnvironment.data, testEnvironment.error]);
|
||||
|
||||
// Current model for display
|
||||
const currentModelValue = isCreate
|
||||
? val!.model ?? ""
|
||||
const currentModelId = isCreate
|
||||
? val!.model
|
||||
: eff("adapterConfig", "model", String(config.model ?? ""));
|
||||
const currentModelId = typeof currentModelValue === "string" ? currentModelValue : "";
|
||||
|
||||
async function handleRefreshModels() {
|
||||
if (!selectedCompanyId) return;
|
||||
|
||||
@@ -19,7 +19,7 @@ export interface AgentConfigOverlay {
|
||||
modelProfiles?: { cheap?: AgentModelProfileOverlay };
|
||||
}
|
||||
|
||||
export function omitUndefinedEntries(value: Record<string, unknown>) {
|
||||
function omitUndefinedEntries(value: Record<string, unknown>) {
|
||||
return Object.fromEntries(
|
||||
Object.entries(value).filter(([, entryValue]) => entryValue !== undefined),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user