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()
}

View file

@ -4,9 +4,11 @@ mod context_pill;
mod end_trial_upsell;
mod onboarding_modal;
pub mod preview;
mod unavailable_editing_tooltip;
pub use agent_notification::*;
pub use burn_mode_tooltip::*;
pub use context_pill::*;
pub use end_trial_upsell::*;
pub use onboarding_modal::*;
pub use unavailable_editing_tooltip::*;

View file

@ -0,0 +1,29 @@
use gpui::{Context, IntoElement, Render, Window};
use ui::{prelude::*, tooltip_container};
pub struct UnavailableEditingTooltip {
agent_name: SharedString,
}
impl UnavailableEditingTooltip {
pub fn new(agent_name: SharedString) -> Self {
Self { agent_name }
}
}
impl Render for UnavailableEditingTooltip {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
tooltip_container(window, cx, |this, _, _| {
this.child(Label::new("Unavailable Editing")).child(
div().max_w_64().child(
Label::new(format!(
"Editing previous messages is not available for {} yet.",
self.agent_name
))
.size(LabelSize::Small)
.color(Color::Muted),
),
)
})
}
}