BlueGit

ict rusty-teams

fix(channels): activity jumps reach the reply, the reply box stays in view

- a channel reply from Activity opens its thread on the reply (Teams), root post as fallback
- a root post not in the cache opens its thread and loads it from the server
- the inline reply box scrolls into view while it grows

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
9cd8dd457d34d45902ccf37a2740d8d7b718607d
Parent
ac1c914a
7 files changed +65 −1
crates/app-state/src/activity/feed.rs +1 −0
@@ -159,6 +159,7 @@ pub struct Entry {
159 159 pub counts_for_bell: bool,
160 160 pub source_label: Option<String>,
161 161 pub link: Option<String>,
162 pub reply_id: Option<String>,
162 163 }
163 164
164 165 impl Entry {
@@ -159,6 +159,7 @@ pub struct Entry {
159 pub counts_for_bell: bool,
159 pub counts_for_bell: bool,
160 pub source_label: Option<String>,
160 pub source_label: Option<String>,
161 pub link: Option<String>,
161 pub link: Option<String>,
162 pub reply_id: Option<String>,
162}
163}
163
164
164impl Entry {
165impl Entry {
crates/app-state/src/activity/server.rs +10 −0
@@ -59,6 +59,7 @@ fn entry_of(item: &ActivityItem) -> Entry {
59 59 counts_for_bell: false,
60 60 source_label: item.source_app_name.clone().or_else(|| item.thread_topic.clone()),
61 61 link: item.tap_url.clone(),
62 reply_id: channel_reply(item, kind),
62 63 }
63 64 }
64 65
@@ -80,6 +81,13 @@ pub fn kind_of(item: &ActivityItem) -> Kind {
80 81 }
81 82 }
82 83
84 fn channel_reply(item: &ActivityItem, kind: Kind) -> Option<String> {
85 let target = jump_target(item, kind);
86 item.source_message_id
87 .clone()
88 .filter(|reply_id| !target.is_empty() && *reply_id != target)
89 }
90
83 91 fn jump_target(item: &ActivityItem, kind: Kind) -> String {
84 92 if matches!(kind, Kind::MissedCall | Kind::Call | Kind::Team | Kind::App) {
85 93 return String::new();
@@ -159,11 +167,13 @@ mod tests {
159 167 fn a_channel_reply_jumps_to_its_root_and_a_chat_to_the_message() {
160 168 let channel = entry_of(&item("replyToReply", ""));
161 169 assert_eq!(channel.message_id, "1791367000001");
170 assert_eq!(channel.reply_id.as_deref(), Some("1791367000002"));
162 171 let chat = entry_of(&ActivityItem {
163 172 thread_type: Some("chat".into()),
164 173 ..item("mentionInChat", "person")
165 174 });
166 175 assert_eq!(chat.message_id, "1791367000002");
176 assert_eq!(chat.reply_id, None);
167 177 assert_eq!(entry_of(&item("call", "missedCall")).message_id, "");
168 178 assert_eq!(chat.actors[0].user_id.as_deref(), Some("user-1"));
169 179 }
@@ -59,6 +59,7 @@ fn entry_of(item: &ActivityItem) -> Entry {
59 counts_for_bell: false,
59 counts_for_bell: false,
60 source_label: item.source_app_name.clone().or_else(|| item.thread_topic.clone()),
60 source_label: item.source_app_name.clone().or_else(|| item.thread_topic.clone()),
61 link: item.tap_url.clone(),
61 link: item.tap_url.clone(),
62 reply_id: channel_reply(item, kind),
62 }
63 }
63}
64}
64
65
@@ -80,6 +81,13 @@ pub fn kind_of(item: &ActivityItem) -> Kind {
80 }
81 }
81}
82}
82
83
84fn channel_reply(item: &ActivityItem, kind: Kind) -> Option<String> {
85 let target = jump_target(item, kind);
86 item.source_message_id
87 .clone()
88 .filter(|reply_id| !target.is_empty() && *reply_id != target)
89}
90
83fn jump_target(item: &ActivityItem, kind: Kind) -> String {
91fn jump_target(item: &ActivityItem, kind: Kind) -> String {
84 if matches!(kind, Kind::MissedCall | Kind::Call | Kind::Team | Kind::App) {
92 if matches!(kind, Kind::MissedCall | Kind::Call | Kind::Team | Kind::App) {
85 return String::new();
93 return String::new();
@@ -159,11 +167,13 @@ mod tests {
159 fn a_channel_reply_jumps_to_its_root_and_a_chat_to_the_message() {
167 fn a_channel_reply_jumps_to_its_root_and_a_chat_to_the_message() {
160 let channel = entry_of(&item("replyToReply", ""));
168 let channel = entry_of(&item("replyToReply", ""));
161 assert_eq!(channel.message_id, "1791367000001");
169 assert_eq!(channel.message_id, "1791367000001");
170 assert_eq!(channel.reply_id.as_deref(), Some("1791367000002"));
162 let chat = entry_of(&ActivityItem {
171 let chat = entry_of(&ActivityItem {
163 thread_type: Some("chat".into()),
172 thread_type: Some("chat".into()),
164 ..item("mentionInChat", "person")
173 ..item("mentionInChat", "person")
165 });
174 });
166 assert_eq!(chat.message_id, "1791367000002");
175 assert_eq!(chat.message_id, "1791367000002");
176 assert_eq!(chat.reply_id, None);
167 assert_eq!(entry_of(&item("call", "missedCall")).message_id, "");
177 assert_eq!(entry_of(&item("call", "missedCall")).message_id, "");
168 assert_eq!(chat.actors[0].user_id.as_deref(), Some("user-1"));
178 assert_eq!(chat.actors[0].user_id.as_deref(), Some("user-1"));
169 }
179 }
crates/app/src/views/activity_panel.rs +8 −1
@@ -98,9 +98,16 @@ impl ActivityPanel {
98 98 let Some(entry) = self.activity.read(cx).feed().get(id) else {
99 99 return;
100 100 };
101 let stored_reply = entry.reply_id.clone().filter(|reply_id| {
102 self.app
103 .read(cx)
104 .store
105 .messages_by_id(&entry.conversation_id, std::slice::from_ref(reply_id))
106 .is_ok_and(|found| !found.is_empty())
107 });
101 108 let event = ActivityPanelEvent::Open {
102 109 conversation_id: entry.conversation_id.clone(),
103 message_id: entry.message_id.clone(),
110 message_id: stored_reply.unwrap_or_else(|| entry.message_id.clone()),
104 111 link: entry.link.clone(),
105 112 };
106 113 self.activity
@@ -98,9 +98,16 @@ impl ActivityPanel {
98 let Some(entry) = self.activity.read(cx).feed().get(id) else {
98 let Some(entry) = self.activity.read(cx).feed().get(id) else {
99 return;
99 return;
100 };
100 };
101 let stored_reply = entry.reply_id.clone().filter(|reply_id| {
102 self.app
103 .read(cx)
104 .store
105 .messages_by_id(&entry.conversation_id, std::slice::from_ref(reply_id))
106 .is_ok_and(|found| !found.is_empty())
107 });
101 let event = ActivityPanelEvent::Open {
108 let event = ActivityPanelEvent::Open {
102 conversation_id: entry.conversation_id.clone(),
109 conversation_id: entry.conversation_id.clone(),
103 message_id: entry.message_id.clone(),
110 message_id: stored_reply.unwrap_or_else(|| entry.message_id.clone()),
104 link: entry.link.clone(),
111 link: entry.link.clone(),
105 };
112 };
106 self.activity
113 self.activity
crates/app/src/views/composer.rs +2 −0
@@ -132,6 +132,7 @@ pub enum ComposerEvent {
132 132 EditLast,
133 133 FocusMessages,
134 134 Typing(bool),
135 Edited,
135 136 }
136 137
137 138 struct MentionPopup {
@@ -530,6 +531,7 @@ impl Composer {
530 531 self.update_slash(cx);
531 532 self.update_link_preview(cx);
532 533 self.schedule_draft_save(cx);
534 cx.emit(ComposerEvent::Edited);
533 535 }
534 536 let value = input.read(cx).value();
535 537 if submitted_text(event, &value).is_some()
@@ -132,6 +132,7 @@ pub enum ComposerEvent {
132 EditLast,
132 EditLast,
133 FocusMessages,
133 FocusMessages,
134 Typing(bool),
134 Typing(bool),
135 Edited,
135}
136}
136
137
137struct MentionPopup {
138struct MentionPopup {
@@ -530,6 +531,7 @@ impl Composer {
530 self.update_slash(cx);
531 self.update_slash(cx);
531 self.update_link_preview(cx);
532 self.update_link_preview(cx);
532 self.schedule_draft_save(cx);
533 self.schedule_draft_save(cx);
534 cx.emit(ComposerEvent::Edited);
533 }
535 }
534 let value = input.read(cx).value();
536 let value = input.read(cx).value();
535 if submitted_text(event, &value).is_some()
537 if submitted_text(event, &value).is_some()
crates/app/src/views/conversation.rs +16 −0
@@ -772,6 +772,7 @@ impl ConversationView {
772 772 ComposerEvent::EditLast => self.edit_last_own(window, cx),
773 773 ComposerEvent::FocusMessages => window.focus(&self.focus_handle, cx),
774 774 ComposerEvent::Typing(active) => self.send_typing(*active, cx),
775 ComposerEvent::Edited => {}
775 776 }
776 777 }
777 778
@@ -1183,6 +1184,7 @@ impl ConversationView {
1183 1184 }
1184 1185 }
1185 1186 let Some(record) = record else {
1187 self.open_unloaded_post(message_id, cx);
1186 1188 return;
1187 1189 };
1188 1190 let messages_from_target = store
@@ -1232,6 +1234,20 @@ impl ConversationView {
1232 1234 self.reveal_row(target_key, cx);
1233 1235 }
1234 1236
1237 fn open_unloaded_post(&mut self, root_id: &str, cx: &mut Context<Self>) {
1238 let in_channel = self
1239 .current
1240 .as_ref()
1241 .is_some_and(|current| matches!(current.selection, Selection::Channel(_)));
1242 if !in_channel {
1243 return;
1244 }
1245 self.pane = ChannelPane::Posts;
1246 self.enter_thread_mode(root_id.to_owned(), cx);
1247 self.refresh_thread(root_id.to_owned(), cx);
1248 self.rebuild(true, cx);
1249 }
1250
1235 1251 fn reveal_row(&mut self, target_key: String, cx: &mut Context<Self>) {
1236 1252 let index = self
1237 1253 .rows
@@ -772,6 +772,7 @@ impl ConversationView {
772 ComposerEvent::EditLast => self.edit_last_own(window, cx),
772 ComposerEvent::EditLast => self.edit_last_own(window, cx),
773 ComposerEvent::FocusMessages => window.focus(&self.focus_handle, cx),
773 ComposerEvent::FocusMessages => window.focus(&self.focus_handle, cx),
774 ComposerEvent::Typing(active) => self.send_typing(*active, cx),
774 ComposerEvent::Typing(active) => self.send_typing(*active, cx),
775 ComposerEvent::Edited => {}
775 }
776 }
776 }
777 }
777
778
@@ -1183,6 +1184,7 @@ impl ConversationView {
1183 }
1184 }
1184 }
1185 }
1185 let Some(record) = record else {
1186 let Some(record) = record else {
1187 self.open_unloaded_post(message_id, cx);
1186 return;
1188 return;
1187 };
1189 };
1188 let messages_from_target = store
1190 let messages_from_target = store
@@ -1232,6 +1234,20 @@ impl ConversationView {
1232 self.reveal_row(target_key, cx);
1234 self.reveal_row(target_key, cx);
1233 }
1235 }
1234
1236
1237 fn open_unloaded_post(&mut self, root_id: &str, cx: &mut Context<Self>) {
1238 let in_channel = self
1239 .current
1240 .as_ref()
1241 .is_some_and(|current| matches!(current.selection, Selection::Channel(_)));
1242 if !in_channel {
1243 return;
1244 }
1245 self.pane = ChannelPane::Posts;
1246 self.enter_thread_mode(root_id.to_owned(), cx);
1247 self.refresh_thread(root_id.to_owned(), cx);
1248 self.rebuild(true, cx);
1249 }
1250
1235 fn reveal_row(&mut self, target_key: String, cx: &mut Context<Self>) {
1251 fn reveal_row(&mut self, target_key: String, cx: &mut Context<Self>) {
1236 let index = self
1252 let index = self
1237 .rows
1253 .rows
crates/app/src/views/conversation/feed.rs +18 −0
@@ -110,6 +110,23 @@ impl ConversationView {
110 110 composer
111 111 }
112 112
113 fn keep_reply_editor_in_view(&mut self, window: &mut Window, cx: &mut Context<Self>) {
114 let Some(root_id) = self.reply_root.clone() else {
115 return;
116 };
117 let view = cx.entity().downgrade();
118 window.on_next_frame(move |_, cx| {
119 view.update(cx, |this, cx| {
120 let index = this.rows.borrow().iter().position(|row| row.key() == root_id);
121 if let Some(index) = index {
122 this.scroller
123 .update(cx, |scroller, cx| scroller.reveal_item(index, cx));
124 }
125 })
126 .ok();
127 });
128 }
129
113 130 pub(super) fn sync_reply_composer(&mut self, window: &mut Window, cx: &mut Context<Self>) {
114 131 self.reply_root = None;
115 132 let (Some(composer), Some(conversation_id)) =
@@ -190,6 +207,7 @@ impl ConversationView {
190 207 let root_id = self.reply_root.clone();
191 208 self.send_typing_in(root_id, *active, cx);
192 209 }
210 ComposerEvent::Edited => self.keep_reply_editor_in_view(window, cx),
193 211 ComposerEvent::Schedule { .. }
194 212 | ComposerEvent::EditLast
195 213 | ComposerEvent::FocusMessages => {}
@@ -110,6 +110,23 @@ impl ConversationView {
110 composer
110 composer
111 }
111 }
112
112
113 fn keep_reply_editor_in_view(&mut self, window: &mut Window, cx: &mut Context<Self>) {
114 let Some(root_id) = self.reply_root.clone() else {
115 return;
116 };
117 let view = cx.entity().downgrade();
118 window.on_next_frame(move |_, cx| {
119 view.update(cx, |this, cx| {
120 let index = this.rows.borrow().iter().position(|row| row.key() == root_id);
121 if let Some(index) = index {
122 this.scroller
123 .update(cx, |scroller, cx| scroller.reveal_item(index, cx));
124 }
125 })
126 .ok();
127 });
128 }
129
113 pub(super) fn sync_reply_composer(&mut self, window: &mut Window, cx: &mut Context<Self>) {
130 pub(super) fn sync_reply_composer(&mut self, window: &mut Window, cx: &mut Context<Self>) {
114 self.reply_root = None;
131 self.reply_root = None;
115 let (Some(composer), Some(conversation_id)) =
132 let (Some(composer), Some(conversation_id)) =
@@ -190,6 +207,7 @@ impl ConversationView {
190 let root_id = self.reply_root.clone();
207 let root_id = self.reply_root.clone();
191 self.send_typing_in(root_id, *active, cx);
208 self.send_typing_in(root_id, *active, cx);
192 }
209 }
210 ComposerEvent::Edited => self.keep_reply_editor_in_view(window, cx),
193 ComposerEvent::Schedule { .. }
211 ComposerEvent::Schedule { .. }
194 | ComposerEvent::EditLast
212 | ComposerEvent::EditLast
195 | ComposerEvent::FocusMessages => {}
213 | ComposerEvent::FocusMessages => {}
vendor/gpui-component/src/message_scroller.rs +10 −0
@@ -167,6 +167,16 @@ impl MessageScrollerState {
167 167 true
168 168 }
169 169
170 /// Scroll as little as needed to show the row at `index` in full.
171 pub fn reveal_item(&mut self, index: usize, cx: &mut Context<Self>) -> bool {
172 if index >= self.list_state.item_count() {
173 return false;
174 }
175 self.list_state.scroll_to_reveal_item(index);
176 cx.notify();
177 true
178 }
179
170 180 /// Return the space kept free above the first row.
171 181 pub fn top_inset(&self) -> gpui::Pixels {
172 182 self.top_inset
@@ -167,6 +167,16 @@ impl MessageScrollerState {
167 true
167 true
168 }
168 }
169
169
170 /// Scroll as little as needed to show the row at `index` in full.
171 pub fn reveal_item(&mut self, index: usize, cx: &mut Context<Self>) -> bool {
172 if index >= self.list_state.item_count() {
173 return false;
174 }
175 self.list_state.scroll_to_reveal_item(index);
176 cx.notify();
177 true
178 }
179
170 /// Return the space kept free above the first row.
180 /// Return the space kept free above the first row.
171 pub fn top_inset(&self) -> gpui::Pixels {
181 pub fn top_inset(&self) -> gpui::Pixels {
172 self.top_inset
182 self.top_inset