From ee33d313e2d8a2aa0d36265b13b8c9b00239caeb Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Wed, 2 Apr 2025 17:05:49 -0400 Subject: [PATCH] agent: Allow editing previous messages (#27965) This PR adds the ability to edit previous user messages in the thread. Release Notes: - Agent: Added the ability to edit previous user messages (Preview-only). --- crates/agent/src/active_thread.rs | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/crates/agent/src/active_thread.rs b/crates/agent/src/active_thread.rs index 33fa0eb802..b9d820d3ac 100644 --- a/crates/agent/src/active_thread.rs +++ b/crates/agent/src/active_thread.rs @@ -861,19 +861,6 @@ impl ActiveThread { cx.notify(); } - fn last_user_message(&self, cx: &Context) -> Option { - self.messages - .iter() - .rev() - .find(|message_id| { - self.thread - .read(cx) - .message(**message_id) - .map_or(false, |message| message.role == Role::User) - }) - .cloned() - } - fn messages_after(&self, message_id: MessageId) -> &[MessageId] { self.messages .iter() @@ -1001,8 +988,7 @@ impl ActiveThread { return Empty.into_any(); } - let allow_editing_message = - message.role == Role::User && self.last_user_message(cx) == Some(message_id); + let allow_editing_message = message.role == Role::User; let edit_message_editor = self .editing_message @@ -1209,10 +1195,6 @@ impl ActiveThread { ) .child( h_flex() - // DL: To double-check whether we want to fully remove - // the editing feature from meassages. Checkpoint sort of - // solve the same problem. - .invisible() .gap_1() .when_some( edit_message_editor.clone(),