Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(threads): add title summary generation and settings #1256

Closedmaria-rckswants to merge 5 commits intomain fromrefs/pull/1256/headopened View on GitHub

maria-rckscommented

What Changed

This PR adds title summaries for threads.

Titles are generated based on the first prompt, there is a manual "Generate title summary" action in the thread menu. I also added an option to fchoose which model is being used for this task.

Why

This is better because it makes threads easier to organize and recognize at a glance. When titles reflect what the thread is actually about, it is easier to scan a long list of threads and come back to older work later.

UI Changes

Added thread title summary controls in Settings > Threads and a manual title summary action in the thread context menu.

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

closes #990

Note

Add automatic thread title generation via Codex with settings controls

  • Adds a generateThreadTitle WebSocket method on the server that prompts Codex with recent user messages and attachments, sanitizes the output to a max-60-char single-line title, and returns it to the client.
  • Introduces titleSummaryState ("missing", "generated", "manual") on threads throughout the stack: contracts, orchestration events, projections, DB migration, and local state.
  • Replaces the previous immediate first-message title update in ChatView with an async call to generateAndRenameThreadTitle, gated by the new titleSummaryMode: 'automatic' app setting.
  • Adds settings UI controls for enabling/disabling automatic title summaries and selecting the model used for generation.
  • Adds DB migration 016 for title_summary_state column and migration 017 to normalize legacy piAgent provider names to codex across persisted rows and event JSON.
  • Behavioral Change: manual renames in the sidebar now set titleSummaryState to "manual"; first-message titling is no longer synchronous and will surface a toast error on failure.
Macroscope summarized 5e0a014.

Note

Medium Risk Adds new persisted thread metadata (titleSummaryState) plus DB migrations and replay-time normalization of legacy provider values, which can affect read models and event replay if incorrect, but changes are localized and covered by tests.

Overview Adds end-to-end thread title summary generation: a new server.generateThreadTitle WebSocket method gathers recent user messages/attachments and calls the Codex text generation service to produce a sanitized <=60 char title.

Introduces and persists titleSummaryState (missing | generated | manual) across thread create/meta-update commands, events, projectors, snapshot queries, and the projection_threads table (new migration).

Updates the web app to optionally auto-generate a title after the first message (setting titleSummaryMode) and to allow manual generation from the thread context menu; manual renames now mark the state as manual, and a separate titleSummaryModel setting controls which model is used.

Adds compatibility for legacy piAgent provider identifiers by normalizing them to codex during event-store replay and provider-session reads (plus a data migration), and hardens terminal state persistence to fall back to in-memory storage when localStorage isn’t available.

Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 5e0a01479caa05cbd00fcd112e3e062590dd5ee7. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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: 1acf233a-238a-4432-8384-b44009274415

      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.
    3. Great work, id propose that we occasionally re-trigger to update the title? Such as if a pull request opens for the work etc

    4. Great work, id propose that we occasionally re-trigger to update the title? Such as if a pull request opens for the work etc

      I thought about this but how do we measure when to re-trigger? Like every ten prompts or when things are committed, or what is the threshold?

      Would love Julius comments on this.

    5. also could be a separate pr

    6. Happy for it to be a separate PR

    7. @@ -2625,3 +2632,12 @@
      26252632 createdAt: messageCreatedAt,
      26262633 });
      26272634 turnStartSucceeded = true;
      2635+ if (isFirstMessage) {
      2636+ void maybeGenerateFirstThreadTitle({ api, threadId: threadIdForSend }).catch((error) => {
      2637+ toastManager.add({
      2638+ type: "error",
      2639+ title: "Failed to generate title summary",
      2640+ description: error instanceof Error ? error.message : "An error occurred.",
      2641+ });
      2642+ });
      2643+ }

      Title generation reads messages before projection stores them

      High Severity

      maybeGenerateFirstThreadTitle fires immediately after the thread.turn.start dispatch succeeds. The server-side generateThreadTitle reads user messages from the projection snapshot. However, thread.turn.start only produces a thread.turn-start-requested event — the actual thread.message-sent event that populates thread.messages in the projection is emitted later by ProviderRuntimeIngestion asynchronously. So the snapshot will contain zero user messages, causing the function to always fail with "Thread has no user messages to summarize" and show an error toast to the user.

      Additional Locations (1)
      Fix in Cursor Fix in Web
      @@ -1155,3 +1155,4 @@
      11551155 commandId: providerCommandId(event, "thread-meta-update"),
      11561156 threadId: thread.id,
      11571157 title: event.payload.name,
      1158+ titleSummaryState: "generated",

      Provider metadata update unconditionally overrides manual title state

      Medium Severity

      When the provider emits a thread.metadata.updated event with a name, the code unconditionally sets titleSummaryState: "generated". This overwrites a user's "manual" state if they had previously renamed the thread. Since the new automatic title generation skips threads with "manual" state (by design), this could cause unexpected re-generation or misrepresent the origin of the title.

      Fix in Cursor Fix in Web
    8. Cursor Bugbot has reviewed your changes and found 2 potential issues.

      There are 4 total unresolved issues (including 2 from previous reviews).

      Fix All in Cursor Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard?tab=bugbot).
      @@ -691,0 +702,21 @@
      702+ if (!thread || thread.deletedAt !== null) {
      703+ return yield* new RouteRequestError({
      704+ message: `Thread not found: ${input.threadId}`,
      705+ });
      706+ }
      707+
      708+ const project = snapshot.projects.find(
      709+ (entry) => entry.id === thread.projectId && entry.deletedAt === null,
      710+ );
      711+ if (!project) {
      712+ return yield* new RouteRequestError({
      713+ message: `Project not found for thread: ${input.threadId}`,
      714+ });
      715+ }
      716+
      717+ const userMessages = thread.messages.filter((message) => message.role === "user");
      718+ if (userMessages.length === 0) {
      719+ return yield* new RouteRequestError({
      720+ message: "Thread has no user messages to summarize.",
      721+ });
      722+ }

      Race condition: title generation reads stale projection snapshot

      High Severity

      generateThreadTitle reads thread messages via projectionReadModelQuery.getSnapshot(), which queries the asynchronously-updated projection database. When maybeGenerateFirstThreadTitle fires right after the thread.turn.start dispatch returns, the projection pipeline likely hasn't processed the thread.message-sent event yet, so userMessages is empty and the function fails with "Thread has no user messages to summarize." The synchronous in-memory read model (orchestrationEngine.getReadModel()) would have the message immediately, since the engine updates it before resolving the dispatch.

      Additional Locations (1)
      Fix in Cursor Fix in Web
      @@ -465,4 +519,21 @@
      519+ const generated = yield* runCodexJson({
      520+ operation: "generateThreadTitle",
      521+ cwd: input.cwd,
      522+ prompt: promptSections.join("\n"),
      523+ outputSchemaJson: Schema.Struct({
      524+ title: Schema.String,
      525+ }),
      526+ imagePaths,
      527+ ...(input.model ? { model: input.model } : {}),
      528+ });
      529+
      530+ return {
      531+ title: sanitizeThreadTitle(generated.title),
      532+ } satisfies ThreadTitleGenerationResult;
      533+ });
      534+
      465535 return {
      466536 generateCommitMessage,
      467537 generatePrContent,
      468538 generateBranchName,
      539+ generateThreadTitle,

      Indentation inconsistency in return object literal

      Low Severity

      generateThreadTitle on line 539 uses 4-space indentation while the sibling properties (generateCommitMessage, generatePrContent, generateBranchName) use 6-space indentation in the returned object literal. This is a minor formatting inconsistency in the satisfies TextGenerationShape return block.

      Fix in Cursor Fix in Web
    9. is there a real use case when people would want different models to generate titles than commit messages or can it all be one setting to control text generation for everything?

    10. is there a real use case when people would want different models to generate titles than commit messages or can it all be one setting to control text generation for everything?

      so use the same as the git commit one but just reword the ui?

    11. also this pr is a mess, i think i'll open another one

    12. maria-rcks closed this

Sign in to join this conversation.