Skip to content

[Code Quality] Replace hardcoded ANSI escape sequence with console package function #12706

@github-actions

Description

@github-actions

Description

A hardcoded ANSI escape sequence in add_interactive_orchestrator.go bypasses the console package's TTY detection and adaptive styling system. This is an anti-pattern identified in the Terminal Stylist analysis.

Current State

  • File: pkg/cli/add_interactive_orchestrator.go
  • Line: 65
  • Code: fmt.Fprint(os.Stderr, "\033[H\033[2J") // Clear screen
  • Issue: No TTY detection, hardcoded ANSI codes

Suggested Changes

Replace the hardcoded ANSI sequence with a console package function that includes TTY detection:

Option 1: Add new console package function

// pkg/console/console.go
func ClearScreen() {
    if !isTTY() {
        return
    }
    fmt.Fprint(os.Stderr, "\033[2J\033[H")
}

Option 2: Use existing Lipgloss functionality

// If Lipgloss provides a clear screen helper
console.ClearScreen()

Then update the call site:

// pkg/cli/add_interactive_orchestrator.go:65
console.ClearScreen()  // TTY-aware, consistent with console package

Files Affected

  • pkg/cli/add_interactive_orchestrator.go (line 65)
  • pkg/console/console.go (add new ClearScreen() function if needed)

Success Criteria

  • Hardcoded ANSI sequence removed
  • TTY detection implemented (no clearing on pipes/redirects)
  • Consistent with console package patterns
  • All existing tests pass
  • Clear screen functionality works in interactive mode

Benefits

  • Consistency: Aligns with console package architecture
  • TTY-aware: Doesn't send ANSI codes to pipes/redirects
  • Maintainability: Centralized control of terminal operations
  • Accessibility: Respects ACCESSIBLE environment variable

Source

Extracted from Terminal Stylist Report discussion #12701

Priority

Medium - Improves code consistency and terminal compatibility

Estimated Effort

30 minutes - 1 hour

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 13, 2026, 9:14 AM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions