Skip to content

Show CI environment name in non-interactive message when in CI #50

Closed

Description

@admarble

Problem

When running in a CI environment like GitHub Actions, the non-interactive mode message shows the stdin reason instead of the CI environment name:

Current behavior:

⚡ Non-interactive mode detected (stdin is not a terminal (piped input detected))

Expected behavior:

⚡ Non-interactive mode detected (running in CI environment (github actions))

Root Cause

In src/lib/tty.ts, getNonInteractiveReason() checks in this order:

  1. stdin not TTY → returns immediately
  2. stdout not TTY
  3. CI environment

Since CI environments typically have non-TTY stdin, the stdin reason fires first.

Proposed Solution

Reorder the checks to prioritize CI detection:

export function getNonInteractiveReason(): string | null {
  // Check CI first - more informative for users
  if (isCI()) {
    for (const envVar of CI_ENV_VARS) {
      if (process.env[envVar]) {
        const ciName = envVar.replace(/_/g, " ").toLowerCase();
        return `running in CI environment (${ciName})`;
      }
    }
    return "running in CI environment";
  }
  
  // Then check TTY
  if (!isStdinTTY()) {
    return "stdin is not a terminal (piped input detected)";
  }
  if (!isStdoutTTY()) {
    return "stdout is not a terminal";
  }
  
  return null;
}

Acceptance Criteria

  • CI environment name shown when CI env var is set (even if stdin is non-TTY)
  • Update tests to verify new priority order
  • Existing non-CI piped input detection still works

Priority

Low - cosmetic UX improvement, core functionality works correctly.

Activity

  1. admarble commented on Jan 11, 2026

    @admarble
    ContributorAuthor

    Plan Review (Phase 1: /spec)

    Acceptance Criteria with Verification

    AC-1: CI environment name shown when CI env var is set (even if stdin is non-TTY)

    Verification Method: Unit Test

    Test Scenario:

    • Given: GITHUB_ACTIONS=true is set AND stdin.isTTY=false
    • When: getNonInteractiveReason() is called
    • Then: Returns "running in CI environment (github actions)" (NOT the stdin reason)

    AC-2: Update tests to verify new priority order

    Verification Method: Unit Test

    Test Scenario:

    • Given: Existing test suite in src/lib/tty.test.ts
    • When: New tests are added for CI priority over TTY checks
    • Then: Tests verify CI reason is returned even when stdin/stdout is non-TTY

    AC-3: Existing non-CI piped input detection still works

    Verification Method: Unit Test

    Test Scenario:

    • Given: No CI env vars set AND stdin.isTTY=false
    • When: getNonInteractiveReason() is called
    • Then: Returns "stdin is not a terminal (piped input detected)"

    Implementation Plan

    Phase 1: Reorder CI Check

    1. Modify src/lib/tty.ts - Move isCI() check to top of getNonInteractiveReason()

    Phase 2: Update Tests
    2. Modify src/lib/tty.test.ts - Add tests for CI priority over TTY checks

    Phase 3: Verification
    3. Run test suite to confirm all tests pass


    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: Small, well-defined bug fix with clear AC and existing test infrastructure.


    🤖 Generated by /spec planning agent

  2. added
    planned
    on Jan 11, 2026
  3. added a commit that references this issue on Jan 11, 2026
  4. admarble commented on Jan 11, 2026

    @admarble
    ContributorAuthor

    Implementation Complete (Phase 2: /exec)

    AC Coverage Summary

    AC Status Notes
    AC-1: CI environment name shown when CI env var is set (even if stdin is non-TTY) ✅ Satisfied CI check moved to top of getNonInteractiveReason()
    AC-2: Update tests to verify new priority order ✅ Satisfied 3 new tests added for CI priority
    AC-3: Existing non-CI piped input detection still works ✅ Satisfied Existing tests pass, clarified test names

    Files Changed

    File Change
    src/lib/tty.ts Reorder getNonInteractiveReason() to check CI first
    src/lib/tty.test.ts Add 3 new priority tests, clarify test names

    Build/Test Results

    • npm test: ✅ 284 tests passed
    • npm run build: ✅ Passed

    PR Status

    ✅ Created: #65

    Next Steps

    Ready for /qa review.

    🤖 Generated by /exec implementation agent

  5. added a commit that references this issue on Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions