From 28e1c15e9013ad3b81adc66cd2ad62bb24dfddb6 Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Fri, 21 Nov 2025 20:03:11 +0530 Subject: [PATCH] agent_ui: Fix sent agent prompt getting lost after authentication (#43245) Closes #42379 Release Notes: - Fixed issue where a sent agent message is not restored after successful authentication. --- crates/agent_ui/src/acp/thread_view.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index f3565356cf5b0501d529ab89e35b955689ef040a..780cff2e78fd4441fc451ddb3bc93b66a940c6c8 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -297,6 +297,7 @@ pub struct AcpThreadView { _cancel_task: Option>, _subscriptions: [Subscription; 5], show_codex_windows_warning: bool, + in_flight_prompt: Option>, } enum ThreadState { @@ -437,6 +438,7 @@ impl AcpThreadView { new_server_version_available: None, resume_thread_metadata: resume_thread, show_codex_windows_warning, + in_flight_prompt: None, } } @@ -1155,6 +1157,7 @@ impl AcpThreadView { } this.update_in(cx, |this, window, cx| { + this.in_flight_prompt = Some(contents.clone()); this.set_editor_is_expanded(false, cx); this.scroll_to_bottom(cx); this.message_editor.update(cx, |message_editor, cx| { @@ -1182,7 +1185,12 @@ impl AcpThreadView { })?; let res = send.await; let turn_time_ms = turn_start_time.elapsed().as_millis(); - let status = if res.is_ok() { "success" } else { "failure" }; + let status = if res.is_ok() { + this.update(cx, |this, _| this.in_flight_prompt.take()).ok(); + "success" + } else { + "failure" + }; telemetry::event!( "Agent Turn Completed", agent = agent_telemetry_id, @@ -5694,6 +5702,11 @@ impl AcpThreadView { provider_id: None, }; this.clear_thread_error(cx); + if let Some(message) = this.in_flight_prompt.take() { + this.message_editor.update(cx, |editor, cx| { + editor.set_message(message, window, cx); + }); + } let this = cx.weak_entity(); window.defer(cx, |window, cx| { Self::handle_auth_required(this, err, agent, connection, window, cx);