Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Show time in assistant messages
Antonio Scandurra890c42a75a4f
diff --git a/Cargo.lock b/Cargo.lockindex 27c3a2fdb17..a22db1b35d2 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -101,6 +101,7 @@ version = "0.1.0"dependencies = ["anyhow","assets",+ "chrono","collections","editor","futures 0.3.28",diff --git a/crates/ai/Cargo.toml b/crates/ai/Cargo.tomlindex 14817916f49..861a9e4785e 100644--- a/crates/ai/Cargo.toml+++ b/crates/ai/Cargo.toml@@ -19,11 +19,12 @@ theme = { path = "../theme" }util = { path = "../util" }workspace = { path = "../workspace" }-serde.workspace = true-serde_json.workspace = trueanyhow.workspace = true+chrono = "0.4"futures.workspace = trueisahc.workspace = true+serde.workspace = true+serde_json.workspace = true[dev-dependencies]editor = { path = "../editor", features = ["test-support"] }diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rsindex 14ac7411146..c6c5d4d009a 100644--- a/crates/ai/src/assistant.rs+++ b/crates/ai/src/assistant.rs@@ -1,5 +1,6 @@use crate::{OpenAIRequest, OpenAIResponseStreamEvent, RequestMessage, Role};use anyhow::{anyhow, Result};+use chrono::{DateTime, Local};use collections::HashMap;use editor::{Editor, ExcerptId, ExcerptRange, MultiBuffer};use futures::{io::BufReader, AsyncBufReadExt, AsyncReadExt, Stream, StreamExt};@@ -343,6 +344,7 @@ impl Assistant {let message = Message {role,content: content.clone(),+ sent_at: Local::now(),};self.messages.push(message.clone());self.messages_by_id.insert(excerpt_id, message.clone());@@ -394,7 +396,16 @@ impl AssistantEditor {};Flex::row()- .with_child(sender)+ .with_child(sender.aligned())+ .with_child(+ Label::new(+ message.sent_at.format("%I:%M%P").to_string(),+ style.sent_at.text.clone(),+ )+ .contained()+ .with_style(style.sent_at.container)+ .aligned(),+ ).aligned().left().contained()@@ -461,6 +472,7 @@ impl Item for AssistantEditor {struct Message {role: Role,content: ModelHandle<Buffer>,+ sent_at: DateTime<Local>,}async fn stream_completion(diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rsindex 00562307668..1f99742cfe2 100644--- a/crates/theme/src/theme.rs+++ b/crates/theme/src/theme.rs@@ -972,6 +972,7 @@ pub struct TerminalStyle {pub struct AssistantStyle {pub container: ContainerStyle,pub header: ContainerStyle,+ pub sent_at: ContainedText,pub user_sender: ContainedText,pub assistant_sender: ContainedText,}diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.tsindex ea02c3b3839..0ff65a22ae3 100644--- a/styles/src/styleTree/assistant.ts+++ b/styles/src/styleTree/assistant.ts@@ -18,6 +18,10 @@ export default function assistant(colorScheme: ColorScheme) {},assistant_sender: {...text(layer, "sans", "accent", { size: "sm", weight: "bold" }),+ },+ sent_at: {+ margin: { top: 2, left: 8 },+ ...text(layer, "sans", "default", { size: "2xs" }),}}}