mirror of
https://github.com/openai/codex.git
synced 2026-11-26 07:26:11 +00:00
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:
1 parent
40ba7da7b4
commit
6988d390b3
17 files changed
+831
-38
No files matched your search
@@ -377,6 +377,11 @@ impl ChatWidget {
|
||||
// App-event submissions are handled serially, and turn/start can wait on remote work.
|
||||
// Queue the optimistic prompt first so the user's input is visible while that happens.
|
||||
// Direct submissions do not share that queue, so keep their existing failure behavior.
|
||||
if render_in_history {
|
||||
// Do not let a transient manual-recap progress cell become permanent terminal
|
||||
// scrollback when the new user prompt flushes the active history cell.
|
||||
self.clear_recap_loading();
|
||||
}
|
||||
let render_before_submit =
|
||||
render_in_history && matches!(&self.codex_op_target, CodexOpTarget::AppEvent);
|
||||
if render_before_submit {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//! Manual recap progress presentation for `ChatWidget`.
|
||||
|
||||
use super::*;
|
||||
|
||||
impl ChatWidget {
|
||||
pub(crate) fn show_recap_loading(&mut self) {
|
||||
self.flush_answer_stream_with_separator();
|
||||
self.flush_active_cell();
|
||||
self.transcript.active_cell = Some(Box::new(history_cell::ThreadRecapLoadingCell::new(
|
||||
self.config.animations,
|
||||
)));
|
||||
self.bump_active_cell_revision();
|
||||
self.request_redraw();
|
||||
}
|
||||
|
||||
pub(crate) fn clear_recap_loading(&mut self) {
|
||||
let Some(active) = self.transcript.active_cell.as_ref() else {
|
||||
return;
|
||||
};
|
||||
if !active.as_any().is::<history_cell::ThreadRecapLoadingCell>() {
|
||||
return;
|
||||
}
|
||||
|
||||
self.transcript.active_cell = None;
|
||||
self.bump_active_cell_revision();
|
||||
self.request_redraw();
|
||||
}
|
||||
}
|
||||
@@ -273,6 +273,16 @@ impl ChatWidget {
|
||||
self.input_queue.user_turn_pending_start = true;
|
||||
self.app_event_tx.compact();
|
||||
}
|
||||
SlashCommand::Recap => {
|
||||
let Some(thread_id) = self.thread_id else {
|
||||
self.add_error_message(
|
||||
"Session is still starting; try /recap again in a moment.".to_string(),
|
||||
);
|
||||
return;
|
||||
};
|
||||
self.app_event_tx
|
||||
.send(AppEvent::GenerateRecap { thread_id });
|
||||
}
|
||||
SlashCommand::Review => {
|
||||
self.open_review_popup();
|
||||
if self.mcp_startup_status.is_some() {
|
||||
@@ -1139,6 +1149,7 @@ impl ChatWidget {
|
||||
| SlashCommand::Diff
|
||||
| SlashCommand::App
|
||||
| SlashCommand::Rename
|
||||
| SlashCommand::Recap
|
||||
| SlashCommand::TestApproval => QueueDrain::Continue,
|
||||
SlashCommand::Cd => match self.thread_id {
|
||||
Some(thread_id) if self.can_change_working_directory(thread_id) => QueueDrain::Stop,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use super::*;
|
||||
use crate::app_event::ConnectorsSnapshot;
|
||||
use crate::history_cell::ThreadRecapLoadingCell;
|
||||
use codex_protocol::models::ManagedFileSystemPermissions;
|
||||
use codex_protocol::permissions::FileSystemAccessMode;
|
||||
use codex_protocol::permissions::FileSystemPath;
|
||||
@@ -32,6 +33,25 @@ fn assert_hidden_shell_payload_is_literal(op: Result<Op, TryRecvError>, payload:
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn user_submission_does_not_commit_recap_loading_to_history() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.thread_id = Some(ThreadId::new());
|
||||
chat.show_recap_loading();
|
||||
while rx.try_recv().is_ok() {}
|
||||
|
||||
chat.submit_user_message(UserMessage::from("Continue with the task"));
|
||||
|
||||
let mut saw_user_message = false;
|
||||
while let Ok(event) = rx.try_recv() {
|
||||
if let AppEvent::InsertHistoryCell(cell) = event {
|
||||
assert!(!cell.as_any().is::<ThreadRecapLoadingCell>());
|
||||
saw_user_message |= cell.as_any().is::<UserHistoryCell>();
|
||||
}
|
||||
}
|
||||
assert!(saw_user_message);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn hidden_shell_paste_submits_literal_prompt() {
|
||||
let (mut chat, _rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
|
||||
@@ -177,6 +177,22 @@ async fn slash_compact_eagerly_queues_follow_up_before_turn_start() {
|
||||
assert_matches!(op_rx.try_recv(), Err(TryRecvError::Empty));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn slash_recap_requests_generation_for_current_thread() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
let thread_id = ThreadId::new();
|
||||
chat.thread_id = Some(thread_id);
|
||||
|
||||
chat.dispatch_command(SlashCommand::Recap);
|
||||
|
||||
assert_matches!(
|
||||
rx.try_recv(),
|
||||
Ok(AppEvent::GenerateRecap {
|
||||
thread_id: requested_thread_id,
|
||||
}) if requested_thread_id == thread_id
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn queued_slash_compact_dispatches_after_active_turn() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
|
||||
Reference in new issue
Block a user