Repository navigation
[terminal-stylist] Terminal output consistency audit for Go CLI code #70838
Closed
Replies: 1 comment
|
This discussion was automatically closed because it expired on 2026-10-22T08:59:01.048Z.
|
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.
Overview
Analyzed every non-test Go source file in the repository, with
pkg/as the primary review area. The scan covered 1,741.gofiles excluding_test.go: 1,721 underpkg/and 20 elsewhere. Serena/gopls semantic lookup and diagnostics completed successfully; the sampled console and theme files had no language-server diagnostics.The overall foundation is strong: gh-aw has a substantial
pkg/consoleabstraction, adaptive styling, destination-aware TTY checks, color-profile degradation, a shared Huh theme, accessible-mode support, and clean non-TTY fallbacks. The main consistency gap is not missing infrastructure—it is a set of older or specialized renderers that still write presentation-heavy text directly withfmt.Fprint*.Key metrics
console.*pkg/console/prompt_form.gofmt.Print*fmt.Fprint*lines inpkg/The final count is a syntactic inventory, not 844 defects. JSON, Markdown, YAML, generated content, command output passthrough, and writer-based renderers should remain plain.
What is working well
pkg/console/console.gochecks the actual output destination and degrades Lipgloss output throughpkg/colorwriterinstead of assuming true color. It also exposes distinct stdout/stderr formatters.pkg/styles/theme.gocentralizes light/dark colors;pkg/styles/huh_theme.gomaps the same palette withlipgloss.LightDark, avoiding a separate form color system.pkg/console/prompt_form.goappliesWithAccessible(IsAccessibleMode())and the shared theme to every Huh form. A repository scan found the onlyhuh.NewFormcall there, so callers do not silently bypass accessibility.pkg/console/confirm.go,pkg/console/list.go, andpkg/cli/interactive.godistinguish stdin from stderr TTY availability and provide text fallbacks or clear errors. Password fields inpkg/cli/engine_secrets.gousehuh.EchoModePassword.pkg/console/console.gouseslipgloss/table, bounded rendering, shared borders, and non-TTY rendering rather than hand-built ANSI tables.pkg/console/render.goprovides structured rendering for tagged Go values.pkg/console/terminal.goandpkg/console/prompt_form.goguard cursor-control sequences with TTY/accessibility conditions;pkg/stringutil/ansi.goandpkg/cli/mcp_compile_diagnostics.gohandle removal/detection rather than user-facing decoration.pkg/cli/compile_schedule_calendar.gochecks stderr TTY and degrades styled cells;pkg/cli/work_command_tui_view.goappropriately uses Lipgloss layout inside a Bubble Tea TUI.Priority findings
1. Standardize the MCP inspector terminal view
pkg/cli/mcp_inspect_mcp.gois the clearest migration target.displayDetailedToolInfomixesconsole.PrintSectionHeaderwith raw emoji, literal Markdown emphasis such as**Name:**, fenced JSON, and unformattedError displaying ...lines on stderr. In an interactive terminal the Markdown markers are visible rather than rendered, and the error lines bypass the shared severity style.Recommended direction:
console.RenderStructor a two-columnconsole.RenderTable.console.PrintSuccessMessage,PrintWarningMessage, andPrintErrorMessagefor allowance and schema-rendering status.2. Remove mixed raw/styled status output in watch mode
pkg/cli/compile_watch.gocombines destination-aware console formatters with raw strings and emoji (🔨,🛑). Similar states therefore have different prefixes, color behavior, and accessibility characteristics.Use the existing progress/info/success formatter family for initial compilation, watch-ready, and shutdown states. This is a small migration with high visibility because watch mode is long-running and repeatedly emits status.
3. Route one-off renderers through a destination-aware helper
pkg/cli/gateway_logs_timeline_render.gocorrectly disables Lipgloss when stdout is not a TTY, but its localstreamColorcallsStyle.Renderdirectly when it is a TTY. Unlikepkg/console, this path does not visibly apply the repository color-profile degradation layer. Expose a small public stdout/stderr style-render helper frompkg/console, or render the timeline through a console-owned API, so TTY detection,NO_COLOR/profile behavior, and future accessibility policy remain centralized.The same rule should guide future one-off Lipgloss usage: Bubble Tea views may render directly; ordinary command output should use the console layer.
4. Reduce duplicated interactive option models
pkg/cli/interactive.gohas well-structured Huh groups, descriptions, a validated text field, and a non-TTY path. However, trigger, engine, tool, and network choices are duplicated between Huh and text fallback construction. The engine list is also separately represented by the engine catalog elsewhere.Define shared option descriptors and adapt them to
[]huh.Option[T]or numbered text choices. This prevents interactive and accessible/non-TTY experiences from drifting as engines or tools are added.5. Make long forms responsive to terminal height
The main workflow form uses fixed field heights (8 and 10), while
PromptFormreserves a fixed 40 rows for cursor restoration. The cleanup behavior is thoughtful, but small terminals can still present a cramped form. Clamp field/form heights to terminal dimensions when available, and let accessible mode remain linear and unbounded. Preserve Huh keyboard defaults rather than implementing custom navigation.Pattern examples
Preferred:
pkg/console/console.goreturns plain text for non-TTY destinations and otherwise runscolorwriter.Degrade(style.Render(text), environ). Call sites then select a formatter that matches both severity and destination.Preferred:
pkg/console/prompt_form.gowrapshuh.NewForm(...).WithTheme(styles.HuhTheme).WithAccessible(accessible), ensuring every form receives consistent theming and screen-reader behavior.Needs improvement:
pkg/cli/mcp_inspect_mcp.goemits📋 **Name:** ...directly to stderr and prints schema failures as rawError displaying ...; use a console table/section and error formatter.Needs improvement:
pkg/cli/compile_watch.goemits some states throughFormatProgressMessageStderrand adjacent states as raw emoji strings; use one semantic status vocabulary.Suggested implementation order
displayDetailedToolInfoinpkg/cli/mcp_inspect_mcp.goto shared console sections/tables and semantic errors.pkg/cli/compile_watch.gostatus lines.pkg/cli/interactive.go.For regression coverage, verify stderr-vs-stdout TTY behavior, non-TTY output with no escape sequences,
NO_COLOR/limited color profiles, accessible mode, cancellation (huh.ErrUserAborted), and small terminal dimensions.References:
All reactions