feat: isolate sticky comments by job ID to prevent workflow conflicts#789
Open
TosinAF wants to merge 7 commits intoanthropics:mainfrom
Open
feat: isolate sticky comments by job ID to prevent workflow conflicts#789TosinAF wants to merge 7 commits intoanthropics:mainfrom
TosinAF wants to merge 7 commits intoanthropics:mainfrom
Conversation
When multiple workflows use `use_sticky_comment: true` on the same PR,
they previously could co-opt each other's comments due to bot ID/name
matching. This change uses `github.job` to automatically isolate each
workflow's sticky comment.
- Add hidden header `<!-- sticky-job: {jobId} -->` to sticky comments
- Match comments strictly by job ID header instead of bot ID/name
- Each workflow job automatically gets its own isolated comment
- No user configuration needed - works automatically
Closes anthropics#419
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The updateCommentBody() function was stripping the sticky header when updating comments after Claude finishes. This caused subsequent workflow runs to create new comments instead of updating the existing sticky comment. - Extract sticky header before processing comment content - Prepend sticky header to final comment body if it existed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The custom GITHUB_JOB_ID env var may not be available in all contexts. Fall back to the native GITHUB_JOB environment variable which is automatically set by GitHub Actions. Also adds debug logging to help diagnose sticky comment issues. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add a visible 🏷️ Job: `{jobId}` label to the comment body when using
sticky comments. This helps debug sticky comment isolation by making
the job ID visible in the rendered comment, not just in the hidden
HTML header.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The stripHtmlComments function was stripping ALL HTML comments, including the sticky-job headers used for comment isolation. This caused duplicate comments when multiple workflows ran on the same PR. Modified stripHtmlComments to preserve <!-- sticky-job: ... --> headers while still stripping other potentially malicious HTML comments. Also removed visible job ID label from comment body. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The MCP server now fetches the current comment before updating to extract and preserve the sticky job header. This ensures the header persists even when Claude sends completely new content that doesn't include the header. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Simplified sticky header preservation by using the GITHUB_JOB_ID environment variable directly instead of fetching the current comment. Avoids an extra API call on every comment update. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When multiple workflows use
use_sticky_comment: trueon the same PR, they previously could co-opt each other's comments due to loose bot ID/name matching. This change usesgithub.jobto automatically isolate each workflow's sticky comment.Problem: PR #780 added
bot_namefor isolation, but the fallback matching logic still had issues where comments from other workflows could be co-opted.Solution: Use the GitHub Actions job ID (
github.job) as an automatic, unique identifier for each workflow's sticky comment.Changes
<!-- sticky-job: {jobId} -->to sticky commentsHow It Works
Mental Model
Test Plan
bun testto verify new tests passbun run typecheckto verify typesuse_sticky_comment: trueand verify they get separate commentsCloses #419
Related to #780
🤖 Generated with Claude Code