BlueGit

ict rusty-teams

Merge remote-tracking branch 'origin/main' into fix/own-reaction-notify

metis Daniel Däschle · pushed by metis

Authored 2026-10-17 · 6 weeks ago

Hash
64b07a011528cf61168018616b1c7bcb9398cf4a
2 files changed +66 −4
crates/app/src/notify/toast.rs +64 −2
@@ -154,6 +154,10 @@ fn flat_button(
154 154 .child(label)
155 155 }
156 156
157 fn keep_clicks_in_toast(area: Stateful<Div>) -> Stateful<Div> {
158 area.on_click(|_, _, cx| cx.stop_propagation())
159 }
160
157 161 fn highlighted_preview(text: &str, mention: bool) -> AnyElement {
158 162 let mut styled = StyledText::new(text.to_owned());
159 163 if mention {
@@ -352,7 +356,7 @@ impl ToastView {
352 356 )
353 357 }
354 358
355 fn reply_field(&self, window: &Window, cx: &mut Context<Self>) -> Div {
359 fn reply_field(&self, window: &Window, cx: &mut Context<Self>) -> Stateful<Div> {
356 360 let focused = self.input.focus_handle(cx).contains_focused(window, cx);
357 361 let empty = self.input.read(cx).value().trim().is_empty();
358 362 let send = div()
@@ -380,7 +384,7 @@ impl ToastView {
380 384 .child(div().text_color(theme::text_soft()).child(keys))
381 385 .child(action)
382 386 };
383 v_flex()
387 keep_clicks_in_toast(v_flex().id("toast-reply-field"))
384 388 .w_full()
385 389 .mt(px(8.))
386 390 .gap(px(4.))
@@ -628,3 +632,61 @@ impl Render for PillView {
628 632 })
629 633 }
630 634 }
635
636 #[cfg(test)]
637 mod tests {
638 use std::cell::Cell;
639 use std::rc::Rc;
640
641 use gpui_kit::component::input::{Textarea, TextareaState};
642 use gpui_kit::{
643 AppContext as _, Context, Entity, Focusable as _, InteractiveElement as _, IntoElement, Modifiers,
644 ParentElement as _, Render, StatefulInteractiveElement as _, Styled as _, TestAppContext,
645 Window, div, point, px,
646 };
647
648 use super::keep_clicks_in_toast;
649
650 struct ToastHarness {
651 input: Entity<TextareaState>,
652 card_clicks: Rc<Cell<usize>>,
653 }
654
655 impl Render for ToastHarness {
656 fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
657 let card_clicks = self.card_clicks.clone();
658 div()
659 .id("toast-card")
660 .size_full()
661 .on_click(move |_, _, _| card_clicks.set(card_clicks.get() + 1))
662 .child(
663 keep_clicks_in_toast(div().id("toast-reply-field"))
664 .w(px(300.))
665 .child(Textarea::new(&self.input)),
666 )
667 }
668 }
669
670 #[gpui_kit::test]
671 fn clicking_the_reply_input_does_not_open_the_chat(cx: &mut TestAppContext) {
672 cx.update(gpui_kit::init);
673 let card_clicks = Rc::new(Cell::new(0));
674 let (harness, window_cx) = cx.add_window_view({
675 let card_clicks = card_clicks.clone();
676 move |window, cx| ToastHarness {
677 input: cx.new(|cx| TextareaState::new(window, cx).auto_grow(1, 1)),
678 card_clicks,
679 }
680 });
681 window_cx.update(|window, cx| window.draw(cx).clear(cx));
682 window_cx.simulate_click(point(px(20.), px(12.)), Modifiers::default());
683 assert_eq!(card_clicks.get(), 0);
684 let focused = window_cx.update(|window, cx| {
685 let input = harness.read(cx).input.clone();
686 input.focus_handle(cx).contains_focused(window, cx)
687 });
688 assert!(focused);
689 window_cx.simulate_click(point(px(20.), px(200.)), Modifiers::default());
690 assert_eq!(card_clicks.get(), 1);
691 }
692 }
@@ -154,6 +154,10 @@ fn flat_button(
154 .child(label)
154 .child(label)
155}
155}
156
156
157fn keep_clicks_in_toast(area: Stateful<Div>) -> Stateful<Div> {
158 area.on_click(|_, _, cx| cx.stop_propagation())
159}
160
157fn highlighted_preview(text: &str, mention: bool) -> AnyElement {
161fn highlighted_preview(text: &str, mention: bool) -> AnyElement {
158 let mut styled = StyledText::new(text.to_owned());
162 let mut styled = StyledText::new(text.to_owned());
159 if mention {
163 if mention {
@@ -352,7 +356,7 @@ impl ToastView {
352 )
356 )
353 }
357 }
354
358
355 fn reply_field(&self, window: &Window, cx: &mut Context<Self>) -> Div {
359 fn reply_field(&self, window: &Window, cx: &mut Context<Self>) -> Stateful<Div> {
356 let focused = self.input.focus_handle(cx).contains_focused(window, cx);
360 let focused = self.input.focus_handle(cx).contains_focused(window, cx);
357 let empty = self.input.read(cx).value().trim().is_empty();
361 let empty = self.input.read(cx).value().trim().is_empty();
358 let send = div()
362 let send = div()
@@ -380,7 +384,7 @@ impl ToastView {
380 .child(div().text_color(theme::text_soft()).child(keys))
384 .child(div().text_color(theme::text_soft()).child(keys))
381 .child(action)
385 .child(action)
382 };
386 };
383 v_flex()
387 keep_clicks_in_toast(v_flex().id("toast-reply-field"))
384 .w_full()
388 .w_full()
385 .mt(px(8.))
389 .mt(px(8.))
386 .gap(px(4.))
390 .gap(px(4.))
@@ -628,3 +632,61 @@ impl Render for PillView {
628 })
632 })
629 }
633 }
630}
634}
635
636#[cfg(test)]
637mod tests {
638 use std::cell::Cell;
639 use std::rc::Rc;
640
641 use gpui_kit::component::input::{Textarea, TextareaState};
642 use gpui_kit::{
643 AppContext as _, Context, Entity, Focusable as _, InteractiveElement as _, IntoElement, Modifiers,
644 ParentElement as _, Render, StatefulInteractiveElement as _, Styled as _, TestAppContext,
645 Window, div, point, px,
646 };
647
648 use super::keep_clicks_in_toast;
649
650 struct ToastHarness {
651 input: Entity<TextareaState>,
652 card_clicks: Rc<Cell<usize>>,
653 }
654
655 impl Render for ToastHarness {
656 fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
657 let card_clicks = self.card_clicks.clone();
658 div()
659 .id("toast-card")
660 .size_full()
661 .on_click(move |_, _, _| card_clicks.set(card_clicks.get() + 1))
662 .child(
663 keep_clicks_in_toast(div().id("toast-reply-field"))
664 .w(px(300.))
665 .child(Textarea::new(&self.input)),
666 )
667 }
668 }
669
670 #[gpui_kit::test]
671 fn clicking_the_reply_input_does_not_open_the_chat(cx: &mut TestAppContext) {
672 cx.update(gpui_kit::init);
673 let card_clicks = Rc::new(Cell::new(0));
674 let (harness, window_cx) = cx.add_window_view({
675 let card_clicks = card_clicks.clone();
676 move |window, cx| ToastHarness {
677 input: cx.new(|cx| TextareaState::new(window, cx).auto_grow(1, 1)),
678 card_clicks,
679 }
680 });
681 window_cx.update(|window, cx| window.draw(cx).clear(cx));
682 window_cx.simulate_click(point(px(20.), px(12.)), Modifiers::default());
683 assert_eq!(card_clicks.get(), 0);
684 let focused = window_cx.update(|window, cx| {
685 let input = harness.read(cx).input.clone();
686 input.focus_handle(cx).contains_focused(window, cx)
687 });
688 assert!(focused);
689 window_cx.simulate_click(point(px(20.), px(200.)), Modifiers::default());
690 assert_eq!(card_clicks.get(), 1);
691 }
692}
crates/app/src/views/message_actions.rs +2 −2
@@ -292,7 +292,7 @@ pub fn message_toolbar(menu: MessageMenu, cx: &App) -> AnyElement {
292 292 children.push(
293 293 div()
294 294 .w(px(1.))
295 .h(px(16.))
295 .h_full()
296 296 .mx(px(4.))
297 297 .flex_none()
298 298 .bg(theme::popup_hover())
@@ -315,7 +315,7 @@ pub fn message_toolbar(menu: MessageMenu, cx: &App) -> AnyElement {
315 315 children.push(more_button(&menu, cx));
316 316 let bar = h_flex()
317 317 .h(px(TOOLBAR_HEIGHT))
318 .p(px(BAR_PADDING))
318 .px(px(BAR_PADDING))
319 319 .gap(px(1.))
320 320 .items_center()
321 321 .rounded(px(10.))
@@ -292,7 +292,7 @@ pub fn message_toolbar(menu: MessageMenu, cx: &App) -> AnyElement {
292 children.push(
292 children.push(
293 div()
293 div()
294 .w(px(1.))
294 .w(px(1.))
295 .h(px(16.))
295 .h_full()
296 .mx(px(4.))
296 .mx(px(4.))
297 .flex_none()
297 .flex_none()
298 .bg(theme::popup_hover())
298 .bg(theme::popup_hover())
@@ -315,7 +315,7 @@ pub fn message_toolbar(menu: MessageMenu, cx: &App) -> AnyElement {
315 children.push(more_button(&menu, cx));
315 children.push(more_button(&menu, cx));
316 let bar = h_flex()
316 let bar = h_flex()
317 .h(px(TOOLBAR_HEIGHT))
317 .h(px(TOOLBAR_HEIGHT))
318 .p(px(BAR_PADDING))
318 .px(px(BAR_PADDING))
319 .gap(px(1.))
319 .gap(px(1.))
320 .items_center()
320 .items_center()
321 .rounded(px(10.))
321 .rounded(px(10.))