feat(chat): right-click message menu at the cursor like Telegram
- With "message actions on right click" on, a right click opens a menu at the cursor: quick reactions in a pill on top, the actions in a flat list below - Closes on a click outside, Escape, an action or a reaction, and on a chat switch - Replaces the hover toolbar that opened above the message - Deviation from Teams (Teams opens the toolbar above the message), on Daniel's request 2026-11-11 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -239,7 +239,7 @@ pub struct ConversationView {
239
239
downloads: Downloads,
240
240
hovered_message: Option<String>,
241
241
toolbar_hovered: Option<String>,
242
toolbar_opened: Option<String>,
242
context_menu: Option<(String, Point<Pixels>)>,
243
243
timeline_bounds: TimelineBounds,
244
244
header_width: Rc<Cell<f32>>,
245
245
toolbar_pinned: Option<String>,
@@ -552,6 +552,7 @@ impl ConversationView {
552
552
cx.observe_keystrokes(|this, event, _, cx| {
553
553
if event.keystroke.key == "escape" {
554
554
this.close_reaction_details(cx);
555
this.close_context_menu(false, cx);
555
556
}
556
557
}),
557
558
];
@@ -590,7 +591,7 @@ impl ConversationView {
590
591
downloads: Downloads::default(),
591
592
hovered_message: None,
592
593
toolbar_hovered: None,
593
toolbar_opened: None,
594
context_menu: None,
594
595
timeline_bounds: TimelineBounds::default(),
595
596
header_width: Rc::default(),
596
597
toolbar_pinned: None,
@@ -932,6 +933,7 @@ impl ConversationView {
932
933
crate::inline_video::stop(cx);
933
934
self.toolbar_pinned = None;
934
935
self.toolbar_suppressed = None;
936
self.context_menu = None;
935
937
self.agent_layouts.clear();
936
938
self.agent_runs.borrow_mut().clear();
937
939
self.reaction_proposals.borrow_mut().clear();
@@ -2812,9 +2814,6 @@ impl ConversationView {
2812
2814
} else if target.as_deref() == Some(key) {
2813
2815
*target = None;
2814
2816
}
2815
if !hovered && matches!(slot, HoverSlot::Row) && self.toolbar_opened.as_deref() == Some(key) {
2816
self.toolbar_opened = None;
2817
}
2818
2817
if hovered
2819
2818
&& matches!(slot, HoverSlot::Row)
2820
2819
&& self.toolbar_hovered.as_deref().is_some_and(|toolbar| toolbar != key)
@@ -2848,11 +2847,9 @@ impl ConversationView {
2848
2847
}
2849
2848
2850
2849
fn toolbar_visible(&self, key: &str, cx: &App) -> bool {
2851
let row_trigger = if self.app.read(cx).actions_on_right_click {
2852
self.toolbar_opened.as_deref()
2853
} else {
2854
self.hovered_message.as_deref()
2855
};
2850
let row_trigger = (!self.app.read(cx).actions_on_right_click)
2851
.then_some(self.hovered_message.as_deref())
2852
.flatten();
2856
2853
self.toolbar_suppressed.as_deref() != Some(key)
2857
2854
&& self
2858
2855
.toolbar_pinned
@@ -2862,9 +2859,26 @@ impl ConversationView {
2862
2859
== Some(key)
2863
2860
}
2864
2861
2865
fn open_toolbar(&mut self, key: &str, cx: &mut Context<Self>) {
2866
self.toolbar_opened = Some(key.to_owned());
2867
self.toolbar_suppressed = None;
2862
pub(crate) fn context_menu_at(&self, key: &str) -> Option<Point<Pixels>> {
2863
self.context_menu
2864
.as_ref()
2865
.filter(|(open, _)| open == key)
2866
.map(|(_, position)| *position)
2867
}
2868
2869
fn open_context_menu(&mut self, key: &str, position: Point<Pixels>, cx: &mut Context<Self>) {
2870
self.context_menu = Some((key.to_owned(), position));
2871
cx.notify();
2872
}
2873
2874
fn close_context_menu(&mut self, from_outside: bool, cx: &mut Context<Self>) {
2875
let Some((key, _)) = &self.context_menu else {
2876
return;
2877
};
2878
if from_outside && self.toolbar_pinned.as_deref() == Some(key.as_str()) {
2879
return;
2880
}
2881
self.context_menu = None;
2868
2882
cx.notify();
2869
2883
}
2870
2884
@@ -239,7 +239,7 @@ pub struct ConversationView {239
downloads: Downloads,239
downloads: Downloads,240
hovered_message: Option<String>,240
hovered_message: Option<String>,241
toolbar_hovered: Option<String>,241
toolbar_hovered: Option<String>,242
toolbar_opened: Option<String>,242
context_menu: Option<(String, Point<Pixels>)>,243
timeline_bounds: TimelineBounds,243
timeline_bounds: TimelineBounds,244
header_width: Rc<Cell<f32>>,244
header_width: Rc<Cell<f32>>,245
toolbar_pinned: Option<String>,245
toolbar_pinned: Option<String>,@@ -552,6 +552,7 @@ impl ConversationView {552
cx.observe_keystrokes(|this, event, _, cx| {552
cx.observe_keystrokes(|this, event, _, cx| {553
if event.keystroke.key == "escape" {553
if event.keystroke.key == "escape" {554
this.close_reaction_details(cx);554
this.close_reaction_details(cx);555
this.close_context_menu(false, cx);555
}556
}556
}),557
}),557
];558
];@@ -590,7 +591,7 @@ impl ConversationView {590
downloads: Downloads::default(),591
downloads: Downloads::default(),591
hovered_message: None,592
hovered_message: None,592
toolbar_hovered: None,593
toolbar_hovered: None,593
toolbar_opened: None,594
context_menu: None,594
timeline_bounds: TimelineBounds::default(),595
timeline_bounds: TimelineBounds::default(),595
header_width: Rc::default(),596
header_width: Rc::default(),596
toolbar_pinned: None,597
toolbar_pinned: None,@@ -932,6 +933,7 @@ impl ConversationView {932
crate::inline_video::stop(cx);933
crate::inline_video::stop(cx);933
self.toolbar_pinned = None;934
self.toolbar_pinned = None;934
self.toolbar_suppressed = None;935
self.toolbar_suppressed = None;936
self.context_menu = None;935
self.agent_layouts.clear();937
self.agent_layouts.clear();936
self.agent_runs.borrow_mut().clear();938
self.agent_runs.borrow_mut().clear();937
self.reaction_proposals.borrow_mut().clear();939
self.reaction_proposals.borrow_mut().clear();@@ -2812,9 +2814,6 @@ impl ConversationView {2812
} else if target.as_deref() == Some(key) {2814
} else if target.as_deref() == Some(key) {2813
*target = None;2815
*target = None;2814
}2816
}2815
if !hovered && matches!(slot, HoverSlot::Row) && self.toolbar_opened.as_deref() == Some(key) {2816
self.toolbar_opened = None;2817
}2818
if hovered2817
if hovered2819
&& matches!(slot, HoverSlot::Row)2818
&& matches!(slot, HoverSlot::Row)2820
&& self.toolbar_hovered.as_deref().is_some_and(|toolbar| toolbar != key)2819
&& self.toolbar_hovered.as_deref().is_some_and(|toolbar| toolbar != key)@@ -2848,11 +2847,9 @@ impl ConversationView {2848
}2847
}2849
2848
2850
fn toolbar_visible(&self, key: &str, cx: &App) -> bool {2849
fn toolbar_visible(&self, key: &str, cx: &App) -> bool {2851
let row_trigger = if self.app.read(cx).actions_on_right_click {2850
let row_trigger = (!self.app.read(cx).actions_on_right_click)2852
self.toolbar_opened.as_deref()2851
.then_some(self.hovered_message.as_deref())2853
} else {2852
.flatten();2854
self.hovered_message.as_deref()2855
};2856
self.toolbar_suppressed.as_deref() != Some(key)2853
self.toolbar_suppressed.as_deref() != Some(key)2857
&& self2854
&& self2858
.toolbar_pinned2855
.toolbar_pinned@@ -2862,9 +2859,26 @@ impl ConversationView {2862
== Some(key)2859
== Some(key)2863
}2860
}2864
2861
2865
fn open_toolbar(&mut self, key: &str, cx: &mut Context<Self>) {2862
pub(crate) fn context_menu_at(&self, key: &str) -> Option<Point<Pixels>> {2866
self.toolbar_opened = Some(key.to_owned());2863
self.context_menu2867
self.toolbar_suppressed = None;2864
.as_ref()2865
.filter(|(open, _)| open == key)2866
.map(|(_, position)| *position)2867
}2868
2869
fn open_context_menu(&mut self, key: &str, position: Point<Pixels>, cx: &mut Context<Self>) {2870
self.context_menu = Some((key.to_owned(), position));2871
cx.notify();2872
}2873
2874
fn close_context_menu(&mut self, from_outside: bool, cx: &mut Context<Self>) {2875
let Some((key, _)) = &self.context_menu else {2876
return;2877
};2878
if from_outside && self.toolbar_pinned.as_deref() == Some(key.as_str()) {2879
return;2880
}2881
self.context_menu = None;2868
cx.notify();2882
cx.notify();2869
}2883
}2870
2884
@@ -20,6 +20,7 @@ use crate::views::attachments::ImageActions;
20
20
use crate::views::call_card::CallActions;
21
21
use crate::views::call_notice::RecapActions;
22
22
use crate::views::composer::Composer;
23
use crate::views::message_context_menu::message_context_menu;
23
24
use crate::views::message_row::{DeliveryActions, RowActions, RowSelect, SharedRowAction};
24
25
use crate::views::post_card::{PostAction, PostActions};
25
26
use crate::views::reaction_proposal_pill::ReactionPill;
@@ -241,14 +242,43 @@ impl RenderEnv {
241
242
})
242
243
.unwrap_or((None, None, None, None));
243
244
let right_click_opens_actions = self.app.read(cx).actions_on_right_click;
244
let reply = (is_real && !message.deleted).then(|| {
245
let open_context = (right_click_opens_actions && actionable).then(|| {
246
let (view, key) = (view.clone(), message.key.clone());
247
Rc::new(move |position: Point<Pixels>, cx: &mut App| {
248
view.update(cx, |this, cx| this.open_context_menu(&key, position, cx))
249
.ok();
250
}) as Rc<dyn Fn(Point<Pixels>, &mut App)>
251
});
252
let context_menu = view
253
.upgrade()
254
.filter(|_| actionable)
255
.and_then(|entity| {
256
let this = entity.read(cx);
257
let position = this.context_menu_at(&message.key)?;
258
let mine = message
259
.reactions
260
.iter()
261
.filter(|chip| chip.mine)
262
.map(|chip| chip.glyph())
263
.collect();
264
let menu = this.message_menu(message, mine, None, view.clone(), cx);
265
let (closing, outside) = (view.clone(), view.clone());
266
Some(message_context_menu(
267
menu,
268
position,
269
Rc::new(move |_, cx| {
270
closing.update(cx, |this, cx| this.close_context_menu(false, cx)).ok();
271
}),
272
Rc::new(move |_, cx| {
273
outside.update(cx, |this, cx| this.close_context_menu(true, cx)).ok();
274
}),
275
cx,
276
))
277
});
278
let reply = (is_real && !message.deleted && !right_click_opens_actions).then(|| {
245
279
let (view, key, handle) = (view.clone(), message.key.clone(), window.window_handle());
246
280
boxed(move |cx| {
247
281
let (view, key) = (view.clone(), key.clone());
248
if right_click_opens_actions {
249
view.update(cx, |this, cx| this.open_toolbar(&key, cx)).ok();
250
return;
251
}
252
282
handle
253
283
.update(cx, move |_, window, cx| {
254
284
view.update(cx, |this, cx| this.begin_reply(&key, window, cx))
@@ -316,6 +346,8 @@ impl RenderEnv {
316
346
bot,
317
347
delivery,
318
348
reply: reply.filter(|_| !selecting),
349
open_context: open_context.filter(|_| !selecting),
350
context_menu: context_menu.filter(|_| !selecting),
319
351
hovered: hovered.filter(|_| !selecting),
320
352
menu: menu.filter(|_| !selecting),
321
353
scheduled_menu,
@@ -20,6 +20,7 @@ use crate::views::attachments::ImageActions;20
use crate::views::call_card::CallActions;20
use crate::views::call_card::CallActions;21
use crate::views::call_notice::RecapActions;21
use crate::views::call_notice::RecapActions;22
use crate::views::composer::Composer;22
use crate::views::composer::Composer;23
use crate::views::message_context_menu::message_context_menu;23
use crate::views::message_row::{DeliveryActions, RowActions, RowSelect, SharedRowAction};24
use crate::views::message_row::{DeliveryActions, RowActions, RowSelect, SharedRowAction};24
use crate::views::post_card::{PostAction, PostActions};25
use crate::views::post_card::{PostAction, PostActions};25
use crate::views::reaction_proposal_pill::ReactionPill;26
use crate::views::reaction_proposal_pill::ReactionPill;@@ -241,14 +242,43 @@ impl RenderEnv {241
})242
})242
.unwrap_or((None, None, None, None));243
.unwrap_or((None, None, None, None));243
let right_click_opens_actions = self.app.read(cx).actions_on_right_click;244
let right_click_opens_actions = self.app.read(cx).actions_on_right_click;244
let reply = (is_real && !message.deleted).then(|| {245
let open_context = (right_click_opens_actions && actionable).then(|| {246
let (view, key) = (view.clone(), message.key.clone());247
Rc::new(move |position: Point<Pixels>, cx: &mut App| {248
view.update(cx, |this, cx| this.open_context_menu(&key, position, cx))249
.ok();250
}) as Rc<dyn Fn(Point<Pixels>, &mut App)>251
});252
let context_menu = view253
.upgrade()254
.filter(|_| actionable)255
.and_then(|entity| {256
let this = entity.read(cx);257
let position = this.context_menu_at(&message.key)?;258
let mine = message259
.reactions260
.iter()261
.filter(|chip| chip.mine)262
.map(|chip| chip.glyph())263
.collect();264
let menu = this.message_menu(message, mine, None, view.clone(), cx);265
let (closing, outside) = (view.clone(), view.clone());266
Some(message_context_menu(267
menu,268
position,269
Rc::new(move |_, cx| {270
closing.update(cx, |this, cx| this.close_context_menu(false, cx)).ok();271
}),272
Rc::new(move |_, cx| {273
outside.update(cx, |this, cx| this.close_context_menu(true, cx)).ok();274
}),275
cx,276
))277
});278
let reply = (is_real && !message.deleted && !right_click_opens_actions).then(|| {245
let (view, key, handle) = (view.clone(), message.key.clone(), window.window_handle());279
let (view, key, handle) = (view.clone(), message.key.clone(), window.window_handle());246
boxed(move |cx| {280
boxed(move |cx| {247
let (view, key) = (view.clone(), key.clone());281
let (view, key) = (view.clone(), key.clone());248
if right_click_opens_actions {249
view.update(cx, |this, cx| this.open_toolbar(&key, cx)).ok();250
return;251
}252
handle282
handle253
.update(cx, move |_, window, cx| {283
.update(cx, move |_, window, cx| {254
view.update(cx, |this, cx| this.begin_reply(&key, window, cx))284
view.update(cx, |this, cx| this.begin_reply(&key, window, cx))@@ -316,6 +346,8 @@ impl RenderEnv {316
bot,346
bot,317
delivery,347
delivery,318
reply: reply.filter(|_| !selecting),348
reply: reply.filter(|_| !selecting),349
open_context: open_context.filter(|_| !selecting),350
context_menu: context_menu.filter(|_| !selecting),319
hovered: hovered.filter(|_| !selecting),351
hovered: hovered.filter(|_| !selecting),320
menu: menu.filter(|_| !selecting),352
menu: menu.filter(|_| !selecting),321
scheduled_menu,353
scheduled_menu,@@ -94,7 +94,7 @@ pub(super) fn bar_button(id: ElementId) -> Stateful<Div> {
94
94
.hover(|button| button.bg(theme::popup_hover()))
95
95
}
96
96
97
fn reaction_button(menu: &MessageMenu, glyph: &str, index: usize) -> AnyElement {
97
pub(super) fn reaction_button(menu: &MessageMenu, glyph: &str, index: usize) -> AnyElement {
98
98
let (react, done, picked) = (menu.react.clone(), menu.done.clone(), glyph.to_owned());
99
99
let selected = menu.mine.contains(&reaction_glyph(glyph));
100
100
bar_button(element_id(&format!("quick-reaction-{index}"), &menu.key))
@@ -161,7 +161,7 @@ fn picker_popover(adder: ReactionAdder, prefix: &str, trigger: Button, anchor: A
161
161
.into_any_element()
162
162
}
163
163
164
fn picker_button(menu: &MessageMenu, cx: &App) -> AnyElement {
164
pub(super) fn picker_button(menu: &MessageMenu, cx: &App) -> AnyElement {
165
165
let trigger = Button::new(element_id("add-reaction", &menu.key))
166
166
.child(icon(IconName::Plus, BAR_ICON, theme::text_soft()))
167
167
.custom(bar_variant(cx))
@@ -94,7 +94,7 @@ pub(super) fn bar_button(id: ElementId) -> Stateful<Div> {94
.hover(|button| button.bg(theme::popup_hover()))94
.hover(|button| button.bg(theme::popup_hover()))95
}95
}96
96
97
fn reaction_button(menu: &MessageMenu, glyph: &str, index: usize) -> AnyElement {97
pub(super) fn reaction_button(menu: &MessageMenu, glyph: &str, index: usize) -> AnyElement {98
let (react, done, picked) = (menu.react.clone(), menu.done.clone(), glyph.to_owned());98
let (react, done, picked) = (menu.react.clone(), menu.done.clone(), glyph.to_owned());99
let selected = menu.mine.contains(&reaction_glyph(glyph));99
let selected = menu.mine.contains(&reaction_glyph(glyph));100
bar_button(element_id(&format!("quick-reaction-{index}"), &menu.key))100
bar_button(element_id(&format!("quick-reaction-{index}"), &menu.key))@@ -161,7 +161,7 @@ fn picker_popover(adder: ReactionAdder, prefix: &str, trigger: Button, anchor: A161
.into_any_element()161
.into_any_element()162
}162
}163
163
164
fn picker_button(menu: &MessageMenu, cx: &App) -> AnyElement {164
pub(super) fn picker_button(menu: &MessageMenu, cx: &App) -> AnyElement {165
let trigger = Button::new(element_id("add-reaction", &menu.key))165
let trigger = Button::new(element_id("add-reaction", &menu.key))166
.child(icon(IconName::Plus, BAR_ICON, theme::text_soft()))166
.child(icon(IconName::Plus, BAR_ICON, theme::text_soft()))167
.custom(bar_variant(cx))167
.custom(bar_variant(cx))@@ -3,6 +3,7 @@ use gpui_kit::component::{h_flex, v_flex};
3
3
use gpui_kit::prelude::FluentBuilder as _;
4
4
use gpui_kit::*;
5
5
use std::time::Duration;
6
use std::rc::Rc;
6
7
7
8
use super::adaptive_card::cards_view;
8
9
use super::attachments::{FileActions, ImageActions, attachments_view, message_body};
@@ -105,6 +106,8 @@ pub struct RowActions {
105
106
pub bot: Option<BotIdentity>,
106
107
pub delivery: DeliveryActions,
107
108
pub reply: RowAction,
109
pub open_context: Option<Rc<dyn Fn(Point<Pixels>, &mut App)>>,
110
pub context_menu: Option<AnyElement>,
108
111
pub hovered: Option<HoverChange>,
109
112
pub menu: Option<MessageMenu>,
110
113
pub scheduled_menu: Option<ScheduledMenu>,
@@ -788,6 +791,8 @@ pub fn render_message_row(
788
791
bot,
789
792
delivery,
790
793
reply,
794
open_context,
795
context_menu,
791
796
hovered,
792
797
menu,
793
798
scheduled_menu,
@@ -849,9 +854,15 @@ pub fn render_message_row(
849
854
.id(ElementId::Name(format!("row-{index}").into()))
850
855
.w_full()
851
856
.pt(spacing)
852
.when_some(reply, |element, reply| {
853
element.on_mouse_down(MouseButton::Right, move |_, _, cx| reply(cx))
857
.map(|element| match (open_context, reply) {
858
(Some(open_context), _) => element.on_mouse_down(MouseButton::Right, move |event, _, cx| {
859
cx.stop_propagation();
860
open_context(event.position, cx)
861
}),
862
(None, Some(reply)) => element.on_mouse_down(MouseButton::Right, move |_, _, cx| reply(cx)),
863
(None, None) => element,
854
864
})
865
.children(context_menu)
855
866
.child(
856
867
div()
857
868
.w_full()
@@ -3,6 +3,7 @@ use gpui_kit::component::{h_flex, v_flex};3
use gpui_kit::prelude::FluentBuilder as _;3
use gpui_kit::prelude::FluentBuilder as _;4
use gpui_kit::*;4
use gpui_kit::*;5
use std::time::Duration;5
use std::time::Duration;6
use std::rc::Rc;6
7
7
use super::adaptive_card::cards_view;8
use super::adaptive_card::cards_view;8
use super::attachments::{FileActions, ImageActions, attachments_view, message_body};9
use super::attachments::{FileActions, ImageActions, attachments_view, message_body};@@ -105,6 +106,8 @@ pub struct RowActions {105
pub bot: Option<BotIdentity>,106
pub bot: Option<BotIdentity>,106
pub delivery: DeliveryActions,107
pub delivery: DeliveryActions,107
pub reply: RowAction,108
pub reply: RowAction,109
pub open_context: Option<Rc<dyn Fn(Point<Pixels>, &mut App)>>,110
pub context_menu: Option<AnyElement>,108
pub hovered: Option<HoverChange>,111
pub hovered: Option<HoverChange>,109
pub menu: Option<MessageMenu>,112
pub menu: Option<MessageMenu>,110
pub scheduled_menu: Option<ScheduledMenu>,113
pub scheduled_menu: Option<ScheduledMenu>,@@ -788,6 +791,8 @@ pub fn render_message_row(788
bot,791
bot,789
delivery,792
delivery,790
reply,793
reply,794
open_context,795
context_menu,791
hovered,796
hovered,792
menu,797
menu,793
scheduled_menu,798
scheduled_menu,@@ -849,9 +854,15 @@ pub fn render_message_row(849
.id(ElementId::Name(format!("row-{index}").into()))854
.id(ElementId::Name(format!("row-{index}").into()))850
.w_full()855
.w_full()851
.pt(spacing)856
.pt(spacing)852
.when_some(reply, |element, reply| {857
.map(|element| match (open_context, reply) {853
element.on_mouse_down(MouseButton::Right, move |_, _, cx| reply(cx))858
(Some(open_context), _) => element.on_mouse_down(MouseButton::Right, move |event, _, cx| {859
cx.stop_propagation();860
open_context(event.position, cx)861
}),862
(None, Some(reply)) => element.on_mouse_down(MouseButton::Right, move |_, _, cx| reply(cx)),863
(None, None) => element,854
})864
})865
.children(context_menu)855
.child(866
.child(856
div()867
div()857
.w_full()868
.w_full()@@ -61,6 +61,7 @@ pub mod join_dialog;
61
61
pub mod jumbo_emoji;
62
62
pub mod link_preview;
63
63
pub mod message_actions;
64
pub mod message_context_menu;
64
65
pub mod message_row;
65
66
pub mod new_chat;
66
67
pub mod notice_toast;
@@ -61,6 +61,7 @@ pub mod join_dialog;61
pub mod jumbo_emoji;61
pub mod jumbo_emoji;62
pub mod link_preview;62
pub mod link_preview;63
pub mod message_actions;63
pub mod message_actions;64
pub mod message_context_menu;64
pub mod message_row;65
pub mod message_row;65
pub mod new_chat;66
pub mod new_chat;66
pub mod notice_toast;67
pub mod notice_toast;