[terminal-stylist] Terminal Stylist: Console Output & Lipgloss/Huh Consistency Report #50825
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #51041. |
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.
Terminal Stylist Report: Console Output Consistency
Scope: 24
.gofiles (excluding_test.go) scanned acrosspkg/, focused onfmt.Print*,console.*,lipgloss.*, andhuh.*usage.Key Metrics
pkg/consoleformattersfmt.Print*in non-test, non-linter-testdata codestringutilandconsole/terminal.go)pkg/styles/pkg/consoleOverall Assessment: Healthy
The codebase shows strong, centralized console-styling discipline. Nearly all user-facing output routes through
pkg/console(247 usage sites), which itself wraps Lipgloss with TTY-aware rendering (pkg/console/colorprofile_writer.go,pkg/console/terminal.gousingtty.IsStderrTerminal()), and adaptive color definitions live solely inpkg/styles/theme.go— no stray hardcoded hex colors were found elsewhere.Lipgloss usage details
pkg/styles/theme.godefines all colors in light/dark pairs (colorErrorLight/Dark, etc.) and composes them vialipgloss.NewStyle()into semantic styles (Error,Warning,Success,Info,FilePath,Prompt, ...). No component reaches for raw ANSI codes or bypasses this palette.theme.gowireslipgloss.HasDarkBackgroundthrough a testablebackgroundDetectorseam (configureHasDarkBackground), a good pattern for terminal-aware rendering without hardcoding assumptions.pkg/console/console.go(RenderTable, ~line 244) correctly useslipgloss/tablerather than manual column alignment, including custom header-row styling.pkg/console/terminal.goguardsClearScreen/ClearLinebehindtty.IsStderrTerminal(), avoiding raw escape codes leaking into piped/redirected output.pkg/stringutil/ansi.goprovides ANSI-stripping utilities (not emission), which is the correct direction for safety.lipgloss.*directly outsidepkg/styles/pkg/console(pkg/logger/logger.go,pkg/cli/compile_schedule_calendar.go). Worth a follow-up check that these don't duplicate palette/style definitions instead of importing frompkg/styles.Huh usage details
Huh (
charm.land/huh/v2) is used across 15 files, mostly in interactive CLI flows:pkg/cli/add_interactive_*.go,run_interactive.go,interactive.go,engine_secrets.go,bootstrap_profile_*.go, plus core wrappers inpkg/console/{confirm,input,list,prompt_form}.go.pkg/styles/huh_theme.godefinesHuhThemeas ahuh.ThemeFunc, mapping the same Dracula-inspired palette (colorPurpleLight/Dark,colorSuccessLight/Dark, etc.) used bytheme.go's Lipgloss styles vialipgloss.LightDark(isDark). This is a single source of truth for both static and interactive UI — a strong pattern worth highlighting as exemplary.pkg/console/confirm.go,input.go,list.go,prompt_form.goare each small (37–74 lines), suggesting focused, single-responsibility wrappers around Huh fields rather than ad hoc form-building scattered throughpkg/cli.huh.WithAccessible(true)) and validation (.Validate()) usage per field — recommend a follow-up grep ofWithAccessible|\.Validate\(in the 15 Huh-consuming files to confirm coverage, since these weren't exhaustively checked here.Remaining raw fmt.Print* calls (reviewed, no action needed)
pkg/cli/status_command.go:288—fmt.Print(console.RenderStruct(statuses)): prints already-styled output from the console package; correct usage (avoids double-wrapping with another console call).pkg/cli/view_command.go:168—fmt.Print(output): prints a pre-rendered timeline stream (renderUnifiedTimelineStream); same pattern, output is built via console/Lipgloss upstream.fmt.Printlnhits are in lintertestdata/fixtures (intentionally "bad" example code for linter tests) or doc comments — not real output paths.Recommendations
pkg/logger/logger.goandpkg/cli/compile_schedule_calendar.goreusepkg/stylescolors rather than defining their own Lipgloss styles, to keep the single-source-of-truth palette intact.pkg/cli/add_interactive_*.goforWithAccessible(true)and per-field.Validate()to confirm accessibility/validation parity across all 15 form call sites.go vet-style analyzer, per this repo's existingpkg/linterspattern) that flags new rawfmt.Print*calls inpkg/clioutside of already-renderedconsole.*output, to keep this discipline as the codebase grows.All reactions