assistant2: Add headers to chat messages (#11191)

This PR adds headers to the chat messages in the new assistant panel.

Adapted from the work on the `assistant-chat-ui` branch.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-04-29 18:21:43 -04:00 committed by GitHub
parent 1c09b69384
commit ae650342ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 65 additions and 6 deletions

View file

@ -33,6 +33,8 @@ use workspace::{
pub use assistant_settings::AssistantSettings;
use crate::ui::{ChatMessageHeader, UserOrAssistant};
const MAX_COMPLETION_CALLS_PER_SUBMISSION: usize = 5;
#[derive(Eq, PartialEq, Copy, Clone, Deserialize)]
@ -526,7 +528,9 @@ impl AssistantChat {
match &self.messages[ix] {
ChatMessage::User(UserMessage { body, .. }) => div()
.when(!is_last, |element| element.mb_2())
.child(div().p_2().child(Label::new("You").color(Color::Default)))
.child(ChatMessageHeader::new(UserOrAssistant::User(
self.user_store.read(cx).current_user(),
)))
.child(
div()
.p_2()
@ -551,11 +555,7 @@ impl AssistantChat {
div()
.when(!is_last, |element| element.mb_2())
.child(
div()
.p_2()
.child(Label::new("Assistant").color(Color::Modified)),
)
.child(ChatMessageHeader::new(UserOrAssistant::Assistant))
.child(assistant_body)
.child(self.render_error(error.clone(), ix, cx))
.children(tool_calls.iter().map(|tool_call| {