Label prefix compaction in TUI

This commit is contained in:
Rohit Arunachalam
2026-04-19 20:19:51 -07:00
parent 99cf6c64bd
commit f883206eb0
4 changed files with 25 additions and 4 deletions
@@ -176,7 +176,7 @@ async fn apply_prefix_compact_candidate(
return Ok(false);
}
let compaction_item = TurnItem::ContextCompaction(ContextCompactionItem::new());
let compaction_item = TurnItem::ContextCompaction(ContextCompactionItem::new_prefix());
sess.emit_turn_item_started(turn_context, &compaction_item)
.await;
+12
View File
@@ -130,12 +130,24 @@ pub struct ImageGenerationItem {
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema)]
pub struct ContextCompactionItem {
pub id: String,
#[serde(default, skip_serializing, skip_deserializing)]
#[schemars(skip)]
#[ts(skip)]
pub is_prefix: bool,
}
impl ContextCompactionItem {
pub fn new() -> Self {
Self {
id: uuid::Uuid::new_v4().to_string(),
is_prefix: false,
}
}
pub fn new_prefix() -> Self {
Self {
id: uuid::Uuid::new_v4().to_string(),
is_prefix: true,
}
}
@@ -894,6 +894,7 @@ fn thread_item_to_core(item: &ThreadItem) -> Option<TurnItem> {
ThreadItem::ContextCompaction { id } => {
Some(TurnItem::ContextCompaction(ContextCompactionItem {
id: id.clone(),
is_prefix: false,
}))
}
ThreadItem::CommandExecution { .. }
+11 -3
View File
@@ -2206,11 +2206,16 @@ impl ChatWidget {
self.request_redraw();
}
fn on_context_compacted(&mut self) {
fn on_context_compacted(&mut self, is_prefix: bool) {
self.flush_answer_stream_with_separator();
self.handle_stream_finished();
let label = if is_prefix {
"Context prefix compacted"
} else {
"Context compacted"
};
self.add_to_history(history_cell::new_info_event(
"Context compacted".to_owned(),
label.to_owned(),
/*hint*/ None,
));
self.request_redraw();
@@ -5990,7 +5995,7 @@ impl ChatWidget {
self.exit_review_mode_after_item();
}
ThreadItem::ContextCompaction { .. } => {
self.on_context_compacted();
self.on_context_compacted(/*is_prefix*/ false);
}
ThreadItem::HookPrompt { .. } => {}
ThreadItem::CollabAgentToolCall {
@@ -6913,6 +6918,9 @@ impl ChatWidget {
if let codex_protocol::items::TurnItem::Plan(plan_item) = &item {
self.on_plan_item_completed(plan_item.text.clone());
}
if let codex_protocol::items::TurnItem::ContextCompaction(item) = &item {
self.on_context_compacted(item.is_prefix);
}
if let codex_protocol::items::TurnItem::AgentMessage(item) = item {
self.on_agent_message_item_completed(item);
}