-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Labels
Description
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/(suggestoutput.goor newterminal.go) - Implement TTY detection using
tty.IsStderrTerminal() - Only output ANSI codes when in TTY mode
- Add new function in
-
Update
logs_orchestrator.go:- Replace manual ANSI escape with
console.ClearLine()call - Import console package if not already imported
- Replace manual ANSI escape with
-
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
-
console.ClearLine()function created with TTY detection - Manual ANSI escape in
logs_orchestrator.goreplaced with console helper - Tests verify TTY and non-TTY behavior
- Code passes
make fmtandmake lint -
make agent-finishcompletes successfully
Priority
Phase 1: Critical Fix (1-2 hours estimated)
AI generated by Plan Command for discussion #11611
Copilot