Skip to content

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

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

feat(threads): auto-generate first-turn thread titles#1375
maria-rcks wants to merge 9 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
Touches orchestration flow and shared contracts by introducing a new textGenerationModel field and server-side async title/branch generation on first turn; failures are logged and forked but could still impact thread metadata updates.

Overview
Auto-generates a thread title on the first user turn by forking a server-side generateThreadTitle call and dispatching thread.meta.update when it succeeds (kept off the critical path for turn start).

Extends the TextGeneration service with generateThreadTitle (implemented via Codex with title sanitization/truncation and attachment-aware prompting; Claude explicitly errors), and reuses the same per-thread textGenerationModel for both first-turn title generation and temporary worktree branch renaming.

Plumbs textGenerationModel through the orchestration contract and web UI thread.turn.start dispatch, and updates settings copy from “Git writing model” to “Text generation model”.

Written by Cursor Bugbot for commit aefb74c. This will update automatically on new commits. Configure here.

Note

Auto-generate thread titles on the first user turn using Codex

  • On the first user message, ProviderCommandReactor now forks two concurrent tasks: rename the worktree branch and generate a thread title via TextGeneration.generateThreadTitle.
  • Title generation is implemented in CodexTextGeneration with a sanitizeThreadTitle helper that trims, removes surrounding quotes/backticks, collapses whitespace, defaults to "New thread" if blank, and truncates to 50 characters with ellipsis.
  • ClaudeTextGeneration returns a TextGenerationError for generateThreadTitle since it is Codex-only; RoutingTextGeneration always delegates this method to Codex regardless of provider.
  • The thread.turn.start command and thread.turn-start-requested event now carry an optional textGenerationModel field, passed from the web client's selected text generation model setting.
  • The "Git writing model" settings label in the UI is renamed to "Text generation model" to reflect the broader usage.

Macroscope summarized aefb74c.

@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: 3266616b-5de3-4986-bf84-abbfd6122788

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
@maria-rcks maria-rcks force-pushed the feat/title-summaries-2 branch from 5335f66 to 6e727cd Compare March 25, 2026 12:59
@maria-rcks maria-rcks force-pushed the feat/title-summaries-2 branch from af6a180 to aefb74c Compare March 26, 2026 03:04
);

await waitFor(() => harness.generateBranchName.mock.calls.length === 1);
expect(harness.generateBranchName.mock.calls[0]?.[0]).toMatchObject({
Copy link
Contributor

Choose a reason for hiding this comment

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

🟠 High Layers/ProviderCommandReactor.test.ts:417

The assertion at line 417 checks for a top-level model field, but generateBranchName receives BranchNameGenerationInput which has modelSelection: { provider, model } — no model key exists at the top level. The test will fail because toMatchObject({ model: "gpt-5.4-mini" }) doesn't match the actual object structure. Update the assertion to check modelSelection.model instead.

🤖 Copy this AI Prompt to have your agent fix this:
In file apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts around line 417:

The assertion at line 417 checks for a top-level `model` field, but `generateBranchName` receives `BranchNameGenerationInput` which has `modelSelection: { provider, model }` — no `model` key exists at the top level. The test will fail because `toMatchObject({ model: "gpt-5.4-mini" })` doesn't match the actual object structure. Update the assertion to check `modelSelection.model` instead.

Evidence trail:
- apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts:417: Test asserts `toMatchObject({ model: "gpt-5.4-mini" })`
- apps/server/src/git/Services/TextGeneration.ts:52-58: `BranchNameGenerationInput` defines `modelSelection: ModelSelection` (no top-level `model`)
- packages/contracts/src/orchestration.ts:47-62: `ModelSelection` is a union of types with `{ provider, model }` structure
- apps/server/src/orchestration/Layers/ProviderCommandReactor.ts:426-434: Actual call passes `{ modelSelection: { provider: "codex", model: ... } }`

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

expect(harness.generateBranchName.mock.calls[0]?.[0]).toMatchObject({
model: "gpt-5.4-mini",
message: "Add a safer reconnect backoff.",
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Test asserts wrong path for nested model property

Medium Severity

The test asserts toMatchObject({ model: "gpt-5.4-mini" }) expecting a top-level model property, but generateBranchName receives the model nested inside modelSelection: { provider: "codex", model: "gpt-5.4-mini" } per the BranchNameGenerationInput interface. There is no top-level model on the input object, so the toMatchObject assertion will fail. The mock's "model" in input check (line 391) is similarly wrong—it always evaluates to false, making the mock always return "feature/generated" instead of the model-derived branch. The correct assertion path is modelSelection: { model: "gpt-5.4-mini" }.

Additional Locations (1)
Fix in Cursor Fix in Web

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

2 participants