From f54c0570012e8ccdbe9e3c2f6ea81c31a6b3edf4 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 27 May 2025 16:26:47 -0400 Subject: [PATCH] Add warning message when editing a message in a thread (#31508) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Screenshot 2025-05-27 at 9 42 44 AM Release Notes: - Added notice that editing a message in the agent panel will restart the thread from that point. --------- Co-authored-by: Danilo Leal --- crates/agent/src/active_thread.rs | 120 ++++++++++++++++++------------ 1 file changed, 72 insertions(+), 48 deletions(-) diff --git a/crates/agent/src/active_thread.rs b/crates/agent/src/active_thread.rs index c749ca8211..6dbbd2b69f 100644 --- a/crates/agent/src/active_thread.rs +++ b/crates/agent/src/active_thread.rs @@ -2006,65 +2006,89 @@ impl ActiveThread { .border_1() .border_color(colors.border) .hover(|hover| hover.border_color(colors.text_accent.opacity(0.5))) - .cursor_pointer() .child( - h_flex() + v_flex() .p_2p5() .gap_1() - .items_end() .children(message_content) .when_some(editing_message_state, |this, state| { let focus_handle = state.editor.focus_handle(cx).clone(); - this.w_full().justify_between().child( + + this.child( h_flex() - .gap_0p5() + .w_full() + .gap_1() + .justify_between() + .flex_wrap() .child( - IconButton::new( - "cancel-edit-message", - IconName::Close, - ) - .shape(ui::IconButtonShape::Square) - .icon_color(Color::Error) - .icon_size(IconSize::Small) - .tooltip({ - let focus_handle = focus_handle.clone(); - move |window, cx| { - Tooltip::for_action_in( - "Cancel Edit", - &menu::Cancel, - &focus_handle, - window, - cx, - ) - } - }) - .on_click(cx.listener(Self::handle_cancel_click)), + h_flex() + .gap_1p5() + .child( + div() + .opacity(0.8) + .child( + Icon::new(IconName::Warning) + .size(IconSize::Indicator) + .color(Color::Warning) + ), + ) + .child( + Label::new("Editing will restart the thread from this point.") + .color(Color::Muted) + .size(LabelSize::XSmall), + ), ) .child( - IconButton::new( - "confirm-edit-message", - IconName::Return, - ) - .disabled(state.editor.read(cx).is_empty(cx)) - .shape(ui::IconButtonShape::Square) - .icon_color(Color::Muted) - .icon_size(IconSize::Small) - .tooltip({ - let focus_handle = focus_handle.clone(); - move |window, cx| { - Tooltip::for_action_in( - "Regenerate", - &menu::Confirm, - &focus_handle, - window, - cx, + h_flex() + .gap_0p5() + .child( + IconButton::new( + "cancel-edit-message", + IconName::Close, ) - } - }) - .on_click( - cx.listener(Self::handle_regenerate_click), - ), - ), + .shape(ui::IconButtonShape::Square) + .icon_color(Color::Error) + .icon_size(IconSize::Small) + .tooltip({ + let focus_handle = focus_handle.clone(); + move |window, cx| { + Tooltip::for_action_in( + "Cancel Edit", + &menu::Cancel, + &focus_handle, + window, + cx, + ) + } + }) + .on_click(cx.listener(Self::handle_cancel_click)), + ) + .child( + IconButton::new( + "confirm-edit-message", + IconName::Return, + ) + .disabled(state.editor.read(cx).is_empty(cx)) + .shape(ui::IconButtonShape::Square) + .icon_color(Color::Muted) + .icon_size(IconSize::Small) + .tooltip({ + let focus_handle = focus_handle.clone(); + move |window, cx| { + Tooltip::for_action_in( + "Regenerate", + &menu::Confirm, + &focus_handle, + window, + cx, + ) + } + }) + .on_click( + cx.listener(Self::handle_regenerate_click), + ), + ), + ) ) }), )