BlueGit

ict rusty-teams

feat(chat): setting to show message actions on right click only

- Settings > Chats: Show message actions on right click (local, off by default)
- on: the hover bar appears after a right click and closes when the pointer leaves the message

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
adac7549e76f128a75e799d773aee260836cb786
Parent
94842e80
6 files changed +70 −5
crates/app-state/src/app_state.rs +4 −0
@@ -156,6 +156,7 @@ pub struct AppState {
156 156 pub account_sounds: Option<chatsvc::sound_settings::SoundSettings>,
157 157 pub chat_settings: teams_core::ChatSettingsDocument,
158 158 pub markdown_mode: bool,
159 pub actions_on_right_click: bool,
159 160 pub demo_chat_desktop: HashMap<String, teams_core::DesktopNotifications>,
160 161 pub own_tenant: Option<String>,
161 162 pub call_share_motion: bool,
@@ -250,6 +251,8 @@ impl AppState {
250 251 let sidebar = store.sidebar().unwrap_or_default();
251 252 let chat_settings = teams_core::stored_chat_settings(&store);
252 253 let markdown_mode = crate::chat_settings_actions::stored_markdown_mode(&store);
254 let actions_on_right_click =
255 crate::chat_settings_actions::stored_actions_on_right_click(&store);
253 256 let mut state = AppState {
254 257 store,
255 258 engine: None,
@@ -320,6 +323,7 @@ impl AppState {
320 323 account_sounds: None,
321 324 chat_settings,
322 325 markdown_mode,
326 actions_on_right_click,
323 327 demo_chat_desktop: HashMap::new(),
324 328 own_tenant: None,
325 329 call_share_motion: false,
@@ -156,6 +156,7 @@ pub struct AppState {
156 pub account_sounds: Option<chatsvc::sound_settings::SoundSettings>,
156 pub account_sounds: Option<chatsvc::sound_settings::SoundSettings>,
157 pub chat_settings: teams_core::ChatSettingsDocument,
157 pub chat_settings: teams_core::ChatSettingsDocument,
158 pub markdown_mode: bool,
158 pub markdown_mode: bool,
159 pub actions_on_right_click: bool,
159 pub demo_chat_desktop: HashMap<String, teams_core::DesktopNotifications>,
160 pub demo_chat_desktop: HashMap<String, teams_core::DesktopNotifications>,
160 pub own_tenant: Option<String>,
161 pub own_tenant: Option<String>,
161 pub call_share_motion: bool,
162 pub call_share_motion: bool,
@@ -250,6 +251,8 @@ impl AppState {
250 let sidebar = store.sidebar().unwrap_or_default();
251 let sidebar = store.sidebar().unwrap_or_default();
251 let chat_settings = teams_core::stored_chat_settings(&store);
252 let chat_settings = teams_core::stored_chat_settings(&store);
252 let markdown_mode = crate::chat_settings_actions::stored_markdown_mode(&store);
253 let markdown_mode = crate::chat_settings_actions::stored_markdown_mode(&store);
254 let actions_on_right_click =
255 crate::chat_settings_actions::stored_actions_on_right_click(&store);
253 let mut state = AppState {
256 let mut state = AppState {
254 store,
257 store,
255 engine: None,
258 engine: None,
@@ -320,6 +323,7 @@ impl AppState {
320 account_sounds: None,
323 account_sounds: None,
321 chat_settings,
324 chat_settings,
322 markdown_mode,
325 markdown_mode,
326 actions_on_right_click,
323 demo_chat_desktop: HashMap::new(),
327 demo_chat_desktop: HashMap::new(),
324 own_tenant: None,
328 own_tenant: None,
325 call_share_motion: false,
329 call_share_motion: false,
crates/app-state/src/chat_settings_actions.rs +23 −0
@@ -10,11 +10,16 @@ use crate::rows::Receipt;
10 10 use crate::runtime;
11 11
12 12 const META_MARKDOWN_MODE: &str = "compose.markdown_mode";
13 const META_ACTIONS_ON_RIGHT_CLICK: &str = "chat.message_actions_on_right_click";
13 14
14 15 pub fn stored_markdown_mode(store: &Store) -> bool {
15 16 store.meta(META_MARKDOWN_MODE).ok().flatten().as_deref() == Some("true")
16 17 }
17 18
19 pub fn stored_actions_on_right_click(store: &Store) -> bool {
20 store.meta(META_ACTIONS_ON_RIGHT_CLICK).ok().flatten().as_deref() == Some("true")
21 }
22
18 23 /// Teams shows no read state at all while the own read receipts setting is off.
19 24 pub fn shown_receipt(settings: &ChatAccountSettings, receipt: Receipt) -> Receipt {
20 25 if settings.read_receipts {
@@ -88,6 +93,16 @@ impl AppState {
88 93 cx.notify();
89 94 }
90 95
96 pub fn set_actions_on_right_click(&mut self, enabled: bool, cx: &mut Context<Self>) {
97 self.actions_on_right_click = enabled;
98 let _ = self.store.set_meta(
99 META_ACTIONS_ON_RIGHT_CLICK,
100 if enabled { "true" } else { "false" },
101 );
102 cx.emit(AppEvent::ChatSettings);
103 cx.notify();
104 }
105
91 106 pub fn chat_desktop_notifications(&self, chat_id: &str) -> DesktopNotifications {
92 107 match &self.engine {
93 108 Some(engine) => engine.chat_desktop_notifications(chat_id),
@@ -152,6 +167,14 @@ mod tests {
152 167 assert_eq!(shown_receipt(&settings, Receipt::Sent), Receipt::Hidden);
153 168 }
154 169
170 #[test]
171 fn right_click_actions_are_a_local_setting_that_starts_off() {
172 let store = Store::open_in_memory().unwrap();
173 assert!(!stored_actions_on_right_click(&store));
174 store.set_meta(META_ACTIONS_ON_RIGHT_CLICK, "true").unwrap();
175 assert!(stored_actions_on_right_click(&store));
176 }
177
155 178 #[test]
156 179 fn markdown_mode_is_a_local_setting_that_starts_off() {
157 180 let store = Store::open_in_memory().unwrap();
@@ -10,11 +10,16 @@ use crate::rows::Receipt;
10use crate::runtime;
10use crate::runtime;
11
11
12const META_MARKDOWN_MODE: &str = "compose.markdown_mode";
12const META_MARKDOWN_MODE: &str = "compose.markdown_mode";
13const META_ACTIONS_ON_RIGHT_CLICK: &str = "chat.message_actions_on_right_click";
13
14
14pub fn stored_markdown_mode(store: &Store) -> bool {
15pub fn stored_markdown_mode(store: &Store) -> bool {
15 store.meta(META_MARKDOWN_MODE).ok().flatten().as_deref() == Some("true")
16 store.meta(META_MARKDOWN_MODE).ok().flatten().as_deref() == Some("true")
16}
17}
17
18
19pub fn stored_actions_on_right_click(store: &Store) -> bool {
20 store.meta(META_ACTIONS_ON_RIGHT_CLICK).ok().flatten().as_deref() == Some("true")
21}
22
18/// Teams shows no read state at all while the own read receipts setting is off.
23/// Teams shows no read state at all while the own read receipts setting is off.
19pub fn shown_receipt(settings: &ChatAccountSettings, receipt: Receipt) -> Receipt {
24pub fn shown_receipt(settings: &ChatAccountSettings, receipt: Receipt) -> Receipt {
20 if settings.read_receipts {
25 if settings.read_receipts {
@@ -88,6 +93,16 @@ impl AppState {
88 cx.notify();
93 cx.notify();
89 }
94 }
90
95
96 pub fn set_actions_on_right_click(&mut self, enabled: bool, cx: &mut Context<Self>) {
97 self.actions_on_right_click = enabled;
98 let _ = self.store.set_meta(
99 META_ACTIONS_ON_RIGHT_CLICK,
100 if enabled { "true" } else { "false" },
101 );
102 cx.emit(AppEvent::ChatSettings);
103 cx.notify();
104 }
105
91 pub fn chat_desktop_notifications(&self, chat_id: &str) -> DesktopNotifications {
106 pub fn chat_desktop_notifications(&self, chat_id: &str) -> DesktopNotifications {
92 match &self.engine {
107 match &self.engine {
93 Some(engine) => engine.chat_desktop_notifications(chat_id),
108 Some(engine) => engine.chat_desktop_notifications(chat_id),
@@ -152,6 +167,14 @@ mod tests {
152 assert_eq!(shown_receipt(&settings, Receipt::Sent), Receipt::Hidden);
167 assert_eq!(shown_receipt(&settings, Receipt::Sent), Receipt::Hidden);
153 }
168 }
154
169
170 #[test]
171 fn right_click_actions_are_a_local_setting_that_starts_off() {
172 let store = Store::open_in_memory().unwrap();
173 assert!(!stored_actions_on_right_click(&store));
174 store.set_meta(META_ACTIONS_ON_RIGHT_CLICK, "true").unwrap();
175 assert!(stored_actions_on_right_click(&store));
176 }
177
155 #[test]
178 #[test]
156 fn markdown_mode_is_a_local_setting_that_starts_off() {
179 fn markdown_mode_is_a_local_setting_that_starts_off() {
157 let store = Store::open_in_memory().unwrap();
180 let store = Store::open_in_memory().unwrap();
crates/app/src/settings/chats.rs +18 −1
@@ -8,6 +8,7 @@ use crate::app_state::AppState;
8 8 use crate::theme;
9 9
10 10 const MARKDOWN_DETAIL: &str = "Use mark-down language to define the structure and appearance of messages. Your formatting will take effect once you send your message. When this is on, the formatting options menu won't be visible.";
11 const ACTIONS_DETAIL: &str = "Reactions and More options appear when you right click a message instead of when you point at it.";
11 12 const RECEIPTS_DETAIL: &str = "Let people know when you've seen their messages and know when they've seen yours. Close and reopen any chat windows for the setting to take effect in those chats.";
12 13
13 14 pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
@@ -15,7 +16,9 @@ pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
15 16 let muted_section = state.directory.section_settings.enabled(ChatSection::Muted);
16 17 let settings = state.account_chat_settings();
17 18 let markdown_mode = state.markdown_mode;
18 let (section_app, markdown_app, receipts_app) = (app.clone(), app.clone(), app.clone());
19 let actions_on_right_click = state.actions_on_right_click;
20 let (section_app, markdown_app, receipts_app, actions_app) =
21 (app.clone(), app.clone(), app.clone(), app.clone());
19 22 v_flex()
20 23 .w_full()
21 24 .child(caption("CHAT LIST"))
@@ -68,6 +71,20 @@ pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
68 71 markdown_app.update(cx, |state, cx| state.set_markdown_mode(!markdown_mode, cx))
69 72 }),
70 73 )
74 .child(
75 toggle_row(
76 "settings-actions-on-right-click",
77 "Show message actions on right click",
78 ACTIONS_DETAIL,
79 theme::text_muted(),
80 actions_on_right_click,
81 )
82 .on_click(move |_, _, cx| {
83 actions_app.update(cx, |state, cx| {
84 state.set_actions_on_right_click(!actions_on_right_click, cx)
85 })
86 }),
87 )
71 88 .child(
72 89 toggle_row(
73 90 "settings-read-receipts",
@@ -8,6 +8,7 @@ use crate::app_state::AppState;
8use crate::theme;
8use crate::theme;
9
9
10const MARKDOWN_DETAIL: &str = "Use mark-down language to define the structure and appearance of messages. Your formatting will take effect once you send your message. When this is on, the formatting options menu won't be visible.";
10const MARKDOWN_DETAIL: &str = "Use mark-down language to define the structure and appearance of messages. Your formatting will take effect once you send your message. When this is on, the formatting options menu won't be visible.";
11const ACTIONS_DETAIL: &str = "Reactions and More options appear when you right click a message instead of when you point at it.";
11const RECEIPTS_DETAIL: &str = "Let people know when you've seen their messages and know when they've seen yours. Close and reopen any chat windows for the setting to take effect in those chats.";
12const RECEIPTS_DETAIL: &str = "Let people know when you've seen their messages and know when they've seen yours. Close and reopen any chat windows for the setting to take effect in those chats.";
12
13
13pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
14pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
@@ -15,7 +16,9 @@ pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
15 let muted_section = state.directory.section_settings.enabled(ChatSection::Muted);
16 let muted_section = state.directory.section_settings.enabled(ChatSection::Muted);
16 let settings = state.account_chat_settings();
17 let settings = state.account_chat_settings();
17 let markdown_mode = state.markdown_mode;
18 let markdown_mode = state.markdown_mode;
18 let (section_app, markdown_app, receipts_app) = (app.clone(), app.clone(), app.clone());
19 let actions_on_right_click = state.actions_on_right_click;
20 let (section_app, markdown_app, receipts_app, actions_app) =
21 (app.clone(), app.clone(), app.clone(), app.clone());
19 v_flex()
22 v_flex()
20 .w_full()
23 .w_full()
21 .child(caption("CHAT LIST"))
24 .child(caption("CHAT LIST"))
@@ -68,6 +71,20 @@ pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
68 markdown_app.update(cx, |state, cx| state.set_markdown_mode(!markdown_mode, cx))
71 markdown_app.update(cx, |state, cx| state.set_markdown_mode(!markdown_mode, cx))
69 }),
72 }),
70 )
73 )
74 .child(
75 toggle_row(
76 "settings-actions-on-right-click",
77 "Show message actions on right click",
78 ACTIONS_DETAIL,
79 theme::text_muted(),
80 actions_on_right_click,
81 )
82 .on_click(move |_, _, cx| {
83 actions_app.update(cx, |state, cx| {
84 state.set_actions_on_right_click(!actions_on_right_click, cx)
85 })
86 }),
87 )
71 .child(
88 .child(
72 toggle_row(
89 toggle_row(
73 "settings-read-receipts",
90 "settings-read-receipts",
crates/app/src/views/conversation.rs +18 −2
@@ -233,6 +233,7 @@ pub struct ConversationView {
233 233 downloads: Downloads,
234 234 hovered_message: Option<String>,
235 235 toolbar_hovered: Option<String>,
236 toolbar_opened: Option<String>,
236 237 timeline_bounds: TimelineBounds,
237 238 header_width: Rc<Cell<f32>>,
238 239 toolbar_pinned: Option<String>,
@@ -581,6 +582,7 @@ impl ConversationView {
581 582 downloads: Downloads::default(),
582 583 hovered_message: None,
583 584 toolbar_hovered: None,
585 toolbar_opened: None,
584 586 timeline_bounds: TimelineBounds::default(),
585 587 header_width: Rc::default(),
586 588 toolbar_pinned: None,
@@ -2690,6 +2692,9 @@ impl ConversationView {
2690 2692 } else if target.as_deref() == Some(key) {
2691 2693 *target = None;
2692 2694 }
2695 if !hovered && matches!(slot, HoverSlot::Row) && self.toolbar_opened.as_deref() == Some(key) {
2696 self.toolbar_opened = None;
2697 }
2693 2698 if hovered
2694 2699 && matches!(slot, HoverSlot::Row)
2695 2700 && self.toolbar_hovered.as_deref().is_some_and(|toolbar| toolbar != key)
@@ -2722,16 +2727,27 @@ impl ConversationView {
2722 2727 cx.notify();
2723 2728 }
2724 2729
2725 fn toolbar_visible(&self, key: &str) -> bool {
2730 fn toolbar_visible(&self, key: &str, cx: &App) -> bool {
2731 let row_trigger = if self.app.read(cx).actions_on_right_click {
2732 self.toolbar_opened.as_deref()
2733 } else {
2734 self.hovered_message.as_deref()
2735 };
2726 2736 self.toolbar_suppressed.as_deref() != Some(key)
2727 2737 && self
2728 2738 .toolbar_pinned
2729 2739 .as_deref()
2730 2740 .or(self.toolbar_hovered.as_deref())
2731 .or(self.hovered_message.as_deref())
2741 .or(row_trigger)
2732 2742 == Some(key)
2733 2743 }
2734 2744
2745 fn open_toolbar(&mut self, key: &str, cx: &mut Context<Self>) {
2746 self.toolbar_opened = Some(key.to_owned());
2747 self.toolbar_suppressed = None;
2748 cx.notify();
2749 }
2750
2735 2751 fn toggle_reaction(&mut self, message_id: &str, glyph: &str, cx: &mut Context<Self>) {
2736 2752 self.change_reaction(message_id, glyph, false, None, cx);
2737 2753 }
@@ -233,6 +233,7 @@ pub struct ConversationView {
233 downloads: Downloads,
233 downloads: Downloads,
234 hovered_message: Option<String>,
234 hovered_message: Option<String>,
235 toolbar_hovered: Option<String>,
235 toolbar_hovered: Option<String>,
236 toolbar_opened: Option<String>,
236 timeline_bounds: TimelineBounds,
237 timeline_bounds: TimelineBounds,
237 header_width: Rc<Cell<f32>>,
238 header_width: Rc<Cell<f32>>,
238 toolbar_pinned: Option<String>,
239 toolbar_pinned: Option<String>,
@@ -581,6 +582,7 @@ impl ConversationView {
581 downloads: Downloads::default(),
582 downloads: Downloads::default(),
582 hovered_message: None,
583 hovered_message: None,
583 toolbar_hovered: None,
584 toolbar_hovered: None,
585 toolbar_opened: None,
584 timeline_bounds: TimelineBounds::default(),
586 timeline_bounds: TimelineBounds::default(),
585 header_width: Rc::default(),
587 header_width: Rc::default(),
586 toolbar_pinned: None,
588 toolbar_pinned: None,
@@ -2690,6 +2692,9 @@ impl ConversationView {
2690 } else if target.as_deref() == Some(key) {
2692 } else if target.as_deref() == Some(key) {
2691 *target = None;
2693 *target = None;
2692 }
2694 }
2695 if !hovered && matches!(slot, HoverSlot::Row) && self.toolbar_opened.as_deref() == Some(key) {
2696 self.toolbar_opened = None;
2697 }
2693 if hovered
2698 if hovered
2694 && matches!(slot, HoverSlot::Row)
2699 && matches!(slot, HoverSlot::Row)
2695 && self.toolbar_hovered.as_deref().is_some_and(|toolbar| toolbar != key)
2700 && self.toolbar_hovered.as_deref().is_some_and(|toolbar| toolbar != key)
@@ -2722,16 +2727,27 @@ impl ConversationView {
2722 cx.notify();
2727 cx.notify();
2723 }
2728 }
2724
2729
2725 fn toolbar_visible(&self, key: &str) -> bool {
2730 fn toolbar_visible(&self, key: &str, cx: &App) -> bool {
2731 let row_trigger = if self.app.read(cx).actions_on_right_click {
2732 self.toolbar_opened.as_deref()
2733 } else {
2734 self.hovered_message.as_deref()
2735 };
2726 self.toolbar_suppressed.as_deref() != Some(key)
2736 self.toolbar_suppressed.as_deref() != Some(key)
2727 && self
2737 && self
2728 .toolbar_pinned
2738 .toolbar_pinned
2729 .as_deref()
2739 .as_deref()
2730 .or(self.toolbar_hovered.as_deref())
2740 .or(self.toolbar_hovered.as_deref())
2731 .or(self.hovered_message.as_deref())
2741 .or(row_trigger)
2732 == Some(key)
2742 == Some(key)
2733 }
2743 }
2734
2744
2745 fn open_toolbar(&mut self, key: &str, cx: &mut Context<Self>) {
2746 self.toolbar_opened = Some(key.to_owned());
2747 self.toolbar_suppressed = None;
2748 cx.notify();
2749 }
2750
2735 fn toggle_reaction(&mut self, message_id: &str, glyph: &str, cx: &mut Context<Self>) {
2751 fn toggle_reaction(&mut self, message_id: &str, glyph: &str, cx: &mut Context<Self>) {
2736 self.change_reaction(message_id, glyph, false, None, cx);
2752 self.change_reaction(message_id, glyph, false, None, cx);
2737 }
2753 }
crates/app/src/views/conversation/render_env.rs +6 −1
@@ -236,17 +236,22 @@ impl RenderEnv {
236 236 });
237 237 let menu = this.message_menu(message, mine, refresh, view.clone(), cx);
238 238 let react = menu.react.clone();
239 let visible = this.toolbar_visible(&message.key);
239 let visible = this.toolbar_visible(&message.key, cx);
240 240 let controls = (!message.reactions.is_empty())
241 241 .then(|| this.reaction_controls(&message.key, view.clone()));
242 242 let adder = (!message.reactions.is_empty()).then(|| menu.reaction_adder());
243 243 (visible.then_some(menu), Some(react), controls, adder)
244 244 })
245 245 .unwrap_or((None, None, None, None));
246 let right_click_opens_actions = self.app.read(cx).actions_on_right_click;
246 247 let reply = (is_real && !message.deleted).then(|| {
247 248 let (view, key, handle) = (view.clone(), message.key.clone(), window.window_handle());
248 249 boxed(move |cx| {
249 250 let (view, key) = (view.clone(), key.clone());
251 if right_click_opens_actions {
252 view.update(cx, |this, cx| this.open_toolbar(&key, cx)).ok();
253 return;
254 }
250 255 handle
251 256 .update(cx, move |_, window, cx| {
252 257 view.update(cx, |this, cx| this.begin_reply(&key, window, cx))
@@ -236,17 +236,22 @@ impl RenderEnv {
236 });
236 });
237 let menu = this.message_menu(message, mine, refresh, view.clone(), cx);
237 let menu = this.message_menu(message, mine, refresh, view.clone(), cx);
238 let react = menu.react.clone();
238 let react = menu.react.clone();
239 let visible = this.toolbar_visible(&message.key);
239 let visible = this.toolbar_visible(&message.key, cx);
240 let controls = (!message.reactions.is_empty())
240 let controls = (!message.reactions.is_empty())
241 .then(|| this.reaction_controls(&message.key, view.clone()));
241 .then(|| this.reaction_controls(&message.key, view.clone()));
242 let adder = (!message.reactions.is_empty()).then(|| menu.reaction_adder());
242 let adder = (!message.reactions.is_empty()).then(|| menu.reaction_adder());
243 (visible.then_some(menu), Some(react), controls, adder)
243 (visible.then_some(menu), Some(react), controls, adder)
244 })
244 })
245 .unwrap_or((None, None, None, None));
245 .unwrap_or((None, None, None, None));
246 let right_click_opens_actions = self.app.read(cx).actions_on_right_click;
246 let reply = (is_real && !message.deleted).then(|| {
247 let reply = (is_real && !message.deleted).then(|| {
247 let (view, key, handle) = (view.clone(), message.key.clone(), window.window_handle());
248 let (view, key, handle) = (view.clone(), message.key.clone(), window.window_handle());
248 boxed(move |cx| {
249 boxed(move |cx| {
249 let (view, key) = (view.clone(), key.clone());
250 let (view, key) = (view.clone(), key.clone());
251 if right_click_opens_actions {
252 view.update(cx, |this, cx| this.open_toolbar(&key, cx)).ok();
253 return;
254 }
250 handle
255 handle
251 .update(cx, move |_, window, cx| {
256 .update(cx, move |_, window, cx| {
252 view.update(cx, |this, cx| this.begin_reply(&key, window, cx))
257 view.update(cx, |this, cx| this.begin_reply(&key, window, cx))
crates/app/src/views/conversation/scheduled.rs +1 −1
@@ -464,7 +464,7 @@ impl ConversationView {
464 464 };
465 465 let visible = view
466 466 .upgrade()
467 .is_some_and(|entity| entity.read(cx).toolbar_visible(&row.key));
467 .is_some_and(|entity| entity.read(cx).toolbar_visible(&row.key, cx));
468 468 Some(ScheduledRowActions {
469 469 delivery: DeliveryActions {
470 470 retry,
@@ -464,7 +464,7 @@ impl ConversationView {
464 };
464 };
465 let visible = view
465 let visible = view
466 .upgrade()
466 .upgrade()
467 .is_some_and(|entity| entity.read(cx).toolbar_visible(&row.key));
467 .is_some_and(|entity| entity.read(cx).toolbar_visible(&row.key, cx));
468 Some(ScheduledRowActions {
468 Some(ScheduledRowActions {
469 delivery: DeliveryActions {
469 delivery: DeliveryActions {
470 retry,
470 retry,