From 16c01b3507e0fc596cfce9e4b5833239f656df41 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 5 Aug 2025 16:57:15 -0700 Subject: [PATCH] fix: Add TTY environment detection to prevent CI failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added comprehensive environment detection in runOnboardingFlow to skip interactive prompts in test/CI environments. Detects: - NODE_ENV=test - CI=true - VITEST=true - GITHUB_ACTIONS=true - \!process.stdin.isTTY This prevents "The current environment doesn't support interactive reading from TTY" errors in GitHub Actions CI. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/onboarding.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/onboarding.ts b/src/onboarding.ts index b379f368d..85f80aabc 100644 --- a/src/onboarding.ts +++ b/src/onboarding.ts @@ -66,7 +66,20 @@ export async function runOnboardingFlow( return { ...result, wasOnboarded: false }; } - // Step 2: Present user with two options + // Step 2: Check if we're in a test/CI environment - if so, skip interactive prompts + const isTestEnv = process.env.NODE_ENV === "test" || + process.env.CI === "true" || + process.env.VITEST === "true" || + process.env.GITHUB_ACTIONS === "true" || + !process.stdin.isTTY; + + if (isTestEnv) { + // In test/CI environment, return a minimal working configuration + const result = await initialize(authConfig, undefined); + return { ...result, wasOnboarded: false }; + } + + // Step 3: Present user with two options console.log(chalk.yellow("How do you want to get started?")); console.log(chalk.white("1. ⏩ Log in with Continue")); console.log(chalk.white("2. 🔑 Enter your Anthropic API key"));