@@ -3,7 +3,6 @@ package messages
4 "encoding/json"
4 "encoding/json"
@@ -657,7 +656,6 @@ func joinHeaderBody(header, body string) string {
657func renderPlainContent(v *toolCallCmp, content string) string {
656func renderPlainContent(v *toolCallCmp, content string) string {
658 t := styles.CurrentTheme()
657 t := styles.CurrentTheme()
659 content = strings.TrimSpace(content)
658 content = strings.TrimSpace(content)
660− content = escapeContent(t, content)
661 lines := strings.Split(content, "\n")
659 lines := strings.Split(content, "\n")
663 width := v.textWidth() - 2 // -2 for left padding
661 width := v.textWidth() - 2 // -2 for left padding
@@ -696,7 +694,6 @@ func pad(v any, width int) string {
697func renderCodeContent(v *toolCallCmp, path, content string, offset int) string {
695func renderCodeContent(v *toolCallCmp, path, content string, offset int) string {
698 t := styles.CurrentTheme()
696 t := styles.CurrentTheme()
699− content = escapeContent(t, content)
700 truncated := truncateHeight(content, responseContextHeight)
697 truncated := truncateHeight(content, responseContextHeight)
702 highlighted, _ := highlight.SyntaxHighlight(truncated, path, t.BgBase)
699 highlighted, _ := highlight.SyntaxHighlight(truncated, path, t.BgBase)
@@ -769,45 +766,3 @@ func prettifyToolName(name string) string {
769 return name
766 return name
773−// escapeContent escapes ANSI escape sequences and control characters in the
774−// content and styles it for display in the terminal.
775−func escapeContent(t *styles.Theme, content string) string {
776− content = strings.ReplaceAll(content, "\r\n", "\n")
777− lines := strings.Split(content, "\n")
778− for i, line := range lines {
779− lines[i] = escapeLine(t, line)
782− content = strings.Join(lines, "\n")
786−// escapeLine escapes ANSI escape sequences and control characters and styles
787−// them for display in the terminal.
788−func escapeLine(t *styles.Theme, text string) string {
796− var faint lipgloss.Style
798− faint = t.S().Muted.Faint(true)
801− seq, w, n, state = ansi.DecodeSequence(text, state, nil)
805− quote := strconv.Quote(seq)
806− quote = strings.TrimPrefix(quote, "\"")
807− quote = strings.TrimSuffix(quote, "\"")
808− sb.WriteString(faint.Render(quote))