-
Notifications
You must be signed in to change notification settings - Fork 322
[plan] Migrate HuhTheme to huh v2 ThemeFunc API with dark mode detection #24314
Description
Objective
After upgrading huh to v2 (see companion issue), migrate HuhTheme() in pkg/styles/huh_theme.go to use the new huh.ThemeFunc API (func(isDark bool) *huh.Styles), enabling proper dark/light terminal detection, and remove the obsolete lipgloss v1 compatibility comment.
Context
From discussion #24261 (Go Fan module review). In huh v2, themes are defined as huh.ThemeFunc = func(isDark bool) *huh.Styles and passed to forms as a function reference rather than a pointer value. The current code:
// Before (v0.8.0)
func HuhTheme() *huh.Theme { ... }
form.WithTheme(styles.HuhTheme()) // called, returns pointerShould become:
// After (v2.x)
func HuhTheme(isDark bool) *huh.Styles { ... }
form.WithTheme(styles.HuhTheme) // pass function reference itselfThe isDark bool parameter replaces the need for lipgloss.AdaptiveColor in color definitions — the theme can now make direct color decisions based on the terminal background.
Steps
-
In
pkg/styles/huh_theme.go:- Update function signature from
func HuhTheme() *huh.Themetofunc HuhTheme(isDark bool) *huh.Styles - Replace
lipgloss.AdaptiveColor{Light: ..., Dark: ...}patterns with direct color selection usingisDark - Remove the obsolete comment about lipgloss v1 / huh v0.8.0 compatibility
- Update the import to use
charm.land/lipgloss/v2(the v1 import should already be gone after the dep upgrade)
- Update function signature from
-
Update all call sites across
pkg/console/andpkg/cli/(approximately 19NewFormcall sites):- Change
.WithTheme(styles.HuhTheme())→.WithTheme(styles.HuhTheme)(pass the function reference, not the result)
- Change
-
Run
make fmtandmake lint
Files to Modify
pkg/styles/huh_theme.go— function signature, color logic, remove compat comment- All files in
pkg/console/andpkg/cli/that call.WithTheme(styles.HuhTheme())
Acceptance Criteria
-
HuhThemematches thehuh.ThemeFunctype signature - All
.WithTheme(styles.HuhTheme())call sites updated to.WithTheme(styles.HuhTheme) - Obsolete v1 compatibility comment removed
-
make buildsucceeds -
make test-unitpasses - Theme visually adapts to dark/light terminal backgrounds
Generated by Plan Command for issue #discussion #24261 · ● 188.9K · ◷
- expires on Apr 5, 2026, 1:46 PM UTC