mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Handle TUI message submission receipts and preserve uncertain drafts (#59817)
## Why The TUI's cached active turn can be stale when a cloud message is submitted. A lost reply also leaves delivery uncertain, so automatically resending the draft risks submitting it twice. ## What changed - Let the cloud server choose whether an Enter submission starts or steers a turn, and apply its receipt to the matching client message ID. - Keep Tab-queued input waiting until the admitted turn finishes, including before its start notification arrives. - Restore rejected submissions to the composer. Hold duplicate or unconfirmed submissions out of automatic delivery until history confirms them. - Reconcile saved drafts and pending steers by client message ID when resuming sessions, and preserve submissions belonging to other turns during interruption recovery. - Classify cloud preflight failures as invalid parameters so rejected queued input can be restored safely. ## Testing Add regression coverage for cloud receipt outcomes, queued-input ordering, rejected drafts, lost replies, interruption recovery, and session resume with identical message text but distinct client IDs. GitOrigin-RevId: ec4eb581e450488434bc4614ec59273d73ffd0a1
This commit is contained in:
committed by
copyberry
parent
6eb51a438a
commit
a142c90e26
@@ -34,6 +34,7 @@ pub(super) struct InputQueueState {
|
||||
/// A user turn has been submitted to core, but `TurnStarted` has not arrived yet.
|
||||
pub(super) user_turn_pending_start: bool,
|
||||
pub(super) pending_user_message_client_id: Option<String>,
|
||||
pub(super) pending_user_message_history_record: Option<UserMessageHistoryRecord>,
|
||||
/// User messages that tried to steer a non-regular turn and must be retried first.
|
||||
pub(super) rejected_steers_queue: VecDeque<UserMessage>,
|
||||
/// The origin of each rejected steer, kept in lockstep with its message.
|
||||
@@ -57,6 +58,14 @@ pub(super) struct InputQueueState {
|
||||
}
|
||||
|
||||
impl InputQueueState {
|
||||
pub(super) fn take_pending_steer(&mut self, client_id: &str) -> Option<PendingSteer> {
|
||||
let index = self
|
||||
.pending_steers
|
||||
.iter()
|
||||
.position(|pending| pending.client_id == client_id)?;
|
||||
self.pending_steers.remove(index)
|
||||
}
|
||||
|
||||
pub(super) fn submissions_paused(&self) -> bool {
|
||||
self.suppress_queue_autosend || self.transcript_copy.strong_count() > 0
|
||||
}
|
||||
@@ -78,6 +87,7 @@ impl InputQueueState {
|
||||
self.queued_user_message_history_records.clear();
|
||||
self.user_turn_pending_start = false;
|
||||
self.pending_user_message_client_id = None;
|
||||
self.pending_user_message_history_record = None;
|
||||
self.rejected_steers_queue.clear();
|
||||
self.rejected_steer_sources.clear();
|
||||
self.rejected_steer_history_records.clear();
|
||||
@@ -139,6 +149,8 @@ mod tests {
|
||||
.push_back(UserMessage::from("rejected"));
|
||||
state.pending_steers.push_back(PendingSteer {
|
||||
client_id: "test-submission".to_string(),
|
||||
admitted_turn_id: None,
|
||||
optimistically_rendered: false,
|
||||
user_message: UserMessage::from("pending"),
|
||||
history_record: UserMessageHistoryRecord::UserMessageText,
|
||||
source: UserMessageSource::Prompt,
|
||||
|
||||
Reference in New Issue
Block a user