TypeScript
fix(web): name inherited background activity profiles (#23450)
Victor Vogel6ad082745a5d
diff --git a/apps/web/src/components/settings/SettingInheritance.test.ts b/apps/web/src/components/settings/SettingInheritance.test.tsindex e02bb6b3d35..527a1cdbbf5 100644--- a/apps/web/src/components/settings/SettingInheritance.test.ts+++ b/apps/web/src/components/settings/SettingInheritance.test.ts@@ -8,6 +8,31 @@ const environmentId = EnvironmentId.make("laptop");const projectId = ProjectId.make("project");describe("settingInheritanceLayers", () => {+ it("identifies the background activity profile supplied by each layer", () => {+ const settings = {+ ...DEFAULT_SERVER_SETTINGS,+ backgroundActivity: {+ schemaVersion: 1 as const,+ profile: "performance" as const,+ overrides: {},+ },+ };+ const layers = settingInheritanceLayers(+ {+ environmentId,+ label: "Laptop",+ projectId: null,+ ...resolveProjectSettings(settings, projectId),+ },+ settings,+ "backgroundActivity",+ );+ expect(layers.map((layer) => [layer.key, layer.value, layer.effective])).toEqual([+ ["environment", "Performance", true],+ ["built-in", "Balanced", false],+ ]);+ });+it("shows the checkout's t3.json as a layer for file-backed keys", () => {const file = { defaultThreadEnvMode: "worktree" as const };const fromFile = settingInheritanceLayers(diff --git a/apps/web/src/components/settings/SettingInheritance.tsx b/apps/web/src/components/settings/SettingInheritance.tsxindex 692f254df1f..051017a9589 100644--- a/apps/web/src/components/settings/SettingInheritance.tsx+++ b/apps/web/src/components/settings/SettingInheritance.tsx@@ -37,6 +37,13 @@ const WRITING_STYLE_LABELS: Record<string, string> = {custom: "Custom instructions",};+const BACKGROUND_ACTIVITY_PROFILE_LABELS: Record<string, string> = {+ balanced: "Balanced",+ performance: "Performance",+ "battery-saver": "Battery saver",+ custom: "Advanced",+};+function formatValue(key: keyof ServerSettings, value: unknown): string {if (value === null || value === undefined) {return key === "pullRequestMergeMethod"@@ -75,6 +82,9 @@ function formatValue(key: keyof ServerSettings, value: unknown): string {}if (Array.isArray(value)) return `${value.length} ${value.length === 1 ? "item" : "items"}`;if (typeof value === "object") {+ if (key === "backgroundActivity" && "profile" in value && typeof value.profile === "string") {+ return BACKGROUND_ACTIVITY_PROFILE_LABELS[value.profile] ?? value.profile;+ }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;