feat(threads): auto-generate first-turn thread titles#1375
feat(threads): auto-generate first-turn thread titles#1375maria-rcks wants to merge 5 commits intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
b256e14 to
5335f66
Compare
| function sanitizeThreadTitle(raw: string): string { | ||
| const normalized = raw | ||
| .trim() | ||
| .split(/\r?\n/g)[0] | ||
| ?.trim() | ||
| .replace(/^['"`]+|['"`]+$/g, "") | ||
| .replace(/\s+/g, " "); | ||
| if (!normalized) { | ||
| return "New thread"; | ||
| } | ||
| if (normalized.length <= 50) { | ||
| return normalized; | ||
| } | ||
| return `${normalized.slice(0, 47).trimEnd()}...`; | ||
| } |
There was a problem hiding this comment.
🟢 Low Layers/CodexTextGeneration.ts:99
After stripping quotes and collapsing whitespace, a string like " " or ''' becomes " " — a non-empty whitespace-only string. The !normalized check passes, so the function returns whitespace instead of the expected "New thread" fallback. Consider checking !normalized.trim() instead of !normalized to ensure whitespace-only results fall back to the default.
function sanitizeThreadTitle(raw: string): string {
const normalized = raw
.trim()
.split(/\r?\n/g)[0]
?.trim()
.replace(/^['"`]+|['"`]+$/g, "")
.replace(/\s+/g, " ");
- if (!normalized) {
+ if (!normalized || !normalized.trim()) {
return "New thread";
}
if (normalized.length <= 50) {
return normalized;
}
return `${normalized.slice(0, 47).trimEnd()}...`;
}🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file apps/server/src/git/Layers/CodexTextGeneration.ts around lines 99-113:
After stripping quotes and collapsing whitespace, a string like `" "` or `'''` becomes `" "` — a non-empty whitespace-only string. The `!normalized` check passes, so the function returns whitespace instead of the expected `"New thread"` fallback. Consider checking `!normalized.trim()` instead of `!normalized` to ensure whitespace-only results fall back to the default.
Evidence trail:
apps/server/src/git/Layers/CodexTextGeneration.ts lines 99-111 at REVIEWED_COMMIT - The sanitizeThreadTitle function's normalization pipeline strips quotes and collapses whitespace, but the `!normalized` check doesn't catch whitespace-only results because `" "` is truthy in JavaScript.
Closes #990
What Changed
Why
Thread titles were still just truncated prompt text.
This makes new threads easier to scan while keeping the model selection simpler and reusing the same text generation path we already have for commit, PR, and branch text.
UI Changes
Settings now says
Text generation modelChecklist
Note
Medium Risk
Updates the turn-start flow to fork new background text-generation tasks (thread title + optional worktree branch rename) and threads a new
textGenerationModelfield through contracts/UI, which could affect first-turn behavior and naming if generation fails or produces unexpected output.Overview
Automatically generates a concise thread title from the first user message by adding
generateThreadTitleto theTextGenerationservice and implementing it inCodexTextGeneration(including sanitization/truncation for sidebar display).On
thread.turn.startfor the first user message,ProviderCommandReactornow forks background tasks to (1) generate+dispatch athread.meta.updatetitle and (2) reuse the same selected text-generation model for automatic temporary worktree branch renaming; failures are logged and do not block turn start.Threads an optional
textGenerationModelthrough the orchestration contracts/decider and web client dispatch, and updates settings copy from “Git writing model” to “Text generation model” to reflect the broader usage.Written by Cursor Bugbot for commit 5335f66. This will update automatically on new commits. Configure here.
Note
Auto-generate thread titles on the first user turn
TextGeneration.generateThreadTitleto theTextGenerationServiceAPI, implemented inCodexTextGenerationwith a prompt that produces concise titles from message text and attachments.'New thread'.ProviderCommandReactorconcurrently triggers both title generation (dispatchingthread.meta.update) and worktree branch rename, using thetextGenerationModelfrom the turn command if present.thread.turn.startcommand andthread.turn-start-requestedevent schemas are extended with an optionaltextGenerationModelfield;ChatViewforwards the value from user settings.Macroscope summarized 5335f66.