Repository navigation
[terminal-stylist] Terminal Stylist review: console output, Lipgloss, and Huh consistency #68645
Replies: 0 comments
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.
Terminal output consistency review
The console layer is fundamentally strong: terminal styling is centralized, destination-aware, adaptive to light/dark backgrounds, and guarded for TTY/color-profile behavior. Huh forms consistently pass through an accessibility-aware wrapper. The main opportunity is to finish migrating several user-facing
pkg/clipaths from rawfmt.Fprint*output to the existingpkg/consoleAPI, and to give the standalone Work Queue TUI an explicit accessible-mode path.Assessment: healthy foundation, with targeted consistency and accessibility debt rather than a need for a library rewrite.
Scan metrics
pkg/testdata)os.Stdout/os.Stderrfmt.Fprint*callsconsole.*console.*call sitesThe raw
fmtcount is not itself a defect. A substantial portion intentionally emits JSON, Markdown reports, generated shell snippets, subprocess output, or carefully aligned diagnostics where styling would be incorrect. Linter fixtures were scanned but excluded from application findings.Highest-value improvements
pkg/cli/mcp_inspect_mcp.go:574and:588writeError displaying ... schemadirectly to stderr, while adjacent messages useconsole.PrintSectionHeaderandconsole.PrintInfoMessage. Useconsole.PrintErrorMessage(or the destination-aware formatter) so these errors receive the same prefix, color policy, and non-TTY behavior.pkg/cli/add_interactive_workflow.go:122-142and:242-271directly print status, failure, and lookup diagnostics. They should useloggerfor debug-only internals orconsole.FormatVerboseMessage/a print helper for--verboseuser output. The current raw errors are visually inconsistent with errors in the same command.pkg/cli/work_command_tui.go:303-325checks stdin/stdout TTYs but notconsole.IsAccessibleMode(). The view uses alternate-screen rendering, reverse video, dense side-by-side panels, and frequent refreshes. In accessible mode, either reject with a clear command fallback (state --json/inspect) or provide a linear, non-alt-screen view. Also expose focus/selection/error state with textual markers rather than relying partly on reverse video.pkg/cli/audit_diff_render.go,pkg/cli/audit_report_render.go,pkg/cli/audit_cross_run_render.go, andpkg/cli/mcp_inspect_mcp.gocontain many direct writes. Their Markdown/JSON output should remain plain, but terminal-mode sections should be built through small destination-aware render helpers. This separates machine output from decorated human output and makes TTY policy reviewable.fmt.Fprintln(os.Stderr, console.Format...(...))withconsole.PrintInfoMessage,PrintWarningMessage,PrintErrorMessage, etc. This removes repeated destination/formatter pairing and makes the existingconsolestderrinvariant easier to maintain.Console package findings
What is working well
pkg/console/console.goapplies styles only for the appropriate stdout/stderr TTY and degrades output throughcolorprofile, honoring terminal capabilities and color environment settings.Format...Stdout, stderr defaults,RenderTableStdout, andRenderTable) avoid styling based on the wrong stream.pkg/linters/consolestderr/statically checks destination/formatter mismatches and offers fixes.pkg/console/print.goprovides semantic one-line output helpers.pkg/console/spinner.godisables animation for non-TTY and accessible environments, prevents concurrent spinner contention, and avoids consuming input intended for later forms.pkg/console/terminal.goconfines raw ANSI to cursor/screen operations that Lipgloss does not provide and guards them with stderr TTY checks.pkg/console/render.goandpkg/console/console.gocentralize struct/table rendering rather than duplicating layout logic.Representative correct consumers
pkg/cli/update_workflows.gopkg/cli/logs_run_processor.gopkg/cli/logs_orchestrator_stdin.gopkg/cli/audit_render_output.gopkg/cli/org_runner.gopkg/cli/compile_stats.gopkg/cli/mcp_list.gopkg/cli/list_workflows_command.gopkg/cli/domains_command.gopkg/cli/forecast_render.gopkg/cli/models_command.gopkg/cli/health_command.gopkg/cli/mcp_registry_list.gopkg/cli/outcomes_history.gopkg/cli/logs_format_compact.goRaw output that should remain raw
run_workflow_execution.go,models_command.go,health_command.go,hash_command.go, and similar command contracts).shell_completion.go.These paths should not be styled because ANSI or semantic prefixes would corrupt machine-readable or copy/paste output.
Lipgloss analysis
Good patterns
pkg/styles/theme.godefines a shared semantic palette with adaptive light/dark colors and reusable border/style tokens.pkg/styles/huh_theme.gouseslipgloss.LightDarkagainst the same palette, preventing theme divergence.lipgloss/table, width-aware wrapping, centralized borders, and TTY-aware style functions.pkg/cli/compile_schedule_calendar.goexplicitly suppresses rich rendering for non-terminal and accessible output.pkg/cli/work_command_tui_view.gouses Lipgloss width/height measurement and responsive one/two-column layouts instead of byte-length padding.pkg/console/terminal.goandpkg/console/prompt_form.go; they are not being used as a substitute for color/style APIs.Recommendations
pkg/styles; avoid introducing one-off hardcoded colors.lipgloss/table: Markdown is an output format, not terminal layout. Use Lipgloss tables only in human terminal mode.Huh and interactive UX analysis
Good patterns
pkg/console/prompt_form.gois the sole directhuh.NewFormsite. It appliesstyles.HuhTheme,WithAccessible(console.IsAccessibleMode()), terminal checks, and consistent cleanup.console.NewForm,NewInputForm,NewSelectForm, andNewConfirmFormrather than constructing unthemed forms.huh.EchoModePasswordinpkg/cli/engine_secrets.goandpkg/console/input.go.console.IsCancelled, allowing callers to distinguish user aborts from failures.Recommendations
huh.NewFormuse inpkg/cli.consolestderr.selectWorkflowNonInteractive's manual numbered prompt (pkg/cli/run_interactive.go:199-218) with a shared console text-select helper, or require interactive stdin explicitly. A “non-TTY” path that immediately callsfmt.Scanfcan be confusing in redirected/closed-input environments.Examples of preferred migrations
Inconsistent
Preferred
Inconsistent verbose output
Preferred
If a verbose print helper is intentionally not added, use the destination-aware verbose formatter with stderr. For implementation-only diagnostics, prefer the existing namespace logger instead.
Suggested next actions
work-queue tui.huh.NewFormconstruction outsidepkg/console.Analysis note
Serena project activation succeeded, but its Go semantic operations could not initialize because the analysis service reported unavailable language runtimes. Per the tool's stop instruction, no semantic workaround was attempted; the complete non-test
.goinventory was instead scanned with repository-local file and pattern analysis, followed by targeted source review.References: §38537843211
All reactions