Support yes/no env aliases in perf toggle parser

Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
Cursor AgentandJulius Marminge committed 2026-02-17 07:14:00 +00:00
1 parent c0f8077010
commit 1cb08a2cb2
2 files changed
+37 -6

No files matched your search

+24
View File
@@ -36,6 +36,18 @@ describe("shouldRunTerminalPerfInteractions", () => {
CI: "true",
}),
).toBe(true);
expect(
shouldRunTerminalPerfInteractions({
T3CODE_DESKTOP_PERF_RUN_TERMINAL: " yes ",
CI: "true",
}),
).toBe(true);
expect(
shouldRunTerminalPerfInteractions({
T3CODE_DESKTOP_PERF_RUN_TERMINAL: "ON",
CI: "true",
}),
).toBe(true);
});
it("supports explicit false values", () => {
@@ -57,6 +69,18 @@ describe("shouldRunTerminalPerfInteractions", () => {
CI: "false",
}),
).toBe(false);
expect(
shouldRunTerminalPerfInteractions({
T3CODE_DESKTOP_PERF_RUN_TERMINAL: " no ",
CI: "false",
}),
).toBe(false);
expect(
shouldRunTerminalPerfInteractions({
T3CODE_DESKTOP_PERF_RUN_TERMINAL: "OFF",
CI: "false",
}),
).toBe(false);
expect(
shouldRunTerminalPerfInteractions({
T3CODE_DESKTOP_PERF_RUN_TERMINAL: "0",
+13 -6
View File
@@ -3,11 +3,19 @@ type PerfToggleEnv = {
CI?: string | undefined;
};
const CI_TRUE_VALUES = new Set(["1", "true", "yes", "on"]);
const TRUE_VALUES = new Set(["1", "true", "yes", "on"]);
const FALSE_VALUES = new Set(["0", "false", "no", "off"]);
function parseBooleanLike(value: string | undefined): boolean | null {
const normalized = value?.trim().toLowerCase();
if (!normalized) return null;
if (TRUE_VALUES.has(normalized)) return true;
if (FALSE_VALUES.has(normalized)) return false;
return null;
}
function isCiEnvironment(value: string | undefined): boolean {
const normalized = value?.trim().toLowerCase();
return normalized ? CI_TRUE_VALUES.has(normalized) : false;
return parseBooleanLike(value) === true;
}
/**
@@ -18,8 +26,7 @@ function isCiEnvironment(value: string | undefined): boolean {
* flaky PTY-dependent interactions in ephemeral Linux runners.
*/
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;
const toggleOverride = parseBooleanLike(env.T3CODE_DESKTOP_PERF_RUN_TERMINAL);
if (toggleOverride !== null) return toggleOverride;
return !isCiEnvironment(env.CI);
}