Generate automatic and manual conversation recaps (#40705)

## Why

Users returning to a conversation need a short summary of its recent progress and next steps.

## What changed

- Generate a recap for eligible idle, unfocused conversations and add it to the transcript.
- Add `/recap` to request the same summary on demand, with visible progress and actionable errors.
- Keep recap requests bounded and isolated, reject stale results, and retry only automatic failures.

## Testing

- Cover automatic and manual generation, request eligibility, failure handling, loading-state cleanup, and temporary-thread configuration.

GitOrigin-RevId: 926a88d6996d67a42809ce2c4091b13fca882b52
This commit is contained in:
Felipe Coury authored and copyberry committed 2026-08-25 21:03:11 +00:00
1 parent 40ba7da7b4
commit 6988d390b3
17 files changed
+831 -38

No files matched your search

+46
View File
@@ -230,6 +230,52 @@ pub(crate) fn new_error_event(message: String) -> PlainHistoryCell {
PlainHistoryCell { lines }
}
#[derive(Debug)]
pub(crate) struct ThreadRecapLoadingCell {
start_time: Instant,
animations_enabled: bool,
}
impl ThreadRecapLoadingCell {
pub(crate) fn new(animations_enabled: bool) -> Self {
Self {
start_time: Instant::now(),
animations_enabled,
}
}
}
impl HistoryCell for ThreadRecapLoadingCell {
fn display_lines(&self, _width: u16) -> Vec<Line<'static>> {
vec![
vec![
activity_indicator(
Some(self.start_time),
MotionMode::from_animations_enabled(self.animations_enabled),
ReducedMotionIndicator::StaticBullet,
)
.unwrap_or_else(|| "•".dim()),
" ".into(),
"Generating conversation recap".bold(),
"…".dim(),
]
.into(),
]
}
fn raw_lines(&self) -> Vec<Line<'static>> {
vec![Line::from("Generating conversation recap...")]
}
fn transcript_animation_tick(&self) -> Option<u64> {
if !self.animations_enabled {
return None;
}
Some((self.start_time.elapsed().as_millis() / 50) as u64)
}
}
#[cfg_attr(not(test), allow(dead_code))]
#[derive(Debug)]
pub(crate) struct ThreadRecapHistoryCell {
+8
View File
@@ -1420,6 +1420,14 @@ fn mcp_inventory_loading_without_animations_is_stable() {
assert_eq!(first, vec!["• Loading MCP inventory…".to_string()]);
}
#[test]
fn thread_recap_loading_without_animations_snapshot() {
let cell = ThreadRecapLoadingCell::new(/*animations_enabled*/ false);
let rendered = render_lines(&cell.display_lines(/*width*/ 80)).join("\n");
insta::assert_snapshot!(rendered, @"• Generating conversation recap…");
}
#[test]
fn completed_mcp_tool_call_success_snapshot() {
let invocation = McpInvocation {