Skip to content

[plan] Migrate HuhTheme to huh v2 ThemeFunc API with dark mode detection #24314

@github-actions

Description

@github-actions

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 pointer

Should become:

// After (v2.x)
func HuhTheme(isDark bool) *huh.Styles { ... }
form.WithTheme(styles.HuhTheme)  // pass function reference itself

The 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

  1. In pkg/styles/huh_theme.go:

    • Update function signature from func HuhTheme() *huh.Theme to func HuhTheme(isDark bool) *huh.Styles
    • Replace lipgloss.AdaptiveColor{Light: ..., Dark: ...} patterns with direct color selection using isDark
    • 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)
  2. Update all call sites across pkg/console/ and pkg/cli/ (approximately 19 NewForm call sites):

    • Change .WithTheme(styles.HuhTheme()).WithTheme(styles.HuhTheme) (pass the function reference, not the result)
  3. Run make fmt and make lint

Files to Modify

  • pkg/styles/huh_theme.go — function signature, color logic, remove compat comment
  • All files in pkg/console/ and pkg/cli/ that call .WithTheme(styles.HuhTheme())

Acceptance Criteria

  • HuhTheme matches the huh.ThemeFunc type signature
  • All .WithTheme(styles.HuhTheme()) call sites updated to .WithTheme(styles.HuhTheme)
  • Obsolete v1 compatibility comment removed
  • make build succeeds
  • make test-unit passes
  • 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

Metadata

Metadata

Labels

Type

No type
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