BlueGit

ict rusty-teams

fix(messages): jump highlight tints the bubble and fades

- tint follows the bubble corners instead of a full-width slab
- fades in, holds, fades out over 2.4 s instead of switching off

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-05 · 3 weeks ago

Hash
c1c2c0c411903e6f093e80a422a24002462c991a
Parent
0c7de303
2 files changed +51 −7
crates/app/src/views/conversation.rs +4 −3
@@ -57,7 +57,9 @@ use super::composer::{Composer, ComposerEvent, EditPreview, Outgoing, ReplyPrevi
57 57 use super::find_panel::{FIND_PANEL_WIDTH, FindPanel, FindPanelEvent};
58 58 use super::group_name::group_name_button;
59 59 use super::message_actions::{Action, DelegateEntry, MessageMenu};
60 use super::message_row::{AVATAR_GAP, AVATAR_SIZE, render_message_row, render_skeleton_row};
60 use super::message_row::{
61 AVATAR_GAP, AVATAR_SIZE, JUMP_HIGHLIGHT_PERIOD, render_message_row, render_skeleton_row,
62 };
61 63 use super::new_chat::{NewChatDraft, NewChatEvent, Pick, composer_placeholder};
62 64 use super::pin_banner::{pin_banner_inset, pin_banner_overlay};
63 65 use super::post_card::render_post;
@@ -126,7 +128,6 @@ const DEMO_DOWNLOAD_STEPS: u8 = 10;
126 128 const DEMO_DOWNLOAD_STEP: Duration = Duration::from_millis(100);
127 129 const JUMP_SCAN_LIMIT: usize = 5000;
128 130 const JUMP_CONTEXT_MESSAGES: usize = 12;
129 const HIGHLIGHT_DURATION: Duration = Duration::from_secs(2);
130 131 const PROGRESS_DELAY: Duration = Duration::from_millis(400);
131 132 const SLOW_AFTER: Duration = Duration::from_secs(8);
132 133 const PROGRESS_MIN_VISIBLE: Duration = Duration::from_millis(500);
@@ -1248,7 +1249,7 @@ impl ConversationView {
1248 1249 self.highlighted_message = Some(key.clone());
1249 1250 cx.notify();
1250 1251 cx.spawn(async move |this, cx| {
1251 cx.background_executor().timer(HIGHLIGHT_DURATION).await;
1252 cx.background_executor().timer(JUMP_HIGHLIGHT_PERIOD).await;
1252 1253 this.update(cx, |this, cx| {
1253 1254 if this.highlighted_message.as_deref() == Some(key.as_str()) {
1254 1255 this.highlighted_message = None;
@@ -57,7 +57,9 @@ use super::composer::{Composer, ComposerEvent, EditPreview, Outgoing, ReplyPrevi
57use super::find_panel::{FIND_PANEL_WIDTH, FindPanel, FindPanelEvent};
57use super::find_panel::{FIND_PANEL_WIDTH, FindPanel, FindPanelEvent};
58use super::group_name::group_name_button;
58use super::group_name::group_name_button;
59use super::message_actions::{Action, DelegateEntry, MessageMenu};
59use super::message_actions::{Action, DelegateEntry, MessageMenu};
60use super::message_row::{AVATAR_GAP, AVATAR_SIZE, render_message_row, render_skeleton_row};
60use super::message_row::{
61 AVATAR_GAP, AVATAR_SIZE, JUMP_HIGHLIGHT_PERIOD, render_message_row, render_skeleton_row,
62};
61use super::new_chat::{NewChatDraft, NewChatEvent, Pick, composer_placeholder};
63use super::new_chat::{NewChatDraft, NewChatEvent, Pick, composer_placeholder};
62use super::pin_banner::{pin_banner_inset, pin_banner_overlay};
64use super::pin_banner::{pin_banner_inset, pin_banner_overlay};
63use super::post_card::render_post;
65use super::post_card::render_post;
@@ -126,7 +128,6 @@ const DEMO_DOWNLOAD_STEPS: u8 = 10;
126const DEMO_DOWNLOAD_STEP: Duration = Duration::from_millis(100);
128const DEMO_DOWNLOAD_STEP: Duration = Duration::from_millis(100);
127const JUMP_SCAN_LIMIT: usize = 5000;
129const JUMP_SCAN_LIMIT: usize = 5000;
128const JUMP_CONTEXT_MESSAGES: usize = 12;
130const JUMP_CONTEXT_MESSAGES: usize = 12;
129const HIGHLIGHT_DURATION: Duration = Duration::from_secs(2);
130const PROGRESS_DELAY: Duration = Duration::from_millis(400);
131const PROGRESS_DELAY: Duration = Duration::from_millis(400);
131const SLOW_AFTER: Duration = Duration::from_secs(8);
132const SLOW_AFTER: Duration = Duration::from_secs(8);
132const PROGRESS_MIN_VISIBLE: Duration = Duration::from_millis(500);
133const PROGRESS_MIN_VISIBLE: Duration = Duration::from_millis(500);
@@ -1248,7 +1249,7 @@ impl ConversationView {
1248 self.highlighted_message = Some(key.clone());
1249 self.highlighted_message = Some(key.clone());
1249 cx.notify();
1250 cx.notify();
1250 cx.spawn(async move |this, cx| {
1251 cx.spawn(async move |this, cx| {
1251 cx.background_executor().timer(HIGHLIGHT_DURATION).await;
1252 cx.background_executor().timer(JUMP_HIGHLIGHT_PERIOD).await;
1252 this.update(cx, |this, cx| {
1253 this.update(cx, |this, cx| {
1253 if this.highlighted_message.as_deref() == Some(key.as_str()) {
1254 if this.highlighted_message.as_deref() == Some(key.as_str()) {
1254 this.highlighted_message = None;
1255 this.highlighted_message = None;
crates/app/src/views/message_row.rs +47 −4
@@ -25,7 +25,9 @@ use crate::data::Directory;
25 25 use crate::importance::importance_label;
26 26 use crate::render::Block;
27 27 use crate::restorable_deletes::{DELETED_TOMBSTONE, UNDO_DELETE_LABEL};
28 use crate::rows::{Delivery, MessageRow, Receipt, ScheduledState, Skeleton, bubble_corners};
28 use crate::rows::{
29 Corners, Delivery, MessageRow, Receipt, ScheduledState, Skeleton, bubble_corners,
30 };
29 31 use crate::sidebar_model::DELETED_PREVIEW;
30 32 use crate::theme;
31 33 use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, ROW_PADDING};
@@ -71,6 +73,10 @@ pub(super) const BUBBLE_PADDING_X: f32 = 12.;
71 73 const FIGURE_SPACE_WIDTH: f32 = 7.4;
72 74 const PULSE_PERIOD: Duration = Duration::from_millis(1600);
73 75 const RECEIPT_FADE_PERIOD: Duration = Duration::from_millis(600);
76 pub const JUMP_HIGHLIGHT_PERIOD: Duration = Duration::from_millis(2400);
77 const HIGHLIGHT_FADE_IN: f32 = 0.1;
78 const HIGHLIGHT_FADE_OUT: f32 = 0.4;
79 const HIGHLIGHT_TINT: f32 = 0.3;
74 80 const SKELETON_LINE_HEIGHT: f32 = 20.;
75 81 pub const SELECT_BOX_SIZE: f32 = 16.;
76 82 pub const SELECT_GAP: f32 = 12.;
@@ -277,6 +283,9 @@ fn bubble(
277 283 },
278 284 )
279 285 });
286 element = element.when(extras.highlighted, |bubble| {
287 bubble.child(jump_highlight(index, corners))
288 });
280 289 let has_reactions = !row.reactions.is_empty();
281 290 let saved = extras.saved;
282 291 let mut content = v_flex().gap(px(6.));
@@ -405,6 +414,7 @@ struct BubbleExtras {
405 414 reaction_proposal: Option<ReactionPill>,
406 415 undo_delete: SharedRowAction,
407 416 compact: bool,
417 highlighted: bool,
408 418 }
409 419
410 420 fn agent_chip(run: Option<AgentRun>) -> Option<Div> {
@@ -510,6 +520,28 @@ fn pulse<E: IntoElement + Styled + 'static>(id: &'static str, element: E) -> Ani
510 520 )
511 521 }
512 522
523 fn jump_highlight(index: usize, corners: Corners) -> AnimationElement<Div> {
524 div()
525 .absolute()
526 .inset_0()
527 .rounded_tl(px(corners.top_left))
528 .rounded_tr(px(corners.top_right))
529 .rounded_br(px(corners.bottom_right))
530 .rounded_bl(px(corners.bottom_left))
531 .bg(theme::accent().opacity(HIGHLIGHT_TINT))
532 .with_animation(
533 SharedString::from(format!("jump-highlight/{index}")),
534 Animation::new(JUMP_HIGHLIGHT_PERIOD),
535 |highlight, delta| highlight.opacity(highlight_opacity(delta)),
536 )
537 }
538
539 fn highlight_opacity(delta: f32) -> f32 {
540 let fade_in = (delta / HIGHLIGHT_FADE_IN).min(1.);
541 let fade_out = ((1. - delta) / HIGHLIGHT_FADE_OUT).min(1.);
542 ease_in_out(fade_in.min(fade_out))
543 }
544
513 545 fn receipt_fade_in(message_key: &str, check: Div) -> AnimationElement<Div> {
514 546 check.with_animation(
515 547 SharedString::from(format!("receipt-fade/{message_key}")),
@@ -800,6 +832,7 @@ pub fn render_message_row(
800 832 reaction_proposal,
801 833 undo_delete,
802 834 compact,
835 highlighted,
803 836 };
804 837 let own = row.own;
805 838 let spacing = px(row_spacing(row.series.has_prev, compact));
@@ -833,9 +866,6 @@ pub fn render_message_row(
833 866 div()
834 867 .w_full()
835 868 .rounded(px(10.))
836 .when(highlighted, |element| {
837 element.bg(theme::accent().opacity(0.2))
838 })
839 869 .when(checked && !highlighted, |element| {
840 870 element.bg(theme::accent().opacity(SELECTED_TINT))
841 871 })
@@ -892,6 +922,19 @@ pub fn select_box(checked: bool, blocked: bool, index: usize) -> Div {
892 922 .when(blocked, |element| element.opacity(SELECT_BLOCKED_OPACITY))
893 923 }
894 924
925 #[cfg(test)]
926 mod highlight_tests {
927 use super::highlight_opacity;
928
929 #[test]
930 fn jump_highlight_fades_in_holds_and_fades_out() {
931 assert_eq!(highlight_opacity(0.), 0.);
932 assert_eq!(highlight_opacity(0.5), 1.);
933 assert!(highlight_opacity(0.8) < 1.);
934 assert!(highlight_opacity(0.99) < 0.05);
935 }
936 }
937
895 938 #[cfg(test)]
896 939 mod density_tests {
897 940 use super::{META_BOTTOM_INSET, bubble_padding_y, row_spacing, runway_width};
@@ -25,7 +25,9 @@ use crate::data::Directory;
25use crate::importance::importance_label;
25use crate::importance::importance_label;
26use crate::render::Block;
26use crate::render::Block;
27use crate::restorable_deletes::{DELETED_TOMBSTONE, UNDO_DELETE_LABEL};
27use crate::restorable_deletes::{DELETED_TOMBSTONE, UNDO_DELETE_LABEL};
28use crate::rows::{Delivery, MessageRow, Receipt, ScheduledState, Skeleton, bubble_corners};
28use crate::rows::{
29 Corners, Delivery, MessageRow, Receipt, ScheduledState, Skeleton, bubble_corners,
30};
29use crate::sidebar_model::DELETED_PREVIEW;
31use crate::sidebar_model::DELETED_PREVIEW;
30use crate::theme;
32use crate::theme;
31use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, ROW_PADDING};
33use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, ROW_PADDING};
@@ -71,6 +73,10 @@ pub(super) const BUBBLE_PADDING_X: f32 = 12.;
71const FIGURE_SPACE_WIDTH: f32 = 7.4;
73const FIGURE_SPACE_WIDTH: f32 = 7.4;
72const PULSE_PERIOD: Duration = Duration::from_millis(1600);
74const PULSE_PERIOD: Duration = Duration::from_millis(1600);
73const RECEIPT_FADE_PERIOD: Duration = Duration::from_millis(600);
75const RECEIPT_FADE_PERIOD: Duration = Duration::from_millis(600);
76pub const JUMP_HIGHLIGHT_PERIOD: Duration = Duration::from_millis(2400);
77const HIGHLIGHT_FADE_IN: f32 = 0.1;
78const HIGHLIGHT_FADE_OUT: f32 = 0.4;
79const HIGHLIGHT_TINT: f32 = 0.3;
74const SKELETON_LINE_HEIGHT: f32 = 20.;
80const SKELETON_LINE_HEIGHT: f32 = 20.;
75pub const SELECT_BOX_SIZE: f32 = 16.;
81pub const SELECT_BOX_SIZE: f32 = 16.;
76pub const SELECT_GAP: f32 = 12.;
82pub const SELECT_GAP: f32 = 12.;
@@ -277,6 +283,9 @@ fn bubble(
277 },
283 },
278 )
284 )
279 });
285 });
286 element = element.when(extras.highlighted, |bubble| {
287 bubble.child(jump_highlight(index, corners))
288 });
280 let has_reactions = !row.reactions.is_empty();
289 let has_reactions = !row.reactions.is_empty();
281 let saved = extras.saved;
290 let saved = extras.saved;
282 let mut content = v_flex().gap(px(6.));
291 let mut content = v_flex().gap(px(6.));
@@ -405,6 +414,7 @@ struct BubbleExtras {
405 reaction_proposal: Option<ReactionPill>,
414 reaction_proposal: Option<ReactionPill>,
406 undo_delete: SharedRowAction,
415 undo_delete: SharedRowAction,
407 compact: bool,
416 compact: bool,
417 highlighted: bool,
408}
418}
409
419
410fn agent_chip(run: Option<AgentRun>) -> Option<Div> {
420fn agent_chip(run: Option<AgentRun>) -> Option<Div> {
@@ -510,6 +520,28 @@ fn pulse<E: IntoElement + Styled + 'static>(id: &'static str, element: E) -> Ani
510 )
520 )
511}
521}
512
522
523fn jump_highlight(index: usize, corners: Corners) -> AnimationElement<Div> {
524 div()
525 .absolute()
526 .inset_0()
527 .rounded_tl(px(corners.top_left))
528 .rounded_tr(px(corners.top_right))
529 .rounded_br(px(corners.bottom_right))
530 .rounded_bl(px(corners.bottom_left))
531 .bg(theme::accent().opacity(HIGHLIGHT_TINT))
532 .with_animation(
533 SharedString::from(format!("jump-highlight/{index}")),
534 Animation::new(JUMP_HIGHLIGHT_PERIOD),
535 |highlight, delta| highlight.opacity(highlight_opacity(delta)),
536 )
537}
538
539fn highlight_opacity(delta: f32) -> f32 {
540 let fade_in = (delta / HIGHLIGHT_FADE_IN).min(1.);
541 let fade_out = ((1. - delta) / HIGHLIGHT_FADE_OUT).min(1.);
542 ease_in_out(fade_in.min(fade_out))
543}
544
513fn receipt_fade_in(message_key: &str, check: Div) -> AnimationElement<Div> {
545fn receipt_fade_in(message_key: &str, check: Div) -> AnimationElement<Div> {
514 check.with_animation(
546 check.with_animation(
515 SharedString::from(format!("receipt-fade/{message_key}")),
547 SharedString::from(format!("receipt-fade/{message_key}")),
@@ -800,6 +832,7 @@ pub fn render_message_row(
800 reaction_proposal,
832 reaction_proposal,
801 undo_delete,
833 undo_delete,
802 compact,
834 compact,
835 highlighted,
803 };
836 };
804 let own = row.own;
837 let own = row.own;
805 let spacing = px(row_spacing(row.series.has_prev, compact));
838 let spacing = px(row_spacing(row.series.has_prev, compact));
@@ -833,9 +866,6 @@ pub fn render_message_row(
833 div()
866 div()
834 .w_full()
867 .w_full()
835 .rounded(px(10.))
868 .rounded(px(10.))
836 .when(highlighted, |element| {
837 element.bg(theme::accent().opacity(0.2))
838 })
839 .when(checked && !highlighted, |element| {
869 .when(checked && !highlighted, |element| {
840 element.bg(theme::accent().opacity(SELECTED_TINT))
870 element.bg(theme::accent().opacity(SELECTED_TINT))
841 })
871 })
@@ -892,6 +922,19 @@ pub fn select_box(checked: bool, blocked: bool, index: usize) -> Div {
892 .when(blocked, |element| element.opacity(SELECT_BLOCKED_OPACITY))
922 .when(blocked, |element| element.opacity(SELECT_BLOCKED_OPACITY))
893}
923}
894
924
925#[cfg(test)]
926mod highlight_tests {
927 use super::highlight_opacity;
928
929 #[test]
930 fn jump_highlight_fades_in_holds_and_fades_out() {
931 assert_eq!(highlight_opacity(0.), 0.);
932 assert_eq!(highlight_opacity(0.5), 1.);
933 assert!(highlight_opacity(0.8) < 1.);
934 assert!(highlight_opacity(0.99) < 0.05);
935 }
936}
937
895#[cfg(test)]
938#[cfg(test)]
896mod density_tests {
939mod density_tests {
897 use super::{META_BOTTOM_INSET, bubble_padding_y, row_spacing, runway_width};
940 use super::{META_BOTTOM_INSET, bubble_padding_y, row_spacing, runway_width};