feat(discussion): add comment command - #13620
Merged
Merged
Conversation
BagToad
approved these changes
Jun 9, 2026
BagToad
left a comment
Member
There was a problem hiding this comment.
LGTM - discussed in sync and there's some stuff we want to change but I trust you'll action those :)
Add client methods for managing discussion comments and replies: - AddComment: creates a top-level comment or reply via addDiscussionComment - UpdateComment: edits a comment body via updateDiscussionComment - DeleteComment: removes a comment via deleteDiscussionComment - GetComment: fetches a comment by node ID with typename validation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implement gh discussion comment for adding, editing, and deleting comments and replies on discussions. Supports --body, --body-file, --editor for input, --reply-to for threading, --edit and --delete for modifying existing comments, with confirmation prompts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…PI calls Replace gh api graphql addDiscussionComment mutations in view and list acceptance tests with gh discussion comment. Extract comment IDs via a single view call with jq2env instead of multiple calls. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover add, reply, edit, delete flows including body-file input, non-interactive delete requiring --yes, and deletion of both parent comment and reply to avoid ghost entries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add test for --delete without --yes in non-TTY mode and fix existing delete tests to set isTTY: true for prompter-based confirmation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add ParseDiscussionOrCommentArg to the shared package for parsing discussion numbers, URLs, comment node IDs, and comment URLs (with #discussioncomment-NNNNN fragments). Add ResolveCommentNodeID to the client for constructing node IDs from repository database ID and comment database ID via msgpack encoding. Update the comment command to accept comment URLs as positional args for reply, edit, and delete operations. Update the view command to accept comment URLs in the --replies flag. Add DiscussionID field to DiscussionComment for reply flow (fetches the parent discussion ID from a comment). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ests Update comment acceptance test to use positional comment IDs instead of --reply-to, and add URL-based add/edit/delete test cases. Update view acceptance test to cover --replies with a comment URL. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
…ment argument Drop the --replies flag from gh discussion view and instead accept a comment URL or comment node ID (DC_*) as the positional argument. A discussion number, #number, or discussion URL behaves as before, while a comment reference shows that comment and its replies. Rework GetCommentReplies to be node-centric: it resolves the parent discussion directly from the comment node, so it no longer needs the discussion number or a repository ownership check. The method now takes a host string instead of a full repository. Also add a comment mode for --web that resolves and opens the comment URL, and add godoc to the DiscussionClient interface methods. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
GetComment resolves a comment by its node ID, so it only needs the host to select the GraphQL endpoint. Change its signature from a full ghrepo.Interface to a host string and update all callers and tests accordingly, mirroring GetCommentReplies. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…test Replace --replies usage with a positional comment node ID or URL to match the redesigned gh discussion view command. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…gument In replies mode the --comments flag is meaningless, so reject the combination with a flag error instead of silently ignoring it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
babakks
force-pushed
the
babakks/add-discussion-comment
branch
from
June 10, 2026 11:48
a147fed to
8d2b059
Compare
Member
Author
|
@BagToad, I've pushed the changes we discussed in sync, and I'll merge this into the feature branch once the CI passes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
gh discussion commentcommandThis PR adds a new
gh discussion commentcommand for managing comments and replies on GitHub Discussions, along with UX improvements to theviewcommand.gh discussion commentThe command supports adding, editing, and deleting comments and replies. The positional argument determines the action context:
Adding a top-level comment:
Replying to a comment (positional arg is a comment ID or URL):
Editing a comment or reply:
Deleting a comment or reply:
When no
--bodyor--body-fileis provided in an interactive terminal, an editor is opened for input. For edits, the editor is pre-populated with the existing comment body.Comment URLs are resolved to node IDs via msgpack encoding of the repository database ID and comment database ID extracted from the URL fragment.
Changes to
gh discussion viewThe
--repliesflag now accepts both comment node IDs and comment URLs:When a URL is provided, the repository and discussion number from the URL override the positional argument.
Tests
commentcommand covering add, reply, edit (including from file), delete (with confirmation prompt check), and URL-based operations.discussion-view.txtar,discussion-list.txtar) to use the newcommentcommand instead of rawgh api graphqlmutations.discussion-view.txtarto verify--repliesworks with a comment URL.