mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Preserve queued TUI input semantics (#39604)
## Why Paste placeholders and deferred slash-command parsing can hide the meaning of an input until it is expanded or a session is configured. Draining such input as an ordinary message can accidentally treat pasted text beginning with `!` as a shell command or lose `/plan` behavior. ## What changed - Track paste-expanded inputs that begin with `!` as literal model input through history, queue editing, retries, and startup queues. - Defer `/plan` parsing when session or model state is unavailable, then submit it in plan mode with shell escapes disabled. - Drain queued input only after session configuration, and keep later queued prompts pending when an initial prompt cannot be submitted. - Suppress queue auto-send before applying a replayed thread session so input from the outgoing thread is not submitted during restoration. ## Testing Add coverage for direct, recalled, edited, interrupted, rejected, startup-queued, and plan-mode paste flows, including placeholder collisions and rejected initial images. GitOrigin-RevId: d482220d8df21754f166fea5b54e9945f622a978
This commit is contained in:
1 parent
8e7f646974
commit
3434c2545b
10 files changed
+519
-36
No files matched your search
@@ -138,7 +138,10 @@ impl ChatWidget {
|
||||
|
||||
/// If idle and there are queued inputs, submit exactly one to start the next turn.
|
||||
pub(crate) fn maybe_send_next_queued_input(&mut self) -> bool {
|
||||
if self.misalignment_policy_violation || self.input_queue.suppress_queue_autosend {
|
||||
if !self.is_session_configured()
|
||||
|| self.misalignment_policy_violation
|
||||
|| self.input_queue.suppress_queue_autosend
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if self.blocks_direct_input {
|
||||
@@ -160,6 +163,48 @@ impl ChatWidget {
|
||||
);
|
||||
break;
|
||||
}
|
||||
QueuedInputAction::Literal => {
|
||||
let QueuedUserMessage {
|
||||
user_message,
|
||||
pending_pastes,
|
||||
..
|
||||
} = queued_message;
|
||||
let mut restored_pending_pastes = self.bottom_pane.composer_pending_pastes();
|
||||
let mut used_paste_placeholders = restored_pending_pastes
|
||||
.iter()
|
||||
.map(|(placeholder, _)| placeholder.clone())
|
||||
.collect();
|
||||
let (mut user_message, pending_pastes) =
|
||||
super::user_messages::remap_colliding_paste_placeholders(
|
||||
user_message,
|
||||
pending_pastes,
|
||||
&mut used_paste_placeholders,
|
||||
);
|
||||
if !self.current_model().trim().is_empty()
|
||||
&& (self.current_model_supports_images()
|
||||
|| (user_message.local_images.is_empty()
|
||||
&& user_message.remote_image_urls.is_empty()))
|
||||
{
|
||||
(user_message.text, user_message.text_elements) =
|
||||
crate::bottom_pane::ChatComposer::expand_pending_pastes(
|
||||
&user_message.text,
|
||||
user_message.text_elements,
|
||||
&pending_pastes,
|
||||
);
|
||||
}
|
||||
submitted_follow_up = self
|
||||
.submit_user_message_with_shell_escape_policy(
|
||||
user_message,
|
||||
ShellEscapePolicy::Disallow,
|
||||
)
|
||||
.is_some();
|
||||
if !submitted_follow_up {
|
||||
restored_pending_pastes.extend(pending_pastes);
|
||||
self.bottom_pane
|
||||
.set_composer_pending_pastes(restored_pending_pastes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
QueuedInputAction::ParseSlash => {
|
||||
let drain = self.submit_queued_slash_prompt(queued_message);
|
||||
if drain == QueueDrain::Stop {
|
||||
|
||||
Reference in new issue
Block a user