//! Conversation history panel.
use crate::state::SessionState;
use eframe::egui::{self, RichText, ScrollArea, Ui};
/// Render the conversation history panel.
pub fn conversation_panel(ui: &mut Ui, session: &SessionState) {
ui.heading("Conversation");
ui.add_space(8.0);
ScrollArea::vertical()
.auto_shrink([false, false])
.show(ui, |ui| {
for (role, content) in &session.history {
let (prefix, color) = match role.as_str() {
"user" => ("You", egui::Color32::from_rgb(100, 180, 255)),
"assistant" => ("AI", egui::Color32::from_rgb(180, 255, 100)),
_ => ("System", egui::Color32::GRAY),
};
ui.horizontal_wrapped(|ui| {
ui.label(RichText::new(format!("{}:", prefix)).color(color).strong());
ui.label(content);
});
ui.add_space(4.0);
}
if session.history.is_empty() {
ui.label(RichText::new("No messages yet.").italics().color(egui::Color32::GRAY));
}
});
}