Add warning message when editing a message in a thread (#31508)

<img width="479" alt="Screenshot 2025-05-27 at 9 42 44 AM"
src="https://github.com/user-attachments/assets/7bd9e1b9-26b4-4396-9f93-e92a5f4ac2e1"
/>

Release Notes:

- Added notice that editing a message in the agent panel will restart
the thread from that point.

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
This commit is contained in:
Richard Feldman 2025-05-27 16:26:47 -04:00 committed by GitHub
parent 32848e9c8a
commit f54c057001
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2006,65 +2006,89 @@ impl ActiveThread {
.border_1() .border_1()
.border_color(colors.border) .border_color(colors.border)
.hover(|hover| hover.border_color(colors.text_accent.opacity(0.5))) .hover(|hover| hover.border_color(colors.text_accent.opacity(0.5)))
.cursor_pointer()
.child( .child(
h_flex() v_flex()
.p_2p5() .p_2p5()
.gap_1() .gap_1()
.items_end()
.children(message_content) .children(message_content)
.when_some(editing_message_state, |this, state| { .when_some(editing_message_state, |this, state| {
let focus_handle = state.editor.focus_handle(cx).clone(); let focus_handle = state.editor.focus_handle(cx).clone();
this.w_full().justify_between().child(
this.child(
h_flex() h_flex()
.gap_0p5() .w_full()
.gap_1()
.justify_between()
.flex_wrap()
.child( .child(
IconButton::new( h_flex()
"cancel-edit-message", .gap_1p5()
IconName::Close, .child(
) div()
.shape(ui::IconButtonShape::Square) .opacity(0.8)
.icon_color(Color::Error) .child(
.icon_size(IconSize::Small) Icon::new(IconName::Warning)
.tooltip({ .size(IconSize::Indicator)
let focus_handle = focus_handle.clone(); .color(Color::Warning)
move |window, cx| { ),
Tooltip::for_action_in( )
"Cancel Edit", .child(
&menu::Cancel, Label::new("Editing will restart the thread from this point.")
&focus_handle, .color(Color::Muted)
window, .size(LabelSize::XSmall),
cx, ),
)
}
})
.on_click(cx.listener(Self::handle_cancel_click)),
) )
.child( .child(
IconButton::new( h_flex()
"confirm-edit-message", .gap_0p5()
IconName::Return, .child(
) IconButton::new(
.disabled(state.editor.read(cx).is_empty(cx)) "cancel-edit-message",
.shape(ui::IconButtonShape::Square) IconName::Close,
.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,
) )
} .shape(ui::IconButtonShape::Square)
}) .icon_color(Color::Error)
.on_click( .icon_size(IconSize::Small)
cx.listener(Self::handle_regenerate_click), .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),
),
),
)
) )
}), }),
) )