[terminal-stylist] Console Output Analysis: Terminal Styling Patterns & Recommendations #30114
Closed
Replies: 1 comment
-
|
This discussion was automatically closed because it expired on 2026-05-05T09:29:18.138Z.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Overview
This analysis scanned 759 non-test Go source files across
pkg/for console output patterns, coveringfmt.Print*usage, the internalconsolepackage, Lipgloss styling, and Huh interactive forms. The codebase demonstrates a mature, well-structured terminal output system with strong adoption of established patterns. A few targeted improvement opportunities are noted.Summary Statistics
console.Format*callshuh.NewForminteractive formslipgloss.NewStylecallsfmt.Printlnto stdoutfmt.Fprintln(os.Stderr)(diagnostic)✅ What's Working Well
Console Package Adoption
The
pkg/consolepackage is heavily and consistently used across the CLI layer, with all major message types applied correctly:console.Format*calls — strong adoption of the formatting helpersFormatInfoMessage(627),FormatWarningMessage(508),FormatSuccessMessage(208),FormatErrorMessage(55)console.RenderTable(42 calls) andconsole.RenderStruct(13) provide consistent tabular outputconsole.NewSpinner(14) used for progress indicationconsole.FormatErrorWithSuggestions(17) for actionable error messagesconsole.IsAccessibleMode()propagated to allhuh.NewFormcalls (see below)TTY Detection
The
applyStyle()function inpkg/console/console.gocorrectly gates Lipgloss rendering on TTY detection (tty.IsStdoutTerminal()/tty.IsStderrTerminal()), preventing ANSI escape codes from polluting piped/redirected output.Lipgloss Styling —
pkg/stylesPackageThe
pkg/stylespackage implements a best-practice adaptive color system:compat.AdaptiveColor{Light: ..., Dark: ...}— automatically adjusts for terminal backgroundColorError,ColorWarning,ColorSuccess,ColorInfo,ColorPurple,ColorYellow,ColorComment,ColorForeground,ColorBackground,ColorBorder,ColorTableAltRowHuhThemeinpkg/styles/huh_theme.gofor consistent Huh form stylingHuh Interactive Forms — Full Coverage
All 19
huh.NewForminstances across the codebase follow best practices:.WithTheme(styles.HuhTheme)— consistent styling applied everywhere.WithAccessible(console.IsAccessibleMode())— accessibility mode respected in all forms.Validate(...)used for critical input fields (workflow names, secrets, auth tokens)Input,Select,MultiSelect,Confirm,Text)EchoModePasswordused for secret inputs (engine_secrets.go)Structured Output Routing
Commands correctly route output by type:
fmt.Fprintln(os.Stderr, console.Format*(...))✅fmt.Println(...)to stdout ✅Examples of correct stdout usage:
hash_command.go,tool_graph.go,compile_pipeline.go,status_command.go,deps_report.go.1. Bare `fmt.Fprintf(os.Stderr)` Without Console Formatting — `pkg/workflow`
Several files in
pkg/workflow/emit diagnostic messages directly without console formatting. These lose color styling and inconsistently format warning/info messages:pkg/workflow/cache.go(lines 338, 347):pkg/workflow/compiler_orchestrator_engine.go(lines 171, 177):pkg/workflow/push_to_pull_request_branch.go(line 112): Similar pattern.2. Debug Diagnostics Should Use Logger — `pkg/workflow/claude_logs.go`
claude_logs.gocontains multiplefmt.Fprintf(os.Stderr, ...)calls that appear to be debug/diagnostic information rather than user-facing output. These should uselogger.New(...)instead:This applies to ~6 calls in
claude_logs.go.3. `audit_cross_run_render.go` and `audit_diff_render.go` — Raw Markdown Headers to Stdout
These files output raw markdown headings (
# Audit Report,## Executive Summary, etc.) viafmt.Println. While this is intentional for report generation (structured output to stdout), the mixing of styled terminal output and markdown is inconsistent with the rest of the audit rendering stack.Consider whether these reports should go through a
console.RenderMarkdownabstraction or use Lipgloss headers for live terminal rendering vs. plain markdown for redirected output.4. `compile_file_operations.go` — One Unformatted Line (line 174)
All other output in this file correctly uses
console.Format*helpers.5. `action_sha_checker.go` and `side_repo_maintenance.go` — Informational Messages Without Console Formatting
6. Hardcoded ANSI Codes in Logger — `pkg/logger/logger.go`
The logger uses raw
\033[38;5;...mANSI escape sequences for namespace colorization. While functional, this bypasses the adaptive color system inpkg/styles. However, given logger colors are debug-only and the current implementation is intentional (zero overhead), this is low priority.Recommendations
pkg/workflow/cache.go,push_to_pull_request_branch.go,compiler_orchestrator_engine.gofmt.Fprintf(os.Stderr, "Warning:...")withconsole.FormatWarningMessagepkg/workflow/claude_logs.gofmt.Fprintfcalls tologger.New("workflow:claude_logs")pkg/cli/compile_file_operations.goline 174console.FormatInfoMessagepkg/workflow/action_sha_checker.go,side_repo_maintenance.goconsole.FormatInfoMessagefor informational outputaudit_cross_run_render.go,audit_diff_render.goArchitecture Strengths
pkg/styles+pkg/consoleprovide a single source of truth for all terminal aestheticscompat.AdaptiveColorapplyStyle()ensures clean output in CI and piped contextspkg/stringutil/ansi.goprevents ANSI codes from leaking into YAML/structured output*_wasm.go) maintain feature parity without stylingReferences:
Beta Was this translation helpful? Give feedback.
All reactions