claude-code-action icon indicating copy to clipboard operation
claude-code-action copied to clipboard

feat: isolate sticky comments by job ID to prevent workflow conflicts

Open TosinAF opened this issue 3 months ago • 0 comments

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

TosinAF avatar Jan 04 '26 22:01 TosinAF