assistant2: Add the ability to collapse chat messages (#11194)
This PR adds the ability to collapse/uncollapse chat messages. I think the spacing might be a little off with the collapsed calculations, so we'll need to look into that. https://github.com/zed-industries/zed/assets/1486634/4009c831-b44e-4b30-85ed-0266cb5b8a26 Release Notes: - N/A
This commit is contained in:
parent
ce643e6bef
commit
04cd8dd0f2
4 changed files with 34 additions and 10 deletions
|
@ -1,7 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use client::User;
|
||||
use gpui::AnyElement;
|
||||
use gpui::{AnyElement, ClickEvent};
|
||||
use ui::{prelude::*, Avatar};
|
||||
|
||||
use crate::MessageId;
|
||||
|
@ -17,7 +17,7 @@ pub struct ChatMessage {
|
|||
player: UserOrAssistant,
|
||||
message: AnyElement,
|
||||
collapsed: bool,
|
||||
on_collapse: Box<dyn Fn(bool, &mut WindowContext) + 'static>,
|
||||
on_collapse_handle_click: Box<dyn Fn(&ClickEvent, &mut WindowContext) + 'static>,
|
||||
}
|
||||
|
||||
impl ChatMessage {
|
||||
|
@ -26,14 +26,14 @@ impl ChatMessage {
|
|||
player: UserOrAssistant,
|
||||
message: AnyElement,
|
||||
collapsed: bool,
|
||||
on_collapse: Box<dyn Fn(bool, &mut WindowContext) + 'static>,
|
||||
on_collapse_handle_click: Box<dyn Fn(&ClickEvent, &mut WindowContext) + 'static>,
|
||||
) -> Self {
|
||||
Self {
|
||||
id,
|
||||
player,
|
||||
message,
|
||||
collapsed,
|
||||
on_collapse,
|
||||
on_collapse_handle_click,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ impl RenderOnce for ChatMessage {
|
|||
.w_1()
|
||||
.mx_2()
|
||||
.h_full()
|
||||
.on_click(move |_event, cx| (self.on_collapse)(!self.collapsed, cx))
|
||||
.on_click(self.on_collapse_handle_click)
|
||||
.child(
|
||||
div()
|
||||
.w_px()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue