Skip to content

Commit bb75862

Browse files
Stewart86claude
andcommitted
feat: hide thread title pattern from user messages
- Extract thread title in background for thread naming - Use regex to remove [THREAD_TITLE: <title>] pattern from user-visible messages - Apply filtering to both streaming content and final results - Thread creation happens silently without exposing internal formatting 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent ad549bb commit bb75862

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,20 @@ Be precise, actionable, and concise. Users value speed and accuracy over verbose
216216
if (content) {
217217
responseContent += content;
218218

219-
// Extract thread title if present
219+
// Extract thread title if present (but don't show to user)
220220
const titleMatch = content.match(/\[THREAD_TITLE:\s*([^\]]+)\]/);
221221
if (titleMatch && !threadTitle) {
222222
threadTitle = titleMatch[1].trim();
223223
console.log(`Extracted thread title: ${threadTitle}`);
224224
}
225225

226+
// Remove thread title from content before sending to user
227+
const userContent = content.replace(/\[THREAD_TITLE:\s*[^\]]+\]/g, '').trim();
228+
226229
// Send each chunk as a new message instead of editing
227230
try {
228-
if (content.trim()) {
229-
await channel.send(content);
231+
if (userContent) {
232+
await channel.send(userContent);
230233
lastMessageRef = true; // Just track that we've sent something
231234
}
232235
} catch (discordError) {
@@ -250,8 +253,12 @@ Be precise, actionable, and concise. Users value speed and accuracy over verbose
250253
// Only send final result if we haven't sent streaming messages
251254
try {
252255
if (!lastMessageRef) {
253-
await channel.send(responseContent);
254-
lastMessageRef = true;
256+
// Remove thread title from final response before sending to user
257+
const userResponse = responseContent.replace(/\[THREAD_TITLE:\s*[^\]]+\]/g, '').trim();
258+
if (userResponse) {
259+
await channel.send(userResponse);
260+
lastMessageRef = true;
261+
}
255262
}
256263
// If we were streaming, the final result is already incorporated
257264
} catch (discordError) {

0 commit comments

Comments
 (0)