Attachment store for assistant2 (#11327)

This sets up a way for the user (or Zed) to _push_ context instead of
having the model retrieve it with a function. Our first use is the
contents of the current file.

<img width="399" alt="image"
src="https://github.com/zed-industries/zed/assets/836375/198429a5-82af-4b82-86f6-cb961f10de5c">

<img width="393" alt="image"
src="https://github.com/zed-industries/zed/assets/836375/cfb52444-723b-4fc1-bddc-57e1810c512b">

I heard the asst2 example was deleted in another branch so I deleted
that here too since we wanted the workspace access.

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
Kyle Kelley
2024-05-03 14:48:00 -07:00
committed by GitHub
co-authored by Marshall
parent 6bdcfad6ad
commit 3e5dcd1bec
10 changed files with 525 additions and 409 deletions
+8
View File
@@ -16,6 +16,7 @@ pub struct ChatMessage {
id: MessageId,
player: UserOrAssistant,
message: Option<AnyElement>,
tools_used: Option<AnyElement>,
collapsed: bool,
on_collapse_handle_click: Box<dyn Fn(&ClickEvent, &mut WindowContext) + 'static>,
}
@@ -25,6 +26,7 @@ impl ChatMessage {
id: MessageId,
player: UserOrAssistant,
message: Option<AnyElement>,
tools_used: Option<AnyElement>,
collapsed: bool,
on_collapse_handle_click: Box<dyn Fn(&ClickEvent, &mut WindowContext) + 'static>,
) -> Self {
@@ -32,6 +34,7 @@ impl ChatMessage {
id,
player,
message,
tools_used,
collapsed,
on_collapse_handle_click,
}
@@ -66,6 +69,10 @@ impl RenderOnce for ChatMessage {
// Clamp the message height to exactly 1.5 lines when collapsed.
let collapsed_height = content_padding.to_pixels(cx.rem_size()) + cx.line_height() * 1.5;
let tools_used = self
.tools_used
.map(|attachment| div().mt_3().child(attachment));
let content = self.message.map(|message| {
div()
.overflow_hidden()
@@ -75,6 +82,7 @@ impl RenderOnce for ChatMessage {
.when(self.collapsed, |this| this.h(collapsed_height))
.bg(cx.theme().colors().surface_background)
.child(message)
.children(tools_used)
});
v_flex()