[terminal-stylist] Terminal Stylist: Console Output & Charmbracelet (Lipgloss/Huh) Analysis #49103
Closed
Replies: 1 comment
|
This discussion was automatically closed because it expired on 2026-07-31T09:33:06.573Z.
|
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 Analysis
Scope: 1167 non-test
.gofiles scanned, prioritizingpkg/. No huh/lipgloss anti-patterns of concern found; the codebase already centralizes styling well.Key metrics
console.*calls (formatters)fmt.Print*in production code (non-test, non-testdata)pkg/cli/status_command.go,pkg/cli/view_command.go)lipglossdirectlyhuh(interactive forms)\x1b[) outsidepkg/stringutil/ansi.gopkg/stylesstrings.Repeat("=", ...)border/separator codeFull analysis details
Console formatting package (
pkg/console) — mature and consistently used:print.goexposesPrintSuccessMessage,PrintInfoMessage,PrintWarningMessage,PrintErrorMessage,PrintCommandMessage,PrintSectionHeader.console.goexposes matchingFormat*/Format*Stderrpairs for every message type (success, info, warning, error, error-chain, section header, list item, table header, command, progress, prompt, verbose), all gated throughapplyStyle/applyStyleWithTTY, which calltty.IsStdoutTerminal()/tty.IsStderrTerminal()before rendering ANSI. Non-TTY output (pipes, CI logs, redirects) degrades cleanly to plain text — no leaked escape codes.RenderTableusescharm.land/lipgloss/v2/table(not manual column alignment), with aTTYFuncoverride for stderr rendering, alternating row backgrounds viastyles.ColorTableAltRow, andcolorwriter.Degradeto honorNO_COLOR/COLORTERM/TERM. This is best-practice lipgloss table usage.pkg/styles/theme.gousinglipgloss.AdaptiveColor/LightDark, not hardcoded per-callsite — verified zero hex-color leakage outside the styles package.fmt.Print usage in production code* — only 2 occurrences, both justifiable:
pkg/cli/status_command.go:288—fmt.Print(console.RenderStruct(statuses)): prints a pre-rendered table string; acceptable since the styling work is already done byconsole.RenderStruct.pkg/cli/view_command.go:168—fmt.Print(output): prints a pre-rendered timeline stream fromrenderUnifiedTimelineStream. Same pattern.fmt.Print*hits are in linter testdata/golden fixtures (pkg/linters/.../testdata/), which are intentionally raw and out of scope.fmt.Printwhile surrounding code in the same functions usesfmt.Fprintln(os.Stderr, ...)— no functional issue, but for consistency they could route through aconsole.Print*wrapper that writes toos.Stdoutexplicitly rather than relying onfmt.Print's implicit stdout target. Not urgent.Huh (interactive forms) —
pkg/console/{confirm,input,list,prompt_form}.go:ConfirmAction,PromptSecretInput,ShowInteractiveList) correctly checktty.IsStderrTerminal()first and fall back to a plain-text prompt (showTextConfirm, plain error,showTextList) when not a TTY — good accessibility/CI safety.pkg/console/prompt_form.go'sNewForm/NewInputForm/NewSelectForm/NewConfirmFormhelpers, each applying.WithTheme(styles.HuhTheme)and.WithAccessible(IsAccessibleMode())uniformly — no call site constructs a rawhuh.NewFormand forgets theming or accessibility, based on the code paths reviewed.IsCancelled(err)wrapshuh.ErrUserAbortedfor consistent Ctrl-C/Esc handling across call sites.PromptSecretInputcorrectly useshuh.EchoModePasswordand deliberately avoids logging the entered secret value — good security hygiene.pkg/styles/huh_theme.gomaps the same Dracula-inspired adaptive palette (colorPurpleLight/Dark,colorSuccessLight/Dark, etc.) used for general console output into huh'sFocused/Blurred/Groupstyles, so forms visually match the rest of the CLI.Opportunities / lower-priority observations:
pkg/console/console_wasm.goandpkg/console/layout_wasm.gouse manualstrings.Repeat("=", width)separators instead of lipgloss layout primitives — acceptable since these are WASM build-tag fallbacks where the full lipgloss/huh stack isn't available, but worth a comment noting why (if not already present).huh.NewNote,FilePicker, orMultiSelectusage found in the codebase — if future interactive flows need static informational panels or multi-value selection, these huh field types are available and already themed viaHuhTheme.IsAccessibleMode()) is wired throughNewFormandspinner.go/compile_schedule_calendar.go, but is not referenced inconfirm.go/input.go/list.godirectly — this is fine since they all funnel throughNewConfirmForm/NewInputForm/NewSelectForm, confirming no bypass exists.Recommendations
fmt.Printcalls (status_command.go,view_command.go) through an explicitos.Stdout-targeted console helper for symmetry with theFprintln(os.Stderr, ...)calls nearby.All reactions