agent2: Add hover preview for image creases (#36427)

Note that (at least for now) this only works for creases in the "new
message" editor, not when editing past messages. That's because we don't
have the original image available when putting together the creases for
past messages, only the base64-encoded language model content.

Release Notes:

- N/A
This commit is contained in:
Cole Miller 2025-08-18 23:26:15 -04:00 committed by GitHub
parent 1b6fd996f8
commit 821e97a392
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 111 additions and 64 deletions

View file

@ -400,6 +400,7 @@ pub struct ButtonLike {
size: ButtonSize,
rounding: Option<ButtonLikeRounding>,
tooltip: Option<Box<dyn Fn(&mut Window, &mut App) -> AnyView>>,
hoverable_tooltip: Option<Box<dyn Fn(&mut Window, &mut App) -> AnyView>>,
cursor_style: CursorStyle,
on_click: Option<Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>>,
on_right_click: Option<Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>>,
@ -420,6 +421,7 @@ impl ButtonLike {
size: ButtonSize::Default,
rounding: Some(ButtonLikeRounding::All),
tooltip: None,
hoverable_tooltip: None,
children: SmallVec::new(),
cursor_style: CursorStyle::PointingHand,
on_click: None,
@ -463,6 +465,14 @@ impl ButtonLike {
self.on_right_click = Some(Box::new(handler));
self
}
pub fn hoverable_tooltip(
mut self,
tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static,
) -> Self {
self.hoverable_tooltip = Some(Box::new(tooltip));
self
}
}
impl Disableable for ButtonLike {
@ -654,6 +664,9 @@ impl RenderOnce for ButtonLike {
.when_some(self.tooltip, |this, tooltip| {
this.tooltip(move |window, cx| tooltip(window, cx))
})
.when_some(self.hoverable_tooltip, |this, tooltip| {
this.hoverable_tooltip(move |window, cx| tooltip(window, cx))
})
.children(self.children)
}
}