Skip to content

[REFACTOR] Cache lipgloss styles per theme change; optional terminal background detection #832

Closed

Description

@edenreich

Problem

internal/ui/styles/provider.go builds 48 lipgloss.NewStyle() chains inside Render* methods that run per item per frame (provider.go:36,47,61,67,80,108,…) — style construction churn across a 2619-LOC conversation render on every repaint. Separately, there is no terminal background detection anywhere (tea.RequestBackgroundColor unused), so themes cannot auto-match light/dark terminals.

Design

  • Build styles once per theme change and store them as fields on the provider (the theme is stable between explicit changes); Render* methods only call .Render().
  • Optional follow-along: return tea.RequestBackgroundColor from Init, handle tea.BackgroundColorMsg (msg.IsDark()), and pick the default theme variant via lipgloss v2 LightDark.

Acceptance criteria

  • No NewStyle() calls remain in per-frame render paths (grep-checkable)
  • Rendering byte-identical before/after (goldens unchanged), apart from intentional background-detection behavior if implemented

Dependencies

None; #824 verifies "no visual change" cheaply.

Activity

  1. added
    refactor
    on Jul 10, 2026
  2. added theissue type on Jul 10, 2026
  3. moved this to Todo in 2026on Jul 10, 2026
  4. added a commit that references this issue on Jul 11, 2026
    c80d92d
  5. moved this from Todo to Done in 2026on Jul 11, 2026
  6. inference-gateway-releaser commented on Jul 11, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.142.2 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorreleased

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions