Reland "refactor transcript view to handle HistoryCells" (#3753)

Reland of #3538
This commit is contained in:
Jeremy Rose
2025-09-18 13:55:53 -07:00
committed by GitHub
parent 71038381aa
commit b34e906396
13 changed files with 477 additions and 405 deletions

View File

@@ -44,6 +44,7 @@ use ratatui::style::Stylize;
use ratatui::widgets::Paragraph;
use ratatui::widgets::WidgetRef;
use ratatui::widgets::Wrap;
use std::any::Any;
use std::collections::HashMap;
use std::io::Cursor;
use std::path::Path;
@@ -70,7 +71,7 @@ pub(crate) enum PatchEventType {
/// Represents an event to display in the conversation history. Returns its
/// `Vec<Line<'static>>` representation to make it easier to display in a
/// scrollable list.
pub(crate) trait HistoryCell: std::fmt::Debug + Send + Sync {
pub(crate) trait HistoryCell: std::fmt::Debug + Send + Sync + Any {
fn display_lines(&self, width: u16) -> Vec<Line<'static>>;
fn transcript_lines(&self) -> Vec<Line<'static>> {
@@ -90,9 +91,15 @@ pub(crate) trait HistoryCell: std::fmt::Debug + Send + Sync {
}
}
impl dyn HistoryCell {
pub(crate) fn as_any(&self) -> &dyn Any {
self
}
}
#[derive(Debug)]
pub(crate) struct UserHistoryCell {
message: String,
pub message: String,
}
impl HistoryCell for UserHistoryCell {