mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Clear pending TUI questions when accepting a new prompt (#44328)
## Why Unanswered questions from the previous prompt remain visible after a new follow-up. Clear them when the user moves on to new work. ## What changed - Clear pending questions when a model prompt is submitted or queued, and when a review starts. Clear again on queued prompt delivery to remove questions that arrived while waiting. - Retain seen question IDs so replay cannot restore cleared questions. - Track question answers separately from prompts through queues, retries, thread restoration, and reconnects so delivering an answer preserves other pending questions. - Preserve questions for local commands and rejected submissions. ## Testing Add regression tests for immediate and queued follow-ups, replay suppression, slash prompts, reviews, rejected input, and answer preservation across delivery and recovery. Add a snapshot of the composer after questions are cleared. GitOrigin-RevId: 76353c6ee098c1505678ac43b1dc6391ea9fa738
This commit is contained in:
1 parent
f11d0dd012
commit
2808a9c348
20 files changed
+528
-26
No files matched your search
@@ -5,6 +5,9 @@
|
||||
//! follow-ups, and restoring draft state across interrupts or thread switches.
|
||||
|
||||
use super::*;
|
||||
use crate::bottom_pane::prompt_args::parse_slash_name;
|
||||
use crate::bottom_pane::slash_commands::SlashCommandItem;
|
||||
use crate::bottom_pane::slash_commands::find_slash_command;
|
||||
|
||||
impl ChatWidget {
|
||||
pub(crate) fn set_parent_owned_thread(&mut self) {
|
||||
@@ -95,8 +98,13 @@ impl ChatWidget {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn queue_user_message(&mut self, user_message: UserMessage) {
|
||||
self.queue_user_message_with_options(user_message, QueuedInputAction::Plain, Vec::new());
|
||||
pub(super) fn queue_user_message(&mut self, user_message: UserMessage) -> bool {
|
||||
self.queue_user_message_with_options_and_source(
|
||||
user_message,
|
||||
QueuedInputAction::Plain,
|
||||
Vec::new(),
|
||||
UserMessageSource::Prompt,
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn set_queue_submissions_until_session_configured(&mut self, queue: bool) {
|
||||
@@ -109,31 +117,82 @@ impl ChatWidget {
|
||||
user_message: UserMessage,
|
||||
action: QueuedInputAction,
|
||||
pending_pastes: Vec<(String, String)>,
|
||||
) {
|
||||
) -> bool {
|
||||
self.queue_user_message_with_options_and_source(
|
||||
user_message,
|
||||
action,
|
||||
pending_pastes,
|
||||
UserMessageSource::Prompt,
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn queue_user_message_with_options_and_source(
|
||||
&mut self,
|
||||
user_message: UserMessage,
|
||||
action: QueuedInputAction,
|
||||
pending_pastes: Vec<(String, String)>,
|
||||
source: UserMessageSource,
|
||||
) -> bool {
|
||||
if self.has_misalignment_policy_violation() {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
let should_run_now = self.is_session_configured()
|
||||
&& !self.is_user_turn_pending_or_running()
|
||||
&& !self.input_queue.suppress_queue_autosend
|
||||
&& !self.input_queue.rate_limit_recovery_pending;
|
||||
if !should_run_now || action != QueuedInputAction::Plain {
|
||||
let queued_slash_prompt = action == QueuedInputAction::ParseSlash
|
||||
&& parse_slash_name(&user_message.text).is_none_or(|(name, args, _)| {
|
||||
if name.contains('/') {
|
||||
return true;
|
||||
}
|
||||
!args.trim().is_empty()
|
||||
&& find_slash_command(
|
||||
name,
|
||||
self.builtin_command_flags(),
|
||||
&self.current_model_service_tier_commands(),
|
||||
)
|
||||
.is_some_and(|command| {
|
||||
!command.supports_inline_args()
|
||||
|| matches!(
|
||||
command,
|
||||
SlashCommandItem::Builtin(
|
||||
SlashCommand::Plan | SlashCommand::Review
|
||||
)
|
||||
)
|
||||
})
|
||||
});
|
||||
let model_prompt = source == UserMessageSource::Prompt
|
||||
&& (action == QueuedInputAction::Literal
|
||||
|| action == QueuedInputAction::Plain && !user_message.text.starts_with('!')
|
||||
|| queued_slash_prompt);
|
||||
self.input_queue
|
||||
.queued_user_messages
|
||||
.push_back(QueuedUserMessage {
|
||||
user_message,
|
||||
action,
|
||||
pending_pastes,
|
||||
source,
|
||||
});
|
||||
self.input_queue
|
||||
.queued_user_message_history_records
|
||||
.push_back(UserMessageHistoryRecord::UserMessageText);
|
||||
self.refresh_pending_input_preview();
|
||||
if model_prompt && !should_run_now {
|
||||
self.bottom_pane.clear_pending_questions();
|
||||
}
|
||||
if should_run_now {
|
||||
self.maybe_send_next_queued_input();
|
||||
}
|
||||
true
|
||||
} else {
|
||||
self.submit_user_message(user_message);
|
||||
self.submit_user_message_with_history_and_shell_escape_policy(
|
||||
user_message,
|
||||
UserMessageHistoryRecord::UserMessageText,
|
||||
ShellEscapePolicy::Allow,
|
||||
source,
|
||||
)
|
||||
.0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,16 +219,22 @@ impl ChatWidget {
|
||||
};
|
||||
match queued_message.action {
|
||||
QueuedInputAction::Plain => {
|
||||
submitted_follow_up = self.submit_user_message_with_history_record(
|
||||
queued_message.into_user_message(),
|
||||
history_record,
|
||||
);
|
||||
let source = queued_message.source;
|
||||
submitted_follow_up = self
|
||||
.submit_user_message_with_history_and_shell_escape_policy(
|
||||
queued_message.into_user_message(),
|
||||
history_record,
|
||||
ShellEscapePolicy::Allow,
|
||||
source,
|
||||
)
|
||||
.0;
|
||||
break;
|
||||
}
|
||||
QueuedInputAction::Literal => {
|
||||
let QueuedUserMessage {
|
||||
user_message,
|
||||
pending_pastes,
|
||||
source,
|
||||
..
|
||||
} = queued_message;
|
||||
let mut restored_pending_pastes = self.bottom_pane.composer_pending_pastes();
|
||||
@@ -196,11 +261,13 @@ impl ChatWidget {
|
||||
);
|
||||
}
|
||||
submitted_follow_up = self
|
||||
.submit_user_message_with_shell_escape_policy(
|
||||
.submit_user_message_with_history_and_shell_escape_policy(
|
||||
user_message,
|
||||
history_record,
|
||||
ShellEscapePolicy::Disallow,
|
||||
source,
|
||||
)
|
||||
.is_some();
|
||||
.0;
|
||||
if !submitted_follow_up {
|
||||
restored_pending_pastes.extend(pending_pastes);
|
||||
self.bottom_pane
|
||||
|
||||
Reference in new issue
Block a user