M9: comment.people lists people who wrote in two cases once

The participant list is deduplicated in any case too, not only the names added from mentions, in
one pass (CodeRabbit on #1591).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon ThomasandClaude Opus 5.5 committed 2026-10-29 21:45:15 -04:00
1 parent 1c97b6fb49
commit a02e975a7f
2 files changed
+18 -6

No files matched your search

+9 -6
View File
@@ -385,12 +385,15 @@ const PROMPT_MAX_MENTIONS: usize = 32;
fn people_and_mentioned(doc: &Document, you: &str) -> Vec<String> {
let people = doc.comment_people();
let resolve = mentionable(&people, you);
let mut out = people.clone();
for m in doc.comments.iter().flat_map(Comment::messages) {
for (name, _) in mentioned(&m.text, &resolve) {
if !out.iter().any(|p| p.eq_ignore_ascii_case(name)) {
out.push(name.to_string());
}
let mut seen = std::collections::HashSet::new();
let mut out: Vec<String> = Vec::new();
let names = people
.iter()
.map(String::as_str)
.chain(doc.comments.iter().flat_map(Comment::messages).flat_map(|m| mentioned(&m.text, &resolve).map(|(n, _)| n)));
for name in names {
if seen.insert(name.to_lowercase()) {
out.push(name.to_string());
}
}
out.sort_by(|a, b| a.to_lowercase().cmp(&b.to_lowercase()).then_with(|| a.cmp(b)));
@@ -90,6 +90,15 @@ fn people_lists_the_names_only_mentioned_too() {
assert_eq!(p["you"], "You");
}
#[test]
fn people_who_write_in_two_cases_are_listed_once() {
let mut s = Session::new();
let id = add(&mut s, "Hi", "Ada");
s.execute("comment.reply", &json!({"id": id, "text": "Hi @ADA", "author": "ada"})).unwrap();
let p = s.execute("comment.people", &json!({})).unwrap();
assert_eq!(p["people"].as_array().map(Vec::len), Some(1), "{}", p["people"]);
}
#[test]
fn next_and_prompt_carry_the_mentions_too() {
let mut s = Session::new();