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:
Felipe Coury authored and copyberry committed 2026-08-25 20:51:34 +00:00
1 parent 725b3a44f8
commit 7c1e36c23f
25 files changed
+867 -34

No files matched your search

+12
View File
@@ -77,11 +77,13 @@ impl App {
return;
};
let input_state = self.chat_widget.capture_thread_input_state();
let recap_progress = self.recap.progress();
if let Some(channel) = self.thread_event_channels.get_mut(&active_id) {
let receiver = self.active_thread_rx.take();
let mut store = channel.store.lock().await;
store.active = false;
store.input_state = input_state;
store.merge_recap_progress(recap_progress);
if let Some(receiver) = receiver {
channel.receiver = Some(receiver);
}
@@ -959,6 +961,12 @@ impl App {
if self.abandoned_side_threads.contains(&thread_id) {
return Ok(());
}
if self.current_displayed_thread_id() == Some(thread_id)
&& let ServerNotification::TurnCompleted(notification) = &notification
&& matches!(notification.turn.status, TurnStatus::Completed)
{
self.recap.note_turn_completed(Instant::now());
}
let misalignment_policy_violation =
match &notification {
ServerNotification::Error(notification) if !notification.will_retry => {
@@ -1286,6 +1294,9 @@ impl App {
self.config.approvals_reviewer = session.approvals_reviewer;
let thread_id = session.thread_id;
if self.primary_thread_id != Some(thread_id) {
self.recap.reset_for_new_thread(Instant::now());
}
self.primary_thread_id = Some(thread_id);
self.primary_session_configured = Some(session.clone());
self.upsert_agent_picker_thread(
@@ -1316,6 +1327,7 @@ impl App {
self.app_event_tx
.send(AppEvent::BeginInitialHistoryReplayBuffer);
}
self.recap.seed_from_turns(&turns, Instant::now());
self.chat_widget
.replay_thread_turns(turns, ReplayKind::ResumeInitialMessages);
if should_buffer_initial_replay {