-
Notifications
You must be signed in to change notification settings - Fork 165
chore: centralize interactive terminal detection #1000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thymikee
merged 1 commit into
feat/replay-test-progress-reporter
from
chore/centralize-ci-env-checks
Jul 2, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { test } from 'vitest'; | ||
| import assert from 'node:assert/strict'; | ||
| import { isInteractive } from '../env-map.ts'; | ||
|
|
||
| test('isInteractive requires a tty and detects CI environment markers', () => { | ||
| assert.equal(isInteractive({ isTTY: true }, {}), true); | ||
| assert.equal(isInteractive({ isTTY: false }, {}), false); | ||
| assert.equal(isInteractive({}, {}), false); | ||
| assert.equal(isInteractive({ isTTY: true }, { CI: '' }), true); | ||
| assert.equal(isInteractive({ isTTY: true }, { CI: ' ' }), false); | ||
| assert.equal(isInteractive({ isTTY: true }, { CI: 'false' }), true); | ||
| assert.equal(isInteractive({ isTTY: true }, { CI: '0' }), true); | ||
| assert.equal(isInteractive({ isTTY: true }, { CI: 'false', GITHUB_ACTIONS: 'true' }), true); | ||
| assert.equal(isInteractive({ isTTY: true }, { CI: '0', GITHUB_ACTIONS: 'true' }), true); | ||
| assert.equal(isInteractive({ isTTY: true }, { CI: 'true' }), false); | ||
| assert.equal(isInteractive({ isTTY: true }, { CI: '1' }), false); | ||
| assert.equal(isInteractive({ isTTY: true }, { BUILD_NUMBER: '123' }), false); | ||
| assert.equal(isInteractive({ isTTY: true }, { CONTINUOUS_INTEGRATION: 'true' }), false); | ||
| assert.equal(isInteractive({ isTTY: true }, { GITHUB_ACTIONS: 'true' }), false); | ||
| assert.equal(isInteractive({ isTTY: true }, { BUILDKITE: 'true' }), false); | ||
| assert.equal( | ||
| isInteractive({ isTTY: true }, { GITHUB_ACTIONS: 'false', BUILDKITE: 'false' }), | ||
| true, | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,29 @@ | ||
| export type EnvMap = Record<string, string | undefined>; | ||
| export type DefinedEnvMap = Record<string, string>; | ||
| export type TtyLike = { isTTY?: boolean | undefined }; | ||
|
|
||
| const CI_ENV_MARKERS = [ | ||
| 'BUILD_ID', | ||
| 'BUILD_NUMBER', | ||
| 'CI', | ||
| 'CI_APP_ID', | ||
| 'CI_BUILD_ID', | ||
| 'CI_BUILD_NUMBER', | ||
| 'CI_NAME', | ||
| 'CONTINUOUS_INTEGRATION', | ||
| 'RUN_ID', | ||
| ] as const; | ||
|
|
||
| const CI_TRUE_MARKERS = ['GITHUB_ACTIONS', 'BUILDKITE'] as const; | ||
|
|
||
| function isCI(env: EnvMap = process.env): boolean { | ||
| if (env.CI === 'false' || env.CI === '0') return false; | ||
| return ( | ||
| CI_ENV_MARKERS.some((name) => Boolean(env[name])) || | ||
| CI_TRUE_MARKERS.some((name) => env[name] === 'true') | ||
| ); | ||
| } | ||
|
|
||
| export function isInteractive(stream: TtyLike, env: EnvMap = process.env): boolean { | ||
| return !isCI(env) && stream.isTTY === true; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚩 CI='false' now overrides all other CI markers, changing auth behavior on GitHub Actions
The new
isCIfunction atsrc/utils/env-map.ts:20returnsfalseimmediately whenCI='false'orCI='0', before checking any other markers likeGITHUB_ACTIONSorBUILDKITE. This means{ CI: 'false', GITHUB_ACTIONS: 'true' }is now treated as non-CI (tests atsrc/utils/__tests__/env-map.test.ts:13-14confirm this). The oldisCiinsrc/cli/auth-session.ts(removed at old lines 485-487) checkedenv.GITHUB_ACTIONS === 'true'independently, so it would have returnedtrue(CI) in that scenario. In practice this means if a GitHub Actions workflow explicitly setsCI=false(some do for build tools),detectAuthModewould now return'local-browser'or'device-code'instead of'non-interactive', potentially attempting to open a browser on a CI runner. The tests assert this is intentional, but it's a meaningful behavioral change worth confirming with the team.Was this helpful? React with 👍 or 👎 to provide feedback.