fix(server): stop titling linked PR threads from local git history (#9191)

Co-authored-by: Claude Fable 5.1 <[email protected]>
This commit is contained in:
Theo BrowneandClaude Fable 5.1 authored and GitHub committed 2026-09-02 04:03:56 -04:00
1 parent dd6879ffea
commit 14f15cfed4
2 files changed
+24 -2

No files matched your search

@@ -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`,
@@ -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: