BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / views / message_row.rs

message_row.rs

message_row.rs 24.0 KiB Download Raw
1use gpui_kit::assets::IconName;
2use gpui_kit::component::{Icon, h_flex, v_flex};
3use gpui_kit::prelude::FluentBuilder as _;
4use gpui_kit::*;
5use std::time::Duration;
6
7use super::adaptive_card::cards_view;
8use super::attachments::{FileActions, ImageActions, attachments_view, message_body};
9use super::avatar::{bot_avatar, person_avatar};
10use super::call_card::{CallActions, call_card_row};
11use super::jumbo_emoji::jumbo_row;
12use super::link_preview::{link_preview_card, meeting_join_chip};
13use super::message_actions::{MessageMenu, message_toolbar};
14use super::profile_card::opens_profile;
15use super::reaction_picker::PickHandler;
16use super::reaction_pills::{ReactionControls, reaction_pills};
17use super::reaction_proposal_pill::{ReactionPill, reaction_pill};
18use super::scheduled_toolbar::{ScheduledMenu, scheduled_toolbar};
19use super::toolbar_placement::{HoverChange, TimelineBounds, placed_toolbar};
20use super::translation_line::{TranslationActions, translation_line};
21use super::widgets::{icon, symbol};
22use crate::agents::{AgentRun, run_chip};
23use crate::card_state::BotIdentity;
24use crate::data::Directory;
25use crate::importance::importance_label;
26use crate::render::Block;
27use crate::restorable_deletes::{DELETED_TOMBSTONE, UNDO_DELETE_LABEL};
28use crate::rows::{Delivery, MessageRow, Receipt, ScheduledState, Skeleton, bubble_corners};
29use crate::sidebar_model::DELETED_PREVIEW;
30use crate::theme;
31use app_ui_kit::layout::ROW_PADDING;
32
33pub type RowAction = Option<Box<dyn Fn(&mut App)>>;
34pub type SharedRowAction = Option<std::rc::Rc<dyn Fn(&mut App)>>;
35
36pub const BUBBLE_TAGS: [&str; 12] = [
37 "message-bubble/0",
38 "message-bubble/1",
39 "message-bubble/2",
40 "message-bubble/3",
41 "message-bubble/4",
42 "message-bubble/5",
43 "message-bubble/6",
44 "message-bubble/7",
45 "message-bubble/8",
46 "message-bubble/9",
47 "message-bubble/10",
48 "message-bubble/11",
49];
50pub const IMPORTANCE_LABEL_TAG: &str = "message-importance-label";
51pub(super) const AVATAR_SIZE: f32 = 28.;
52pub(super) const AVATAR_GAP: f32 = 8.;
53const SERIES_START_GAP: f32 = 8.;
54pub(super) const BODY_SIZE: f32 = 13.5;
55const MAX_WIDTH_RATIO: f32 = 0.7;
56const NARROW_BUBBLE_WIDTH: f32 = 300.;
57const BUBBLE_PADDING_Y: f32 = 8.;
58const META_BOTTOM_INSET: f32 = 4.;
59const META_SIZE: f32 = 11.;
60const META_CHECK_SIZE: f32 = 15.;
61const SAVED_MARK_SIZE: f32 = 12.;
62const FORWARDED_SIZE: f32 = 11.;
63const IMPORTANCE_LABEL_SIZE: f32 = 12.;
64pub(super) const BUBBLE_PADDING_X: f32 = 12.;
65const FIGURE_SPACE_WIDTH: f32 = 7.4;
66const PULSE_PERIOD: Duration = Duration::from_millis(1600);
67const RECEIPT_FADE_PERIOD: Duration = Duration::from_millis(600);
68const SKELETON_LINE_HEIGHT: f32 = 20.;
69
70pub struct DeliveryActions {
71 pub retry: RowAction,
72 pub delete: RowAction,
73 pub send_now: RowAction,
74}
75
76pub struct RowActions {
77 pub bot: Option<BotIdentity>,
78 pub delivery: DeliveryActions,
79 pub reply: RowAction,
80 pub hovered: Option<HoverChange>,
81 pub menu: Option<MessageMenu>,
82 pub scheduled_menu: Option<ScheduledMenu>,
83 pub react: Option<PickHandler>,
84 pub reaction_controls: Option<ReactionControls>,
85 pub files: Option<FileActions>,
86 pub open_image: Option<ImageActions>,
87 pub highlighted: bool,
88 pub saved: bool,
89 pub pinned: bool,
90 pub translation: Option<TranslationActions>,
91 pub timeline: TimelineBounds,
92 pub agent_run: Option<AgentRun>,
93 pub call: CallActions,
94 pub reaction_proposal: Option<ReactionPill>,
95 pub undo_delete: SharedRowAction,
96}
97
98const TOOLBAR_RIGHT_INSET: f32 = 0.;
99
100fn separator_pill(label: &str, fill: Hsla, text_color: Hsla) -> Div {
101 h_flex()
102 .w_full()
103 .justify_center()
104 .mt(px(12.))
105 .mb(px(6.))
106 .child(
107 div()
108 .h(px(24.))
109 .px(px(8.))
110 .flex()
111 .items_center()
112 .rounded(px(12.))
113 .bg(fill)
114 .text_size(px(11.))
115 .text_color(text_color)
116 .child(label.to_owned()),
117 )
118}
119
120pub(super) fn day_separator(label: &str) -> Div {
121 separator_pill(label, theme::row_hover(), theme::text_muted())
122}
123
124pub(super) fn new_marker() -> Div {
125 separator_pill(
126 "New",
127 theme::mention_background(false),
128 theme::accent_text(),
129 )
130}
131
132pub(super) fn deleted_tombstone(index: usize, undo_delete: SharedRowAction) -> Div {
133 let line =
134 h_flex()
135 .gap(px(8.))
136 .items_baseline()
137 .text_size(px(13.))
138 .child(div().italic().text_color(theme::text_muted()).child(
139 if undo_delete.is_some() {
140 DELETED_TOMBSTONE
141 } else {
142 DELETED_PREVIEW
143 },
144 ));
145 match undo_delete {
146 Some(undo) => line.child(
147 div()
148 .id(ElementId::Name(format!("undo-delete-{index}").into()))
149 .cursor_pointer()
150 .font_weight(FontWeight::SEMIBOLD)
151 .text_color(theme::accent_text())
152 .hover(|link| link.underline())
153 .child(UNDO_DELETE_LABEL)
154 .on_click(move |_, _, cx| undo(cx)),
155 ),
156 None => line,
157 }
158}
159
160fn bubble_max_width(timeline: &TimelineBounds, reserved: f32) -> Length {
161 let Some(bounds) = timeline.get() else {
162 return relative(MAX_WIDTH_RATIO).into();
163 };
164 let row_width = (f32::from(bounds.size.width) - 2. * ROW_PADDING - reserved).max(0.);
165 px((row_width * MAX_WIDTH_RATIO).max(row_width.min(NARROW_BUBBLE_WIDTH))).into()
166}
167
168fn bubble(
169 row: &MessageRow,
170 index: usize,
171 own: bool,
172 directory: &Directory,
173 extras: BubbleExtras,
174 cx: &App,
175) -> Stateful<Div> {
176 let corners = bubble_corners(own, row.series);
177 let jumbo = row.jumbo.as_deref().filter(|_| {
178 !row.deleted && matches!(row.delivery, Delivery::Delivered | Delivery::Sending)
179 });
180 let mut element = div()
181 .id(ElementId::Name(format!("bubble-{index}").into()))
182 .when_some(extras.hover.clone(), |element, hover| {
183 element.on_hover(move |is_hovered, _, cx| hover(*is_hovered, cx))
184 })
185 .relative()
186 .max_w_full()
187 .when_some(BUBBLE_TAGS.get(index).copied(), |element, tag| {
188 element.debug_selector(|| tag.into())
189 })
190 .when(jumbo.is_none(), |element| {
191 element
192 .rounded_tl(px(corners.top_left))
193 .rounded_tr(px(corners.top_right))
194 .rounded_br(px(corners.bottom_right))
195 .rounded_bl(px(corners.bottom_left))
196 .px(px(BUBBLE_PADDING_X))
197 .py(px(BUBBLE_PADDING_Y))
198 })
199 .text_size(px(BODY_SIZE))
200 .line_height(relative(1.45));
201 if row.deleted {
202 return element
203 .border_1()
204 .border_color(theme::border_strong())
205 .py(px(6.))
206 .child(deleted_tombstone(index, extras.undo_delete));
207 }
208 let failed = matches!(row.delivery, Delivery::Failed(_));
209 let scheduled = matches!(row.delivery, Delivery::Scheduled(_));
210 element = element
211 .when(!scheduled && jumbo.is_none(), |bubble| {
212 bubble.bg(if own && !failed {
213 theme::bubble_own()
214 } else {
215 theme::bubble_other()
216 })
217 })
218 .when(failed, |bubble| {
219 bubble.border_1().border_color(theme::red())
220 })
221 .when(scheduled, |bubble| {
222 bubble.border_1().border_color(
223 if row.delivery == Delivery::Scheduled(ScheduledState::DeliveryFailed) {
224 theme::red()
225 } else {
226 theme::accent()
227 },
228 )
229 });
230 let has_reactions = !row.reactions.is_empty();
231 let saved = extras.saved;
232 let mut content = v_flex().gap(px(6.));
233 content = content.children(importance_header(row));
234 if row.forwarded {
235 content = content.child(forwarded_header());
236 }
237 let attachments = attachments_view(
238 &row.blocks,
239 &row.images,
240 &row.local_images,
241 &row.files,
242 &format!("message-{index}"),
243 directory,
244 extras.files.as_ref(),
245 extras.open_image.as_ref(),
246 );
247 let cards = cards_view(&row.adaptive_cards, &row.conversation_id, &row.key, cx);
248 let trailing_content = attachments.is_some()
249 || row.meeting_link.is_some()
250 || row.link_preview.is_some()
251 || !cards.is_empty();
252 let padded_blocks = if has_reactions || trailing_content || jumbo.is_some() {
253 None
254 } else {
255 with_meta_room(&row.blocks, meta_room(row, own, saved))
256 };
257 let meta_inline = has_text(row) && padded_blocks.is_some();
258 if let Some(jumbo) = jumbo {
259 content = content.child(jumbo_row(&row.key, jumbo, own));
260 } else if has_text(row) {
261 content = content.children(message_body(
262 padded_blocks.as_deref().unwrap_or(&row.blocks),
263 &row.images,
264 &row.local_images,
265 &format!("message-{index}"),
266 own,
267 directory,
268 extras.open_image.as_ref(),
269 cx,
270 ));
271 }
272 content = content.children(attachments);
273 content = content.children(
274 row.meeting_link
275 .clone()
276 .map(|url| meeting_join_chip(format!("message-{index}-join"), url)),
277 );
278 content = content.children(row.link_preview.as_ref().map(|preview| {
279 link_preview_card(
280 preview,
281 format!("message-{index}-link"),
282 directory,
283 false,
284 None,
285 )
286 }));
287 content = content.children(cards);
288 if has_reactions {
289 content = content.child(
290 h_flex()
291 .gap(px(8.))
292 .items_end()
293 .child(
294 reaction_pills(
295 &row.reactions,
296 index,
297 own,
298 directory,
299 extras.react.clone(),
300 extras.controls.as_ref(),
301 )
302 .flex_auto(),
303 )
304 .child(
305 h_flex()
306 .flex_none()
307 .mb(px(META_BOTTOM_INSET - BUBBLE_PADDING_Y))
308 .child(bubble_meta(row, own, saved)),
309 ),
310 );
311 } else if !meta_inline {
312 content = content.child(h_flex().justify_end().child(bubble_meta(row, own, saved)));
313 }
314 element = element.child(content);
315 if meta_inline {
316 element = element.child(
317 div()
318 .absolute()
319 .right(px(8.))
320 .bottom(px(META_BOTTOM_INSET))
321 .child(bubble_meta(row, own, saved)),
322 );
323 }
324 if let Some(menu) = extras.menu {
325 element = element.child(placed_toolbar(
326 message_toolbar(menu, cx),
327 extras.timeline.clone(),
328 TOOLBAR_RIGHT_INSET,
329 ));
330 }
331 if let Some(menu) = extras.scheduled_menu {
332 element = element.child(placed_toolbar(
333 scheduled_toolbar(menu),
334 extras.timeline.clone(),
335 TOOLBAR_RIGHT_INSET,
336 ));
337 }
338 element
339}
340
341#[derive(Default)]
342struct BubbleExtras {
343 hover: Option<HoverChange>,
344 menu: Option<MessageMenu>,
345 scheduled_menu: Option<ScheduledMenu>,
346 react: Option<PickHandler>,
347 controls: Option<ReactionControls>,
348 files: Option<FileActions>,
349 open_image: Option<ImageActions>,
350 saved: bool,
351 translation: Option<TranslationActions>,
352 timeline: TimelineBounds,
353 agent_run: Option<AgentRun>,
354 reaction_proposal: Option<ReactionPill>,
355 undo_delete: SharedRowAction,
356}
357
358fn agent_chip(run: Option<AgentRun>) -> Option<Div> {
359 run.map(|run| div().py(px(2.)).child(run_chip(&run, theme::row_hover())))
360}
361
362/// Teams: bold "Important!" / "Urgent!" in capitals above the message text.
363pub(super) fn importance_header(row: &MessageRow) -> Option<Div> {
364 let label = importance_label(row.importance)?;
365 Some(
366 div()
367 .debug_selector(|| IMPORTANCE_LABEL_TAG.into())
368 .text_size(px(IMPORTANCE_LABEL_SIZE))
369 .line_height(px(16.))
370 .font_weight(FontWeight::BOLD)
371 .text_color(theme::red())
372 .child(label),
373 )
374}
375
376pub(super) fn forwarded_header() -> Div {
377 h_flex()
378 .gap(px(4.))
379 .items_center()
380 .text_size(px(FORWARDED_SIZE))
381 .text_color(theme::text_muted())
382 .child(icon(IconName::Forward, FORWARDED_SIZE, theme::text_muted()))
383 .child("Forwarded")
384}
385
386fn bubble_meta(row: &MessageRow, own: bool, saved: bool) -> Div {
387 let tint = if own {
388 theme::own_meta()
389 } else {
390 theme::text_muted()
391 };
392 h_flex()
393 .gap(px(4.))
394 .items_center()
395 .text_size(px(META_SIZE))
396 .line_height(px(14.))
397 .italic()
398 .text_color(tint)
399 .when(row.edited, |meta| meta.child("Edited"))
400 .when(saved, |meta| {
401 meta.child(icon(
402 IconName::Bookmark,
403 SAVED_MARK_SIZE,
404 theme::accent_text(),
405 ))
406 })
407 .child(row.time.clone())
408 .when(own && row.delivery == Delivery::Sending, |meta| {
409 meta.child(symbol("schedule", META_CHECK_SIZE, tint))
410 })
411 .when(matches!(row.delivery, Delivery::Scheduled(_)), |meta| {
412 meta.child(symbol("schedule", META_SIZE + 3., tint))
413 })
414 .when(
415 own && row.delivery == Delivery::Delivered,
416 |meta| match row.receipt {
417 Receipt::Hidden => meta,
418 Receipt::Sent => meta.child(on_baseline(symbol("done", META_CHECK_SIZE, tint))),
419 Receipt::Read => meta.child(on_baseline(symbol(
420 "done_all",
421 META_CHECK_SIZE,
422 theme::own_read(),
423 ))),
424 Receipt::ReadLive => meta.child(receipt_fade_in(
425 &row.key,
426 on_baseline(symbol("done_all", META_CHECK_SIZE, theme::own_read())),
427 )),
428 },
429 )
430}
431
432fn on_baseline(check: Icon) -> Div {
433 div().relative().top(px(1.)).child(check)
434}
435
436fn pulse<E: IntoElement + Styled + 'static>(id: &'static str, element: E) -> AnimationElement<E> {
437 element.with_animation(
438 id,
439 Animation::new(PULSE_PERIOD)
440 .repeat_synced()
441 .with_easing(pulsating_between(0.35, 1.)),
442 |element, opacity| element.opacity(opacity),
443 )
444}
445
446fn receipt_fade_in(message_key: &str, check: Div) -> AnimationElement<Div> {
447 check.with_animation(
448 SharedString::from(format!("receipt-fade/{message_key}")),
449 Animation::new(RECEIPT_FADE_PERIOD).with_easing(ease_in_out),
450 |check, delta| check.opacity(0.25 + 0.75 * delta),
451 )
452}
453
454pub fn render_skeleton_row(skeleton: &Skeleton, index: usize) -> AnyElement {
455 let corners = bubble_corners(skeleton.own, Default::default());
456 let height = 14. + SKELETON_LINE_HEIGHT * f32::from(skeleton.lines);
457 let shape = div()
458 .w(relative(skeleton.width_ratio))
459 .h(px(height))
460 .rounded_tl(px(corners.top_left))
461 .rounded_tr(px(corners.top_right))
462 .rounded_br(px(corners.bottom_right))
463 .rounded_bl(px(corners.bottom_left))
464 .bg(if skeleton.own {
465 theme::bubble_own().opacity(0.55)
466 } else {
467 theme::bubble_other()
468 });
469 let line = h_flex()
470 .w_full()
471 .when(skeleton.own, |line| line.justify_end())
472 .when(!skeleton.own, |line| {
473 line.gap(px(AVATAR_GAP)).child(
474 div()
475 .size(px(AVATAR_SIZE))
476 .flex_none()
477 .rounded_full()
478 .bg(theme::bubble_other()),
479 )
480 })
481 .child(shape);
482 div()
483 .id(ElementId::Name(format!("row-{index}").into()))
484 .w_full()
485 .px(px(ROW_PADDING))
486 .pt(px(SERIES_START_GAP))
487 .child(pulse("skeleton", line))
488 .into_any_element()
489}
490
491fn meta_room(row: &MessageRow, own: bool, saved: bool) -> usize {
492 let mut width = 12. + row.time.chars().count() as f32 * 6.;
493 if saved {
494 width += SAVED_MARK_SIZE + 4.;
495 }
496 if row.edited {
497 width += 56.;
498 }
499 if own {
500 width += META_CHECK_SIZE + 4.;
501 }
502 (width / FIGURE_SPACE_WIDTH).ceil() as usize
503}
504
505fn with_meta_room(blocks: &[Block], room: usize) -> Option<Vec<Block>> {
506 let mut padded = blocks.to_vec();
507 let inline = padded.last_mut()?.last_inline_mut()?;
508 *inline = inline.with_trailing_room(room);
509 Some(padded)
510}
511
512pub(super) fn has_text(row: &MessageRow) -> bool {
513 !row.blocks.is_empty()
514 || (row.images.is_empty()
515 && row.local_images.is_empty()
516 && row.files.is_empty()
517 && row.adaptive_cards.is_empty())
518}
519
520fn delivery_link(
521 index: usize,
522 name: &str,
523 label: &'static str,
524 action: RowAction,
525) -> Stateful<Div> {
526 div()
527 .id(ElementId::Name(format!("{name}-{index}").into()))
528 .cursor_pointer()
529 .text_color(theme::red_tint())
530 .underline()
531 .child(label)
532 .when_some(action, |link, action| {
533 link.on_click(move |_, _, cx| action(cx))
534 })
535}
536
537pub(super) fn delivery_note(
538 row: &MessageRow,
539 delivery: DeliveryActions,
540 index: usize,
541) -> Option<AnyElement> {
542 let DeliveryActions {
543 retry,
544 delete,
545 send_now,
546 } = delivery;
547 let note = |text: &'static str| {
548 h_flex()
549 .gap(px(4.))
550 .text_size(px(11.))
551 .text_color(theme::red_soft())
552 .child(text)
553 };
554 match &row.delivery {
555 Delivery::Delivered | Delivery::Sending | Delivery::Scheduled(ScheduledState::Waiting) => {
556 None
557 }
558 Delivery::Failed(_) => Some(
559 note("Failed to send.")
560 .child(delivery_link(index, "retry", "Retry", retry))
561 .child(delivery_link(index, "delete", "Delete", delete))
562 .into_any_element(),
563 ),
564 Delivery::Scheduled(ScheduledState::DeliveryFailed) => Some(
565 note("Couldn't send at the scheduled time.")
566 .child(delivery_link(index, "send-now", "Send now", send_now))
567 .child(delivery_link(index, "delete", "Delete", delete))
568 .into_any_element(),
569 ),
570 Delivery::Scheduled(ScheduledState::ChangeFailed) => Some(
571 note("Couldn't change the scheduled message.")
572 .child(delivery_link(index, "retry", "Retry", retry))
573 .into_any_element(),
574 ),
575 }
576}
577
578fn others_row(
579 row: &MessageRow,
580 index: usize,
581 directory: &Directory,
582 bot: Option<&BotIdentity>,
583 delivery: DeliveryActions,
584 mut extras: BubbleExtras,
585 cx: &App,
586) -> Div {
587 let translation = extras.translation.take();
588 let agent_run = extras.agent_run.take();
589 let reaction_proposal = extras.reaction_proposal.take();
590 let first = !row.series.has_prev;
591 let author = bot.map_or_else(|| row.author.clone(), |bot| bot.name.clone());
592 let profile_user = row.sender_id.as_deref().filter(|_| bot.is_none());
593 let mut column = v_flex()
594 .gap(px(2.))
595 .flex_1()
596 .min_w_0()
597 .max_w(bubble_max_width(&extras.timeline, AVATAR_SIZE + AVATAR_GAP))
598 .items_start();
599 if first {
600 column = column.child(
601 h_flex().gap(px(8.)).items_baseline().pl(px(2.)).child(
602 opens_profile(
603 div().id(ElementId::Name(format!("author-{index}").into())),
604 profile_user,
605 )
606 .text_size(px(12.))
607 .font_weight(FontWeight::SEMIBOLD)
608 .text_color(theme::text_soft())
609 .child(author.clone()),
610 ),
611 );
612 }
613 column = column.child(bubble(row, index, false, directory, extras, cx));
614 column = column.children(agent_chip(agent_run));
615 column = column.children(reaction_proposal.map(|pill| reaction_pill(pill, &row.key)));
616 column = column.children(translation_line(row, index, translation.as_ref()));
617 if let Some(note) = delivery_note(row, delivery, index) {
618 column = column.child(note);
619 }
620 let lead = if let Some(bot) = bot.filter(|_| first) {
621 bot_avatar(bot, AVATAR_SIZE)
622 } else if first {
623 person_avatar(
624 directory,
625 row.sender_id.as_deref(),
626 &row.author,
627 AVATAR_SIZE,
628 )
629 } else {
630 div().size(px(AVATAR_SIZE)).into_any_element()
631 };
632 h_flex()
633 .w_full()
634 .gap(px(AVATAR_GAP))
635 .items_start()
636 .child(
637 opens_profile(
638 div().id(ElementId::Name(format!("author-avatar-{index}").into())),
639 profile_user.filter(|_| first),
640 )
641 .w(px(AVATAR_SIZE))
642 .flex_none()
643 .child(lead),
644 )
645 .child(column)
646}
647
648fn own_row(
649 row: &MessageRow,
650 index: usize,
651 directory: &Directory,
652 delivery: DeliveryActions,
653 mut extras: BubbleExtras,
654 cx: &App,
655) -> Div {
656 let translation = extras.translation.take();
657 let agent_run = extras.agent_run.take();
658 let reaction_proposal = extras.reaction_proposal.take();
659 let mut column = v_flex().w_full().items_end().gap(px(2.));
660 column = column.child(
661 h_flex().w_full().justify_end().child(
662 div()
663 .min_w_0()
664 .max_w(bubble_max_width(&extras.timeline, 0.))
665 .child(bubble(row, index, true, directory, extras, cx)),
666 ),
667 );
668 column = column.children(agent_chip(agent_run));
669 column = column.children(reaction_proposal.map(|pill| reaction_pill(pill, &row.key)));
670 column = column.children(translation_line(row, index, translation.as_ref()));
671 if let Some(note) = delivery_note(row, delivery, index) {
672 column = column.child(note);
673 }
674 column
675}
676
677pub fn render_message_row(
678 row: &MessageRow,
679 index: usize,
680 actions: RowActions,
681 directory: &Directory,
682 cx: &App,
683) -> AnyElement {
684 if let Some(call) = &row.call {
685 return call_card_row(row, call, index, directory, actions.call);
686 }
687 let RowActions {
688 bot,
689 delivery,
690 reply,
691 hovered,
692 menu,
693 scheduled_menu,
694 react,
695 reaction_controls,
696 files,
697 open_image,
698 highlighted,
699 saved,
700 translation,
701 timeline,
702 agent_run,
703 call: _,
704 pinned: _,
705 reaction_proposal,
706 undo_delete,
707 } = actions;
708 let extras = BubbleExtras {
709 hover: hovered,
710 menu,
711 scheduled_menu,
712 react,
713 controls: reaction_controls,
714 files,
715 open_image,
716 saved,
717 translation,
718 timeline,
719 agent_run,
720 reaction_proposal,
721 undo_delete,
722 };
723 let own = row.own;
724 let spacing = if row.series.has_prev {
725 px(2.)
726 } else {
727 px(SERIES_START_GAP)
728 };
729 let mut container = v_flex().w_full().px(px(ROW_PADDING));
730 if let Some(day) = &row.day_header {
731 container = container.child(day_separator(day));
732 }
733 if row.new_marker {
734 container = container.child(new_marker());
735 }
736 let body = if own {
737 own_row(row, index, directory, delivery, extras, cx)
738 } else {
739 others_row(row, index, directory, bot.as_ref(), delivery, extras, cx)
740 };
741 container
742 .child(
743 div()
744 .id(ElementId::Name(format!("row-{index}").into()))
745 .w_full()
746 .pt(spacing)
747 .when_some(reply, |element, reply| {
748 element.on_mouse_down(MouseButton::Right, move |_, _, cx| reply(cx))
749 })
750 .child(
751 div()
752 .w_full()
753 .rounded(px(10.))
754 .when(highlighted, |element| {
755 element.bg(theme::accent().opacity(0.2))
756 })
757 .child(body),
758 ),
759 )
760 .into_any_element()
761}