Remove test-only agent message grouping from TUI backtracking (#63423)

Delete the agent message grouping helpers and their sole test, which
checked that a context compaction marker did not count as an agent
message group.

GitOrigin-RevId: e694196474529f101fff5893f0fcf04161024595
This commit is contained in:
jif
2026-11-23 20:09:12 +00:00
committed by copyberry
parent aae9db9f5f
commit 06d76ee77b
-50
View File
@@ -35,8 +35,6 @@ use crate::bottom_pane::LocalImageAttachment;
use crate::chatwidget::ChatWidget;
use crate::chatwidget::UserMessage;
use crate::chatwidget::mention_bindings_from_user_inputs;
#[cfg(test)]
use crate::history_cell::AgentMessageCell;
use crate::history_cell::SessionInfoCell;
use crate::history_cell::UserHistoryCell;
use crate::history_cell::sanitize_user_text;
@@ -758,34 +756,6 @@ fn user_positions_iter(
})
}
#[cfg(test)]
fn agent_group_count(cells: &[Arc<dyn crate::history_cell::HistoryCell>]) -> usize {
agent_group_positions_iter(cells).count()
}
#[cfg(test)]
fn agent_group_positions_iter(
cells: &[Arc<dyn crate::history_cell::HistoryCell>],
) -> impl Iterator<Item = usize> + '_ {
let session_start_type = TypeId::of::<SessionInfoCell>();
let type_of = |cell: &Arc<dyn crate::history_cell::HistoryCell>| cell.as_any().type_id();
let start = cells
.iter()
.rposition(|cell| type_of(cell) == session_start_type)
.map_or(0, |idx| idx + 1);
cells
.iter()
.enumerate()
.skip(start)
.filter_map(move |(idx, cell)| {
let is_agent = cell.as_any().downcast_ref::<AgentMessageCell>().is_some();
let is_copy_source_group = is_agent && !cell.is_stream_continuation();
is_copy_source_group.then_some(idx)
})
}
#[cfg(test)]
mod tests {
use super::*;
@@ -1196,26 +1166,6 @@ mod tests {
);
}
#[test]
fn agent_group_count_ignores_context_compacted_marker() {
let cells: Vec<Arc<dyn HistoryCell>> = vec![
Arc::new(AgentMessageCell::new(
vec![Line::from("first")],
/*is_first_line*/ true,
)) as Arc<dyn HistoryCell>,
Arc::new(crate::history_cell::new_info_event(
"Context compacted".to_string(),
/*hint*/ None,
)) as Arc<dyn HistoryCell>,
Arc::new(AgentMessageCell::new(
vec![Line::from("second")],
/*is_first_line*/ true,
)) as Arc<dyn HistoryCell>,
];
assert_eq!(agent_group_count(&cells), 2);
}
#[test]
fn backtrack_target_requires_user_message() {
let mut cells: Vec<Arc<dyn HistoryCell>> = vec![