Repository navigation
[terminal-stylist] Terminal Stylist report: Go console output, Lipgloss, and Huh #68373
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #68645. |
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
The Go console-output architecture is generally strong: terminal styling is centralized, stdout/stderr-aware formatters are widely adopted, Lipgloss colors adapt to light/dark backgrounds, and Huh forms share one accessible theme and TTY gate.
The main gaps are a small set of raw error/warning writes, two tree renderers that bypass the console package's TTY/color-profile handling, duplicated manual prompt logic, and several fixed-width reports that do not adapt well to narrow terminals or long values.
Key metrics
.gofiles scanned underpkg/testdata)testdatafmt.Print*/fmt.Fprint*callsos.Stderros.Stdoutpkg/consolepkg/consoleMost
fmtcalls are not style violations: many write generated YAML/scripts or wrap destination-awareconsole.Format*output. The high raw call count should therefore not be treated as a migration count.Priority findings
Standardize five raw error/warning paths. These bypass semantic prefixes, adaptive styling, and consistent severity formatting:
pkg/cli/mcp_inspect_mcp.go:574and:588pkg/workflow/cache_steps.go:23pkg/workflow/mcp_renderer.go:111pkg/workflow/push_to_pull_request_branch.go:120Use
console.PrintErrorMessage,console.PrintWarningMessage, or destination-awareconsole.Format*helpers. This would also remove inconsistent capitalized prefixes such asError:andWarning:.Make tree rendering pipe-safe.
pkg/cli/mcp_inspect.go:205-223andpkg/cli/status_command.go:437-446attach styledtreeenumerators/items unconditionally, then write the result directly to stderr. Unlikepkg/console, this path does not visibly gate styling on TTY status or degrade through the destination color profile. Build plain trees for non-TTY/accessibility mode, or add a console tree renderer that appliestty.IsStderrTerminal,NO_COLOR, and color-profile degradation consistently.Replace fixed-width report layouts where values are unbounded.
pkg/cli/audit_cross_run_render.go:290-399uses manual spacing and widths such as%-30sand%-45s. Long server names/domains and narrow terminals can break alignment. Preferconsole.RenderTablewithMaxWidth: console.DefaultTableWidth; it already wraps cells and falls back to a narrow key/value layout.Consolidate the remaining manual selection flow.
pkg/cli/run_interactive.go:164-221duplicates numbered-list prompting and checks stderr TTY without first checking stdin TTY.console.ShowInteractiveListalready centralizes stdin/stderr checks, themed Huh selection, and text fallback. Reusing it would align cancellation, accessibility, and non-TTY behavior.Reduce formatter/write boilerplate incrementally. Many locations use
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(...))even thoughconsole.PrintInfoMessageand related print helpers exist. This is correct today, but direct helper use would make stream ownership clearer and prevent future destination mismatch. Limit migration to exact one-line equivalents; retainfmtwhere composing reports or writing generated content.What is working well
pkg/styles/theme.goprovides one adaptive semantic palette for errors, warnings, success, info, commands, tables, trees, and schedules.pkg/console/console.goapplies styles only for the relevant TTY and degrades output using the destination environment/color profile.pkg/linters/consolestderr/consolestderr.godetects stdout/stderr formatter mismatches and offers suggested fixes.pkg/console/table_width.gouses ANSI-aware width calculation, wraps cells, and provides a narrow fallback.pkg/console/prompt_form.gois the sole production creator ofhuh.NewForm; it consistently appliesstyles.HuhTheme, accessibility mode, context support, and stdin/stderr TTY checks.pkg/styles/huh_theme.gouseslipgloss.LightDarkand styles focus, errors, options, navigation, buttons, and text input from the shared palette.huh.EchoModePassword; required workflow inputs and profile values use field validation.pkg/cli/compile_schedule_calendar.goexplicitly gates cell styling on TTY/accessibility and applies color-profile degradation.pkg/cli/work_command_tui_view.goresponds to terminal dimensions, bounds rendered content, supplies a minimum-size fallback, and uses Bubble Tea's alternate screen.pkg/console/prompt_form.goandpkg/console/terminal.go, where it performs cursor/screen control unavailable through Lipgloss and is TTY-gated.Lipgloss usage inventory
Production imports occur in:
pkg/cli/compile_schedule_calendar.gopkg/cli/engine_secrets.gopkg/cli/mcp_inspect.gopkg/cli/status_command.gopkg/cli/work_command_tui_view.gopkg/console/banner.gopkg/console/console.gopkg/console/render.gopkg/console/table_width.gopkg/logger/logger.gopkg/styles/huh_theme.gopkg/styles/theme.goThe strongest patterns are the centralized palette, adaptive colors, bounded tables, ANSI-aware width calculations, and responsive TUI layout. The tree renderers are the notable destination-awareness exception.
Huh usage assessment
Huh is used across 17 production files. The scan found 9 input constructors, 11 selects, 2 multi-selects, 8 confirms, and 1 text field, plus shared option/group construction.
All complete forms flow through
console.NewForm, so theme and accessible mode are applied consistently. The implementation correctly distinguishes cancellation throughhuh.ErrUserAborted, masks secrets, and validates required values in the flows that need it.Recommended UX follow-up:
run_interactiveworkflow selection through the shared list abstraction.Next actions
console.ShowInteractiveListinrun_interactive.Error:/Warning:writes to standard streams if recurrence becomes common.Analysis note
Serena project activation succeeded, but its Go language server failed to initialize in the analysis environment. The complete scan therefore used Go's parser/AST plus targeted source inspection; no repository files were changed.
References: §38372536185
All reactions