@@ -400,6 +400,12 @@ func (a *appModel) handleOpenThemePicker() (tea.Model, tea.Cmd) {
400400}
401401
402402func (a * appModel ) handleChangeTheme (themeRef string ) (tea.Model , tea.Cmd ) {
403+ // Skip if selecting the already-persisted theme - preview already applied it visually,
404+ // so no need for notification, cache invalidation, or re-persisting.
405+ if styles .GetPersistedThemeRef () == themeRef {
406+ return a , nil
407+ }
408+
403409 // Load and apply the theme
404410 theme , err := styles .LoadTheme (themeRef )
405411 if err != nil {
@@ -424,6 +430,11 @@ func (a *appModel) handleChangeTheme(themeRef string) (tea.Model, tea.Cmd) {
424430
425431// handleThemePreview applies a theme temporarily for live preview (without persisting).
426432func (a * appModel ) handleThemePreview (themeRef string ) (tea.Model , tea.Cmd ) {
433+ // Skip if already on this theme - no need to invalidate caches
434+ if current := styles .CurrentTheme (); current != nil && current .Ref == themeRef {
435+ return a , nil
436+ }
437+
427438 // Load and apply the theme (without persisting)
428439 theme , err := styles .LoadTheme (themeRef )
429440 if err != nil {
@@ -439,6 +450,11 @@ func (a *appModel) handleThemePreview(themeRef string) (tea.Model, tea.Cmd) {
439450
440451// handleThemeCancelPreview restores the original theme when the user cancels the theme picker.
441452func (a * appModel ) handleThemeCancelPreview (originalRef string ) (tea.Model , tea.Cmd ) {
453+ // Skip if already on the original theme - no need to invalidate caches
454+ if current := styles .CurrentTheme (); current != nil && current .Ref == originalRef {
455+ return a , nil
456+ }
457+
442458 // Load and apply the original theme
443459 theme , err := styles .LoadTheme (originalRef )
444460 if err != nil {
0 commit comments