fix(chat): bubbles, link previews and file cards fit narrow chat panels
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -1293,6 +1293,31 @@ fn standup_messages() -> Vec<MessageRecord> {
1293
1293
"[]",
1294
1294
false,
1295
1295
),
1296
with_links(
1297
message(
1298
"demo-chat-meeting-standup",
1299
"su3",
1300
None,
1301
jonas,
1302
at(0, 9, 50),
1303
"<p><a href=\"https://example.com/checklist\">https://example.com/checklist</a></p>",
1304
"[]",
1305
false,
1306
),
1307
link_preview("https://example.com/checklist")
1308
.map(|preview| preview.links_json())
1309
.unwrap_or_default(),
1310
),
1311
message(
1312
"demo-chat-meeting-standup",
1313
"su4",
1314
None,
1315
priya,
1316
at(0, 9, 52),
1317
"<p>I will quickly fix the comments and then push the final version before the review starts.</p>",
1318
"[]",
1319
false,
1320
),
1296
1321
]
1297
1322
}
1298
1323
@@ -1293,6 +1293,31 @@ fn standup_messages() -> Vec<MessageRecord> {1293
"[]",1293
"[]",1294
false,1294
false,1295
),1295
),1296
with_links(1297
message(1298
"demo-chat-meeting-standup",1299
"su3",1300
None,1301
jonas,1302
at(0, 9, 50),1303
"<p><a href=\"https://example.com/checklist\">https://example.com/checklist</a></p>",1304
"[]",1305
false,1306
),1307
link_preview("https://example.com/checklist")1308
.map(|preview| preview.links_json())1309
.unwrap_or_default(),1310
),1311
message(1312
"demo-chat-meeting-standup",1313
"su4",1314
None,1315
priya,1316
at(0, 9, 52),1317
"<p>I will quickly fix the comments and then push the final version before the review starts.</p>",1318
"[]",1319
false,1320
),1296
]1321
]1297
}1322
}1298
1323
@@ -130,6 +130,8 @@ mod frames {
130
130
use crate::demo;
131
131
use crate::user_activity::UserInput;
132
132
use crate::views::call_transcript::TranscriptPanel;
133
use crate::views::call_view::CHAT_PANEL_TAG;
134
use crate::views::message_row::BUBBLE_TAGS;
133
135
use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};
134
136
use crate::views::reaction_proposal_pill::REACTION_PILL;
135
137
use crate::views::recap_tab::RECAP_REGION;
@@ -640,6 +642,52 @@ mod frames {
640
642
.join("\n")
641
643
);
642
644
}
645
#[gpui_kit::test]
646
fn call_chat_bubbles_stay_inside_the_panel(cx: &mut TestAppContext) {
647
let (handle, app) = mount(cx);
648
let mut visual = VisualTestContext::from_window(handle, cx);
649
for (width, height) in SIZES {
650
visual.simulate_resize(size(px(width), px(height)));
651
visual.update(|_, cx| {
652
app.update(cx, |state, cx| {
653
let mut call = gallery_call();
654
call.conversation_id = Some(RECAP_MEETING_CHAT.to_owned());
655
call.chat_open = true;
656
state.call = Some(call);
657
cx.notify();
658
})
659
});
660
collect(&mut visual, Some(CHAT_PANEL_TAG));
661
let panel = visual
662
.debug_bounds(CHAT_PANEL_TAG)
663
.expect("chat panel rendered");
664
let bubbles: Vec<(usize, Bounds<Pixels>)> = BUBBLE_TAGS
665
.iter()
666
.enumerate()
667
.filter_map(|(index, tag)| visual.debug_bounds(tag).map(|bounds| (index, bounds)))
668
.collect();
669
assert!(!bubbles.is_empty(), "no bubbles rendered in the call chat");
670
let found: Vec<String> = bubbles
671
.into_iter()
672
.filter(|(_, bounds)| !contains(panel, *bounds))
673
.map(|(index, bounds)| {
674
format!(
675
"call-chat@{width}x{height}: bubble {index} {} leaves the chat panel {}",
676
describe(bounds),
677
describe(panel)
678
)
679
})
680
.collect();
681
visual.update(|_, cx| {
682
app.update(cx, |state, cx| {
683
state.call = None;
684
cx.notify();
685
})
686
});
687
assert!(found.is_empty(), "{}", found.join("\n"));
688
}
689
}
690
643
691
#[gpui_kit::test]
644
692
fn recap_tab_stays_inside_the_main_island(cx: &mut TestAppContext) {
645
693
let (handle, state) = mount(cx);
@@ -130,6 +130,8 @@ mod frames {130
use crate::demo;130
use crate::demo;131
use crate::user_activity::UserInput;131
use crate::user_activity::UserInput;132
use crate::views::call_transcript::TranscriptPanel;132
use crate::views::call_transcript::TranscriptPanel;133
use crate::views::call_view::CHAT_PANEL_TAG;134
use crate::views::message_row::BUBBLE_TAGS;133
use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};135
use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};134
use crate::views::reaction_proposal_pill::REACTION_PILL;136
use crate::views::reaction_proposal_pill::REACTION_PILL;135
use crate::views::recap_tab::RECAP_REGION;137
use crate::views::recap_tab::RECAP_REGION;@@ -640,6 +642,52 @@ mod frames {640
.join("\n")642
.join("\n")641
);643
);642
}644
}645
#[gpui_kit::test]646
fn call_chat_bubbles_stay_inside_the_panel(cx: &mut TestAppContext) {647
let (handle, app) = mount(cx);648
let mut visual = VisualTestContext::from_window(handle, cx);649
for (width, height) in SIZES {650
visual.simulate_resize(size(px(width), px(height)));651
visual.update(|_, cx| {652
app.update(cx, |state, cx| {653
let mut call = gallery_call();654
call.conversation_id = Some(RECAP_MEETING_CHAT.to_owned());655
call.chat_open = true;656
state.call = Some(call);657
cx.notify();658
})659
});660
collect(&mut visual, Some(CHAT_PANEL_TAG));661
let panel = visual662
.debug_bounds(CHAT_PANEL_TAG)663
.expect("chat panel rendered");664
let bubbles: Vec<(usize, Bounds<Pixels>)> = BUBBLE_TAGS665
.iter()666
.enumerate()667
.filter_map(|(index, tag)| visual.debug_bounds(tag).map(|bounds| (index, bounds)))668
.collect();669
assert!(!bubbles.is_empty(), "no bubbles rendered in the call chat");670
let found: Vec<String> = bubbles671
.into_iter()672
.filter(|(_, bounds)| !contains(panel, *bounds))673
.map(|(index, bounds)| {674
format!(675
"call-chat@{width}x{height}: bubble {index} {} leaves the chat panel {}",676
describe(bounds),677
describe(panel)678
)679
})680
.collect();681
visual.update(|_, cx| {682
app.update(cx, |state, cx| {683
state.call = None;684
cx.notify();685
})686
});687
assert!(found.is_empty(), "{}", found.join("\n"));688
}689
}690
643
#[gpui_kit::test]691
#[gpui_kit::test]644
fn recap_tab_stays_inside_the_main_island(cx: &mut TestAppContext) {692
fn recap_tab_stays_inside_the_main_island(cx: &mut TestAppContext) {645
let (handle, state) = mount(cx);693
let (handle, state) = mount(cx);@@ -245,8 +245,8 @@ fn file_view(
245
245
.id(ElementId::Name(id.into()))
246
246
.relative()
247
247
.overflow_hidden()
248
.w(px(FILE_CARD_WIDTH))
249
.max_w(relative(1.))
248
.w_full()
249
.max_w(px(FILE_CARD_WIDTH))
250
250
.gap(px(12.))
251
251
.px(px(8.))
252
252
.py(px(8.))
@@ -245,8 +245,8 @@ fn file_view(245
.id(ElementId::Name(id.into()))245
.id(ElementId::Name(id.into()))246
.relative()246
.relative()247
.overflow_hidden()247
.overflow_hidden()248
.w(px(FILE_CARD_WIDTH))248
.w_full()249
.max_w(relative(1.))249
.max_w(px(FILE_CARD_WIDTH))250
.gap(px(12.))250
.gap(px(12.))251
.px(px(8.))251
.px(px(8.))252
.py(px(8.))252
.py(px(8.))@@ -57,6 +57,7 @@ pub(super) const GRID_PADDING: f32 = 24.;
57
57
pub(super) const STRIP_GAP: f32 = 12.;
58
58
const TILE_RADIUS: f32 = 12.;
59
59
const NAME_PLATE_BACKGROUND: f32 = 0.6;
60
pub const CHAT_PANEL_TAG: &str = "shell/islands/main/call-chat-panel";
60
61
pub const NO_MICROPHONE_HINT: &str = "No microphone found";
61
62
const AUDIO_OFF_HINT: &str = "Audio is off for this meeting";
62
63
pub const NO_CAMERA_HINT: &str = "No camera found";
@@ -1347,6 +1348,7 @@ fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElem
1347
1348
move |cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)),
1348
1349
chat,
1349
1350
)
1351
.debug_selector(|| CHAT_PANEL_TAG.into())
1350
1352
.into_any_element()
1351
1353
}
1352
1354
@@ -57,6 +57,7 @@ pub(super) const GRID_PADDING: f32 = 24.;57
pub(super) const STRIP_GAP: f32 = 12.;57
pub(super) const STRIP_GAP: f32 = 12.;58
const TILE_RADIUS: f32 = 12.;58
const TILE_RADIUS: f32 = 12.;59
const NAME_PLATE_BACKGROUND: f32 = 0.6;59
const NAME_PLATE_BACKGROUND: f32 = 0.6;60
pub const CHAT_PANEL_TAG: &str = "shell/islands/main/call-chat-panel";60
pub const NO_MICROPHONE_HINT: &str = "No microphone found";61
pub const NO_MICROPHONE_HINT: &str = "No microphone found";61
const AUDIO_OFF_HINT: &str = "Audio is off for this meeting";62
const AUDIO_OFF_HINT: &str = "Audio is off for this meeting";62
pub const NO_CAMERA_HINT: &str = "No camera found";63
pub const NO_CAMERA_HINT: &str = "No camera found";@@ -1347,6 +1348,7 @@ fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElem1347
move |cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)),1348
move |cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)),1348
chat,1349
chat,1349
)1350
)1351
.debug_selector(|| CHAT_PANEL_TAG.into())1350
.into_any_element()1352
.into_any_element()1351
}1353
}1352
1354
@@ -14,6 +14,7 @@ use crate::theme;
14
14
const CARD_WIDTH: f32 = 360.;
15
15
const THUMB_WIDTH: f32 = 112.;
16
16
const THUMB_WIDTH_COMPACT: f32 = 72.;
17
const THUMB_MAX_WIDTH_RATIO: f32 = 0.4;
17
18
const THUMB_MIN_HEIGHT: f32 = 48.;
18
19
const THUMB_MAX_HEIGHT: f32 = 112.;
19
20
const THUMB_RADIUS: f32 = 6.;
@@ -59,6 +60,7 @@ fn thumbnail(
59
60
.w(px(width))
60
61
.h(px(height))
61
62
.flex_none()
63
.max_w(relative(THUMB_MAX_WIDTH_RATIO))
62
64
.rounded(px(THUMB_RADIUS))
63
65
.overflow_hidden()
64
66
.bg(theme::background());
@@ -116,9 +118,8 @@ pub fn link_preview_card(
116
118
.id(ElementId::Name(id.clone().into()))
117
119
.relative()
118
120
.overflow_hidden()
119
.when(compact, |card| card.w_full())
120
.when(!compact, |card| card.w(px(CARD_WIDTH)))
121
.max_w(relative(1.))
121
.w_full()
122
.when(!compact, |card| card.max_w(px(CARD_WIDTH)))
122
123
.gap(px(12.))
123
124
.p(px(8.))
124
125
.items_start()
@@ -14,6 +14,7 @@ use crate::theme;14
const CARD_WIDTH: f32 = 360.;14
const CARD_WIDTH: f32 = 360.;15
const THUMB_WIDTH: f32 = 112.;15
const THUMB_WIDTH: f32 = 112.;16
const THUMB_WIDTH_COMPACT: f32 = 72.;16
const THUMB_WIDTH_COMPACT: f32 = 72.;17
const THUMB_MAX_WIDTH_RATIO: f32 = 0.4;17
const THUMB_MIN_HEIGHT: f32 = 48.;18
const THUMB_MIN_HEIGHT: f32 = 48.;18
const THUMB_MAX_HEIGHT: f32 = 112.;19
const THUMB_MAX_HEIGHT: f32 = 112.;19
const THUMB_RADIUS: f32 = 6.;20
const THUMB_RADIUS: f32 = 6.;@@ -59,6 +60,7 @@ fn thumbnail(59
.w(px(width))60
.w(px(width))60
.h(px(height))61
.h(px(height))61
.flex_none()62
.flex_none()63
.max_w(relative(THUMB_MAX_WIDTH_RATIO))62
.rounded(px(THUMB_RADIUS))64
.rounded(px(THUMB_RADIUS))63
.overflow_hidden()65
.overflow_hidden()64
.bg(theme::background());66
.bg(theme::background());@@ -116,9 +118,8 @@ pub fn link_preview_card(116
.id(ElementId::Name(id.clone().into()))118
.id(ElementId::Name(id.clone().into()))117
.relative()119
.relative()118
.overflow_hidden()120
.overflow_hidden()119
.when(compact, |card| card.w_full())121
.w_full()120
.when(!compact, |card| card.w(px(CARD_WIDTH)))122
.when(!compact, |card| card.max_w(px(CARD_WIDTH)))121
.max_w(relative(1.))122
.gap(px(12.))123
.gap(px(12.))123
.p(px(8.))124
.p(px(8.))124
.items_start()125
.items_start()@@ -27,11 +27,27 @@ use crate::theme;
27
27
28
28
pub type RowAction = Option<Box<dyn Fn(&mut App)>>;
29
29
30
pub const BUBBLE_TAGS: [&str; 12] = [
31
"message-bubble/0",
32
"message-bubble/1",
33
"message-bubble/2",
34
"message-bubble/3",
35
"message-bubble/4",
36
"message-bubble/5",
37
"message-bubble/6",
38
"message-bubble/7",
39
"message-bubble/8",
40
"message-bubble/9",
41
"message-bubble/10",
42
"message-bubble/11",
43
];
30
44
pub(super) const AVATAR_SIZE: f32 = 28.;
31
45
pub(super) const AVATAR_GAP: f32 = 8.;
32
46
const SERIES_START_GAP: f32 = 8.;
33
47
pub(super) const BODY_SIZE: f32 = 13.5;
34
48
const MAX_WIDTH_RATIO: f32 = 0.7;
49
const NARROW_BUBBLE_WIDTH: f32 = 300.;
50
const ROW_PADDING: f32 = 20.;
35
51
const REACTION_FOOTER_HEIGHT: f32 = 24.;
36
52
const META_SIZE: f32 = 11.;
37
53
const META_CHECK_SIZE: f32 = 15.;
@@ -100,6 +116,14 @@ fn new_marker() -> Div {
100
116
)
101
117
}
102
118
119
fn bubble_max_width(timeline: &TimelineBounds, reserved: f32) -> Length {
120
let Some(bounds) = timeline.get() else {
121
return relative(MAX_WIDTH_RATIO).into();
122
};
123
let row_width = (f32::from(bounds.size.width) - 2. * ROW_PADDING - reserved).max(0.);
124
px((row_width * MAX_WIDTH_RATIO).max(row_width.min(NARROW_BUBBLE_WIDTH))).into()
125
}
126
103
127
fn bubble(
104
128
row: &MessageRow,
105
129
index: usize,
@@ -115,6 +139,10 @@ fn bubble(
115
139
element.on_hover(move |is_hovered, _, cx| hover(*is_hovered, cx))
116
140
})
117
141
.relative()
142
.max_w_full()
143
.when_some(BUBBLE_TAGS.get(index).copied(), |element, tag| {
144
element.debug_selector(|| tag.into())
145
})
118
146
.rounded_tl(px(corners.top_left))
119
147
.rounded_tr(px(corners.top_right))
120
148
.rounded_br(px(corners.bottom_right))
@@ -389,7 +417,7 @@ pub fn render_skeleton_row(skeleton: &Skeleton, index: usize) -> AnyElement {
389
417
div()
390
418
.id(ElementId::Name(format!("row-{index}").into()))
391
419
.w_full()
392
.px(px(20.))
420
.px(px(ROW_PADDING))
393
421
.pt(px(SERIES_START_GAP))
394
422
.child(pulse("skeleton", line))
395
423
.into_any_element()
@@ -499,7 +527,9 @@ fn others_row(
499
527
let profile_user = row.sender_id.as_deref().filter(|_| bot.is_none());
500
528
let mut column = v_flex()
501
529
.gap(px(2.))
502
.max_w(relative(MAX_WIDTH_RATIO))
530
.flex_1()
531
.min_w_0()
532
.max_w(bubble_max_width(&extras.timeline, AVATAR_SIZE + AVATAR_GAP))
503
533
.items_start();
504
534
if first {
505
535
column = column.child(
@@ -563,9 +593,15 @@ fn own_row(
563
593
let reaction_proposal = extras.reaction_proposal.take();
564
594
let mut column = v_flex().w_full().items_end().gap(px(2.));
565
595
column = column.child(
566
div()
567
.max_w(relative(MAX_WIDTH_RATIO))
568
.child(bubble(row, index, true, directory, extras, cx)),
596
h_flex()
597
.w_full()
598
.justify_end()
599
.child(
600
div()
601
.min_w_0()
602
.max_w(bubble_max_width(&extras.timeline, 0.))
603
.child(bubble(row, index, true, directory, extras, cx)),
604
),
569
605
);
570
606
column = column.children(agent_chip(agent_run));
571
607
column = column.children(reaction_proposal.map(|pill| reaction_pill(pill, &row.key)));
@@ -621,7 +657,7 @@ pub fn render_message_row(
621
657
} else {
622
658
px(SERIES_START_GAP)
623
659
};
624
let mut container = v_flex().w_full().px(px(20.));
660
let mut container = v_flex().w_full().px(px(ROW_PADDING));
625
661
if let Some(day) = &row.day_header {
626
662
container = container.child(day_separator(day));
627
663
}
@@ -27,11 +27,27 @@ use crate::theme;27
27
28
pub type RowAction = Option<Box<dyn Fn(&mut App)>>;28
pub type RowAction = Option<Box<dyn Fn(&mut App)>>;29
29
30
pub const BUBBLE_TAGS: [&str; 12] = [31
"message-bubble/0",32
"message-bubble/1",33
"message-bubble/2",34
"message-bubble/3",35
"message-bubble/4",36
"message-bubble/5",37
"message-bubble/6",38
"message-bubble/7",39
"message-bubble/8",40
"message-bubble/9",41
"message-bubble/10",42
"message-bubble/11",43
];30
pub(super) const AVATAR_SIZE: f32 = 28.;44
pub(super) const AVATAR_SIZE: f32 = 28.;31
pub(super) const AVATAR_GAP: f32 = 8.;45
pub(super) const AVATAR_GAP: f32 = 8.;32
const SERIES_START_GAP: f32 = 8.;46
const SERIES_START_GAP: f32 = 8.;33
pub(super) const BODY_SIZE: f32 = 13.5;47
pub(super) const BODY_SIZE: f32 = 13.5;34
const MAX_WIDTH_RATIO: f32 = 0.7;48
const MAX_WIDTH_RATIO: f32 = 0.7;49
const NARROW_BUBBLE_WIDTH: f32 = 300.;50
const ROW_PADDING: f32 = 20.;35
const REACTION_FOOTER_HEIGHT: f32 = 24.;51
const REACTION_FOOTER_HEIGHT: f32 = 24.;36
const META_SIZE: f32 = 11.;52
const META_SIZE: f32 = 11.;37
const META_CHECK_SIZE: f32 = 15.;53
const META_CHECK_SIZE: f32 = 15.;@@ -100,6 +116,14 @@ fn new_marker() -> Div {100
)116
)101
}117
}102
118
119
fn bubble_max_width(timeline: &TimelineBounds, reserved: f32) -> Length {120
let Some(bounds) = timeline.get() else {121
return relative(MAX_WIDTH_RATIO).into();122
};123
let row_width = (f32::from(bounds.size.width) - 2. * ROW_PADDING - reserved).max(0.);124
px((row_width * MAX_WIDTH_RATIO).max(row_width.min(NARROW_BUBBLE_WIDTH))).into()125
}126
103
fn bubble(127
fn bubble(104
row: &MessageRow,128
row: &MessageRow,105
index: usize,129
index: usize,@@ -115,6 +139,10 @@ fn bubble(115
element.on_hover(move |is_hovered, _, cx| hover(*is_hovered, cx))139
element.on_hover(move |is_hovered, _, cx| hover(*is_hovered, cx))116
})140
})117
.relative()141
.relative()142
.max_w_full()143
.when_some(BUBBLE_TAGS.get(index).copied(), |element, tag| {144
element.debug_selector(|| tag.into())145
})118
.rounded_tl(px(corners.top_left))146
.rounded_tl(px(corners.top_left))119
.rounded_tr(px(corners.top_right))147
.rounded_tr(px(corners.top_right))120
.rounded_br(px(corners.bottom_right))148
.rounded_br(px(corners.bottom_right))@@ -389,7 +417,7 @@ pub fn render_skeleton_row(skeleton: &Skeleton, index: usize) -> AnyElement {389
div()417
div()390
.id(ElementId::Name(format!("row-{index}").into()))418
.id(ElementId::Name(format!("row-{index}").into()))391
.w_full()419
.w_full()392
.px(px(20.))420
.px(px(ROW_PADDING))393
.pt(px(SERIES_START_GAP))421
.pt(px(SERIES_START_GAP))394
.child(pulse("skeleton", line))422
.child(pulse("skeleton", line))395
.into_any_element()423
.into_any_element()@@ -499,7 +527,9 @@ fn others_row(499
let profile_user = row.sender_id.as_deref().filter(|_| bot.is_none());527
let profile_user = row.sender_id.as_deref().filter(|_| bot.is_none());500
let mut column = v_flex()528
let mut column = v_flex()501
.gap(px(2.))529
.gap(px(2.))502
.max_w(relative(MAX_WIDTH_RATIO))530
.flex_1()531
.min_w_0()532
.max_w(bubble_max_width(&extras.timeline, AVATAR_SIZE + AVATAR_GAP))503
.items_start();533
.items_start();504
if first {534
if first {505
column = column.child(535
column = column.child(@@ -563,9 +593,15 @@ fn own_row(563
let reaction_proposal = extras.reaction_proposal.take();593
let reaction_proposal = extras.reaction_proposal.take();564
let mut column = v_flex().w_full().items_end().gap(px(2.));594
let mut column = v_flex().w_full().items_end().gap(px(2.));565
column = column.child(595
column = column.child(566
div()596
h_flex()567
.max_w(relative(MAX_WIDTH_RATIO))597
.w_full()568
.child(bubble(row, index, true, directory, extras, cx)),598
.justify_end()599
.child(600
div()601
.min_w_0()602
.max_w(bubble_max_width(&extras.timeline, 0.))603
.child(bubble(row, index, true, directory, extras, cx)),604
),569
);605
);570
column = column.children(agent_chip(agent_run));606
column = column.children(agent_chip(agent_run));571
column = column.children(reaction_proposal.map(|pill| reaction_pill(pill, &row.key)));607
column = column.children(reaction_proposal.map(|pill| reaction_pill(pill, &row.key)));@@ -621,7 +657,7 @@ pub fn render_message_row(621
} else {657
} else {622
px(SERIES_START_GAP)658
px(SERIES_START_GAP)623
};659
};624
let mut container = v_flex().w_full().px(px(20.));660
let mut container = v_flex().w_full().px(px(ROW_PADDING));625
if let Some(day) = &row.day_header {661
if let Some(day) = &row.day_header {626
container = container.child(day_separator(day));662
container = container.child(day_separator(day));627
}663
}