diff --git a/src/github/operations/comments/common.ts b/src/github/operations/comments/common.ts index df24c0329..bc592df69 100644 --- a/src/github/operations/comments/common.ts +++ b/src/github/operations/comments/common.ts @@ -24,8 +24,10 @@ export function createBranchLink( export function createCommentBody( jobRunLink: string, branchLink: string = "", + botName: string = "", ): string { - return `Claude Code is working… ${SPINNER_HTML} + const header = botName ? `\n` : ""; + return `${header}Claude Code is working… ${SPINNER_HTML} I'll analyze this and get back to you. diff --git a/src/github/operations/comments/create-initial.ts b/src/github/operations/comments/create-initial.ts index 1243035b7..4491598fb 100644 --- a/src/github/operations/comments/create-initial.ts +++ b/src/github/operations/comments/create-initial.ts @@ -14,8 +14,6 @@ import { } from "../../context"; import type { Octokit } from "@octokit/rest"; -const CLAUDE_APP_BOT_ID = 209825114; - export async function createInitialComment( octokit: Octokit, context: ParsedGitHubContext, @@ -23,7 +21,12 @@ export async function createInitialComment( const { owner, repo } = context.repository; const jobRunLink = createJobRunLink(owner, repo, context.runId); - const initialBody = createCommentBody(jobRunLink); + // Add hidden header with bot name for sticky comment identification + const initialBody = createCommentBody( + jobRunLink, + "", + context.inputs.useStickyComment ? context.inputs.botName : "", + ); try { let response; @@ -39,12 +42,29 @@ export async function createInitialComment( issue_number: context.entityNumber, }); const existingComment = comments.data.find((comment) => { - const idMatch = comment.user?.id === CLAUDE_APP_BOT_ID; + const idMatch = comment.user?.id === Number(context.inputs.botId); + + // Check for hidden header match to support multiple bots + const hiddenHeader = ``; + const headerMatch = comment.body?.includes(hiddenHeader); + + // Check if comment has ANY hidden header (to detect other bots) + const hasAnyHeader = comment.body?.includes(""); + expect(body).toContain("Claude Code is working"); + }); + + test("does not generate header when botName is missing", () => { + const body = createCommentBody("http://example.com"); + expect(body).not.toContain("