agent: Fix reinsertion of creases when editing past messages (#30417)

Just noticed this got lost when main was merged in #29828.

Release Notes:

- agent: Fixed the rendering of added context when editing past messages
in a thread.
This commit is contained in:
Cole Miller 2025-05-09 16:53:30 -04:00 committed by GitHub
parent 2b249f9e68
commit 000077facf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,9 +3,10 @@ use crate::context::{AgentContextHandle, RULES_ICON};
use crate::context_picker::{ContextPicker, MentionLink}; use crate::context_picker::{ContextPicker, MentionLink};
use crate::context_store::ContextStore; use crate::context_store::ContextStore;
use crate::context_strip::{ContextStrip, ContextStripEvent, SuggestContextKind}; use crate::context_strip::{ContextStrip, ContextStripEvent, SuggestContextKind};
use crate::message_editor::insert_message_creases;
use crate::thread::{ use crate::thread::{
LastRestoreCheckpoint, MessageId, MessageSegment, Thread, ThreadError, ThreadEvent, LastRestoreCheckpoint, MessageCrease, MessageId, MessageSegment, Thread, ThreadError,
ThreadFeedback, ThreadEvent, ThreadFeedback,
}; };
use crate::thread_store::{RulesLoadingError, TextThreadStore, ThreadStore}; use crate::thread_store::{RulesLoadingError, TextThreadStore, ThreadStore};
use crate::tool_use::{PendingToolUseStatus, ToolUse}; use crate::tool_use::{PendingToolUseStatus, ToolUse};
@ -1267,6 +1268,7 @@ impl ActiveThread {
&mut self, &mut self,
message_id: MessageId, message_id: MessageId,
message_segments: &[MessageSegment], message_segments: &[MessageSegment],
message_creases: &[MessageCrease],
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
@ -1286,6 +1288,7 @@ impl ActiveThread {
); );
editor.update(cx, |editor, cx| { editor.update(cx, |editor, cx| {
editor.set_text(message_text.clone(), window, cx); editor.set_text(message_text.clone(), window, cx);
insert_message_creases(editor, message_creases, &self.context_store, window, cx);
editor.focus_handle(cx).focus(window); editor.focus_handle(cx).focus(window);
editor.move_to_end(&editor::actions::MoveToEnd, window, cx); editor.move_to_end(&editor::actions::MoveToEnd, window, cx);
}); });
@ -1740,6 +1743,7 @@ impl ActiveThread {
let Some(message) = self.thread.read(cx).message(message_id) else { let Some(message) = self.thread.read(cx).message(message_id) else {
return Empty.into_any(); return Empty.into_any();
}; };
let message_creases = message.creases.clone();
let Some(rendered_message) = self.rendered_messages_by_id.get(&message_id) else { let Some(rendered_message) = self.rendered_messages_by_id.get(&message_id) else {
return Empty.into_any(); return Empty.into_any();
@ -2031,6 +2035,7 @@ impl ActiveThread {
this.start_editing_message( this.start_editing_message(
message_id, message_id,
&message_segments, &message_segments,
&message_creases,
window, window,
cx, cx,
); );