Skip to content

Add immediate centralized command reactions and propagate desired reaction context#31847

Merged
pelikhan merged 4 commits into
mainfrom
copilot/update-agentic-commands-yml
May 13, 2026
Merged

Add immediate centralized command reactions and propagate desired reaction context#31847
pelikhan merged 4 commits into
mainfrom
copilot/update-agentic-commands-yml

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 13, 2026

✨ Enhancement

This change improves centralized slash-command UX by reacting immediately when a matched command defines ai_reaction, instead of waiting for the dispatched workflow to start. It also carries the chosen reaction in the dispatched workflow context so downstream jobs can read the intended reaction explicitly.

  • What does this improve?

    • Faster user-visible feedback on command invocation in agentic_commands.yml routing flow.
    • Explicit propagation of per-command reaction intent into workflow context.
  • Why is this valuable?

    • Reduces perceived latency for command handling.
    • Removes ambiguity between “configured reaction” and “effective reaction” for dispatched workflows.
  • Implementation approach:

    • Extended centralized route payload entries with ai_reaction.
    • Updated centralized router (route_slash_command.cjs) to:
      • resolve the first valid route reaction for the matched command/event,
      • post that reaction immediately on the triggering artifact (issue/PR/comment/discussion),
      • inject desired_ai_reaction into aw_context when dispatching child workflows.
    • Updated centralized workflow generation/tests to emit and validate ai_reaction in routing metadata.
# agentic_commands.yml
GH_AW_SLASH_ROUTING: '{
  "plan":[
    {"workflow":"plan","events":["issue_comment"],"ai_reaction":"eyes"}
  ]
}'
// dispatched aw_context (conceptual)
{
  ...buildAwContext(),
  command_name: "plan",
  desired_ai_reaction: "eyes"
}

Copilot AI and others added 3 commits May 13, 2026 02:39
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Add immediate centralized slash-command reactions and propagate desired reaction context Add immediate centralized command reactions and propagate desired reaction context May 13, 2026
Copilot AI requested a review from pelikhan May 13, 2026 02:48
@pelikhan pelikhan marked this pull request as ready for review May 13, 2026 02:52
Copilot AI review requested due to automatic review settings May 13, 2026 02:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enhances centralized slash-command routing by supporting per-route ai_reaction metadata, adding an immediate reaction on command match, and propagating the intended reaction into dispatched workflow context.

Changes:

  • Extend centralized routing payload entries to include ai_reaction.
  • Add immediate reaction posting in route_slash_command.cjs and propagate desired_ai_reaction via aw_context.
  • Update Go workflow generator and tests to emit/validate ai_reaction routing metadata.
Show a summary per file
File Description
pkg/workflow/central_slash_command_workflow.go Adds ai_reaction to centralized route payload and resolves per-route reaction at compile time.
pkg/workflow/central_slash_command_workflow_test.go Updates assertions for emitted routing JSON and adds reaction-targeting test.
go.mod Promotes gopkg.in/yaml.v3 to a direct dependency.
actions/setup/js/route_slash_command.cjs Implements immediate reaction behavior and injects desired_ai_reaction into dispatch context.
actions/setup/js/route_slash_command.test.cjs Adds tests for immediate reactions and context propagation.
.github/workflows/agentic_commands.yml Updates generated routing metadata to include ai_reaction for routes.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 6/6 changed files
  • Comments generated: 4

Comment on lines +141 to +160
func resolveCentralizedRouteReaction(wd *WorkflowData, routeEvents []string) string {
if wd == nil || wd.AIReaction == "" || wd.AIReaction == "none" {
return ""
}

for _, eventName := range routeEvents {
switch eventName {
case "issues", "issue_comment":
if shouldIncludeIssueReactions(wd) {
return wd.AIReaction
}
case "pull_request", "pull_request_comment", "pull_request_review_comment":
if shouldIncludePullRequestReactions(wd) {
return wd.AIReaction
}
case "discussion", "discussion_comment":
if shouldIncludeDiscussionReactions(wd) {
return wd.AIReaction
}
}
Comment on lines +80 to +116
const { owner, repo } = context.repo;
try {
switch (context.eventName) {
case "issues": {
const issueNumber = context.payload?.issue?.number;
if (!issueNumber) {
core.warning("Skipping immediate reaction: issue number was not found in payload.");
return;
}
await github.request(`POST /repos/${owner}/${repo}/issues/${issueNumber}/reactions`, {
content: normalized,
headers: { Accept: "application/vnd.github+json" },
});
return;
}
case "issue_comment": {
const commentId = context.payload?.comment?.id;
if (!commentId) {
core.warning("Skipping immediate reaction: comment id was not found in payload.");
return;
}
await github.request(`POST /repos/${owner}/${repo}/issues/comments/${commentId}/reactions`, {
content: normalized,
headers: { Accept: "application/vnd.github+json" },
});
return;
}
case "pull_request": {
const prNumber = context.payload?.pull_request?.number;
if (!prNumber) {
core.warning("Skipping immediate reaction: pull request number was not found in payload.");
return;
}
await github.request(`POST /repos/${owner}/${repo}/issues/${prNumber}/reactions`, {
content: normalized,
headers: { Accept: "application/vnd.github+json" },
});
Comment on lines +37 to +57
const REACTION_MAP = {
"+1": "THUMBS_UP",
"-1": "THUMBS_DOWN",
laugh: "LAUGH",
confused: "CONFUSED",
heart: "HEART",
hooray: "HOORAY",
rocket: "ROCKET",
eyes: "EYES",
};

function normalizeReaction(reaction) {
if (typeof reaction !== "string") {
return "";
}
const trimmed = reaction.trim();
if (!trimmed || trimmed === "none" || !Object.hasOwn(REACTION_MAP, trimmed)) {
return "";
}
return trimmed;
}
Comment on lines +131 to +136
case "discussion_comment": {
const commentNodeId = context.payload?.comment?.node_id;
if (!commentNodeId) {
core.warning("Skipping immediate reaction: discussion comment node id was not found in payload.");
return;
}
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot review all comments

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

Copilot AI commented May 13, 2026

@copilot review all comments

Done in 2b27f1e. I addressed the review feedback by fixing per-event centralized ai_reaction eligibility, adding centralized route permissions for immediate reactions, reusing the shared reaction map from add_reaction.cjs, and adding targeted router tests for discussion, discussion_comment, pull_request_review_comment, issues, and pull_request.

@pelikhan pelikhan merged commit 22cc7fb into main May 13, 2026
@pelikhan pelikhan deleted the copilot/update-agentic-commands-yml branch May 13, 2026 03:32
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.

3 participants