[terminal-stylist] Terminal Stylist: Console Output Analysis for pkg/ #42703
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #42932. |
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.
-
Repository: github/gh-aw | Scope:
pkg/Go source files (non-test) | Files scanned: 986Summary
The codebase demonstrates excellent console output discipline. A dedicated
pkg/consolepackage abstracts all user-facing output behind well-named formatter functions,pkg/stylescentralises the entire Lipgloss style and adaptive-color system, and every Huh form is consistently themed. The issues found are minor and localised.Key Metrics
.gofiles inpkg/console.*output functionsconsole.FormatInfoMessagecall-sitesconsole.FormatWarningMessagecall-sitesconsole.FormatSuccessMessagecall-sitesWithTheme+WithAccessiblefmt.Print*for user-facing output (outsidepkg/console)Lipgloss Usage Analysis
Adaptive Color System (pkg/styles/theme.go)
The package implements a custom adaptive color type selecting light vs. dark hex values at runtime based on
lipgloss.HasDarkBackground. 14 semantic color variables (Error, Warning, Success, Info, Purple, Yellow, Comment, Foreground, Background, Border, TableAltRow, ...) each have explicit light (darker/saturated) and dark (Dracula-inspired) variants. Background probing is skipped on Windows to avoid ConPTY crashes.All pre-configured
lipgloss.Stylevars use these adaptive colors.TTY-Aware Rendering (pkg/console/console.go)
All styling entry-points use
applyStyleWithTTYwhich gateslipgloss.Style.Renderbehindtty.IsStdoutTerminal()/tty.IsStderrTerminal().RenderTable,RenderTitleBox,RenderErrorBox,RenderInfoSection, andRenderComposedSectionsall follow this contract — plain text is emitted for pipes/redirects.Direct Lipgloss in CLI (one file only)
pkg/cli/compile_schedule_calendar.gois the onlypkg/cli/file calling Lipgloss directly. It receives anisTerminal boolparameter and guards every render call. It uses namedstyles.ScheduleCalendar*style vars — no ad-hoc style construction.Opportunity: Moving the heatmap renderer to a
console.RenderCalendarGridhelper would remove the direct Lipgloss dependency frompkg/cli/. Low priority — correctness is not affected.Border & Layout Patterns
Three named border vars (
RoundedBorder,NormalBorder,ThickBorder) are centralised inpkg/styles/theme.go.RenderTitleBoxuses an inlinelipgloss.DoubleBorder()— the only deviation. Addingstyles.DoubleBorderwould complete centralisation.Table rendering via
lipgloss/tableis encapsulated inconsole.RenderTablewith aTableConfigstruct. Zebra-striping, total rows, and per-column styling are handled insidebuildTableStyleFunc.Huh Form Analysis
Form Consistency & Theming
All 18
huh.NewForm(...)instantiations across 9 files call both.WithTheme(styles.HuhTheme).WithAccessible(console.IsAccessibleMode()). The customstyles.HuhThememaps the Dracula-inspired palette to every Huh style token (titles, selectors, buttons, text-input cursor, etc.).Field types in use:
huh.NewConfirm,huh.NewSelect[string],huh.NewInput(withEchoModePassword). Appropriate for the current UX.Non-TTY Fallbacks & Accessibility
pkg/console/confirm.goandpkg/console/list.goboth checktty.IsStderrTerminal()before callinghuh.NewForm, falling back to numbered text menus.console.IsAccessibleMode()reads theACCESSIBLEenv var and is passed to every form and spinner — animations are disabled in accessibility mode.Findings & Recommendations
✅ Strengths
styles.HuhThemeandIsAccessibleMode().\033[sequences are the three constants inpkg/console/terminal.go(used by the Bubble Tea spinner).formatCompilerMessage— usesconsole.FormatError(CompilerError{...})for structured IDE-parseable output with Rust-like context rendering.1. Unstyled sub-list items in
pkg/cli/trial_confirmation.goLines 182–183 and 199–200 emit raw
fmt.Fprintf(os.Stderr, " a. ...\n")without console styling, mixed with styledconsole.FormatInfoMessage(...)lines:Consider a
console.FormatSubItem(label string)helper for visual consistency.2. Inline
lipgloss.DoubleBorder()inpkg/console/console.go(RenderTitleBox)Add
styles.DoubleBorder = lipgloss.DoubleBorder()topkg/styles/theme.goto complete border centralisation.3. Direct
styles.*usage inpkg/cli/compile_schedule_calendar.goExtract the heatmap grid rendering into
pkg/consoleto keep all Lipgloss dependencies out ofpkg/cli/. Low priority.References: §28508976423
Beta Was this translation helpful? Give feedback.
All reactions