mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
## 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
187 lines
6.4 KiB
Rust
187 lines
6.4 KiB
Rust
//! Review preset selection and custom review prompt surfaces.
|
|
|
|
use super::*;
|
|
|
|
impl ChatWidget {
|
|
pub(crate) fn on_review_started(&mut self) {
|
|
self.bottom_pane.clear_pending_questions();
|
|
}
|
|
|
|
pub(crate) fn open_review_popup(&mut self) {
|
|
let mut items: Vec<SelectionItem> = Vec::new();
|
|
|
|
items.push(SelectionItem {
|
|
name: "Review against a base branch".to_string(),
|
|
description: Some("(PR Style)".into()),
|
|
actions: vec![Box::new({
|
|
let cwd = self.config.cwd.to_path_buf();
|
|
move |tx| {
|
|
tx.send(AppEvent::OpenReviewBranchPicker(cwd.clone()));
|
|
}
|
|
})],
|
|
dismiss_on_select: false,
|
|
dismiss_parent_on_child_accept: true,
|
|
..Default::default()
|
|
});
|
|
|
|
items.push(SelectionItem {
|
|
name: "Review uncommitted changes".to_string(),
|
|
actions: vec![Box::new(move |tx: &AppEventSender| {
|
|
tx.review(ReviewTarget::UncommittedChanges);
|
|
})],
|
|
dismiss_on_select: true,
|
|
..Default::default()
|
|
});
|
|
|
|
items.push(SelectionItem {
|
|
name: "Review a commit".to_string(),
|
|
actions: vec![Box::new({
|
|
let cwd = self.config.cwd.to_path_buf();
|
|
move |tx| {
|
|
tx.send(AppEvent::OpenReviewCommitPicker(cwd.clone()));
|
|
}
|
|
})],
|
|
dismiss_on_select: false,
|
|
dismiss_parent_on_child_accept: true,
|
|
..Default::default()
|
|
});
|
|
|
|
items.push(SelectionItem {
|
|
name: "Custom review instructions".to_string(),
|
|
actions: vec![Box::new(move |tx| {
|
|
tx.send(AppEvent::OpenReviewCustomPrompt);
|
|
})],
|
|
dismiss_on_select: false,
|
|
dismiss_parent_on_child_accept: true,
|
|
..Default::default()
|
|
});
|
|
|
|
self.bottom_pane.show_selection_view(SelectionViewParams {
|
|
title: Some("Select a review preset".into()),
|
|
footer_hint: Some(standard_popup_hint_line()),
|
|
items,
|
|
..Default::default()
|
|
});
|
|
}
|
|
|
|
pub(crate) async fn show_review_branch_picker(&mut self, cwd: &Path) {
|
|
let branches = local_git_branches(cwd).await;
|
|
let current_branch = current_branch_name(cwd)
|
|
.await
|
|
.unwrap_or_else(|| "(detached HEAD)".to_string());
|
|
let mut items: Vec<SelectionItem> = Vec::with_capacity(branches.len());
|
|
|
|
for option in branches {
|
|
let branch = option.clone();
|
|
items.push(SelectionItem {
|
|
name: format!("{current_branch} -> {branch}"),
|
|
actions: vec![Box::new(move |tx3: &AppEventSender| {
|
|
tx3.review(ReviewTarget::BaseBranch {
|
|
branch: branch.clone(),
|
|
});
|
|
})],
|
|
dismiss_on_select: true,
|
|
search_value: Some(option),
|
|
..Default::default()
|
|
});
|
|
}
|
|
|
|
self.bottom_pane.show_selection_view(SelectionViewParams {
|
|
title: Some("Select a base branch".to_string()),
|
|
footer_hint: Some(standard_popup_hint_line()),
|
|
items,
|
|
is_searchable: true,
|
|
search_placeholder: Some("Type to search branches".to_string()),
|
|
..Default::default()
|
|
});
|
|
}
|
|
|
|
pub(crate) async fn show_review_commit_picker(&mut self, cwd: &Path) {
|
|
let commits = recent_commits(cwd, /*limit*/ 100).await;
|
|
|
|
let mut items: Vec<SelectionItem> = Vec::with_capacity(commits.len());
|
|
for entry in commits {
|
|
let subject = entry.subject.clone();
|
|
let sha = entry.sha.clone();
|
|
let search_val = format!("{subject} {sha}");
|
|
|
|
items.push(SelectionItem {
|
|
name: subject.clone(),
|
|
actions: vec![Box::new(move |tx3: &AppEventSender| {
|
|
tx3.review(ReviewTarget::Commit {
|
|
sha: sha.clone(),
|
|
title: Some(subject.clone()),
|
|
});
|
|
})],
|
|
dismiss_on_select: true,
|
|
search_value: Some(search_val),
|
|
..Default::default()
|
|
});
|
|
}
|
|
|
|
self.bottom_pane.show_selection_view(SelectionViewParams {
|
|
title: Some("Select a commit to review".to_string()),
|
|
footer_hint: Some(standard_popup_hint_line()),
|
|
items,
|
|
is_searchable: true,
|
|
search_placeholder: Some("Type to search commits".to_string()),
|
|
..Default::default()
|
|
});
|
|
}
|
|
|
|
pub(crate) fn show_review_custom_prompt(&mut self) {
|
|
let tx = self.app_event_tx.clone();
|
|
let view = CustomPromptView::new(
|
|
"Custom review instructions".to_string(),
|
|
"Type instructions and press Enter".to_string(),
|
|
/*initial_text*/ String::new(),
|
|
/*context_label*/ None,
|
|
Box::new(move |prompt: String| {
|
|
let trimmed = prompt.trim().to_string();
|
|
if trimmed.is_empty() {
|
|
return;
|
|
}
|
|
tx.review(ReviewTarget::Custom {
|
|
instructions: trimmed,
|
|
});
|
|
}),
|
|
);
|
|
self.bottom_pane.show_text_prompt(view);
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
pub(crate) fn show_review_commit_picker_with_entries(
|
|
chat: &mut ChatWidget,
|
|
entries: Vec<CommitLogEntry>,
|
|
) {
|
|
let mut items: Vec<SelectionItem> = Vec::with_capacity(entries.len());
|
|
for entry in entries {
|
|
let subject = entry.subject.clone();
|
|
let sha = entry.sha.clone();
|
|
let search_val = format!("{subject} {sha}");
|
|
|
|
items.push(SelectionItem {
|
|
name: subject.clone(),
|
|
actions: vec![Box::new(move |tx3: &AppEventSender| {
|
|
tx3.review(ReviewTarget::Commit {
|
|
sha: sha.clone(),
|
|
title: Some(subject.clone()),
|
|
});
|
|
})],
|
|
dismiss_on_select: true,
|
|
search_value: Some(search_val),
|
|
..Default::default()
|
|
});
|
|
}
|
|
|
|
chat.bottom_pane.show_selection_view(SelectionViewParams {
|
|
title: Some("Select a commit to review".to_string()),
|
|
footer_hint: Some(standard_popup_hint_line()),
|
|
items,
|
|
is_searchable: true,
|
|
search_placeholder: Some("Type to search commits".to_string()),
|
|
..Default::default()
|
|
});
|
|
}
|