TypeScript
fix(server): stop titling linked PR threads from local git history (#9191)
Theo Browne14f15cfed48b
diff --git a/apps/server/src/textGeneration/TextGenerationPrompts.test.ts b/apps/server/src/textGeneration/TextGenerationPrompts.test.tsindex f382f9af092..253d8877982 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.tsindex c676a1760d0..b1c55939878 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: