Harden perf toggle fallback for CI truthy values

Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
Cursor AgentandJulius Marminge authored and Julius Marminge committed 2026-02-17 19:49:55 -08:00
1 parent 51b89effd8
commit def1086143
2 files changed
+13 -1

No files matched your search

+5
View File
@@ -5,11 +5,16 @@ import { shouldRunTerminalPerfInteractions } from "./perfConfig";
describe("shouldRunTerminalPerfInteractions", () => {
it("defaults to enabled outside CI when env is unset", () => {
expect(shouldRunTerminalPerfInteractions({ CI: "false" })).toBe(true);
expect(shouldRunTerminalPerfInteractions({ CI: "0" })).toBe(true);
expect(shouldRunTerminalPerfInteractions({ CI: undefined })).toBe(true);
});
it("defaults to disabled in CI when env is unset", () => {
expect(shouldRunTerminalPerfInteractions({ CI: "true" })).toBe(false);
expect(shouldRunTerminalPerfInteractions({ CI: "TRUE" })).toBe(false);
expect(shouldRunTerminalPerfInteractions({ CI: "1" })).toBe(false);
expect(shouldRunTerminalPerfInteractions({ CI: " yes " })).toBe(false);
expect(shouldRunTerminalPerfInteractions({ CI: "on" })).toBe(false);
});
it("supports explicit true values", () => {
+8 -1
View File
@@ -3,6 +3,13 @@ type PerfToggleEnv = {
CI?: string | undefined;
};
const CI_TRUE_VALUES = new Set(["1", "true", "yes", "on"]);
function isCiEnvironment(value: string | undefined): boolean {
const normalized = value?.trim().toLowerCase();
return normalized ? CI_TRUE_VALUES.has(normalized) : false;
}
/**
* Controls whether desktop perf automation should include terminal shortcuts.
*
@@ -14,5 +21,5 @@ export function shouldRunTerminalPerfInteractions(env: PerfToggleEnv): boolean {
const raw = env.T3CODE_DESKTOP_PERF_RUN_TERMINAL?.trim().toLowerCase();
if (raw === "1" || raw === "true") return true;
if (raw === "0" || raw === "false") return false;
return env.CI !== "true";
return !isCiEnvironment(env.CI);
}