codex: address PR review feedback (#14710)

This commit is contained in:
Eric Traut
2026-03-14 20:18:55 -06:00
parent 60bb9cd15e
commit c4a574c823
3 changed files with 53 additions and 5 deletions

View File

@@ -705,7 +705,7 @@ pub(crate) struct App {
pending_patch_approval_request_ids: HashMap<String, RequestId>,
pending_elicitation_request_ids: HashMap<(String, RequestId), RequestId>,
pending_permissions_request_ids: HashMap<String, RequestId>,
pending_user_input_request_ids: HashMap<String, RequestId>,
pending_user_input_request_ids: HashMap<String, VecDeque<RequestId>>,
pending_dynamic_tool_request_ids: HashMap<String, RequestId>,
}
@@ -7600,6 +7600,24 @@ smart_approvals = true
.expect("shutdown should complete");
}
#[tokio::test]
async fn pending_user_input_request_ids_preserve_fifo_per_turn() {
let mut app = make_test_app().await;
app.note_pending_user_input_request_id("turn-1", RequestId::Integer(1));
app.note_pending_user_input_request_id("turn-1", RequestId::Integer(2));
assert_eq!(
app.pop_pending_user_input_request_id("turn-1"),
Some(RequestId::Integer(1))
);
assert_eq!(
app.pop_pending_user_input_request_id("turn-1"),
Some(RequestId::Integer(2))
);
assert_eq!(app.pop_pending_user_input_request_id("turn-1"), None);
}
#[tokio::test]
async fn clear_only_ui_reset_preserves_chat_session_state() {
let mut app = make_test_app().await;

View File

@@ -577,7 +577,7 @@ impl App {
.await?;
}
Op::UserInputAnswer { id, response } => {
let Some(request_id) = self.pending_user_input_request_ids.remove(&id) else {
let Some(request_id) = self.pop_pending_user_input_request_id(&id) else {
return Err(format!(
"Missing app-server request for user input turn {id}."
));
@@ -775,8 +775,7 @@ impl App {
.insert(params.item_id.clone(), request_id.clone());
}
ServerRequest::ToolRequestUserInput { request_id, params } => {
self.pending_user_input_request_ids
.insert(params.turn_id.clone(), request_id.clone());
self.note_pending_user_input_request_id(&params.turn_id, request_id.clone());
}
ServerRequest::DynamicToolCall { request_id, params } => {
self.pending_dynamic_tool_request_ids
@@ -791,6 +790,35 @@ impl App {
}
}
pub(super) fn note_pending_user_input_request_id(
&mut self,
turn_id: &str,
request_id: RequestId,
) {
self.pending_user_input_request_ids
.entry(turn_id.to_string())
.or_default()
.push_back(request_id);
}
pub(super) fn pop_pending_user_input_request_id(&mut self, turn_id: &str) -> Option<RequestId> {
let mut remove_turn_id = false;
let request_id = self
.pending_user_input_request_ids
.get_mut(turn_id)
.and_then(|request_ids| {
let request_id = request_ids.pop_front();
if request_ids.is_empty() {
remove_turn_id = true;
}
request_id
});
if remove_turn_id {
self.pending_user_input_request_ids.remove(turn_id);
}
request_id
}
async fn route_thread_update(&mut self, update: ThreadUpdate) {
let Some(thread_id_text) = update.thread_id() else {
self.handle_thread_update_now(update);

View File

@@ -460,7 +460,9 @@ pub(crate) async fn run_onboarding_app(
&mut onboarding_screen,
).await;
} else {
break;
return Err(eyre!(
"onboarding app server event stream closed before onboarding completed"
));
}
}
}