mirror of
https://github.com/openai/codex.git
synced 2026-11-07 16:35:32 +00:00
TUI: route elicitation responses to request thread (#23241)
## Why Fixes #21894. When the TUI handles an MCP elicitation, the request payload already includes the thread that generated the elicitation. `ChatWidget::handle_elicitation_request_now` was ignoring that value and using the currently visible chat thread instead. In a multi-session TUI, that can send `resolve_elicitation` to an older visible thread rather than the session that owns the pending elicitation, producing `elicitation request not found` and leaving the prompt unresolved. ## What changed - Parse `McpServerElicitationRequestParams.thread_id` in the ChatWidget elicitation handler and use it for app-link, form, fallback approval, and auto-decline resolution paths. - Keep the existing visible-thread fallback only for malformed request payloads with an invalid thread id. - Update the invalid URL elicitation regression test so the visible thread and request thread intentionally differ.
This commit is contained in:
1 parent
4ac3ea20a2
commit
53a1f4c29e
2 files changed
+7
-5
No files matched your search
@@ -4,13 +4,14 @@ use pretty_assertions::assert_eq;
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn invalid_url_elicitation_is_declined() {
|
async fn invalid_url_elicitation_is_declined() {
|
||||||
let (mut chat, _app_event_tx, mut rx, _op_rx) = make_chatwidget_manual_with_sender().await;
|
let (mut chat, _app_event_tx, mut rx, _op_rx) = make_chatwidget_manual_with_sender().await;
|
||||||
let thread_id = ThreadId::new();
|
let visible_thread_id = ThreadId::new();
|
||||||
chat.thread_id = Some(thread_id);
|
let request_thread_id = ThreadId::new();
|
||||||
|
chat.thread_id = Some(visible_thread_id);
|
||||||
|
|
||||||
chat.handle_elicitation_request_now(
|
chat.handle_elicitation_request_now(
|
||||||
codex_app_server_protocol::RequestId::Integer(9),
|
codex_app_server_protocol::RequestId::Integer(9),
|
||||||
codex_app_server_protocol::McpServerElicitationRequestParams {
|
codex_app_server_protocol::McpServerElicitationRequestParams {
|
||||||
thread_id: thread_id.to_string(),
|
thread_id: request_thread_id.to_string(),
|
||||||
turn_id: Some("turn-auth".to_string()),
|
turn_id: Some("turn-auth".to_string()),
|
||||||
server_name: "payments".to_string(),
|
server_name: "payments".to_string(),
|
||||||
request: codex_app_server_protocol::McpServerElicitationRequest::Url {
|
request: codex_app_server_protocol::McpServerElicitationRequest::Url {
|
||||||
@@ -33,7 +34,7 @@ async fn invalid_url_elicitation_is_declined() {
|
|||||||
content: None,
|
content: None,
|
||||||
meta: None,
|
meta: None,
|
||||||
},
|
},
|
||||||
}) if op_thread_id == thread_id && server_name == "payments"
|
}) if op_thread_id == request_thread_id && server_name == "payments"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -341,7 +341,8 @@ impl ChatWidget {
|
|||||||
server_name: params.server_name.clone(),
|
server_name: params.server_name.clone(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let thread_id = self.thread_id.unwrap_or_default();
|
let thread_id = ThreadId::from_string(¶ms.thread_id)
|
||||||
|
.unwrap_or_else(|_| self.thread_id.unwrap_or_default());
|
||||||
if let Some(params) = crate::bottom_pane::AppLinkViewParams::from_url_app_server_request(
|
if let Some(params) = crate::bottom_pane::AppLinkViewParams::from_url_app_server_request(
|
||||||
thread_id,
|
thread_id,
|
||||||
¶ms.server_name,
|
¶ms.server_name,
|
||||||
|
|||||||
Reference in new issue
Block a user