Skip to content

feat: add issue comment delete command#243

Open
amondnet wants to merge 1 commit intomainfrom
feat-issue-delete
Open

feat: add issue comment delete command#243
amondnet wants to merge 1 commit intomainfrom
feat-issue-delete

Conversation

@amondnet
Copy link
Contributor

Summary

Implement GraphQL-based deletion of issue comments with support for both Database ID and Node ID formats. Includes confirmation prompt and --yes flag for automation. Adds bilingual i18n support (Korean/English) and comprehensive test coverage.

Features

  • New command: gh please issue comment delete <comment-id>
  • ID format support: Database ID (numeric) with --issue flag or Node ID (IC_...) directly
  • Interactive confirmation: Prompt before deletion with --yes flag to skip
  • GraphQL implementation: Uses GraphQL deleteIssueComment mutation for reliable deletion
  • Bilingual support: Full i18n support for Korean and English messages
  • Test coverage: Comprehensive test suite with mocked GraphQL operations

Usage Examples

# Delete with Node ID (no --issue flag needed)
gh please issue comment delete IC_kwDOABC123 --yes

# Delete with Database ID (requires --issue flag)
gh please issue comment delete 2442802556 --issue 123 --yes

# Interactive confirmation (default)
gh please issue comment delete IC_kwDOABC123
# Are you sure you want to delete this comment? (y/N):

Implementation Details

  • Uses existing deleteIssueCommentByNodeId GraphQL function
  • Leverages ID converter utility for Database ID to Node ID conversion
  • Integrates with i18n system for bilingual messages
  • Follows project patterns for command structure and error handling

Test Plan

  • Unit tests verify command argument parsing
  • Database ID to Node ID conversion tested
  • Node ID direct usage tested
  • Error handling and validation tested
  • Mock GraphQL operations for safe testing

Related

  • Extends comment management features (edit, list now with delete)
  • Uses existing id-converter.ts for ID format handling
  • Leverages GraphQL API infrastructure established in previous work

Implement GraphQL-based deletion of issue comments with support for both Database ID and Node ID formats. Includes confirmation prompt and --yes flag for automation. Adds bilingual i18n support (Korean/English) and comprehensive test coverage.

- New command: gh please issue comment delete <comment-id>
- Supports Database ID (numeric) with --issue flag or Node ID (IC_...) directly
- Interactive confirmation with --yes flag to skip prompt
- Uses GraphQL deleteIssueComment mutation
- Bilingual messages in Korean and English
- Full test coverage with mocked GraphQL operations
@vercel
Copy link

vercel bot commented Nov 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
gh-please Ready Ready Preview Comment Nov 26, 2025 6:15am

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @amondnet, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the gh please CLI tool by adding the capability to delete issue comments. It provides a robust and user-friendly experience, allowing users to specify comments by either their Database ID or Node ID, with an optional confirmation step. The implementation leverages GitHub's GraphQL API and integrates seamlessly with the existing i18n system, ensuring a consistent and localized experience.

Highlights

  • New Command: Introduced a new command: gh please issue comment delete <comment-id> to remove issue comments.
  • Flexible ID Support: The command supports both GitHub Database IDs (numeric, requiring --issue <number>) and Node IDs (e.g., IC_...) for identifying comments.
  • Confirmation Prompt: An interactive confirmation prompt is displayed before deletion, which can be skipped using the --yes flag for automation.
  • GraphQL Implementation: Comment deletion is performed using the GraphQL deleteIssueComment mutation for reliable and efficient operation.
  • Bilingual Support: Full internationalization (i18n) support has been added for all new messages, including Korean and English.
  • Comprehensive Testing: Extensive unit tests cover argument parsing, ID conversion, error handling, and mocked GraphQL operations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
8.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

❌ Patch coverage is 67.77778% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/commands/issue/comment-delete.ts 60.27% 29 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new issue comment delete command, which is a valuable addition to the tool's comment management features. The implementation correctly handles both Node IDs and Database IDs, includes an interactive confirmation prompt, and integrates with the existing i18n system. The code is well-structured. My review includes two main points: first, to improve maintainability by moving all user-facing strings to the i18n files, and second, a high-priority suggestion to enable the currently skipped unit tests to ensure the new command's core functionality is fully verified.

expect(mockExit).toHaveBeenCalledWith(1)
})

test.skip('should delete comment with Node ID and --yes flag', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This test, along with 'should delete comment with Database ID and --issue flag', is currently skipped. The pull request description mentions a 'comprehensive test suite', but skipping these core functionality tests leaves significant gaps in coverage. It's important to enable and pass these tests to ensure the command works as expected in both Node ID and Database ID scenarios. If there are issues with the mocking setup, it would be better to address them rather than skipping the tests.

Comment on lines +57 to +73
console.log(`✓ Node ID detected, using directly`)
}
else {
// Database ID - need issue number to convert
if (!options.issue) {
throw new Error(
'Issue number is required when using Database ID. '
+ 'Use --issue <number> or provide Node ID instead.',
)
}

const issueNumber = Number.parseInt(options.issue, 10)
if (Number.isNaN(issueNumber)) {
throw new TypeError('Invalid issue number')
}

console.log(`🔄 Converting Database ID to Node ID...`)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There are several hardcoded English strings in the command's logic. To maintain consistency with the project's internationalization (i18n) approach, these should be moved to the src/lib/i18n.ts file.

Specifically, the following strings are hardcoded:

  • Informational messages for ID detection and conversion.
  • Error messages for missing --issue flag and invalid issue numbers.

I have added separate comments on src/lib/i18n.ts with suggestions to add the necessary keys. Once those are added, please update this file to use the new i18n messages. Remember to also use msg.invalidIssueNumber for the TypeError, as it's already available in CommentMessages.

          console.log(msg.nodeIdDetected)
        }
        else {
          // Database ID - need issue number to convert
          if (!options.issue) {
            throw new Error(msg.issueRequiredForDbId)
          }

          const issueNumber = Number.parseInt(options.issue, 10)
          if (Number.isNaN(issueNumber)) {
            throw new TypeError(msg.invalidIssueNumber)
          }

          console.log(msg.convertingId)

Comment on lines +91 to +95
deletingComment: (commentId: number | string) => string
commentDeleted: string
confirmDelete: string
deleteAborted: string
usageDeleteIssue: string
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To support full internationalization in the new issue comment delete command and remove hardcoded strings from its logic, some additional message keys are needed for informational logs and error handling.

Suggested change
deletingComment: (commentId: number | string) => string
commentDeleted: string
confirmDelete: string
deleteAborted: string
usageDeleteIssue: string
deletingComment: (commentId: number | string) => string
commentDeleted: string
confirmDelete: string
deleteAborted: string
usageDeleteIssue: string
nodeIdDetected: string
convertingId: string
issueRequiredForDbId: string

Comment on lines +307 to +311
deletingComment: (commentId: number | string) => `🗑️ 댓글 ${commentId} 삭제 중...`,
commentDeleted: '✅ 댓글이 성공적으로 삭제되었습니다!',
confirmDelete: '정말로 이 댓글을 삭제하시겠습니까? (y/N): ',
deleteAborted: '삭제가 취소되었습니다.',
usageDeleteIssue: ' 사용법: gh please issue comment delete <comment-id> [--yes]',
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Please add the Korean translations for the new i18n keys to ensure a consistent experience for Korean-speaking users.

Suggested change
deletingComment: (commentId: number | string) => `🗑️ 댓글 ${commentId} 삭제 중...`,
commentDeleted: '✅ 댓글이 성공적으로 삭제되었습니다!',
confirmDelete: '정말로 이 댓글을 삭제하시겠습니까? (y/N): ',
deleteAborted: '삭제가 취소되었습니다.',
usageDeleteIssue: ' 사용법: gh please issue comment delete <comment-id> [--yes]',
deletingComment: (commentId: number | string) => `🗑️ 댓글 ${commentId} 삭제 중...`,
commentDeleted: '✅ 댓글이 성공적으로 삭제되었습니다!',
confirmDelete: '정말로 이 댓글을 삭제하시겠습니까? (y/N): ',
deleteAborted: '삭제가 취소되었습니다.',
usageDeleteIssue: ' 사용법: gh please issue comment delete <comment-id> [--yes]',
nodeIdDetected: '✓ 노드 ID가 감지되어 직접 사용합니다',
convertingId: '🔄 데이터베이스 ID를 노드 ID로 변환 중...',
issueRequiredForDbId: '데이터베이스 ID를 사용할 때는 이슈 번호가 필요합니다. --issue <번호>를 사용하거나 노드 ID를 대신 제공하세요.',

Comment on lines +330 to +334
deletingComment: (commentId: number | string) => `🗑️ Deleting comment ${commentId}...`,
commentDeleted: '✅ Comment deleted successfully!',
confirmDelete: 'Are you sure you want to delete this comment? (y/N): ',
deleteAborted: 'Delete aborted.',
usageDeleteIssue: ' Usage: gh please issue comment delete <comment-id> [--yes]',
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Please add the English translations for the new i18n keys. This completes the internationalization for the new command's logic.

Suggested change
deletingComment: (commentId: number | string) => `🗑️ Deleting comment ${commentId}...`,
commentDeleted: '✅ Comment deleted successfully!',
confirmDelete: 'Are you sure you want to delete this comment? (y/N): ',
deleteAborted: 'Delete aborted.',
usageDeleteIssue: ' Usage: gh please issue comment delete <comment-id> [--yes]',
deletingComment: (commentId: number | string) => `🗑️ Deleting comment ${commentId}...`,
commentDeleted: '✅ Comment deleted successfully!',
confirmDelete: 'Are you sure you want to delete this comment? (y/N): ',
deleteAborted: 'Delete aborted.',
usageDeleteIssue: ' Usage: gh please issue comment delete <comment-id> [--yes]',
nodeIdDetected: '✓ Node ID detected, using directly',
convertingId: '🔄 Converting Database ID to Node ID...',
issueRequiredForDbId: 'Issue number is required when using Database ID. Use --issue <number> or provide Node ID instead.',

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.

1 participant