@@ -1461,11 +1461,18 @@ func (m *UI) handleDialogMsg(msg tea.Msg) tea.Cmd {
14611461
14621462 if err := m.com.Workspace.UpdatePreferredModel(config.ScopeGlobal, msg.ModelType, msg.Model); err != nil {
14631463 cmds = append(cmds, util.ReportError(err))
1464− } else if _, ok := cfg.Models[config.SelectedModelTypeSmall]; !ok {
1465− // Ensure small model is set is unset.
1466− smallModel := m.com.Workspace.GetDefaultSmallModel(providerID)
1467− if err := m.com.Workspace.UpdatePreferredModel(config.ScopeGlobal, config.SelectedModelTypeSmall, smallModel); err != nil {
1468− cmds = append(cmds, util.ReportError(err))
1464+ } else {
1465+ if msg.ModelType == config.SelectedModelTypeLarge {
1466+ // Swap the theme live based on the newly selected large
1467+ // model's provider.
1468+ m.applyTheme(styles.ThemeForProvider(providerID))
1469+ }
1470+ if _, ok := cfg.Models[config.SelectedModelTypeSmall]; !ok {
1471+ // Ensure small model is set is unset.
1472+ smallModel := m.com.Workspace.GetDefaultSmallModel(providerID)
1473+ if err := m.com.Workspace.UpdatePreferredModel(config.ScopeGlobal, config.SelectedModelTypeSmall, smallModel); err != nil {
1474+ cmds = append(cmds, util.ReportError(err))
1475+ }
14691476 }
14701477 }
14711478
@@ -2980,6 +2987,34 @@ func (m *UI) cacheSidebarLogo(width int) {
29802987 m.sidebarLogo = renderLogo(m.com.Styles, true, width)
29812988}
29822989
2990+// applyTheme replaces the active styles with the given theme and
2991+// refreshes every component that caches style data.
2992+func (m *UI) applyTheme(s styles.Styles) {
2993+ *m.com.Styles = s
2994+ m.refreshStyles()
2995+}
2996+
2997+// refreshStyles pushes the current *m.com.Styles into every subcomponent
2998+// that copies or pre-renders style-dependent values at construction time.
2999+func (m *UI) refreshStyles() {
3000+ t := m.com.Styles
3001+ m.header.refresh()
3002+ if m.layout.sidebar.Dx() > 0 {
3003+ m.cacheSidebarLogo(m.layout.sidebar.Dx())
3004+ }
3005+ m.textarea.SetStyles(t.Editor.Textarea)
3006+ m.completions.SetStyles(t.Completions.Normal, t.Completions.Focused, t.Completions.Match)
3007+ m.attachments.Renderer().SetStyles(
3008+ t.Attachments.Normal,
3009+ t.Attachments.Deleting,
3010+ t.Attachments.Image,
3011+ t.Attachments.Text,
3012+ )
3013+ m.todoSpinner.Style = t.Pills.TodoSpinner
3014+ m.status.help.Styles = t.Help
3015+ m.chat.InvalidateRenderCaches()
3016+}
3017+
29833018// sendMessage sends a message with the given content and attachments.
29843019func (m *UI) sendMessage(content string, attachments ...message.Attachment) tea.Cmd {
29853020 if !m.com.Workspace.AgentIsReady() {