From dcf9dadb1cabb522854db2fec78e5a44e8259b57 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Mon, 6 Apr 2026 22:47:23 -0400 Subject: [PATCH] restore markdown formatting --- src/user/chat.rs | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/user/chat.rs b/src/user/chat.rs index af5d4bb..61d2c7e 100644 --- a/src/user/chat.rs +++ b/src/user/chat.rs @@ -279,6 +279,24 @@ impl PaneState { self.push_line_with_marker(line, color, Marker::None); } + fn append_text(&mut self, text: &str) { + let clean = strip_ansi(text); + if self.use_markdown { + self.md_buffer.push_str(&clean); + } else { + for ch in clean.chars() { + if ch == '\n' { + let line = std::mem::take(&mut self.current_line); + self.lines.push(Line::styled(line, Style::default().fg(self.current_color))); + self.markers.push(Marker::None); + self.evict(); + } else { + self.current_line.push(ch); + } + } + } + } + fn push_line_with_marker(&mut self, line: String, color: Color, marker: Marker) { self.flush_pending(); self.lines.push(Line::styled(strip_ansi(&line), Style::default().fg(color))); @@ -482,10 +500,18 @@ impl InteractScreen { for entry in entries.iter().skip(start) { for (target, text, marker) in Self::route_entry(entry) { match target { - PaneTarget::Conversation => - self.conversation.push_line_with_marker(text, Color::Cyan, marker), - PaneTarget::ConversationAssistant => - self.conversation.push_line_with_marker(text, Color::Reset, marker), + PaneTarget::Conversation => { + self.conversation.current_color = Color::Cyan; + self.conversation.append_text(&text); + self.conversation.pending_marker = marker; + self.conversation.flush_pending(); + }, + PaneTarget::ConversationAssistant => { + self.conversation.current_color = Color::Reset; + self.conversation.append_text(&text); + self.conversation.pending_marker = marker; + self.conversation.flush_pending(); + }, PaneTarget::Tools => self.tools.push_line(text, Color::Yellow), PaneTarget::ToolResult => {