[terminal-stylist] Terminal Stylist: Console Output & Lipgloss/Huh Consistency Report #50525
Closed
Replies: 1 comment
|
This discussion was automatically closed because it expired on 2026-08-06T09:34:03.426Z.
|
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.
Analysis of console output patterns across
pkg/(1,181 non-test.gofiles scanned).Summary
The codebase has a mature, well-centralized
pkg/consolepackage (37 files) with 247 files consuming it. Lipgloss (viacharm.land/lipgloss/v2) and Huh (viacharm.land/huh/v2) are already wrapped behind this package with adaptive theming (pkg/styles/theme.go,pkg/styles/huh_theme.go). Only a handful of rawfmt.Print*calls remain, and they are justified.Key Metrics
console.*fmt.Print*(non-test, non-testdata, non-linter-source)lipglossdirectlypkg/console/pkg/styles, as expected)huhdirectlyadd/bootstrapCLI flows)pkg/stringutil/pkg/consolelipgloss.Color(...)outsidepkg/stylesFiles using console formatters correctly (representative)
pkg/console/console.go— central formatter API:FormatError,FormatSuccessMessage,FormatInfoMessage,FormatWarningMessage,FormatSectionHeader,RenderTable,RenderTitleBox,RenderErrorBox, all with*Stderrcounterparts and TTY-aware variants.pkg/console/confirm.go,input.go,list.go,prompt_form.go— wrap Huh forms with a themedNewConfirmForm/NewInputForm, and gracefully fall back to plain text prompts viatty.IsStderrTerminal()when not in a TTY (showTextConfirm).pkg/console/accessibility.go—IsAccessibleMode()checksACCESSIBLE,TERM=dumb,NO_COLORand is designed to be consulted before enabling spinners/animations.pkg/styles/huh_theme.go— maps the same Dracula-inspired adaptive palette (lipgloss.LightDark) used elsewhere into Huh'sThemeFunc, giving forms visual parity with the rest of the CLI.pkg/cli/status_command.go,pkg/cli/view_command.go— useconsole.FormatInfoMessage/FormatWarningMessagefor status/errors, reserving rawfmt.Printonly for already-fully-rendered blocks (console.RenderStruct(...), a pre-rendered timeline stream) — this is an acceptable pattern since the styling decision was already made upstream.Files/areas needing improvement
pkg/cli/logs_format_compact.go— usestext/tabwriterfor two aligned tables (lines ~113, ~286) instead ofconsole.RenderTable/lipgloss/table. This bypasses the adaptive color/TTY-degradation logic thatconsole.RenderTablealready provides (seepkg/console/console.go:245RenderTable,pkg/console/console.go:289renderTableWithTTY). Recommend migrating these two tables toconsole.TableConfig+console.RenderTablefor consistent borders/coloring and automatic plain-text degradation on non-TTY output (CI logs, pipes).Huhforms outsidepkg/consoleandpkg/cli/add_interactive_*/bootstrap_profile_*/run_interactive.go/engine_secrets.go/interactive.gowere found still using barefmt.Scan/manual prompts, so there is no consolidation work needed there — all interactive prompts already route through the sharedconsolewrappers.pkg/linters/hardcodedfilepath/hardcodedfilepath.gocontainsfmt.Print*only in a comment referencingfmt.Printlnas an example of what the linter flags — not an actual violation.Lipgloss-specific notes
pkg/styles/theme.goandhuh_theme.goare defined as light/dark pairs combined vialipgloss.LightDark(isDark), not hardcoded ANSI/hex values baked into call sites.pkg/console/console.go(isTTY,isStderrTTY,applyStyleWithTTY) and consistently used before styling is applied — everyFormat*function has a TTY-aware code path and most have a*Stderrvariant, avoiding stray ANSI codes leaking into piped/redirected output.console.RenderTable/TableConfigwith per-cell style functions (buildTableStyleFunc) and TTY degradation (renderTableWithTTY), except for the twotabwriterusages noted above.pkg/stringutil/ansi.gofor text width calculations,pkg/console/terminal.gofor terminal capability probing) — both legitimate, low-level use cases rather than app-level styling.Huh-specific notes
PromptSecretInputinpkg/console/input.govalidates non-empty input).IsAccessibleMode()exists but its usages should be double-checked for coverage across all spinner/animation call sites in a follow-up (not verified line-by-line here due to scope) — recommend a dedicated pass confirming everyconsolespinner/progress component consultsIsAccessibleMode()before animating.ConfirmAction/PromptSecretInputcorrectly detect non-TTY environments and either fall back to plain text (confirm.go) or return a clear error (input.go) rather than hanging or corrupting output.Recommendations
tabwriter-based tables inpkg/cli/logs_format_compact.gotoconsole.RenderTablefor consistent styling and TTY degradation.consolespinner/progress/animation code paths checkconsole.IsAccessibleMode()before rendering.fmt.Print*usages are limited to two call sites that print already-fully-renderedconsole-produced strings, which is an acceptable pattern.References: Analysis performed via static grep across
pkg/in workflow run §30993424579.All reactions