package tui import ( "fmt" "strings" "github.com/charmbracelet/lipgloss" ) func (m Model) renderChat() string { var b strings.Builder header := sectionStyle.Render("Chat") header += " " header += lipgloss.NewStyle().Foreground(mutedColor).Render("(" + m.config.Profile.Preferences.DefaultAI + ")") if m.chatLoading { header += " " + m.spinner.View() + lipgloss.NewStyle().Foreground(warningColor).Render("thinking...") } b.WriteString(header) b.WriteString("\n\n") separator := lipgloss.NewStyle().Foreground(dimColor).Render(strings.Repeat("─", max(m.width-4, 10))) b.WriteString(separator) b.WriteString("\n\n") for _, msg := range m.chatLog { b.WriteString(msg) b.WriteString("\n\n") } if m.previewURL != "" { b.WriteString(itemOKStyle.Render(fmt.Sprintf("Preview: %s", m.previewURL))) b.WriteString("\n\n") } return b.String() } func (m Model) renderChatInput() string { if m.chatLoading { return inputStyle.Render("> ") + m.spinner.View() + lipgloss.NewStyle().Foreground(mutedColor).Render(" waiting for response...") } cursor := lipgloss.NewStyle().Foreground(baseColor).Render("") return inputStyle.Render("> ") + m.chatInput + cursor }