diff --git a/crates/agent_ui/src/connection_view/thread_view.rs b/crates/agent_ui/src/connection_view/thread_view.rs index 771d80f08306838e756a2ea3dd8aa4b378cfd402..88bdf9d6b455b99e8cb2832d2133b023e5fccfee 100644 --- a/crates/agent_ui/src/connection_view/thread_view.rs +++ b/crates/agent_ui/src/connection_view/thread_view.rs @@ -665,6 +665,7 @@ impl ThreadView { if let Some(AgentThreadEntry::UserMessage(user_message)) = self.thread.read(cx).entries().get(event.entry_index) && user_message.id.is_some() + && !self.is_subagent() { self.editing_message = Some(event.entry_index); cx.notify(); @@ -674,6 +675,7 @@ impl ThreadView { if let Some(AgentThreadEntry::UserMessage(user_message)) = self.thread.read(cx).entries().get(event.entry_index) && user_message.id.is_some() + && !self.is_subagent() { if editor.read(cx).text(cx).as_str() == user_message.content.to_markdown(cx) { self.editing_message = None; @@ -683,7 +685,9 @@ impl ThreadView { } ViewEvent::MessageEditorEvent(_editor, MessageEditorEvent::SendImmediately) => {} ViewEvent::MessageEditorEvent(editor, MessageEditorEvent::Send) => { - self.regenerate(event.entry_index, editor.clone(), window, cx); + if !self.is_subagent() { + self.regenerate(event.entry_index, editor.clone(), window, cx); + } } ViewEvent::MessageEditorEvent(_editor, MessageEditorEvent::Cancel) => { self.cancel_editing(&Default::default(), window, cx); @@ -3795,14 +3799,12 @@ impl ThreadView { .as_ref() .is_some_and(|checkpoint| checkpoint.show); - let agent_name = self.agent_name.clone(); let is_subagent = self.is_subagent(); - - let non_editable_icon = || { - IconButton::new("non_editable", IconName::PencilUnavailable) - .icon_size(IconSize::Small) - .icon_color(Color::Muted) - .style(ButtonStyle::Transparent) + let is_editable = message.id.is_some() && !is_subagent; + let agent_name = if is_subagent { + "subagents".into() + } else { + self.agent_name.clone() }; v_flex() @@ -3823,8 +3825,8 @@ impl ThreadView { .gap_1p5() .w_full() .children(rules_item) - .children(message.id.clone().and_then(|message_id| { - message.checkpoint.as_ref()?.show.then(|| { + .when(is_editable && has_checkpoint_button, |this| { + this.children(message.id.clone().map(|message_id| { h_flex() .px_3() .gap_2() @@ -3843,8 +3845,8 @@ impl ThreadView { })) ) .child(Divider::horizontal()) - }) - })) + })) + }) .child( div() .relative() @@ -3860,8 +3862,11 @@ impl ThreadView { }) .border_color(cx.theme().colors().border) .map(|this| { - if is_subagent { - return this.border_dashed(); + if !is_editable { + if is_subagent { + return this.border_dashed(); + } + return this; } if editing && editor_focus { return this.border_color(focus_border); @@ -3869,12 +3874,9 @@ impl ThreadView { if editing && !editor_focus { return this.border_dashed() } - if message.id.is_some() { - return this.shadow_md().hover(|s| { - s.border_color(focus_border.opacity(0.8)) - }); - } - this + this.shadow_md().hover(|s| { + s.border_color(focus_border.opacity(0.8)) + }) }) .text_xs() .child(editor.clone().into_any_element()) @@ -3892,20 +3894,7 @@ impl ThreadView { .overflow_hidden(); let is_loading_contents = self.is_loading_contents; - if is_subagent { - this.child( - base_container.border_dashed().child( - non_editable_icon().tooltip(move |_, cx| { - Tooltip::with_meta( - "Unavailable Editing", - None, - "Editing subagent messages is currently not supported.", - cx, - ) - }), - ), - ) - } else if message.id.is_some() { + if is_editable { this.child( base_container .child( @@ -3944,26 +3933,29 @@ impl ThreadView { this.child( base_container .border_dashed() - .child( - non_editable_icon() - .tooltip(Tooltip::element({ - move |_, _| { - v_flex() - .gap_1() - .child(Label::new("Unavailable Editing")).child( - div().max_w_64().child( - Label::new(format!( - "Editing previous messages is not available for {} yet.", - agent_name.clone() - )) - .size(LabelSize::Small) - .color(Color::Muted), - ), - ) - .into_any_element() - } - })) - ) + .child(IconButton::new("non_editable", IconName::PencilUnavailable) + .icon_size(IconSize::Small) + .icon_color(Color::Muted) + .style(ButtonStyle::Transparent) + .tooltip(Tooltip::element({ + let agent_name = agent_name.clone(); + move |_, _| { + v_flex() + .gap_1() + .child(Label::new("Unavailable Editing")) + .child( + div().max_w_64().child( + Label::new(format!( + "Editing previous messages is not available for {} yet.", + agent_name + )) + .size(LabelSize::Small) + .color(Color::Muted), + ), + ) + .into_any_element() + } + }))), ) } }),