mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Prepare the TUI for conversation recaps (#40696)
## What changed - Forward terminal focus changes through the TUI event stream and handle them across interactive screens. - Track completed turns and recap eligibility across active, resumed, and switched threads. - Add bounded recent-conversation prompt construction and a wrapping `Conversation recap` history cell. - Cover focus timing, repeat eligibility, restored progress, UTF-8 prompt limits, and recap rendering with unit and snapshot tests. GitOrigin-RevId: d7542c18b2bb1e72f5906f563898645bb526255f
This commit is contained in:
1 parent
725b3a44f8
commit
7c1e36c23f
25 files changed
+867
-34
No files matched your search
@@ -50,6 +50,7 @@ pub(super) struct ThreadEventStore {
|
||||
pub(super) capacity: usize,
|
||||
pub(super) active: bool,
|
||||
pub(super) buffered_agent_message_delta_bytes: usize,
|
||||
recap_progress: recap::RecapProgress,
|
||||
}
|
||||
|
||||
impl ThreadEventStore {
|
||||
@@ -78,6 +79,7 @@ impl ThreadEventStore {
|
||||
capacity,
|
||||
active: false,
|
||||
buffered_agent_message_delta_bytes: 0,
|
||||
recap_progress: recap::RecapProgress::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +106,8 @@ impl ThreadEventStore {
|
||||
}
|
||||
|
||||
pub(super) fn set_turns(&mut self, turns: Vec<Turn>) {
|
||||
self.recap_progress
|
||||
.merge(recap::RecapProgress::from_turns(&turns));
|
||||
self.active_turn_id = turns
|
||||
.iter()
|
||||
.rev()
|
||||
@@ -128,6 +132,9 @@ impl ThreadEventStore {
|
||||
self.active_turn_id = Some(turn.turn.id.clone());
|
||||
}
|
||||
ServerNotification::TurnCompleted(turn) => {
|
||||
if matches!(turn.turn.status, TurnStatus::Completed) {
|
||||
self.recap_progress.completed_turns += 1;
|
||||
}
|
||||
if self.active_turn_id.as_deref() == Some(turn.turn.id.as_str()) {
|
||||
self.active_turn_id = None;
|
||||
}
|
||||
@@ -222,6 +229,14 @@ impl ThreadEventStore {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn recap_progress(&self) -> recap::RecapProgress {
|
||||
self.recap_progress
|
||||
}
|
||||
|
||||
pub(super) fn merge_recap_progress(&mut self, progress: recap::RecapProgress) {
|
||||
self.recap_progress.merge(progress);
|
||||
}
|
||||
|
||||
pub(super) fn note_outbound_op<T>(&mut self, op: T)
|
||||
where
|
||||
T: Into<AppCommand>,
|
||||
@@ -556,6 +571,38 @@ mod tests {
|
||||
assert_eq!(store.active_turn_id(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_event_store_preserves_recap_progress_across_replay() {
|
||||
let thread_id = ThreadId::new();
|
||||
let mut store = ThreadEventStore::new(/*capacity*/ 8);
|
||||
store.set_turns(vec![
|
||||
test_turn("turn-1", TurnStatus::Completed, Vec::new()),
|
||||
test_turn("turn-2", TurnStatus::Failed, Vec::new()),
|
||||
]);
|
||||
store.push_notification(turn_completed_notification(
|
||||
thread_id,
|
||||
"turn-3",
|
||||
TurnStatus::Completed,
|
||||
));
|
||||
store.push_notification(turn_completed_notification(
|
||||
thread_id,
|
||||
"turn-4",
|
||||
TurnStatus::Interrupted,
|
||||
));
|
||||
store.merge_recap_progress(recap::RecapProgress {
|
||||
completed_turns: 2,
|
||||
last_recapped_turn_count: Some(2),
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
store.recap_progress(),
|
||||
recap::RecapProgress {
|
||||
completed_turns: 2,
|
||||
last_recapped_turn_count: Some(2),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_event_store_restores_active_turn_from_snapshot_turns() {
|
||||
let thread_id = ThreadId::new();
|
||||
|
||||
Reference in new issue
Block a user