Summary
Improve thread name generation to detect questions and truncate at word boundaries.
How Andy Does It
In bot.ts generateThreadName():
const MAX_THREAD_NAME_LENGTH = 80;
function generateThreadName(text: string): string {
const cleaned = text.replace(/\s+/g, ' ').trim();
// If empty, fall back to timestamp
if (!cleaned) {
const now = new Date();
return `💬 ${now.toLocaleString('en-US', {
month: 'short', day: 'numeric',
hour: 'numeric', minute: '2-digit',
hour12: true, timeZone: 'America/New_York',
})}`;
}
// If short enough, use as-is
if (cleaned.length <= MAX_THREAD_NAME_LENGTH) {
return cleaned;
}
// For questions, keep the question word and truncate
const questionMatch = cleaned.match(/^(What|How|Why|Can|Is|Are|Do|Does|Should|Would|Could|Will|Where|When|Who)\s/i);
if (questionMatch) {
// Truncate at word boundary
const truncated = cleaned.slice(0, MAX_THREAD_NAME_LENGTH);
const lastSpace = truncated.lastIndexOf(' ');
return (lastSpace > 20 ? truncated.slice(0, lastSpace) : truncated) + '...';
}
// Default: truncate at word boundary
const truncated = cleaned.slice(0, MAX_THREAD_NAME_LENGTH);
const lastSpace = truncated.lastIndexOf(' ');
return (lastSpace > 20 ? truncated.slice(0, lastSpace) : truncated) + '...';
}
Current Cord Behavior
Basic truncation at 50 chars with no word boundary awareness:
const threadName = rawText.length > 50
? rawText.slice(0, 47) + '...'
: rawText || 'New conversation';
Implementation
- Increase limit to 80 chars
- Add timestamp fallback for empty messages
- Truncate at word boundaries (find lastIndexOf(' '))
- Keep question words intact when possible
Priority
Low - cosmetic improvement
Summary
Improve thread name generation to detect questions and truncate at word boundaries.
How Andy Does It
In
bot.tsgenerateThreadName():Current Cord Behavior
Basic truncation at 50 chars with no word boundary awareness:
Implementation
Priority
Low - cosmetic improvement