Repository navigation
[terminal-stylist] Terminal styling audit: stream-aware formatting and console consistency #66843
Closed
Replies: 1 comment
|
This discussion was automatically closed because it expired on 2026-10-09T09:00:52.911Z.
|
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 has a strong modern foundation: centralized semantic styles, adaptive light/dark colors, TTY-aware rendering, a shared accessible Huh wrapper, Lipgloss tables/trees, and Unicode-aware width calculation. The main consistency defect is not missing styling; it is that CLI code frequently formats text with stdout-aware helpers and then writes it to stderr.
Scope: all 1,467 non-test
.gofiles were scanned, including 1,450 underpkg/. Files ending in_test.goand all non-Go files were excluded.Key metrics and issues
fmt.Print*/fmt.Fprint*usagepkg/cliprint callspkg/consolepkg/cliconsole.Print*MessagecallsHighest-priority issue: calls such as
use
FormatInfoMessage, which checks stdout TTY state, while the rendered value is sent to stderr. When stdout and stderr are routed differently, color can be omitted from an interactive stderr or emitted based on the wrong stream. Prefer:or, when a custom writer is required:
The most affected files include
pkg/cli/logs_metrics.go(57),pkg/cli/trial_repository.go(46),pkg/cli/pr_command.go(43),pkg/cli/run_workflow_execution.go(39),pkg/cli/logs_orchestrator_download.go(38), andpkg/cli/dispatch.go(37).What is working well
pkg/console/console.gocentralizes semantic message styles, checks the correct TTY in its stderr-specific APIs, honors terminal color capabilities, and useslipgloss/table.pkg/styles/theme.goprovides a single adaptive light/dark palette and shared border/style definitions.pkg/styles/huh_theme.gouseslipgloss.LightDarkand gives focused, blurred, navigation, input, validation, and button states a coherent theme.pkg/console/prompt_form.gois an effective accessibility boundary: every Huh form is routed through it, accessible mode is enabled centrally, stdin/stderr TTYs are required, context-aware runs are supported, and cancellation can be distinguished from failure.pkg/cli/engine_secrets.go,pkg/cli/compile_schedule_calendar.go, andpkg/console/render.gouselipgloss.Width/style widths rather than byte counts for Unicode-safe alignment.pkg/cli/mcp_inspect.goandpkg/cli/status_command.gouse Lipgloss tree rendering rather than hand-building hierarchy graphics.pkg/console/terminal.go,pkg/console/prompt_form.go, andpkg/stringutil/ansi.go. Cursor/screen control is TTY-gated where emitted and is a reasonable exception because Lipgloss is a styling/layout library, not a terminal-control API.Detailed improvement opportunities
1. Standardize stream-aware message emission
Migrate stderr output to
console.PrintInfoMessage,PrintWarningMessage,PrintSuccessMessage,PrintErrorMessage,PrintCommandMessage, andPrintSectionHeader. Where output must target an injected writer, use the corresponding*Stderrformatter.A small static check should reject
fmt.Fprint*(os.Stderr, console.Format*Message(...))whenever a stderr-specific formatter exists. This prevents the current mismatch from returning.2. Avoid duplicated semantic markers
The console formatters already add
i,✓,⚠,✗, or▸. Several call sites add another icon or severity label inside the message, producing visually noisy combinations. Examples occur in:pkg/cli/actions_build_command.go("✅ Validating...","✨ All actions valid","⚠ Warning: ...")pkg/cli/generate_action_metadata_command.go("✗ Failed..."passed to the error formatter)pkg/cli/deps_outdated.go,pkg/cli/deps_report.go, andpkg/cli/deps_security.go("✅ ..."passed to the success formatter)pkg/cli/project_command.goandpkg/cli/upgrade_command.go("✓ ..."passed to the success formatter)Pass plain message text to semantic formatters and let the console package own the marker.
3. Replace manual tables and fixed-width separators
Several human-facing reports use
%‐Nspadding and fixed 60/62/66-column separators. These do not account for wide Unicode glyphs and do not adapt to narrow terminals. Candidates include:pkg/cli/audit_cross_run_render.gopkg/cli/audit_cross_run_clusters_render.gopkg/cli/outcomes_command.gopkg/cli/experiments_analyze_statistics.gopkg/cli/remove_command.gopkg/cli/actionlint.gopkg/cli/audit_diff_render.goUse the existing
console.RenderTablefor tabular data and Lipgloss width/layout primitives for report sections. Keep plain, ANSI-free fallback output for pipes and redirected streams.4. Consolidate interactive explanatory output
The Huh implementation itself is sound, but several interactive flows alternate themed forms with raw
fmt.Fprintln(os.Stderr, ...)paragraphs and hand-built separators.pkg/cli/add_interactive_auth.go,pkg/cli/add_interactive_git.go,pkg/cli/add_interactive_orchestrator.go, andpkg/cli/add_interactive_workflow.gowould benefit from shared note/instruction renderers (RenderInfoSection, section headers, command formatting, and list helpers).Continue using field-level validation for structured values and secrets. For dynamically generated workflow inputs in
pkg/cli/run_interactive.go, ensure workflow constraints are surfaced through Huh validation rather than only after submission. PreserveRunWithContextandconsole.IsCancelledhandling.5. Separate human UI from machine output
Not every raw
fmtcall should be styled. Shell completion, TSV/JSON, generated source, subprocess passthrough, and builder output should remain deterministic and ANSI-free. Standardization should target user-facing stderr paths, not blanket-replace all 3,677 print calls.Recommended next actions
console.RenderTableor Unicode-aware Lipgloss layout.References:
All reactions