From 14f15cfed48bc7519e8e5eeac03f483f4b11ef3a Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Wed, 2 Sep 2026 01:03:56 -0700 Subject: [PATCH] fix(server): stop titling linked PR threads from local git history (#9191) Co-authored-by: Claude Fable 5.1 --- .../TextGenerationPrompts.test.ts | 18 ++++++++++++++++++ .../textGeneration/TextGenerationPrompts.ts | 8 ++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/apps/server/src/textGeneration/TextGenerationPrompts.test.ts b/apps/server/src/textGeneration/TextGenerationPrompts.test.ts index f382f9af09214ba54f877f5c176615978df014f1..253d88779827a4bb7bad9820971c0d8b7b06791e 100644 --- a/apps/server/src/textGeneration/TextGenerationPrompts.test.ts +++ b/apps/server/src/textGeneration/TextGenerationPrompts.test.ts @@ -188,6 +188,24 @@ describe("buildThreadTitlePrompt", () => { expect(result.prompt).toContain("67890 bytes"); }); + it.each([ + { mode: "initial", previousTitle: undefined }, + { mode: "regeneration", previousTitle: "Open Projects in Desktop App" }, + ])( + "tells the $mode prompt not to title linked PRs from local git history", + ({ previousTitle }) => { + const result = buildThreadTitlePrompt({ + message: "$takeover https://github.com/pingdotgg/t3code/pull/8588", + ...(previousTitle === undefined ? {} : { previousTitle }), + }); + + expect(result.prompt).toContain( + "Local git history is not evidence of what a linked PR or issue is about.", + ); + expect(result.prompt).toContain('such as "Take Over PR 8588"'); + }, + ); + it("regenerates from recent thread contents and identifies the previous title", () => { const result = buildThreadTitlePrompt({ message: `USER:\nInvestigate reconnect regressions\n\nASSISTANT:\nThe remaining issue is stale session state`, diff --git a/apps/server/src/textGeneration/TextGenerationPrompts.ts b/apps/server/src/textGeneration/TextGenerationPrompts.ts index c676a1760d0d0390a0e007a965eaa9a52c6a548b..b1c55939878a35727e2fe6abe6321f18e3d3019d 100644 --- a/apps/server/src/textGeneration/TextGenerationPrompts.ts +++ b/apps/server/src/textGeneration/TextGenerationPrompts.ts @@ -238,7 +238,9 @@ Editorial rules: - Do not copy and truncate the user's message. - Avoid project names already visible in the UI, quotes, labels, filler, and trailing punctuation. - Use attached images as primary context for UI issues. -- When a URL or attachment is the only source of the subject, use available tools to inspect it. If it cannot be resolved, remain accurate rather than guessing.`; +- When a URL or attachment is the only source of the subject, use available tools to inspect it directly. +- Local git history is not evidence of what a linked PR or issue is about. Never title the thread after branch names, commit messages, or merged commits found in the checkout. +- If a linked PR or issue cannot be read, fall back to the user's stated action plus its number, such as "Take Over PR 8588". This is the one case where a PR or issue number belongs in the title.`; function regenerateThreadTitlePrompt(previousTitle: string): string { return `Regenerate the title for an existing T3 Code thread so the user can recognize it weeks later. @@ -265,7 +267,9 @@ Editorial rules: - Do not copy and truncate a thread message. - Avoid project names already visible in the UI, PR numbers, quotes, labels, filler, and trailing punctuation. - Use attached images as primary context for UI issues. -- When a URL or attachment is the only source of the subject, use available tools to inspect it. If it cannot be resolved, remain accurate rather than guessing. +- When a URL or attachment is the only source of the subject, use available tools to inspect it directly. +- Local git history is not evidence of what a linked PR or issue is about. Never title the thread after branch names, commit messages, or merged commits found in the checkout. +- If a linked PR or issue cannot be read, fall back to the user's stated action plus its number, such as "Take Over PR 8588". This is the one case where a PR or issue number belongs in the title. - Return a meaningfully improved title, not a cosmetic paraphrase of the previous title. Examples of the distinction: -- 2.54.0