Skip to content

feat(threads): auto-generate first-turn thread titles#1375

Open
maria-rcks wants to merge 5 commits intopingdotgg:mainfrom
maria-rcks:feat/title-summaries-2
Open

feat(threads): auto-generate first-turn thread titles#1375
maria-rcks wants to merge 5 commits intopingdotgg:mainfrom
maria-rcks:feat/title-summaries-2

Conversation

@maria-rcks
Copy link
Collaborator

@maria-rcks maria-rcks commented Mar 24, 2026

Closes #990

What Changed

  • use the existing text generation model setting for first-turn thread title generation
  • auto-generate a thread title from the first user prompt on the server
  • keep title generation off the critical path so the turn starts immediately
  • rename the settings copy from "Git writing model" to "Text generation model"
  • reuse the same text generation model for automatic worktree branch naming

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 model

image

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

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 textGenerationModel field 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 generateThreadTitle to the TextGeneration service and implementing it in CodexTextGeneration (including sanitization/truncation for sidebar display).

On thread.turn.start for the first user message, ProviderCommandReactor now forks background tasks to (1) generate+dispatch a thread.meta.update title 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 textGenerationModel through 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

  • Adds TextGeneration.generateThreadTitle to the TextGenerationService API, implemented in CodexTextGeneration with a prompt that produces concise titles from message text and attachments.
  • Titles are sanitized: single-line, de-quoted, whitespace-collapsed, and capped at 50 characters with an ellipsis fallback of 'New thread'.
  • On the first user turn, ProviderCommandReactor concurrently triggers both title generation (dispatching thread.meta.update) and worktree branch rename, using the textGenerationModel from the turn command if present.
  • The thread.turn.start command and thread.turn-start-requested event schemas are extended with an optional textGenerationModel field; ChatView forwards the value from user settings.
  • The 'Git writing model' settings label is renamed to 'Text generation model' to reflect its expanded scope.

Macroscope summarized 5335f66.

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7f9bc80e-ef54-4762-9b4a-e6301bb50d86

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Mar 24, 2026
@maria-rcks maria-rcks force-pushed the feat/title-summaries-2 branch from b256e14 to 5335f66 Compare March 24, 2026 20:32
Comment on lines +99 to +113
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()}...`;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support ai generated thread names

1 participant