use super::HistoryCell;
#[derive(Default)]
pub(super) struct TranscriptState {
pub(super) active_cell: Option<Box<dyn HistoryCell>>,
pub(super) active_cell_revision: u64,
pub(super) last_agent_markdown: Option<String>,
pub(super) latest_proposed_plan_markdown: Option<String>,
pub(super) saw_copy_source_this_turn: bool,
pub(super) needs_final_message_separator: bool,
pub(super) had_work_activity: bool,
pub(super) saw_plan_update_this_turn: bool,
pub(super) saw_plan_item_this_turn: bool,
pub(super) last_plan_progress: Option<(usize, usize)>,
pub(super) plan_delta_buffer: String,
pub(super) plan_item_active: bool,
}
impl TranscriptState {
pub(super) fn new(active_cell: Option<Box<dyn HistoryCell>>) -> Self {
Self {
active_cell,
..Self::default()
}
}
pub(super) fn bump_active_cell_revision(&mut self) {
self.active_cell_revision = self.active_cell_revision.wrapping_add(1);
}
pub(super) fn record_agent_markdown(&mut self, markdown: String) {
self.last_agent_markdown = Some(markdown);
self.saw_copy_source_this_turn = true;
}
pub(super) fn reset_copy_history(&mut self) {
self.last_agent_markdown = None;
self.saw_copy_source_this_turn = false;
}
pub(super) fn reset_turn_flags(&mut self) {
self.saw_copy_source_this_turn = false;
self.saw_plan_update_this_turn = false;
self.saw_plan_item_this_turn = false;
self.had_work_activity = false;
self.latest_proposed_plan_markdown = None;
self.plan_delta_buffer.clear();
self.plan_item_active = false;
}
}
#[cfg(test)]
mod tests {
use pretty_assertions::assert_eq;
use super::*;
#[test]
fn active_cell_revision_wraps() {
let mut state = TranscriptState {
active_cell_revision: u64::MAX,
..TranscriptState::default()
};
state.bump_active_cell_revision();
assert_eq!(state.active_cell_revision, 0);
}
}