thread view: Inform when editing previous messages is unavailable (#36727)

Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2025-08-22 08:28:03 -03:00 committed by GitHub
parent d88fd00e87
commit 27a26d53b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 98 additions and 37 deletions

View file

@ -57,7 +57,9 @@ use crate::agent_diff::AgentDiff;
use crate::profile_selector::{ProfileProvider, ProfileSelector};
use crate::ui::preview::UsageCallout;
use crate::ui::{AgentNotification, AgentNotificationEvent, BurnModeTooltip};
use crate::ui::{
AgentNotification, AgentNotificationEvent, BurnModeTooltip, UnavailableEditingTooltip,
};
use crate::{
AgentDiffPane, AgentPanel, ContinueThread, ContinueWithBurnMode, ExpandMessageEditor, Follow,
KeepAll, OpenAgentDiff, OpenHistory, RejectAll, ToggleBurnMode, ToggleProfileSelector,
@ -1239,6 +1241,8 @@ impl AcpThreadView {
None
};
let agent_name = self.agent.name();
v_flex()
.id(("user_message", entry_ix))
.pt_2()
@ -1292,42 +1296,61 @@ impl AcpThreadView {
.text_xs()
.child(editor.clone().into_any_element()),
)
.when(editing && editor_focus, |this|
this.child(
h_flex()
.absolute()
.top_neg_3p5()
.right_3()
.gap_1()
.rounded_sm()
.border_1()
.border_color(cx.theme().colors().border)
.bg(cx.theme().colors().editor_background)
.overflow_hidden()
.child(
IconButton::new("cancel", IconName::Close)
.icon_color(Color::Error)
.icon_size(IconSize::XSmall)
.on_click(cx.listener(Self::cancel_editing))
)
.child(
IconButton::new("regenerate", IconName::Return)
.icon_color(Color::Muted)
.icon_size(IconSize::XSmall)
.tooltip(Tooltip::text(
"Editing will restart the thread from this point."
))
.on_click(cx.listener({
let editor = editor.clone();
move |this, _, window, cx| {
this.regenerate(
entry_ix, &editor, window, cx,
);
}
})),
)
)
),
.when(editor_focus, |this| {
let base_container = h_flex()
.absolute()
.top_neg_3p5()
.right_3()
.gap_1()
.rounded_sm()
.border_1()
.border_color(cx.theme().colors().border)
.bg(cx.theme().colors().editor_background)
.overflow_hidden();
if message.id.is_some() {
this.child(
base_container
.child(
IconButton::new("cancel", IconName::Close)
.icon_color(Color::Error)
.icon_size(IconSize::XSmall)
.on_click(cx.listener(Self::cancel_editing))
)
.child(
IconButton::new("regenerate", IconName::Return)
.icon_color(Color::Muted)
.icon_size(IconSize::XSmall)
.tooltip(Tooltip::text(
"Editing will restart the thread from this point."
))
.on_click(cx.listener({
let editor = editor.clone();
move |this, _, window, cx| {
this.regenerate(
entry_ix, &editor, window, cx,
);
}
})),
)
)
} else {
this.child(
base_container
.border_dashed()
.child(
IconButton::new("editing_unavailable", IconName::PencilUnavailable)
.icon_size(IconSize::Small)
.icon_color(Color::Muted)
.style(ButtonStyle::Transparent)
.tooltip(move |_window, cx| {
cx.new(|_| UnavailableEditingTooltip::new(agent_name.into()))
.into()
})
)
)
}
}),
)
.into_any()
}