Skip to content

[go-fan] Go Module Review: charm.land/lipgloss/v2Β #46185

Description

@github-actions

🐹 Go Fan Report: Lip Gloss (v2)

Module Overview

charm.land/lipgloss/v2 is Charm's declarative library for styling terminal output β€” colors, borders, padding, alignment, layout joins, plus table, tree, and list sub-packages. It is the foundation of all styled CLI output in gh-aw.

Current Usage in gh-aw

  • Files: 10 non-test files
  • Version: v2.0.5 β€” βœ… the latest release (published 2026-07-03). No upgrade needed.
  • Key APIs Used: NewStyle (44x), Color (38x), Style (8x), border helpers (Normal/Rounded/Thick/Double/HiddenBorder), LightDark, HasDarkBackground, Fprintf, JoinVertical, Center/Left
  • Sub-packages: table (console output), tree (status, mcp_inspect)
Files using lipgloss
  • pkg/styles/theme.go β€” central palette, adaptive-color system, borders, startup probe
  • pkg/styles/huh_theme.go β€” palette to huh forms via lipgloss.LightDark
  • pkg/console/console.go β€” table, boxes, JoinVertical, style gating
  • pkg/console/spinner.go, pkg/console/banner.go
  • pkg/logger/logger.go β€” lipgloss.Fprintf to a colorprofile-aware stderr writer
  • pkg/cli/status_command.go, pkg/cli/mcp_inspect.go β€” tree
  • pkg/cli/compile_schedule_calendar.go, pkg/cli/gateway_logs_timeline_render.go

Research Findings

  • Releases: v2.0.5 (07-03), v2.0.4 (06-12), v2.0.3 (04-13), v2.0.0 (2026-02-24). v2.0.5 is a maintenance release β€” grapheme/emoji rendering edge-case fixes via an ultraviolet bump. No API changes since v2.0.0.
  • v2 vs v1: v2 dropped the global renderer and the standalone AdaptiveColor/CompleteColor types. Colors are now plain color.Color; light/dark selection happens at render time via LightDark(isDark) / HasDarkBackground; color-profile downgrading moved to the separate colorprofile package.

Best Practices

gh-aw already follows the maintainer-recommended v2 idioms: color.Color-based palette, LightDark for per-render selection, a StyleFunc for table styling, and colorprofile.Writer (via pkg/colorwriter) for degradation. Nicely done. πŸ‘

Improvement Opportunities

πŸƒ Quick Wins

  • huh_theme.go re-parses hex on every call: lipgloss.Color(hexColor...) runs on each HuhTheme(isDark) invocation and duplicates the hex parsing already in theme.go. Pre-convert the hexColor* constants to package-level color.Color values once and reference them from both files. Low impact (ThemeFunc is called rarely) β€” pure tidiness + drift prevention.

✨ Feature Opportunities

  • list sub-package: v2 ships a list package (bullet/ordered lists with custom enumerators) that could replace any hand-built bulleted output, matching the existing tree/table adoption. Only worth it where such output already exists.

πŸ“ Best Practice Alignment

  • TTY gating vs colorprofile (subtle, worth an audit): console.applyStyleWithTTY strips styling based only on a TTY check. The recommended v2 path is to always render and let a colorprofile.Writer degrade output (already used for stderr). The manual gate does not honor NO_COLOR by itself β€” strings from applyStyle printed to a color TTY stay colored even when NO_COLOR is set, unless they pass through the colorprofile writer. Suggest auditing that all styled stdout paths flow through a colorprofile writer so NO_COLOR/COLORTERM/TERM are honored consistently; the manual TTY gate can then be simplified.

πŸ”§ General Improvements

  • The dual adaptive-color strategy (package-global adaptiveColor + per-render LightDark) is intentional and documented β€” no change needed. A one-line cross-link comment noting both consume the same hexColor* constants would help prevent drift.

Recommendations

  1. (Low) Audit styled stdout paths for consistent colorprofile.Writer usage so NO_COLOR is honored everywhere, then simplify the manual TTY gate.
  2. (Low) Hoist hexColor* to color.Color conversions to package level, shared by theme.go and huh_theme.go.
  3. (Optional) Adopt the list sub-package where hand-built bullet lists exist.

Next Steps

  • No urgent action: usage is idiomatic and on the latest version.
  • Treat the items above as small, opportunistic cleanups.

Generated by Go Fan
Module summary saved to: scratchpad/mods/lipgloss.md

Generated by 🐹 Go Fan Β· 127 AIC Β· βŒ– 13.1 AIC Β· ⊞ 7.3K Β· β—·

  • expires on Jul 18, 2026, 12:47 AM UTC-08:00

Metadata

Metadata

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions