mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 18:10:39 +09:00
Hide deprecated agent working directory by default
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
4ab3e4f7ab
commit
bf5cfaaeab
5 changed files with 64 additions and 28 deletions
40
ui/src/lib/legacy-agent-config.test.ts
Normal file
40
ui/src/lib/legacy-agent-config.test.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
hasLegacyWorkingDirectory,
|
||||
shouldShowLegacyWorkingDirectoryField,
|
||||
} from "./legacy-agent-config";
|
||||
|
||||
describe("legacy agent config helpers", () => {
|
||||
it("treats non-empty cwd values as legacy working directories", () => {
|
||||
expect(hasLegacyWorkingDirectory("/tmp/workspace")).toBe(true);
|
||||
expect(hasLegacyWorkingDirectory(" /tmp/workspace ")).toBe(true);
|
||||
});
|
||||
|
||||
it("ignores nullish and blank cwd values", () => {
|
||||
expect(hasLegacyWorkingDirectory("")).toBe(false);
|
||||
expect(hasLegacyWorkingDirectory(" ")).toBe(false);
|
||||
expect(hasLegacyWorkingDirectory(null)).toBe(false);
|
||||
expect(hasLegacyWorkingDirectory(undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it("shows the deprecated field only for edit forms with an existing cwd", () => {
|
||||
expect(
|
||||
shouldShowLegacyWorkingDirectoryField({
|
||||
isCreate: true,
|
||||
adapterConfig: { cwd: "/tmp/workspace" },
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
shouldShowLegacyWorkingDirectoryField({
|
||||
isCreate: false,
|
||||
adapterConfig: { cwd: "" },
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
shouldShowLegacyWorkingDirectoryField({
|
||||
isCreate: false,
|
||||
adapterConfig: { cwd: "/tmp/workspace" },
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
17
ui/src/lib/legacy-agent-config.ts
Normal file
17
ui/src/lib/legacy-agent-config.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
function asNonEmptyString(value: unknown): string | null {
|
||||
if (typeof value !== "string") return null;
|
||||
const trimmed = value.trim();
|
||||
return trimmed.length > 0 ? trimmed : null;
|
||||
}
|
||||
|
||||
export function hasLegacyWorkingDirectory(value: unknown): boolean {
|
||||
return asNonEmptyString(value) !== null;
|
||||
}
|
||||
|
||||
export function shouldShowLegacyWorkingDirectoryField(input: {
|
||||
isCreate: boolean;
|
||||
adapterConfig: Record<string, unknown> | null | undefined;
|
||||
}): boolean {
|
||||
if (input.isCreate) return false;
|
||||
return hasLegacyWorkingDirectory(input.adapterConfig?.cwd);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue