Repository navigation
[terminal-stylist] Terminal output consistency and accessibility audit (Go) #72365
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #72620. |
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
The Go console layer is mature and generally follows Charmbracelet best practices: styling is centralized, TTY-aware, color-profile degradation is supported, Huh forms share one adaptive theme, and raw ANSI is confined to terminal-control utilities. The main opportunities are API consistency, keeping styling out of error values, removing duplicated visual markers, and adding an accessible path for the Work Queue TUI.
Scan metrics
.gofiles, excluding_test.go; 1,771 were underpkg/.pkg/view (excluding lintertestdatafixtures): 1,589 files.fmt.Print*/fmt.Fprint*-style calls in productionpkg/; 2,665 directly target standard streams.console.Format*result, while the higher-levelconsole.Print*helpers are used only 78 times.Priority findings
pkg/cli/env_command.go:214returnserrors.New(console.FormatErrorMessage(err.Error())). This can place prefixes and ANSI styling inside an error value before the final output boundary is known. Return the original/plain wrapped error and style it once at the command’s top-level renderer.fmt.Fprintln(os.Stderr, console.Format...()), despitepkg/console/print.goalready exposingPrintInfoMessage,PrintWarningMessage, and related helpers. A writer-aware console renderer would reduce repeated stream selection, newline handling, and accidental stdout/stderr style mismatches while preserving raw writers for JSON, Markdown, completion, and other machine output.✓,i,⚠, or✗, but at least 19 formatted messages add another emoji. Examples includeconsole.PrintSuccessMessage("✅ Successfully connected...")and emoji-prefixed section/info messages inpkg/cli/mcp_inspect_mcp.go. This produces output such as✓ ✅ ...and adds noise in accessible/plain modes.console.IsAccessibleMode()and.WithAccessible(...), butworkTUICommandonly checks stdin/stdout TTYs. Its view depends on alternate-screen rendering, borders, reverse-video focus, compact symbols, and a dense persistent footer. RespectACCESSIBLE,TERM=dumb, andNO_COLOR; provide a linear non-alt-screen presentation or route users to equivalent list/inspect/action commands.What is already working well
pkg/console/console.gostrips styling when output is not a TTY and degrades rendered color through the detected terminal profile.pkg/styles/theme.goprovides a shared light/dark palette and reusable semantic styles instead of scattering hardcoded colors.pkg/console/console.gouseslipgloss/table, bounded widths, alternate rows, totals, and shared borders rather than manual terminal tables.pkg/styles/huh_theme.gomaps the shared palette throughlipgloss.LightDark, including focused, blurred, validation, selection, and input states.pkg/console/prompt_form.goapplies the theme and accessible mode centrally; Huh inputs use validation and secret inputs use password echo mode.pkg/console/terminal.goandpkg/console/prompt_form.goare for operations Lipgloss does not model; parsing/stripping is centralized inpkg/stringutil/ansi.go.Representative consistency opportunities
pkg/cli/mcp_inspect_mcp.go: mixesconsole.Print*with extra emoji markers and substantial raw formatted output. Standardize section labels and let semantic console styles own status markers.pkg/cli/interactive.go: TTY mode uses well-structured Huh groups and validation; non-TTY prompts duplicate option definitions and formatting. Extract shared option models so labels, defaults, and validation cannot drift between modes.pkg/cli/work_command_tui_view.go: uses local border/reverse styles rather than sharedpkg/stylestokens. Reuse shared border/focus styles and ensure focus is conveyed by text as well as reverse video.audit_diff_render.gointentionally emit raw Markdown to stdout and styled terminal tables to stderr. Keep this separation explicit; these machine/report paths should not be mechanically migrated to styled console helpers.Recommended next actions
pkg/cli/env_command.goand add a lint/check preventingconsole.Format*insideerrors.Neworfmt.Errorf.console.Printerbound to stderr/stdout) and migrate human-facing diagnostics incrementally; exclude serialized JSON, Markdown, shell completion, and generated content.Format*/Print*helpers and document whether section headers may use decorative icons.NO_COLOR,TERM=dumb,ACCESSIBLE, narrow terminals, and redirected stdout/stderr.References:
All reactions