BlueGit

ict rusty-teams

fix(activity): channel jumps find the message and mark it in the feed

- chatsvc sends activity ids as floats, they were read as <id>.0: the jump found nothing and the reply load hit HTTP 400
- a channel reply opens the channel feed at its post and marks the reply, like Teams
- a post missing from the cache is fetched once, then the jump runs again

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
2c6d7dadc5b59891b4d6e0afc9960c12e8205fff
Parent
9cd8dd45
3 files changed +40 −39
crates/app/src/views/conversation.rs +37 −32
@@ -233,6 +233,7 @@ pub struct ConversationView {
233 233 picker: Entity<ReactionPicker>,
234 234 reaction_details: Option<ReactionDetails>,
235 235 highlighted_message: Option<String>,
236 fetched_jump: Option<String>,
236 237 pin_index: usize,
237 238 channel_details_open: bool,
238 239 pinned_posts_expanded: bool,
@@ -580,6 +581,7 @@ impl ConversationView {
580 581 picker,
581 582 reaction_details: None,
582 583 highlighted_message: None,
584 fetched_jump: None,
583 585 pin_index: 0,
584 586 channel_details_open: false,
585 587 pinned_posts_expanded: false,
@@ -1210,54 +1212,57 @@ impl ConversationView {
1210 1212 let in_channel = matches!(current.selection, Selection::Channel(_));
1211 1213 if in_channel {
1212 1214 self.pane = ChannelPane::Posts;
1213 match record.reply_to_id.clone() {
1214 Some(root_id) => {
1215 self.enter_thread_mode(root_id.clone(), cx);
1216 self.refresh_thread(root_id, cx);
1217 }
1218 None => {
1219 self.enter_feed_mode();
1220 }
1221 }
1215 self.enter_feed_mode();
1222 1216 }
1223 let in_thread = self
1224 .current
1225 .as_ref()
1226 .is_some_and(|current| matches!(current.mode, ViewMode::Thread(_)));
1227 let target_key = if in_thread {
1228 message_id.to_owned()
1229 } else {
1230 row_key
1231 };
1232 1217 self.reload_pending(cx);
1233 1218 self.rebuild(true, cx);
1234 self.reveal_row(target_key, cx);
1219 self.reveal_row(row_key, message_id.to_owned(), cx);
1235 1220 }
1236 1221
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 {
1222 fn open_unloaded_post(&mut self, message_id: &str, cx: &mut Context<Self>) {
1223 let state = self.app.read(cx);
1224 let (Some(engine), Some(current)) = (state.engine.clone(), self.current.as_ref()) else {
1225 return;
1226 };
1227 if !matches!(current.selection, Selection::Channel(_))
1228 || state.mode.demo
1229 || self.fetched_jump.as_deref() == Some(message_id)
1230 {
1243 1231 return;
1244 1232 }
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);
1233 self.fetched_jump = Some(message_id.to_owned());
1234 let conversation_id = current.selection.conversation_id().to_owned();
1235 let (task_conversation_id, task_message_id) = (conversation_id.clone(), message_id.to_owned());
1236 let receiver = runtime::spawn(async move {
1237 engine
1238 .refresh_message(&task_conversation_id, &task_message_id)
1239 .await
1240 });
1241 let message_id = message_id.to_owned();
1242 cx.spawn(async move |this, cx| {
1243 let Ok(Ok(Some(_))) = receiver.await else {
1244 return;
1245 };
1246 this.update(cx, |this, cx| {
1247 if this.conversation_id().as_deref() == Some(conversation_id.as_str()) {
1248 this.jump_to_message(&conversation_id, &message_id, cx);
1249 }
1250 })
1251 .ok();
1252 })
1253 .detach();
1249 1254 }
1250 1255
1251 fn reveal_row(&mut self, target_key: String, cx: &mut Context<Self>) {
1256 fn reveal_row(&mut self, row_key: String, message_key: String, cx: &mut Context<Self>) {
1252 1257 let index = self
1253 1258 .rows
1254 1259 .borrow()
1255 1260 .iter()
1256 .position(|row| row.key() == target_key);
1261 .position(|row| row.key() == row_key);
1257 1262 if let Some(index) = index {
1258 1263 self.scroller
1259 1264 .update(cx, |scroller, cx| scroller.scroll_to_item(index, cx));
1260 self.highlight(target_key, cx);
1265 self.highlight(message_key, cx);
1261 1266 }
1262 1267 }
1263 1268
@@ -233,6 +233,7 @@ pub struct ConversationView {
233 picker: Entity<ReactionPicker>,
233 picker: Entity<ReactionPicker>,
234 reaction_details: Option<ReactionDetails>,
234 reaction_details: Option<ReactionDetails>,
235 highlighted_message: Option<String>,
235 highlighted_message: Option<String>,
236 fetched_jump: Option<String>,
236 pin_index: usize,
237 pin_index: usize,
237 channel_details_open: bool,
238 channel_details_open: bool,
238 pinned_posts_expanded: bool,
239 pinned_posts_expanded: bool,
@@ -580,6 +581,7 @@ impl ConversationView {
580 picker,
581 picker,
581 reaction_details: None,
582 reaction_details: None,
582 highlighted_message: None,
583 highlighted_message: None,
584 fetched_jump: None,
583 pin_index: 0,
585 pin_index: 0,
584 channel_details_open: false,
586 channel_details_open: false,
585 pinned_posts_expanded: false,
587 pinned_posts_expanded: false,
@@ -1210,54 +1212,57 @@ impl ConversationView {
1210 let in_channel = matches!(current.selection, Selection::Channel(_));
1212 let in_channel = matches!(current.selection, Selection::Channel(_));
1211 if in_channel {
1213 if in_channel {
1212 self.pane = ChannelPane::Posts;
1214 self.pane = ChannelPane::Posts;
1213 match record.reply_to_id.clone() {
1215 self.enter_feed_mode();
1214 Some(root_id) => {
1215 self.enter_thread_mode(root_id.clone(), cx);
1216 self.refresh_thread(root_id, cx);
1217 }
1218 None => {
1219 self.enter_feed_mode();
1220 }
1221 }
1222 }
1216 }
1223 let in_thread = self
1224 .current
1225 .as_ref()
1226 .is_some_and(|current| matches!(current.mode, ViewMode::Thread(_)));
1227 let target_key = if in_thread {
1228 message_id.to_owned()
1229 } else {
1230 row_key
1231 };
1232 self.reload_pending(cx);
1217 self.reload_pending(cx);
1233 self.rebuild(true, cx);
1218 self.rebuild(true, cx);
1234 self.reveal_row(target_key, cx);
1219 self.reveal_row(row_key, message_id.to_owned(), cx);
1235 }
1220 }
1236
1221
1237 fn open_unloaded_post(&mut self, root_id: &str, cx: &mut Context<Self>) {
1222 fn open_unloaded_post(&mut self, message_id: &str, cx: &mut Context<Self>) {
1238 let in_channel = self
1223 let state = self.app.read(cx);
1239 .current
1224 let (Some(engine), Some(current)) = (state.engine.clone(), self.current.as_ref()) else {
1240 .as_ref()
1225 return;
1241 .is_some_and(|current| matches!(current.selection, Selection::Channel(_)));
1226 };
1242 if !in_channel {
1227 if !matches!(current.selection, Selection::Channel(_))
1228 || state.mode.demo
1229 || self.fetched_jump.as_deref() == Some(message_id)
1230 {
1243 return;
1231 return;
1244 }
1232 }
1245 self.pane = ChannelPane::Posts;
1233 self.fetched_jump = Some(message_id.to_owned());
1246 self.enter_thread_mode(root_id.to_owned(), cx);
1234 let conversation_id = current.selection.conversation_id().to_owned();
1247 self.refresh_thread(root_id.to_owned(), cx);
1235 let (task_conversation_id, task_message_id) = (conversation_id.clone(), message_id.to_owned());
1248 self.rebuild(true, cx);
1236 let receiver = runtime::spawn(async move {
1237 engine
1238 .refresh_message(&task_conversation_id, &task_message_id)
1239 .await
1240 });
1241 let message_id = message_id.to_owned();
1242 cx.spawn(async move |this, cx| {
1243 let Ok(Ok(Some(_))) = receiver.await else {
1244 return;
1245 };
1246 this.update(cx, |this, cx| {
1247 if this.conversation_id().as_deref() == Some(conversation_id.as_str()) {
1248 this.jump_to_message(&conversation_id, &message_id, cx);
1249 }
1250 })
1251 .ok();
1252 })
1253 .detach();
1249 }
1254 }
1250
1255
1251 fn reveal_row(&mut self, target_key: String, cx: &mut Context<Self>) {
1256 fn reveal_row(&mut self, row_key: String, message_key: String, cx: &mut Context<Self>) {
1252 let index = self
1257 let index = self
1253 .rows
1258 .rows
1254 .borrow()
1259 .borrow()
1255 .iter()
1260 .iter()
1256 .position(|row| row.key() == target_key);
1261 .position(|row| row.key() == row_key);
1257 if let Some(index) = index {
1262 if let Some(index) = index {
1258 self.scroller
1263 self.scroller
1259 .update(cx, |scroller, cx| scroller.scroll_to_item(index, cx));
1264 .update(cx, |scroller, cx| scroller.scroll_to_item(index, cx));
1260 self.highlight(target_key, cx);
1265 self.highlight(message_key, cx);
1261 }
1266 }
1262 }
1267 }
1263
1268
crates/app/src/views/conversation/detached.rs +1 −1
@@ -127,7 +127,7 @@ impl ConversationView {
127 127 });
128 128 self.reload_pending(cx);
129 129 self.rebuild(true, cx);
130 self.reveal_row(message_id, cx);
130 self.reveal_row(message_id.clone(), message_id, cx);
131 131 }
132 132
133 133 pub(super) fn leave_detached(&mut self, cx: &mut Context<Self>) {
@@ -127,7 +127,7 @@ impl ConversationView {
127 });
127 });
128 self.reload_pending(cx);
128 self.reload_pending(cx);
129 self.rebuild(true, cx);
129 self.rebuild(true, cx);
130 self.reveal_row(message_id, cx);
130 self.reveal_row(message_id.clone(), message_id, cx);
131 }
131 }
132
132
133 pub(super) fn leave_detached(&mut self, cx: &mut Context<Self>) {
133 pub(super) fn leave_detached(&mut self, cx: &mut Context<Self>) {
crates/chatsvc/src/activity_feed.rs +2 −6
@@ -263,11 +263,7 @@ fn object_property(properties: &Value, key: &str) -> Option<Value> {
263 263 }
264 264
265 265 fn text_of(value: &Value) -> Option<String> {
266 match value {
267 Value::String(text) if !text.is_empty() => Some(text.clone()),
268 Value::Number(number) => Some(number.to_string()),
269 _ => None,
270 }
266 crate::json_id::id_text(value)
271 267 }
272 268
273 269 fn flag(value: Option<&Value>) -> bool {
@@ -343,7 +339,7 @@ mod tests {
343 339 message("1791368000001", 1791368000500, json!({
344 340 "activityId": 4711, "activityType": "reactionInChat", "activitySubtype": "heart",
345 341 "activityTimestamp": "1791368000000", "sourceThreadId": "19:a@thread.v2",
346 "sourceMessageId": 1791367000000_i64, "sourceReplyChainId": "1791367000000",
342 "sourceMessageId": 1791367000000.0, "sourceReplyChainId": "1791367000000",
347 343 "sourceUserId": "8:orgid:user-1", "sourceUserImDisplayName": "Ada Example",
348 344 "messagePreview": "Ship it", "messagePreviewTemplateOption": "hasText",
349 345 "sourceThreadTopic": "Release", "sourceThreadType": "chat", "count": "3"
@@ -263,11 +263,7 @@ fn object_property(properties: &Value, key: &str) -> Option<Value> {
263}
263}
264
264
265fn text_of(value: &Value) -> Option<String> {
265fn text_of(value: &Value) -> Option<String> {
266 match value {
266 crate::json_id::id_text(value)
267 Value::String(text) if !text.is_empty() => Some(text.clone()),
268 Value::Number(number) => Some(number.to_string()),
269 _ => None,
270 }
271}
267}
272
268
273fn flag(value: Option<&Value>) -> bool {
269fn flag(value: Option<&Value>) -> bool {
@@ -343,7 +339,7 @@ mod tests {
343 message("1791368000001", 1791368000500, json!({
339 message("1791368000001", 1791368000500, json!({
344 "activityId": 4711, "activityType": "reactionInChat", "activitySubtype": "heart",
340 "activityId": 4711, "activityType": "reactionInChat", "activitySubtype": "heart",
345 "activityTimestamp": "1791368000000", "sourceThreadId": "19:a@thread.v2",
341 "activityTimestamp": "1791368000000", "sourceThreadId": "19:a@thread.v2",
346 "sourceMessageId": 1791367000000_i64, "sourceReplyChainId": "1791367000000",
342 "sourceMessageId": 1791367000000.0, "sourceReplyChainId": "1791367000000",
347 "sourceUserId": "8:orgid:user-1", "sourceUserImDisplayName": "Ada Example",
343 "sourceUserId": "8:orgid:user-1", "sourceUserImDisplayName": "Ada Example",
348 "messagePreview": "Ship it", "messagePreviewTemplateOption": "hasText",
344 "messagePreview": "Ship it", "messagePreviewTemplateOption": "hasText",
349 "sourceThreadTopic": "Release", "sourceThreadType": "chat", "count": "3"
345 "sourceThreadTopic": "Release", "sourceThreadType": "chat", "count": "3"