Repository navigation
[terminal-stylist] Terminal styling audit: Go console output, Lipgloss, and Huh #72620
Closed
Replies: 1 comment
|
This discussion was automatically closed because it expired on 2026-10-29T08:51:06.183Z.
|
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
Scanned all 1,812 non-test Go files in the repository, with 1,792 files under
pkg/as the primary analysis area. The codebase has a strong central terminal UI foundation:pkg/consoleprovides TTY-aware formatting,pkg/stylescentralizes adaptive colors, and interactive forms consistently flow through a shared Huh wrapper.The main opportunity is migration, not redesign: a substantial set of CLI and workflow paths still writes human-facing status, warning, and report text directly with
fmt.Fprint*, bypassing the shared severity, TTY, width, and accessibility behavior.Key metrics and findings
pkg/fmt.Print*/fmt.Fprint*patternsconsole.*fmt.Fprint*sites underpkg/not wrappingconsole.*pkg/console, plus ANSI detection/removal utilitiesThe 843 direct-write sites are not all defects. Machine-readable JSON, Markdown output, pass-through subprocess output, blank-line layout, and generated content should often remain raw. The actionable subset is human-facing severity/status text and manually aligned terminal reports.
What is working well
pkg/console/console.goreturns plain text when the target stream is not a TTY and degrades color based on the terminal environment when styling is enabled.pkg/styles/theme.godefines paired light/dark colors and selects them through a shared adaptive color implementation.console.RenderTableuseslipgloss/table, bounded rendering, centralized borders, totals, and TTY-aware styling rather than ad hoc spacing.pkg/console/prompt_form.goconstructs forms withstyles.HuhThemeand.WithAccessible(...);pkg/cli/interactive.goalso supplies a non-TTY text-prompt path.Select,MultiSelect, andTextfields, and validates workflow intent.huh.EchoModePassword.pkg/console/terminal.goandpkg/console/prompt_form.go, rather than scattered through commands.Representative strong implementations:
pkg/console/console.gopkg/console/prompt_form.gopkg/console/input.gopkg/console/list.gopkg/styles/theme.gopkg/styles/huh_theme.gopkg/cli/interactive.gopkg/cli/run_interactive.gopkg/cli/forecast_render.goPriority improvements
Standardize remaining raw warnings and errors. These paths emit severity text directly and should use console formatters or the existing namespace logger as appropriate:
pkg/workflow/cache_steps.go:23pkg/workflow/push_to_pull_request_branch.go:128pkg/workflow/mcp_renderer.go:114pkg/workflow/compiler_orchestrator_engine.go:302-308pkg/cli/mcp_inspect_mcp.go:577,591Preferred pattern:
Avoid severity encoded manually in the string:
Move parser internals from unconditional stderr to debug logging.
pkg/workflow/claude_logs.goalready declaresclaudeLogsLog, but several parse fallbacks and extraction counters use rawfmt.Fprintf(os.Stderr, ...). These messages look diagnostic rather than user-actionable and should usepkg/loggerso normal command output remains quiet. User-actionable failures can remain console warnings/errors.Migrate manual terminal tables and aligned reports selectively. Good candidates include:
pkg/cli/experiments_analyze_statistics.gopkg/cli/audit_cross_run_render.gopkg/cli/deps_report.gopkg/cli/remove_command.goThese contain fixed-width
%20s/%-45slayouts and Unicode separators that can wrap poorly in narrow terminals. Preferconsole.RenderTablewith a maximum width, while retaining raw Markdown and JSON renderers for machine-oriented output.Create shared section/list helpers for narrative command output.
pkg/cli/add_interactive_orchestrator.go,pkg/cli/preconditions.go,pkg/cli/enable.go, andpkg/cli/fix_command.goassemble headings, bullets, separators, and blank lines manually. UsingFormatSectionHeader,FormatListItem,FormatCommandMessage, and composed sections would make TTY and non-TTY rendering consistent.Use shared Lipgloss style tokens in the work-queue TUI.
pkg/cli/work_command_tui_view.gocorrectly uses Lipgloss layout and responsive breakpoints, but defines a local ASCII border and mostly monochrome focus state. Consider shared border/style tokens for focused panels, status, warnings, disabled actions, and selection. Keep an ASCII/no-color presentation for accessibility and compatibility.Review
NO_COLORversus accessibility semantics.pkg/console/accessibility.gotreatsNO_COLORas full Huh accessible mode.NO_COLORconventionally requests color suppression, not necessarily a different interaction model. Consider separating:NO_COLOR), andACCESSIBLE,TERM=dumb, or explicit configuration).Lipgloss assessment
Detailed Lipgloss findings
pkg/styles/theme.go, and stdout formatting is degraded according to terminal capabilities.lipgloss/table; expanding this approach to manually aligned CLI reports would improve narrow-terminal behavior.pkg/cli/work_command_tui_view.gousesMaxWidth,MaxHeight, horizontal joins, viewport thresholds, and an alternate screen appropriately. Shared semantic style tokens would improve visual consistency with the rest of the CLI.Huh assessment
Detailed Huh findings
huh.NewFormconstruction is centralized throughconsole.NewForm, which applies the repository theme and accessibility setting.console.IsCancelled, improving consistent Ctrl-C/Esc handling.pkg/cli/interactive.gois a strong accessibility and automation pattern. Consider extracting its select/multi-select rendering intopkg/consoleso other commands can reuse the same fallback behavior.NO_COLORis decoupled from accessible mode, Huh can remain interactive while rendering without color for users who only request color suppression.Suggested migration order
pkg/workflowand MCP inspection.claude_logs.goparser diagnostics to the namespace logger.console.RenderTable, preserving separate JSON/Markdown output paths.References:
All reactions