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>
@@ -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, ReplyPrevi57
use super::find_panel::{FIND_PANEL_WIDTH, FindPanel, FindPanelEvent};57
use super::find_panel::{FIND_PANEL_WIDTH, FindPanel, FindPanelEvent};58
use super::group_name::group_name_button;58
use super::group_name::group_name_button;59
use super::message_actions::{Action, DelegateEntry, MessageMenu};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
use super::new_chat::{NewChatDraft, NewChatEvent, Pick, composer_placeholder};63
use super::new_chat::{NewChatDraft, NewChatEvent, Pick, composer_placeholder};62
use super::pin_banner::{pin_banner_inset, pin_banner_overlay};64
use super::pin_banner::{pin_banner_inset, pin_banner_overlay};63
use super::post_card::render_post;65
use super::post_card::render_post;@@ -126,7 +128,6 @@ const DEMO_DOWNLOAD_STEPS: u8 = 10;126
const DEMO_DOWNLOAD_STEP: Duration = Duration::from_millis(100);128
const DEMO_DOWNLOAD_STEP: Duration = Duration::from_millis(100);127
const JUMP_SCAN_LIMIT: usize = 5000;129
const JUMP_SCAN_LIMIT: usize = 5000;128
const JUMP_CONTEXT_MESSAGES: usize = 12;130
const JUMP_CONTEXT_MESSAGES: usize = 12;129
const HIGHLIGHT_DURATION: Duration = Duration::from_secs(2);130
const PROGRESS_DELAY: Duration = Duration::from_millis(400);131
const PROGRESS_DELAY: Duration = Duration::from_millis(400);131
const SLOW_AFTER: Duration = Duration::from_secs(8);132
const SLOW_AFTER: Duration = Duration::from_secs(8);132
const PROGRESS_MIN_VISIBLE: Duration = Duration::from_millis(500);133
const 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;@@ -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;25
use crate::importance::importance_label;25
use crate::importance::importance_label;26
use crate::render::Block;26
use crate::render::Block;27
use crate::restorable_deletes::{DELETED_TOMBSTONE, UNDO_DELETE_LABEL};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
use crate::sidebar_model::DELETED_PREVIEW;31
use crate::sidebar_model::DELETED_PREVIEW;30
use crate::theme;32
use crate::theme;31
use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, ROW_PADDING};33
use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, ROW_PADDING};@@ -71,6 +73,10 @@ pub(super) const BUBBLE_PADDING_X: f32 = 12.;71
const FIGURE_SPACE_WIDTH: f32 = 7.4;73
const FIGURE_SPACE_WIDTH: f32 = 7.4;72
const PULSE_PERIOD: Duration = Duration::from_millis(1600);74
const PULSE_PERIOD: Duration = Duration::from_millis(1600);73
const RECEIPT_FADE_PERIOD: Duration = Duration::from_millis(600);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
const SKELETON_LINE_HEIGHT: f32 = 20.;80
const SKELETON_LINE_HEIGHT: f32 = 20.;75
pub const SELECT_BOX_SIZE: f32 = 16.;81
pub const SELECT_BOX_SIZE: f32 = 16.;76
pub const SELECT_GAP: f32 = 12.;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
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
410
fn agent_chip(run: Option<AgentRun>) -> Option<Div> {420
fn agent_chip(run: Option<AgentRun>) -> Option<Div> {@@ -510,6 +520,28 @@ fn pulse<E: IntoElement + Styled + 'static>(id: &'static str, element: E) -> Ani510
)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
fn receipt_fade_in(message_key: &str, check: Div) -> AnimationElement<Div> {545
fn 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)]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
#[cfg(test)]938
#[cfg(test)]896
mod density_tests {939
mod 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};