From 436a2817561aa1e3ee152efdeb2e9afbc46135fd Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 5 Jan 2024 17:18:52 -0700 Subject: [PATCH 1/2] Align the assistant message headers with the editable message content Since the message headers are buttons, we need to shift them relatively to compensate for the fact that the background is only visible when hovered. I'm ok with the background not being aligned so long as the unhovered text is. --- crates/assistant/src/assistant_panel.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rs index 452538b910..58e7ddc382 100644 --- a/crates/assistant/src/assistant_panel.rs +++ b/crates/assistant/src/assistant_panel.rs @@ -29,7 +29,7 @@ use editor::{ use fs::Fs; use futures::StreamExt; use gpui::{ - canvas, div, point, relative, rems, uniform_list, Action, AnyElement, AppContext, + canvas, div, point, relative, rems, rgba, uniform_list, Action, AnyElement, AppContext, AsyncWindowContext, AvailableSpace, ClipboardItem, Context, EventEmitter, FocusHandle, FocusableView, FontStyle, FontWeight, HighlightStyle, InteractiveElement, IntoElement, Model, ModelContext, ParentElement, Pixels, PromptLevel, Render, SharedString, @@ -2325,12 +2325,16 @@ impl ConversationEditor { } }); - h_stack() + div() + .h_flex() .id(("message_header", message_id.0)) .h_11() + .relative() .gap_1() - .p_1() - .child(sender) + // Sender is a button with a padding of 1, but only has a background on hover, + // so we shift it left by the same amount to align the text with the content + // in the un-hovered state. + .child(div().child(sender).relative().neg_left_1()) // TODO: Only show this if the message if the message has been sent .child( Label::new( @@ -2538,7 +2542,7 @@ impl Render for ConversationEditor { .child( div() .size_full() - .pl_2() + .pl_4() .bg(cx.theme().colors().editor_background) .child(self.editor.clone()), ) From aaada7d5087ba75f5a16cee1f3a0230f138749e8 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 5 Jan 2024 17:22:59 -0700 Subject: [PATCH 2/2] Implement From for Fill --- crates/assistant/src/assistant_panel.rs | 2 +- crates/gpui/src/style.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rs index 58e7ddc382..385c6f5239 100644 --- a/crates/assistant/src/assistant_panel.rs +++ b/crates/assistant/src/assistant_panel.rs @@ -29,7 +29,7 @@ use editor::{ use fs::Fs; use futures::StreamExt; use gpui::{ - canvas, div, point, relative, rems, rgba, uniform_list, Action, AnyElement, AppContext, + canvas, div, point, relative, rems, uniform_list, Action, AnyElement, AppContext, AsyncWindowContext, AvailableSpace, ClipboardItem, Context, EventEmitter, FocusHandle, FocusableView, FontStyle, FontWeight, HighlightStyle, InteractiveElement, IntoElement, Model, ModelContext, ParentElement, Pixels, PromptLevel, Render, SharedString, diff --git a/crates/gpui/src/style.rs b/crates/gpui/src/style.rs index 7e9504d434..244ccebf24 100644 --- a/crates/gpui/src/style.rs +++ b/crates/gpui/src/style.rs @@ -561,6 +561,12 @@ impl From for Fill { } } +impl From for Fill { + fn from(color: Rgba) -> Self { + Self::Color(color.into()) + } +} + impl From for HighlightStyle { fn from(other: TextStyle) -> Self { Self::from(&other)