mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
Open notes when accepting the request input Other option (#38624)
## What changed When the generated `None of the above` option is selected in a request user input prompt, route Enter and configured accept actions to the notes editor instead of submitting the response. Tab continues to open the same editor. ## Testing Add a regression test confirming that both Tab and Enter reveal the notes editor without submitting the response. GitOrigin-RevId: 8a563d81a82a11ca0b26c2b1100053f13be8e8f4
This commit is contained in:
committed by
copyberry
parent
42b5f05cef
commit
1426592fcc
@@ -1363,7 +1363,15 @@ impl BottomPaneView for RequestUserInputOverlay {
|
||||
(_, KeyCode::Backspace | KeyCode::Delete) => {
|
||||
self.clear_selection();
|
||||
}
|
||||
(_, KeyCode::Tab) if self.selected_option_index().is_some() => {
|
||||
(_, KeyCode::Tab) | (Some(ListAction::Accept), _) | (_, KeyCode::Enter)
|
||||
if self.selected_option_index().is_some()
|
||||
&& (key_event.code == KeyCode::Tab
|
||||
|| self.current_question().is_some_and(|question| {
|
||||
Self::other_option_enabled_for_question(question)
|
||||
&& self.selected_option_index()
|
||||
== question.options.as_ref().map(Vec::len)
|
||||
})) =>
|
||||
{
|
||||
self.focus = Focus::Notes;
|
||||
self.ensure_selected_for_notes();
|
||||
}
|
||||
@@ -3234,6 +3242,35 @@ mod tests {
|
||||
assert!(answer.answer_committed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tab_and_enter_open_notes_for_other_option() {
|
||||
for key in [KeyCode::Tab, KeyCode::Enter] {
|
||||
let (tx, mut rx) = test_sender();
|
||||
let mut overlay = RequestUserInputOverlay::new(
|
||||
request_event(
|
||||
"turn-1",
|
||||
vec![question_with_options_and_other("q1", "Pick one")],
|
||||
),
|
||||
tx,
|
||||
/*has_input_focus*/ true,
|
||||
/*enhanced_keys_supported*/ false,
|
||||
/*disable_paste_burst*/ false,
|
||||
);
|
||||
let other_idx = overlay.options_len().saturating_sub(1);
|
||||
overlay
|
||||
.current_answer_mut()
|
||||
.expect("answer missing")
|
||||
.options_state
|
||||
.selected_idx = Some(other_idx);
|
||||
|
||||
overlay.handle_key_event(KeyEvent::from(key));
|
||||
|
||||
assert!(matches!(overlay.focus, Focus::Notes));
|
||||
assert!(overlay.notes_ui_visible());
|
||||
assert!(rx.try_recv().is_err());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_other_adds_none_of_the_above_and_submits_it() {
|
||||
let (tx, mut rx) = test_sender();
|
||||
|
||||
Reference in New Issue
Block a user