mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
Acknowledge pending TUI steers by submission ID (#42451)
## Why Completion receipts for identical user messages could acknowledge the wrong pending steer. When the receipt arrived while another thread was displayed, the stale pending state could later be restored and resubmitted. ## What changed - Assign each TUI submission a client message ID and pass it through turn start and steer requests. - Preserve pending steer IDs across thread input snapshots and match completion receipts by ID, while retaining content-based matching for older app servers that do not echo IDs. - Acknowledge matching receipts for inactive threads before their notifications can be discarded, including threads stored in the agents overview. ## Testing Added coverage for identical steer receipts and for switching within and between tasks before interrupting an active turn. GitOrigin-RevId: 28bd80a735ff86cd7bf836f24b448e7499f0a902
This commit is contained in:
@@ -449,6 +449,7 @@ mod usage;
|
||||
mod user_messages;
|
||||
mod working_directory;
|
||||
use self::user_messages::PendingSteer;
|
||||
#[cfg(test)]
|
||||
use self::user_messages::PendingSteerCompareKey;
|
||||
use self::user_messages::QueueDrain;
|
||||
use self::user_messages::QueuedUserMessage;
|
||||
@@ -1319,7 +1320,12 @@ impl ChatWidget {
|
||||
self.request_redraw();
|
||||
}
|
||||
|
||||
fn on_committed_user_message(&mut self, items: &[UserInput], from_replay: bool) {
|
||||
fn on_committed_user_message(
|
||||
&mut self,
|
||||
items: &[UserInput],
|
||||
client_id: Option<&str>,
|
||||
from_replay: bool,
|
||||
) {
|
||||
let display = Self::user_message_display_from_inputs(items);
|
||||
if from_replay {
|
||||
if self.review.is_review_mode {
|
||||
@@ -1338,12 +1344,15 @@ impl ChatWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
let compare_key = Self::pending_steer_compare_key_from_items(items);
|
||||
if self
|
||||
.input_queue
|
||||
.pending_steers
|
||||
.front()
|
||||
.is_some_and(|pending| pending.compare_key == compare_key)
|
||||
.is_some_and(|pending| match client_id {
|
||||
Some(client_id) => pending.client_id == client_id,
|
||||
// Older app servers do not echo submission IDs.
|
||||
None => pending.compare_key == Self::pending_steer_compare_key_from_items(items),
|
||||
})
|
||||
{
|
||||
if let Some(pending) = self.input_queue.pending_steers.pop_front() {
|
||||
self.refresh_pending_input_preview();
|
||||
@@ -1352,7 +1361,7 @@ impl ChatWidget {
|
||||
self.on_user_message_display(pending_display);
|
||||
} else if self.last_rendered_user_message_display.as_ref() != Some(&display) {
|
||||
tracing::warn!(
|
||||
"pending steer matched compare key but queue was empty when rendering committed user message"
|
||||
"pending steer matched receipt but queue was empty when rendering committed user message"
|
||||
);
|
||||
self.on_user_message_display(display);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user