Repository navigation
[terminal-stylist] Terminal output consistency audit: sink-aware styling and accessibility #67389
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #67686. |
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
A static scan covered all 1,516 tracked non-test Go files (
*_test.goexcluded), with 1,496 files underpkg/as the primary review area. The codebase already has a strong terminal foundation: centralized semantic styles, adaptive light/dark colors, TTY-aware rendering, color-profile degradation, a reusable Lipgloss table renderer, and accessibility-aware Huh wrappers.The main consistency defect is output-sink mismatch. Most user-facing status messages are written to
stderrbut formatted by helpers that detectstdout. This can suppress color whenstdoutis redirected whilestderris interactive, or emit ANSI into redirectedstderrwhenstdoutremains a TTY.pkg/fmt.Print*/fmt.Fprint*references inpkg/console.*references inpkg/console.New*Formstderrtable rendersstderrTTY detectionKey issues and recommendations
High — make formatting destination-aware by construction. Examples such as
pkg/cli/audit_diff_render.go,pkg/cli/logs_metrics.go,pkg/cli/dispatch.go,pkg/cli/run_workflow_execution.go, and many add/update commands writeconsole.FormatInfoMessage,FormatWarningMessage,FormatSuccessMessage, orFormatErrorMessagetoos.Stderr. Those non-Stderrhelpers inspectstdout.console.PrintInfoMessage,PrintWarningMessage, etc., or the existing*Stderrformatters.console.Printerbound to anio.Writerand its TTY detector so callers cannot accidentally pair a formatter with the wrong stream.pkg/console/print.goitself:PrintErrorMessagecurrently delegates toFormatErrorMessage, for which noFormatErrorMessageStderrcounterpart exists.High — bind tables to their destination.
console.RenderTabledefaults tostdoutdetection. There are 22 direct renders tostderr, while only the two configs inpkg/cli/experiments_render.gosetTTYFunc: tty.IsStderrTerminal. Representative affected files arepkg/cli/audit_diff_render.go(12 calls),compile_stats.go,deps_outdated.go,domains_command.go,mcp_list.go,mcp_registry_list.go, andoutcomes_history.go.RenderTableTo(io.Writer, TableConfig)or require a destination/profile inTableConfig.TTYFuncat call sites; infer the correct profile from a printer/render target.Medium — finish migration from raw status output. Raw
fmt.Fprint*is appropriate for machine-readable stdout and report builders, but status/error lines should consistently use semantic console methods. Concentrated candidates includepkg/cli/audit_report_render.go,mcp_inspect_mcp.go,experiments_analyze_statistics.go,preconditions.go,audit_cross_run_render.go,engine_secrets.go,deps_report.go, andadd_interactive_workflow.go.fmtfor JSON, Markdown, shell completion, and pass-through subprocess output.⚠ Warning: ...; the formatter already communicates severity.console.FormatErrorMessage(...)inerrors.New(...), which risks ANSI leaking into logs or later wrapping.Medium — add an accessible fallback for the full-screen work queue.
pkg/cli/work_command_tui_view.gohas good responsive sizing, clipping, ASCII borders, explicit keyboard help, and an alternate screen, but it does not consultconsole.IsAccessibleMode()and has no visible non-alt-screen/screen-reader mode.ACCESSIBLE,NO_COLOR, orTERM=dumbis active.Reverse(true)/ad hoc frames when adding status emphasis.Low — tighten interactive preflight and cancellation handling. The shared Huh wrapper correctly requires both stdin and stderr TTYs, applies the project theme, and enables accessible mode. Some callers (for example
pkg/cli/interactive.goandpkg/cli/run_interactive.go) preflight only stderr before choosing interactive versus fallback mode. If stdin is piped but stderr is a TTY, the fallback is skipped and the form returns an availability error.console.IsCancelledconsistently so cancellation is not reported as a generic failure.What is already working well
pkg/styles/theme.gocentralizes semantic styles and adaptive light/dark palette values.pkg/styles/huh_theme.gomaps that same palette into Huh withlipgloss.LightDark, avoiding a second color system.pkg/console/console.godegrades colors according to terminal capabilities andNO_COLOR, and useslipgloss/tablerather than hand-built display tables.pkg/console/prompt_form.gocentralizes Huh theming, accessibility, TTY requirements, and cleanup.pkg/console/spinner.godisables animation outside a TTY and in accessible mode, and prevents concurrent spinner corruption.pkg/cli/compile_schedule_calendar.gois a strong sink-aware example: stderr detection, accessible plain-text fallback, centralized styles, and profile degradation are all explicit.pkg/console/prompt_form.goandpkg/console/terminal.go; they are used for cursor/screen operations rather than hard-coded colors and are guarded by terminal checks.Pattern examples
Preferred stderr pattern
Or, once writer-bound output is adopted:
Current mismatch
FormatWarningMessageuses stdout TTY detection even though the rendered value is sent to stderr.Preferred interactive construction
This preserves the shared theme and accessible-mode policy; direct
huh.NewFormconstruction should remain insidepkg/console.Representative file categorization
Good centralized implementations / exemplars
pkg/console/console.gopkg/console/prompt_form.gopkg/console/spinner.gopkg/console/accessibility.gopkg/styles/theme.gopkg/styles/huh_theme.gopkg/cli/compile_schedule_calendar.gopkg/cli/compile_file_operations.go,compile_pipeline.go, andcompile_post_processing.goHighest-value migration targets
pkg/cli/audit_diff_render.gopkg/cli/logs_metrics.gopkg/cli/dispatch.gopkg/cli/run_workflow_execution.gopkg/cli/trial_repository.gopkg/cli/pr_command.gopkg/cli/update_workflows.gopkg/cli/mcp_list.gopkg/cli/outcomes_history.gopkg/console/print.gopkg/cli/work_command_tui_view.goNext actions
stderrtables/status calls first.Stderrformatters from being passed toos.Stderr, and preventing styled console strings from being embedded in returned errors.The requested Serena project activation succeeded, but semantic lookup could not start because the Serena service reported that its Go language server runtime was unavailable. The report therefore uses a complete tracked-Go lexical scan plus targeted source review rather than Serena diagnostics.
References:
All reactions