Skip to content

Add comment creation for issue/PR reactions with workflow run links#1346

Merged
pelikhan merged 6 commits intomainfrom
copilot/update-add-comment-js-reactions
Oct 8, 2025
Merged

Add comment creation for issue/PR reactions with workflow run links#1346
pelikhan merged 6 commits intomainfrom
copilot/update-add-comment-js-reactions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 8, 2025

Task: Add comment with workflow run link for issue/PR reactions

Problem Statement

When an agentic workflow is triggered by an issue or pull request and has the "reaction" frontmatter enabled, the add_reaction job should:

  1. Add a comment pointing to the workflow run (in addition to adding the reaction)
  2. Expose the comment ID as an output of the job

Implementation Plan

  • Explore repository structure and understand current code
  • Update add_reaction_and_edit_comment.cjs to create comments for issues and pull_request events
  • Add comment ID output to the job outputs in reaction.go
  • Add unit tests for the new functionality
  • Run existing tests to ensure no regressions
  • Run make recompile to update compiled workflows
  • Run make agent-finish before final commit
  • Update documentation for reaction feature
  • Use Astro Starlight adornment style for notes

Changes Made

  1. JavaScript (add_reaction_and_edit_comment.cjs):

    • For issues events: Now creates a new comment with workflow run link instead of just adding a reaction
    • For pull_request events: Now creates a new comment with workflow run link instead of just adding a reaction
    • Renamed editCommentWithWorkflowLink to addOrEditCommentWithWorkflowLink to handle both comment creation and editing
    • Added logic to differentiate between creating new comments (for issues/PRs) and editing existing comments (for comment events)
    • Sets comment-id and comment-url outputs when creating comments
  2. Go (reaction.go):

    • Added comment_id and comment_url to job outputs map
    • These outputs are now available to downstream jobs
  3. Tests:

    • Updated compiler_test.go to match new function name addOrEditCommentWithWorkflowLink
    • Added reaction_outputs_test.go to verify comment outputs are properly exposed
    • All tests passing
  4. Documentation:

    • Updated docs/src/content/docs/reference/frontmatter.md to document the new reaction behavior
    • Added Behavior section explaining when comments are created vs edited
    • Added Outputs section documenting reaction_id, comment_id, and comment_url
    • Updated docs/src/content/docs/reference/command-triggers.md to clarify the difference between command workflows and non-command workflows with reactions
    • Converted notes to Astro Starlight :::note adornment style

Example Output

When an issue or PR is opened with a reaction-enabled workflow:

YAML outputs:

add_reaction:
  needs: activation
  outputs:
    comment_id: ${{ steps.react.outputs.comment-id }}
    comment_url: ${{ steps.react.outputs.comment-url }}
    reaction_id: ${{ steps.react.outputs.reaction-id }}

JavaScript behavior:

  • For issues event: Creates comment with text like > Agentic [workflow run](URL) triggered by this issue
  • For pull_request event: Creates comment with text like > Agentic [workflow run](URL) triggered by this pull request
  • For comment events (issue_comment, etc.): Edits existing comment (preserves original behavior)

Technical Approach

The change is minimal and focused:

  • Reused existing GitHub API patterns from add_comment.cjs
  • Maintained backward compatibility for comment events (issue_comment, pull_request_review_comment)
  • Added proper error handling with warnings instead of failures
  • All changes pass linting, formatting, and testing
Original prompt

A agentic workflow that is triggered by a pull request/issue and has the "reaction" front matter enabled should add a pull request/issue comment pointing to the workflow run.

  • update add comment JavaScript to handle this case in add_reaction job
  • expose comment id as output of the job

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 8, 2025 05:51
- Update add_reaction_and_edit_comment.cjs to create comments for issues and pull requests
- Rename editCommentWithWorkflowLink to addOrEditCommentWithWorkflowLink to handle both creation and editing
- Add comment_id and comment_url outputs to reaction job in reaction.go
- Update test expectations to match new function name
- Format JavaScript code with prettier

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add TestReactionJobOutputs to verify comment_id and comment_url are exposed
- All tests passing
- Ready for final review

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update add comment JS for reaction handling Add comment creation for issue/PR reactions with workflow run links Oct 8, 2025
Copilot AI requested a review from pelikhan October 8, 2025 05:58
Copy link
Copy Markdown
Collaborator

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update docs on reaction

- Document new behavior for issues/pull_request events (creates comment)
- Document exposed outputs (comment_id, comment_url, reaction_id)
- Update command-triggers.md to clarify difference from command workflows
- Add behavior section explaining when comments are created vs edited

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot update docs on reaction

Updated documentation in commit e65ccba. Changes include:

  • Added Behavior section to frontmatter.md explaining when comments are created vs edited
  • Added Outputs section documenting reaction_id, comment_id, and comment_url
  • Updated command-triggers.md to clarify the difference between command workflows and non-command workflows with reactions

Copilot AI requested a review from pelikhan October 8, 2025 12:19
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Oct 8, 2025

@copilot use Astro Starlight adornment style for notes in docs

- Convert **Note**: to :::note::: format in command-triggers.md
- Follows Starlight documentation conventions

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot use Astro Starlight adornment style for notes in docs

Converted to Starlight adornment style in commit 87bce49. Changed **Note**: to :::note format in command-triggers.md.

@pelikhan pelikhan marked this pull request as ready for review October 8, 2025 13:02
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@pelikhan pelikhan merged commit f47aa85 into main Oct 8, 2025
@pelikhan pelikhan deleted the copilot/update-add-comment-js-reactions branch October 8, 2025 13:09
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.

2 participants