Repository navigation
[terminal-stylist] Terminal Stylist: Console Output Analysis — Lipgloss, Huh & Formatting Patterns #32324
Closed
Replies: 2 comments 1 reply
|
/plan |
1 reply
|
This discussion was automatically closed because it expired on 2026-05-16T09:42:19.280Z.
|
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.
This is an automated analysis of console output patterns across 792 Go source files in
pkg/, examining Lipgloss styling, Huh forms, and output consistency.Executive Summary
console.Format*callslipgloss.*usagespkg/styles+pkg/consolehuh.*usagesfmt.Print*to stdoutOverall the codebase is in good shape. The
pkg/consoleandpkg/stylespackages provide a well-structured abstraction layer that most code uses correctly.✅ What's Working Well
Adaptive Color System (
pkg/styles/theme.go)The styles package is a standout example. It uses a dual-palette Dracula-inspired system with
charm.land/lipgloss/v2/compat.AdaptiveColor, providing both light and dark variants for every semantic color:This covers terminal compatibility for light/dark backgrounds and follows CSS-like semantic naming (Error, Warning, Success, Info).
TTY Detection and Style Gating (
pkg/console/console.go)The
applyStyle()helper correctly gates all Lipgloss rendering onisTTY():This prevents ANSI codes leaking into piped output — a critical correctness requirement.
Huh Forms: Custom Theme + Accessibility (
pkg/styles/huh_theme.go,pkg/console/confirm.go)All interactive Huh forms use the custom
styles.HuhThemeand passIsAccessibleMode(), which checksACCESSIBLE,TERM=dumb, andNO_COLORenv vars:The
HuhThememaps the entirepkg/stylespalette to all Huh widget states (focused/blurred, selected/unselected, error, button states), giving forms the same visual identity as the rest of the CLI.Console Package Wraps Huh Primitives
The
pkg/consolepackage providesConfirmAction,SelectItem,GetInputwrappers so CLI commands never callhuh.*directly — a correct abstraction boundary.Spinner: Full Bubble Tea Integration
pkg/console/spinner.gousestea.NewProgram()with thread-safe lifecycle management, proper TTY detection before animating, and accessibility mode support.Consistent Message Types
The
console.Format*functions cover all standard message types with 1,775 total call sites:FormatInfoMessageFormatWarningMessageFormatSuccessMessageFormatVerboseMessageFormatErrorMessageFormatSectionHeader1. Raw ANSI Codes in
pkg/logger/logger.goThe debug logger uses hardcoded ANSI 256-color codes instead of Lipgloss:
The logger does check
tty.IsStderrTerminal()before applying color, so there is no leakage. However, these hardcoded codes bypass thepkg/stylesadaptive color system and won't respectNO_COLORunless explicitly handled. Low priority since this is debug output only.Suggestion: Replace with
lipgloss.NewStyle().Foreground(color).Render(text)using colors frompkg/styles, and remove the manual TTY check (Lipgloss handles it). This would unify the color story.2. Raw ANSI in
pkg/console/terminal.goTwo raw ANSI sequences for cursor control:
These are used for in-place terminal updates (spinner-style clearing). Lipgloss v2 does not expose direct cursor control, so this is acceptable as a pragmatic choice. The ANSI codes used here are widely supported. No change needed unless Lipgloss adds cursor APIs.
3. Audit Render Files:
fmt.Printffor Markdown Reportspkg/cli/audit_cross_run_render.goandpkg/cli/audit_diff_render.gouse rawfmt.Printf/fmt.Printlnto write markdown-formatted tables to stdout:This is intentional — these are document-output commands (markdown reports piped to files or pagers). Stdout is the correct destination. However, a future improvement could be using
lipgloss/tablefor terminal-aware rendering that falls back to plain markdown when piped.4.
compile_schedule_calendar.go: Direct Lipgloss in CLI LayerThe
intensityStyle()helper creates new Lipgloss styles inline:This works correctly (uses
pkg/stylescolors) but bypassesapplyStyle()TTY gating. When not in a TTY, the rendered text will still include ANSI codes. Minor issue — should useapplyStyle()or move to the console package.5. Outcomes Command: Unformatted Output
pkg/cli/outcomes_command.gopasses raw JSON bytes directly to stdout without the structured output helpers used by similar commands:Other commands consistently use
fmt.Println(string(jsonBytes))for JSON output (correct per guidelines) but the pattern in outcomes is bypassing any potential formatting. Acceptable if the output is intentionally raw JSON for piping.📋 Recommendations (Priority Order)
pkg/logger/logger.gopkg/stylescolors for unified themingpkg/cli/compile_schedule_calendar.gointensityStyle()skips TTY gateapplyStyle()or move topkg/consolepkg/cli/audit_*_render.gofmt.Printfmarkdown tableslipgloss/tablefor terminal rendering with markdown fallbackpkg/console/terminal.goFile Inventory: Console Output Patterns
Files using Lipgloss directly:
pkg/console/console.go— Core formatting with TTY-gatedapplyStyle()pkg/console/banner.go— Logo renderingpkg/styles/theme.go— Centralized adaptive color palettepkg/styles/huh_theme.go— Huh form themingpkg/cli/compile_schedule_calendar.go— Inline intensity stylesFiles using Huh forms:
pkg/console/confirm.go,input.go,list.go— Console-layer wrapperspkg/cli/add_interactive_*.go— Wizard forms (use console wrappers correctly)pkg/cli/interactive.go,run_interactive.go,engine_secrets.go— Direct huh usageFiles with raw fmt.Print to stdout (all legitimate):*
audit_cross_run_render.go,audit_diff_render.go— markdown document outputhash_command.go,tool_graph.go,forecast.go,compile_pipeline.go— JSON/hash/graphstatus_command.go,list_workflows_command.go— mixed (JSON + RenderStruct)References:
All reactions