[terminal-stylist] Terminal Stylist Audit: Console Output Analysis #26024
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #26207. |
Beta Was this translation helpful? Give feedback.
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.
-
This report summarizes the console output patterns found across the codebase (
/pkg/and/cmd/), analyzed through the lens of Charmbracelet ecosystem best practices.Overview
The codebase demonstrates strong, consistent adoption of modern terminal UI patterns. The
pkg/consoleandpkg/stylespackages serve as a well-designed central styling system, and usage is widespread. A few API gaps between the WASM and non-WASM builds represent the only noteworthy findings.Console Output Summary
console.Format*/console.Render*calls (non-test)fmt.Println/Printfto stdout (non-test, non-script).WithTheme+.WithAccessible✅ What's Working Well
Lipgloss
Adaptive color system — fully compliant
pkg/styles/theme.godefines the entire color palette usingcompat.AdaptiveColor{Light: ..., Dark: ...}, covering all semantic use cases:ColorError,ColorWarning,ColorSuccess,ColorInfoColorForeground,ColorBackground,ColorBorderColorPurple(commands/paths),ColorYellow(progress),ColorComment(muted text)ColorTableAltRowfor zebra stripingThe Dracula-inspired dark-mode palette and high-contrast light-mode palette meet accessibility contrast requirements.
TTY detection — properly implemented
pkg/console/console.gowraps all styling with:isTTY()delegates totty.IsStdoutTerminal(). TTY detection is also applied separately for stderr viatty.IsStderrTerminal()inRenderTitleBox,RenderErrorBox,RenderInfoSection, andRenderComposedSections. No raw ANSI escape codes are present anywhere in the codebase.Layout features — good use of lipgloss primitives
lipgloss/tablepackage used inRenderTable()with zebra striping and header/total row differentiationlipgloss.JoinVertical()used inRenderComposedSections()for composing multi-section layoutslipgloss.DoubleBorder()for title boxes,lipgloss.RoundedBorder()for standard boxes,lipgloss.NormalBorder()for left-side info emphasislipgloss.HiddenBorder()applied to blurred huh form fields — subtle and correctOutput routing — follows Unix conventions
All diagnostic output (info, warnings, errors, progress) goes to stderr via
fmt.Fprintln(os.Stderr, ...)with console formatting. Structured output (JSON, hashes, Mermaid graphs, markdown reports) goes to stdout viafmt.Println(...). This allows piping and redirection to work cleanly.Huh Forms
Consistent theming — 100% compliance
Every
huh.NewForm(...)call across all 13 files that use huh applies:styles.HuhThemeis ahuh.ThemeFuncinpkg/styles/huh_theme.gothat maps the Dracula-inspired palette to all huh element states: focused/blurred titles, selectors, options, buttons, text input cursor/placeholder/prompt, and error indicators.Reusable wrappers — good abstraction
pkg/consoleprovides three high-level wrappers:ConfirmAction(title, affirmative, negative)— confirm dialogsPromptSecretInput(title, description)— password-masked input with TTY guardShowInteractiveList(title, items)— select list with non-TTY text fallbackThese wrappers centralize the theme application and accessibility mode check, reducing duplication.
Validation — consistently present
All password/token input forms include inline validation:
1. WASM / Non-WASM API Parity Gap
The following functions are defined in
console_wasm.gobut missing fromconsole.go(the non-WASM build):FormatLocationMessage(msg)📁 + msgFormatCountMessage(msg)📊 + msgFormatListHeader(header)RenderTree(root TreeNode)Conversely,
FormatErrorChainis inconsole.gobut missing fromconsole_wasm.go.None of these WASM-only functions are currently called from non-WASM code, so there is no active breakage. However, the gap means:
FormatLocationMessageorFormatCountMessagein CLI code would fail to compileRenderTreefunction referenced indoc.gois not available in the native buildRecommendation: Add stub implementations of
FormatLocationMessage,FormatCountMessage,FormatListHeader, andRenderTreetoconsole.go, and addFormatErrorChaintoconsole_wasm.go.2.
FormatErrorWithSuggestionsLocationFormatErrorWithSuggestions(13 call sites) lives inpkg/console/render.gorather thanconsole.go. While this is not a bug, it may cause developers to miss this formatter when looking atconsole.go.Recommendation: Add a comment at the top of
console.gopointing to the additional formatters inrender.go.3. Markdown Render Files Use Raw
fmt(Intentional)audit_cross_run_render.goandaudit_diff_render.gooutput markdown table syntax viafmt.Printf("| col | col |\n", ...)to stdout. This is the correct pattern for piped/structured markdown output and follows Unix conventions. However, these files have no TTY check — they always emit raw markdown even in a terminal.Recommendation: Consider adding a "pretty" output path for TTY mode using
console.RenderTable(), similar to howrenderAuditDiffPrettywraps the same data with console-formatted stderr output.Recommendations Summary
FormatLocationMessage,FormatCountMessage,FormatListHeader,RenderTree)console.go; addFormatErrorChaintoconsole_wasm.goFormatErrorWithSuggestionsinrender.gonot obviousconsole.goconsole.RenderTable()References:
Beta Was this translation helpful? Give feedback.
All reactions