Skip to content

Conversation

@TosinAF
Copy link

@TosinAF TosinAF commented Jan 4, 2026

Summary

When multiple workflows use use_sticky_comment: true on the same PR, they previously could co-opt each other's comments due to loose bot ID/name matching. This change uses github.job to automatically isolate each workflow's sticky comment.

Problem: PR #780 added bot_name for 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

  • Add hidden header <!-- sticky-job: {jobId} --> to sticky comments
  • Match comments strictly by this job ID header instead of bot ID/name
  • Each workflow job automatically gets its own isolated comment
  • Zero configuration needed - works automatically

How It Works

# .github/workflows/claude-docs-review.yml
jobs:
  claude-docs-review:  # <-- This job ID becomes the sticky comment identifier
    steps:
      - uses: anthropics/claude-code-action@main
        with:
          use_sticky_comment: true
          # No bot_name needed! Uses job ID automatically

# .github/workflows/claude-security-review.yml
jobs:
  claude-security-review:  # <-- Different job ID = different comment
    steps:
      - uses: anthropics/claude-code-action@main
        with:
          use_sticky_comment: true

Mental Model

  • One job = one sticky comment
  • Same job ID = same comment gets updated (intended)
  • Different job IDs = separate comments (no conflicts)

Test Plan

  • Run bun test to verify new tests pass
  • Run bun run typecheck to verify types
  • Manual test: Create PR with two workflows using use_sticky_comment: true and verify they get separate comments
  • Manual test: Re-run same workflow and verify it updates the same comment

Closes #419
Related to #780

🤖 Generated with Claude Code

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 <[email protected]>
TosinAF and others added 6 commits January 4, 2026 15:08
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sticky comment for review mode

1 participant