Commit 44ab83f5c4

44ab83f5c447aa9bb96c4a86f473ae88fd9206bf

parent: 0ebc487ddd

Unsigned

Darafei Praliaskouski <me@komzpa.net> · 2026-07-21 21:58 UTC
committer: <strk@kbt.io>

fix: tidy thread buffer presentation

Layout: unified · split

src/room/buffer.rs +23 −3
@@ -383,12 +383,21 @@ fn buffer_contains_tag(buffer: &Buffer, tag: &Cow<str>) -> bool {
383383}
384384
385385fn sanitize_thread_id(thread_root: &EventId) -> String {
386 thread_root
386 const THREAD_ID_DISPLAY_CHARS: usize = 12;
387
388 let mut sanitized: String = thread_root
387389 .as_str()
388390 .trim_start_matches('$')
389391 .chars()
390392 .map(|c| if c.is_ascii_alphanumeric() { c } else { '_' })
391 .collect()
393 .take(THREAD_ID_DISPLAY_CHARS)
394 .collect();
395
396 if sanitized.is_empty() {
397 sanitized.push_str("unknown");
398 }
399
400 sanitized
392401}
393402
394403fn reply_sender_id_from_tags<T: AsRef<str>>(tags: &[T]) -> Option<OwnedUserId> {
@@ -508,6 +517,7 @@ mod tests {
508517
509518 use super::{
510519 format_buffer_name, reply_sender_id_from_tags, sanitize_thread_id,
520 RoomBuffer,
511521 };
512522
513523 #[test]
@@ -555,7 +565,17 @@ mod tests {
555565 fn sanitizes_thread_event_id_for_buffer_name() {
556566 assert_eq!(
557567 sanitize_thread_id(event_id!("$abc/def:example.org")),
558 "abc_def_example_org"
568 "abc_def_exam"
569 );
570 }
571
572 #[test]
573 fn thread_buffer_suffix_uses_short_human_id() {
574 assert_eq!(
575 RoomBuffer::thread_buffer_suffix(event_id!(
576 "$abcdef0123456789:example.org"
577 )),
578 "abcdef012345"
559579 );
560580 }
561581}
src/room/mod.rs −1
@@ -825,7 +825,6 @@ impl MatrixRoom {
825825
826826 buffer.set_localvar("room_id", self.room_id.as_str());
827827 buffer.set_localvar("thread_root", thread_root.as_str());
828 buffer.set_localvar("type", "thread");
829828 buffer.set_title(&format!(
830829 "Thread {} in {}",
831830 thread_root, room_short_name