From 8ac011cc62025522894b2518241ad4146103e18a Mon Sep 17 00:00:00 2001 From: chaodu-agent Date: Wed, 15 Apr 2026 20:04:41 +0000 Subject: [PATCH] fix: strip @(role) and @(user) placeholders in shorten_thread_name() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #372 — thread titles leaked literal @(role)/@(user) placeholders from resolve_mentions(). Now stripped before shortening. --- src/discord.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/discord.rs b/src/discord.rs index 0311b898..278d3bf1 100644 --- a/src/discord.rs +++ b/src/discord.rs @@ -821,9 +821,11 @@ fn resolve_mentions(content: &str, bot_id: UserId, mentions: &[User]) -> String } fn shorten_thread_name(prompt: &str) -> String { + // Strip @(role) and @(user) placeholders left by resolve_mentions() + let cleaned = prompt.replace("@(role)", "").replace("@(user)", ""); // Shorten GitHub URLs: https://github.com/owner/repo/issues/123 → owner/repo#123 let re = regex::Regex::new(r"https?://github\.com/([^/]+/[^/]+)/(issues|pull)/(\d+)").unwrap(); - let shortened = re.replace_all(prompt, "$1#$3"); + let shortened = re.replace_all(cleaned.trim(), "$1#$3"); let name: String = shortened.chars().take(40).collect(); if name.len() < shortened.len() { format!("{name}...")