From 1ed6f5248c5eb8d86d002d22578b206a09e2ceed Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 4 May 2026 11:58:52 +0000 Subject: [PATCH] refactor(ui): pair markdown cache invalidation with the styles mutation This is an additional guard to invalidate the cache in the off-chance styles are mutated (rather than updated via applyTheme(), as they should be). --- internal/ui/model/ui.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/ui/model/ui.go b/internal/ui/model/ui.go index 75eead0149b2145166557e4aff6050cd40206ae5..4a4a343acf5a7a1aa89a2eaf61e09424eaca4dbc 100644 --- a/internal/ui/model/ui.go +++ b/internal/ui/model/ui.go @@ -3091,10 +3091,12 @@ func (m *UI) cacheSidebarLogo(width int) { m.sidebarLogo = renderLogo(m.com.Styles, true, m.com.IsHyper(), width) } -// applyTheme replaces the active styles with the given theme and -// refreshes every component that caches style data. +// applyTheme replaces the active styles with the given theme, drops the +// shared markdown renderer cache, and refreshes every component that +// caches style data. func (m *UI) applyTheme(s styles.Styles) { *m.com.Styles = s + common.InvalidateMarkdownRendererCache() m.refreshStyles() } @@ -3116,7 +3118,6 @@ func (m *UI) refreshStyles() { ) m.todoSpinner.Style = t.Pills.TodoSpinner m.status.help.Styles = t.Help - common.InvalidateMarkdownRendererCache() m.chat.InvalidateRenderCaches() }