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

+16
View File
@@ -530,6 +530,14 @@ impl App {
&mut snapshot,
)
.await;
// Refreshing can merge restored turns into the store, so recap progress must be read only
// after the refresh while the activated thread channel is still retained.
let Some(channel) = self.thread_event_channels.get(&thread_id) else {
self.chat_widget
.add_error_message(format!("Agent thread {thread_id} is no longer available."));
return Ok(());
};
let recap_progress = channel.store.lock().await.recap_progress();
if snapshot.input_state.is_none() {
snapshot.input_state = self.agents_overview.input_states.remove(&thread_id);
}
@@ -538,6 +546,14 @@ impl App {
self.active_thread_id = Some(thread_id);
self.active_thread_rx = Some(receiver);
self.recap = recap::RecapState::default();
if !tui.is_terminal_focused() {
self.recap.note_focus_lost(Instant::now());
}
self.recap
.seed_from_progress(recap_progress, Instant::now());
let init = self.chatwidget_init_for_forked_or_resumed_thread(
tui,
self.config.clone(),