mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 02:26:12 +02:00
Preserve existing environment overrides
Keep saved non-local overrides visible even when they are not runnable so operators can inspect or clear stale environment selections. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
7a74d93579
commit
d935c3113a
2 files changed
+34
-3
No files matched your search
@@ -155,7 +155,7 @@ function makeEnvironment(overrides: Partial<Environment>): Environment {
|
||||
};
|
||||
}
|
||||
|
||||
async function renderForm(environments: Environment[]) {
|
||||
async function renderForm(environments: Environment[], agentOverrides: Partial<Agent> = {}) {
|
||||
mockEnvironmentsApi.list.mockResolvedValue(environments);
|
||||
|
||||
const container = document.createElement("div");
|
||||
@@ -174,7 +174,7 @@ async function renderForm(environments: Environment[]) {
|
||||
<TooltipProvider>
|
||||
<AgentConfigForm
|
||||
mode="edit"
|
||||
agent={makeAgent()}
|
||||
agent={makeAgent(agentOverrides)}
|
||||
onSave={vi.fn()}
|
||||
hidePromptTemplate
|
||||
showAdapterTypeField={false}
|
||||
@@ -246,4 +246,27 @@ describe("AgentConfigForm environment selector", () => {
|
||||
expect(text).not.toContain("Leave this unset to inherit the instance default");
|
||||
expect(text).not.toContain("Inherit instance default");
|
||||
});
|
||||
|
||||
it("keeps an existing non-runnable override visible so it can be cleared", async () => {
|
||||
const result = await renderForm(
|
||||
[
|
||||
makeEnvironment({ id: "local-1", name: "Local", driver: "local" }),
|
||||
makeEnvironment({
|
||||
id: "fake-sandbox-1",
|
||||
name: "Fake Sandbox",
|
||||
driver: "sandbox",
|
||||
config: { provider: "fake" },
|
||||
}),
|
||||
],
|
||||
{ defaultEnvironmentId: "fake-sandbox-1" },
|
||||
);
|
||||
roots.push(result.root);
|
||||
|
||||
const text = result.container.textContent ?? "";
|
||||
const selector = result.container.querySelector("select");
|
||||
|
||||
expect(text).toContain("Environment override");
|
||||
expect(selector?.textContent).toContain("Default: Local");
|
||||
expect(selector?.textContent).toContain("Fake Sandbox · sandbox");
|
||||
});
|
||||
});
|
||||
@@ -400,11 +400,19 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
||||
}),
|
||||
[environments, supportedEnvironmentDrivers],
|
||||
);
|
||||
const environmentOptions = useMemo(() => {
|
||||
if (!currentDefaultEnvironment) return runnableEnvironments;
|
||||
if (runnableEnvironments.some((environment) => environment.id === currentDefaultEnvironment.id)) {
|
||||
return runnableEnvironments;
|
||||
}
|
||||
return [...runnableEnvironments, currentDefaultEnvironment];
|
||||
}, [currentDefaultEnvironment, runnableEnvironments]);
|
||||
// `runnableEnvironments` excludes the always-available Local environment, so a
|
||||
// single entry already means the user has more than one environment configured
|
||||
// (Local + that environment) and the override selector is meaningful.
|
||||
const showEnvironmentOverrideControl = environmentsEnabled && (
|
||||
forcedKubernetes ||
|
||||
currentDefaultEnvironmentId.length > 0 ||
|
||||
runnableEnvironments.length >= 1
|
||||
);
|
||||
const inheritedEnvironmentLabel = instanceDefaultEnvironment
|
||||
@@ -929,7 +937,7 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
||||
}}
|
||||
>
|
||||
<option value="">Default: {inheritedEnvironmentLabel}</option>
|
||||
{runnableEnvironments.map((environment) => (
|
||||
{environmentOptions.map((environment) => (
|
||||
<option key={environment.id} value={environment.id}>
|
||||
{environment.name} · {environment.driver}
|
||||
</option>
|
||||
|
||||
Reference in new issue
Block a user