Skip to content
TypeScript

fix(web): label inherited worktree cleanup modes correctly (#23678)

Victor Vogel13f9bc4e5575
diff --git a/apps/web/src/components/settings/SettingInheritance.test.ts b/apps/web/src/components/settings/SettingInheritance.test.ts
index 527a1cdbbf5..3c178cd4c2c 100644
--- a/apps/web/src/components/settings/SettingInheritance.test.ts
+++ b/apps/web/src/components/settings/SettingInheritance.test.ts
@@ -7,6 +7,36 @@ import { settingInheritanceLayers } from "./SettingInheritance";
const environmentId = EnvironmentId.make("laptop");
const projectId = ProjectId.make("project");
+describe("worktree cleanup inheritance", () => {
+ it("distinguishes project and environment worktree cleanup policies", () => {
+ const settings = {
+ ...DEFAULT_SERVER_SETTINGS,
+ worktreeCleanup: {
+ mode: "custom" as const,
+ rules: DEFAULT_SERVER_SETTINGS.storageCleanup,
+ },
+ projectSettingsOverrides: {
+ [projectId]: { worktreeCleanup: { mode: "off" as const } },
+ },
+ };
+ const layers = settingInheritanceLayers(
+ {
+ environmentId,
+ label: "Laptop",
+ projectId,
+ ...resolveProjectSettings(settings, projectId),
+ },
+ settings,
+ "worktreeCleanup",
+ );
+ expect(layers.map((layer) => [layer.key, layer.value, layer.effective])).toEqual([
+ ["project", "Off", true],
+ ["environment", "Custom", false],
+ ["built-in", "Not set", false],
+ ]);
+ });
+});
+
describe("settingInheritanceLayers", () => {
it("identifies the background activity profile supplied by each layer", () => {
const settings = {
diff --git a/apps/web/src/components/settings/SettingInheritance.tsx b/apps/web/src/components/settings/SettingInheritance.tsx
index 051017a9589..8f83f137241 100644
--- a/apps/web/src/components/settings/SettingInheritance.tsx
+++ b/apps/web/src/components/settings/SettingInheritance.tsx
@@ -87,7 +87,10 @@ function formatValue(key: keyof ServerSettings, value: unknown): string {
}
if ("model" in value && typeof value.model === "string") return value.model;
if ("mode" in value && typeof value.mode === "string") {
- return WRITING_STYLE_LABELS[value.mode] ?? value.mode;
+ if (key === "worktreeCleanup") return value.mode === "off" ? "Off" : "Custom";
+ return key === "sourceControlWritingStyle"
+ ? (WRITING_STYLE_LABELS[value.mode] ?? value.mode)
+ : value.mode;
}
}
return "Custom";