From a7fa8c76a487d254ccddd2a265e6aa0280136f5a Mon Sep 17 00:00:00 2001 From: Gerkinfeltser Date: Thu, 19 Feb 2026 11:10:42 -0600 Subject: [PATCH] fix: use CI env var to detect test environment Check for CI environment variable (set by GitHub Actions and most CI systems) instead of VITEST to skip beforeunload handler registration during automated tests. --- src/server/process/WindowsProcess.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/process/WindowsProcess.ts b/src/server/process/WindowsProcess.ts index 7e1ee65..02563d7 100644 --- a/src/server/process/WindowsProcess.ts +++ b/src/server/process/WindowsProcess.ts @@ -78,8 +78,8 @@ export class WindowsProcess implements OpenCodeProcess { } // Register beforeunload handler for window close cleanup - // Skip in test environment to avoid interfering with test lifecycle - if (typeof window !== "undefined" && !process.env.VITEST) { + // Skip in CI/test environments to avoid interfering with test lifecycle + if (typeof window !== "undefined" && !process.env.CI) { window.addEventListener("beforeunload", () => { if (WindowsProcess.currentProcess?.pid) { WindowsProcess.killProcessSync(WindowsProcess.currentProcess.pid);