Repository navigation
[terminal-stylist] Terminal Stylist: console output consistency review (pkg/) #77113
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #77398. |
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
Scanned all 1,988 non-test
.gofiles underpkg/, focusing on console, Lipgloss, and Huh usage. This was analysis only; no code was changed.The design holds up. Stream routing is consistent, colors adapt to light and dark backgrounds, and interactive prompts check for a TTY. Four gaps matter most:
i ✓ Agent file exists.FormatInfoMessageandFormatInfoMessageStderr, and call sites use both.Key metrics
pkg/pkg/consoleand linter fixtures)consolehelperformatCompilerMessage(styled)RenderTable/RenderTableStdoutcall sites%-Nstable linesFindings by library and pattern
Console formatting
Double glyphs.
FormatInfoMessagealready prefixesi, so a message starting with✓rendersi ✓ .... Switch these to the success helper and drop the glyph:pkg/workflow/agent_validation.go:109and:449: useFormatSuccessMessageStderrpkg/workflow/pip_validation.go:110and:268: useFormatSuccessMessagepkg/workflow/npm_validation.go:102: useFormatSuccessMessagepkg/workflow/repository_features_validation.go:285and:289: useFormatSuccessMessagePlain-text stderr writes (581). Examples:
pkg/workflow/cache_steps.go:24andpkg/workflow/push_to_pull_request_branch.go:128hand-write aWarning:prefix. UseFormatWarningMessageStderr.pkg/cli/preconditions.go:93and:145hand-write aNote:prefix. UseFormatInfoMessageStderr.pkg/cli/deps_report.go:177hard-codes a warning emoji with extra spaces. UseFormatWarningMessageStderr.pkg/workflow/side_repo_maintenance.go:218and:237prepend a stray space. Use a console helper.pkg/workflow/claude_logs.go:144to:155are verbose-gated rawfmt.Fprintfcalls.console.LogVerbosewould keep them consistent.Alias naming.
pkg/console/destination_aliases.godefines nine*Stderrfunctions that only call the unsuffixed versions. Serena reference lookup shows bareFormatInfoMessagereferenced from 692 non-test symbols in 153 files, andFormatInfoMessageStderrfrom 76 in 28. Both mean the same thing, so readers cannot tell which calls are stream-aware. Recommendation: use the bare names for stderr, since*Stdoutis the explicit exception, and deprecate the aliases in a follow-up.Positive. The
*Stdout/*Stderrrouting is documented inpkg/console/README.mdand matches the code. My scan found zero mismatches.Lipgloss and color
pkg/styles/theme.gohas light and dark palettes, detects background at startup on non-Windows, andHuhThemeuseslipgloss.LightDark.%-Nscounts runes, not display cells, so wide glyphs misalign.experiments_analyze_statistics.goandaudit_cross_run_render.goare the main cases.pkg/cli/engine_secrets.go:798to:832already useslipgloss.Width, which is the model to follow. Also considerconsole.RenderTable.strings.Repeatwith box-drawing characters ataudit_diff_render.go:52,experiments_analyze_statistics.go:806and:821, andactionlint.go:123. A small console helper would keep them consistent.pkg/cli/compile_stats.go:327.pkg/console/terminal.godocuments its ANSI exception.pkg/console/prompt_form.gocursor controls have no such note.renderTableWithTTY(..., degradeStdout bool)inpkg/console/console.goreceivestruefrom the stderrRenderTablepath. The flag controls color degradation, so rename it, e.g.degradeColor. A customTTYFuncalso skips degradation. No production code sets it, so this is latent.colorwriter.noColorEnabledinpkg/colorwriter/colorprofile_writer.gousesstrconv.ParseBool.NO_COLOR=yestherefore enables accessible mode (see Huh) but is not treated as no-color by this explicit check. I did not verify whethercolorprofile.Envcovers it. Make it use presence semantics, as no-color.org describes.Huh
console.NewFormapplies the shared theme and accessible mode.PromptForm.Runrejects non-TTY stdin or stderr.ConfirmActionfalls back to plain text when only stderr is not a TTY.console.IsAccessibleMode()treats any non-emptyNO_COLORas accessible mode.pkg/cli/interactive_test.gopins this. The effect is that forms switch to accessible prompts and spinners stop, even though the user only asked for no color. The NO_COLOR policy decision is in the Lipgloss section.Bubble Tea
pkg/cli/work_command_tui.go:308checks only stdin and stdout TTYs. It does not callconsole.IsAccessibleMode().pkg/cli/org_rollout_flags.go:82checks TTY and CI for--interactive, thenrunOrgRolloutTUI(pkg/cli/org_rollout_tui.go:271) runs even whenTERM=dumborACCESSIBLEis set.runOrgRolloutPlainalready exists and could serve as the accessible fallback.pkg/console/spinner.go:142to:146) already honor accessible mode.IsAccessibleMode()is true.Method and limitations
go,typescript, andbashlanguage servers active). Usedget_symbols_overviewonpkg/styles/theme.goandfind_referencing_symbolsfor alias counts.fmt.Fprint*(os.Stderr or os.Stdout, ...)in non-test files. Excluded:pkg/console,pkg/lintersfixtures, andtestdata.consolestderranalyzer (cmd/linters) could not be built. The sandbox cannot reach the Go module proxy and the repo has no vendor directory. I did not work around this, so the zero-mismatch result comes from my scan, not the analyzer.HasDarkBackgroundbehavior when stdin or stderr is not a terminal (init-time probe inpkg/styles/theme.go), andcolorprofile.Envhandling ofNO_COLOR. Module sources are not cached locally.Next actions
Warning:,Note:, and emoji-prefixed raw writes through console helpers, starting withpkg/workflow/cache_steps.goandpkg/cli/preconditions.go.work tuiandorg rollout --interactive.noColorEnabledwith it.*Stderraliases.References: §43184716859
All reactions