Skip to content

fix: thread discussion replies when add_comment triggered by discussion_comment event#23836

Merged
pelikhan merged 2 commits intomainfrom
copilot/allow-commenting-editing-posts
Apr 1, 2026
Merged

fix: thread discussion replies when add_comment triggered by discussion_comment event#23836
pelikhan merged 2 commits intomainfrom
copilot/allow-commenting-editing-posts

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

add_comment always posted top-level discussion comments, even when triggered by a discussion_comment event — making agent replies appear disconnected from the comment they were responding to.

Changes

  • add_comment.cjs: When the triggering event is discussion_comment and no explicit item_number is provided, derive replyToId from context.payload?.comment?.node_id and pass it to commentOnDiscussion(). The threading infrastructure was already in place; it just wasn't being used.

    const hasExplicitItemNumber = message.item_number !== undefined && message.item_number !== null;
    const replyToId = context.eventName === "discussion_comment" && !hasExplicitItemNumber
      ? context.payload?.comment?.node_id
      : null;
    comment = await commentOnDiscussion(..., replyToId);
  • add_comment.test.cjs: Two new tests covering the triggering-context threading path and the explicit-item_number non-threaded path.

Behavior matrix

Trigger item_number Result
discussion_comment not set Threaded reply ✅
discussion_comment explicit Top-level on target discussion
discussion not set Top-level (unchanged)
any explicit (404 → discussion fallback) Top-level (unchanged)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw go-udiff@v0.4.1/rev-parse 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git se .cfg ache/go/1.25.0/x--show-toplevel git (http block)
  • https://api.github.com/orgs/test-owner/actions/secrets
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name bose (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --show-toplevel x_amd64/vet /opt/hostedtoolcache/node/24.14.0/x64/bin/node ub/workflows committer.email x_amd64/vet node /tmp�� v1.0.0 x_amd64/vet /usr/bin/git */*.json' '!../.git main x_amd64/vet /usr/bin/git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha -bool -buildtags om/testowner/testrepo.git -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/compile -o /tmp/go-build3991629093/b420/_pkg_.a -trimpath /usr/bin/git -p main -lang=go1.25 git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha te 'scripts/**/*.js' --ignore-path .prettierigno-errorsas add_comment.test.cjs 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha env.NODE_VERSION x_amd64/vet /usr/bin/git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet /usr/bin/git npx prettier --wgit (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --show-toplevel git r,url,status,conclusion,workflowName,createdAt,startedAt,updated-nilfunc rt/yaml/yaml_defgit flow x_amd64/compile git rev-�� 0:00Z x_amd64/compile /usr/bin/git '**/*.ts' '**/*.git user.name x_amd64/vet git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha -bool -buildtags /usr/bin/git -errorsas -ifaceassert -nilfunc git remo�� add origin /opt/hostedtoolcache/node/24.14.0/x64/bin/node '**/*.ts' '**/*.git pull.rebase x_amd64/vet node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --show-toplevel ache/go/1.25.0/x-d /usr/bin/git Onlymin-integritgit (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha submodules | hea-errorsas --global t http.https://git/opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha submodules | hea-c=4 --global cal/bin/git http.https://git/opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha /repos/actions/github-script/git/ref/tags/v8 resolved$ /usr/bin/git )$/\1/p --local x_amd64/vet git rese�� HEAD .github/workflows/test.md /usr/bin/git '**/*.ts' '**/*.git pull.rebase x_amd64/vet git (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha /tmp/shared-actions-test836700347 rev-parse /usr/bin/git /\1/p --local x_amd64/vet git -C /tmp/gh-aw-test-runs/20260401-054141-13690/test-1728879965 status /usr/bin/git .github/workflowgit pull.rebase x_amd64/vet git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0.1.2
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq .object.sha k/gh-aw/gh-aw/.github/workflows/audit-workflows.md git /usr/bin/git ../pkg/workflow/git --local x_amd64/vet git -C /tmp/gh-aw-test-runs/20260401-054141-13690/test-1728879965 rev-parse /usr/bin/git @{u} user.name x_amd64/vet git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha KalLpCxFj /tmp/go-build3991629093/b116/vet.cfg 1629093/b402/_pkg_.a l (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha 4141-13690/test-1728879965 /tmp/go-build3991629093/b154/vet.cfg 1629093/b126/vet.cfg (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 /var/lib/waagent/Microsoft.CPlat-ifaceassert x_amd64/compile ignore (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 .cjs 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path bose (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 all("session") a-C (http block)
  • https://api.github.com/repos/github/gh-aw/contents/.github%2Fworkflows%2Faudit-workflows.md
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node --experimental-import-meta-resolve --require /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/suppress-warnings.cjs --conditions node --conditions development /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/dist/workers/forks.js . 0/x64/lib/node_mgit add . forks.js rev-�� --reverse origin/fallback-branch..HEAD 86_64/git -m Initial commit it /usr/lib/git-cordfc87c6480180a5afc5d79c54379a5d1046c2567..HEAD (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v0.47.4
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq .object.sha --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git --noprofile .cfg 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git rity301436861/00git (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha ty-test.md .cfg 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha th .prettierigno-errorsas --local _modules/.bin/no-nilfunc credential.helpe/opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v2.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha th .prettierigno-errorsas --local node credential.helpe/opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha th .prettierignore --log-level=error --local ash credential.helpe/tmp/go-build3991629093/b408/envutil.test (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha th .prettierigno-errorsas --local ode_modules/.bin-nilfunc credential.userngit (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha th .prettierigno-errorsas --local /Microsoft.CPlat-nilfunc credential.helpe/tmp/go-build3991629093/b402/console.test (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha ty-test.md (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion nore (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo t[bot] (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo nfig/composer/vendor/bin/git (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build3991629093/b396/cli.test /tmp/go-build3991629093/b396/cli.test -test.testlogfile=/tmp/go-build3991629093/b396/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name (http block)
  • invalid.example.invalid
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin https://invalid.example.invalid/nonexistent-repo.git git add . lure test commit e_modules/.bin/git -b main _modules/.bin/gi-b git conf�� user.email test@test.com /git -b feature-branch it git (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

Hey @Copilot 👋 — great to see work starting on threaded discussion replies! The ability to have agents reply directly to a specific discussion comment (rather than always posting top-level) is a genuinely useful addition to the agentic workflows toolkit.

That said, this PR is currently a [WIP] draft with no code changes yet (the single "Initial plan" commit has 0 files and 0 lines changed). Before it's ready for review, here are the things to address:

  • No implementation yet — the diff is empty. The PR description acknowledges this, but the implementation needs to follow.
  • No tests — every new safe-output operation in this codebase has a corresponding _test.go file. A reply_to_discussion_comment_test.go will be needed.
  • PR description needs updating — as implementation progresses, the PR body should summarise what changed and why, not just the original issue text.

Use reply_to_pr_review_comment.go as a model for implementation, and ensure all new safe-output operations are registered in compiler_types.go, safe_outputs_config.go, and safe_outputs_tools.json. Run make agent-finish before pushing to confirm build, test, lint, and recompile all pass.

Generated by Contribution Check ·

…on_comment event

When triggered by a `discussion_comment` event without an explicit `item_number`,
`add_comment` now posts a threaded reply to the triggering comment instead of
creating a new top-level discussion comment.

The `replyToId` is derived from `context.payload?.comment?.node_id` and passed
to `commentOnDiscussion()`. When an explicit `item_number` is provided, the
behavior is unchanged (top-level comment).

Fixes: #allow-commenting-editing-posts

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/51ca4e81-4946-4fa0-a5a0-04063662c3b8

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for commenting and editing posts in discussions fix: thread discussion replies when add_comment triggered by discussion_comment event Apr 1, 2026
Copilot AI requested a review from pelikhan April 1, 2026 05:48
@pelikhan pelikhan marked this pull request as ready for review April 1, 2026 11:19
Copilot AI review requested due to automatic review settings April 1, 2026 11:19
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

Fixes add_comment so that when invoked from a discussion_comment workflow event (and no explicit item_number is provided), the action posts a threaded reply to the triggering discussion comment instead of creating a new top-level discussion comment.

Changes:

  • Derive replyToId from context.payload.comment.node_id for discussion_comment events (when message.item_number is not explicitly set) and pass it to commentOnDiscussion().
  • Add tests to verify (1) threaded replies for discussion_comment trigger context and (2) non-threaded behavior when item_number is explicitly provided (via 404-to-discussion fallback).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
actions/setup/js/add_comment.cjs Uses triggering discussion comment node_id as replyToId to create threaded replies for discussion_comment events.
actions/setup/js/add_comment.test.cjs Adds coverage for threaded reply behavior and ensures explicit item_number keeps comments top-level.

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

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 make sure temporary ids are handled

@pelikhan pelikhan merged commit e0ce097 into main Apr 1, 2026
65 of 66 checks passed
@pelikhan pelikhan deleted the copilot/allow-commenting-editing-posts branch April 1, 2026 11:33
Copilot stopped work on behalf of pelikhan due to an error April 1, 2026 11:34
Copilot AI requested a review from pelikhan April 1, 2026 11:34
@github-actions github-actions bot mentioned this pull request Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request: Allow commenting, editing posts within a Discussion

3 participants