Objective
Move hardcoded ANSI escape sequence (\033[K) from logs_orchestrator.go into the console package as a proper helper function.
Context
From discussion #11611: The codebase has 1 instance of manual ANSI escape codes that should be abstracted through the console package for consistency and TTY detection.
Current Issue: logs_orchestrator.go:778 uses fmt.Fprint(os.Stderr, "\r\033[K") directly.
Approach
-
Create console.ClearLine() helper function:
- Add new function in
pkg/console/ (suggest output.go or new terminal.go)
- Implement TTY detection using
tty.IsStderrTerminal()
- Only output ANSI codes when in TTY mode
-
Update logs_orchestrator.go:
- Replace manual ANSI escape with
console.ClearLine() call
- Import console package if not already imported
-
Add tests:
- Test TTY mode outputs ANSI sequence
- Test non-TTY mode outputs nothing
- Add to existing console package tests
Files to Modify
- Create/Update:
pkg/console/terminal.go (or appropriate file)
- Update:
pkg/cli/logs_orchestrator.go (line ~778)
- Update:
pkg/console/*_test.go (add test coverage)
Implementation Example
// pkg/console/terminal.go
func ClearLine() {
if tty.IsStderrTerminal() {
fmt.Fprint(os.Stderr, "\r\033[K")
}
}
// logs_orchestrator.go (replace line ~778)
// Before:
fmt.Fprint(os.Stderr, "\r\033[K")
// After:
console.ClearLine()
Acceptance Criteria
Priority
Phase 1: Critical Fix (1-2 hours estimated)
AI generated by Plan Command for discussion #11611
Objective
Move hardcoded ANSI escape sequence (
\033[K) fromlogs_orchestrator.gointo the console package as a proper helper function.Context
From discussion #11611: The codebase has 1 instance of manual ANSI escape codes that should be abstracted through the console package for consistency and TTY detection.
Current Issue:
logs_orchestrator.go:778usesfmt.Fprint(os.Stderr, "\r\033[K")directly.Approach
Create
console.ClearLine()helper function:pkg/console/(suggestoutput.goor newterminal.go)tty.IsStderrTerminal()Update
logs_orchestrator.go:console.ClearLine()callAdd tests:
Files to Modify
pkg/console/terminal.go(or appropriate file)pkg/cli/logs_orchestrator.go(line ~778)pkg/console/*_test.go(add test coverage)Implementation Example
Acceptance Criteria
console.ClearLine()function created with TTY detectionlogs_orchestrator.goreplaced with console helpermake fmtandmake lintmake agent-finishcompletes successfullyPriority
Phase 1: Critical Fix (1-2 hours estimated)