Skip to content

feat: add bl issue comment count/show and comment notification commands#59

Closed
23prime wants to merge 2 commits intomainfrom
feature/issue-comment-enhancements
Closed

feat: add bl issue comment count/show and comment notification commands#59
23prime wants to merge 2 commits intomainfrom
feature/issue-comment-enhancements

Conversation

@23prime
Copy link
Owner

@23prime 23prime commented Mar 15, 2026

Checklist

  • Target branch is main
  • Status checks are passing

Summary

  • Add bl issue comment count <key>
  • Add bl issue comment show <key> <comment-id>
  • Add bl issue comment notification list <key> <comment-id>
  • Add bl issue comment notification add <key> <comment-id>

Reason for change

Closes #46

Changes

  • src/api/issue.rsIssueCommentCount, IssueCommentNotification structs + 4 new methods
  • src/api/mod.rs — trait + impl
  • src/cmd/issue/comment/count.rs, show.rs, notification/
  • src/main.rs — clap wiring

Notes

None.

Implements GitHub issue #46:
- bl issue comment count <key> — GET /api/v2/issues/{key}/comments/count
- bl issue comment show <key> <comment-id> — GET /api/v2/issues/{key}/comments/{id}
- bl issue comment notification list <key> <comment-id> — GET notifications
- bl issue comment notification add <key> <comment-id> --notified-user-id <id> — POST notifications

Adds IssueCommentCount and IssueCommentNotification structs, four new BacklogApi
trait methods, and updates all MockApi impls across 42 test files.
Copilot AI review requested due to automatic review settings March 15, 2026 02:48
@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

📝 Walkthrough

Walkthrough

This PR implements comprehensive issue comment management features, adding four new API endpoints (count, fetch, list notifications, add notifications) with corresponding CLI commands and full test coverage. The changes span API layer definitions, trait extensions, command implementations, and mock test infrastructure across 60+ files.

Changes

Cohort / File(s) Summary
Core API Definitions
src/api/issue.rs, src/api/mod.rs
Added IssueCommentCount and IssueCommentNotification structs with camelCase serialization. Introduced four new BacklogApi methods: count_issue_comments, get_issue_comment, get_issue_comment_notifications, add_issue_comment_notifications. Implemented delegating methods in BacklogClient and updated module exports.
Issue Comment Count Command
src/cmd/issue/comment/count.rs
New command module providing IssueCommentCountArgs struct and count/count_with functions to fetch and display comment counts via API, with JSON and text output support.
Issue Comment Show Command
src/cmd/issue/comment/show.rs
New command module implementing IssueCommentShowArgs and show/show_with functions to retrieve and display a specific comment with formatted output.
Comment Notification Commands
src/cmd/issue/comment/notification/list.rs, src/cmd/issue/comment/notification/add.rs
Two new modules for notification management: list fetches notifications for a comment, add sends notifications to specified users. Each provides corresponding Args structs and list/add functions with JSON/text output formatting.
Command Module Organization
src/cmd/issue/comment/mod.rs, src/cmd/issue/comment/notification/mod.rs
Updated module declarations and public re-exports to expose new count, show, and notification submodules and their public APIs.
CLI Wiring
src/main.rs
Added IssueCommentNotificationCommands enum with List and Add variants. Extended IssueCommentCommands with Count, Show, and Notification variants. Integrated command dispatching in run() function with proper argument construction.
Test Mock Infrastructure
src/cmd/auth.rs, src/cmd/issue/comment/*.rs, src/cmd/issue/*.rs, src/cmd/notification/*.rs, src/cmd/project/*.rs, src/cmd/space/*.rs, src/cmd/team/*.rs, src/cmd/user/*.rs, src/cmd/wiki/*.rs
Added trait method stub implementations across 40+ test files to support new BacklogApi methods in MockApi implementations, returning unimplemented!() placeholders. Updates ensure test compilation against expanded trait surface.

Sequence Diagram(s)

sequenceDiagram
    participant User as User/CLI
    participant Main as main.rs
    participant Cmd as Command Handler
    participant API as BacklogClient
    participant Remote as Remote API

    User->>Main: bl issue comment count KEY
    Main->>Cmd: count(IssueCommentCountArgs)
    Cmd->>API: count_issue_comments(key)
    API->>Remote: GET /issues/{key}/comments/count
    Remote-->>API: IssueCommentCount { count }
    API-->>Cmd: IssueCommentCount
    Cmd->>Cmd: Format output (JSON or text)
    Cmd-->>User: Display count

    User->>Main: bl issue comment show KEY COMMENT_ID
    Main->>Cmd: show(IssueCommentShowArgs)
    Cmd->>API: get_issue_comment(key, comment_id)
    API->>Remote: GET /issues/{key}/comments/{id}
    Remote-->>API: IssueComment
    API-->>Cmd: IssueComment
    Cmd->>Cmd: Format output (JSON or text)
    Cmd-->>User: Display comment

    User->>Main: bl issue comment notification list KEY COMMENT_ID
    Main->>Cmd: list(IssueCommentNotificationListArgs)
    Cmd->>API: get_issue_comment_notifications(key, id)
    API->>Remote: GET /issues/{key}/comments/{id}/notifications
    Remote-->>API: Vec<IssueCommentNotification>
    API-->>Cmd: Notifications
    Cmd->>Cmd: Format output (JSON or text)
    Cmd-->>User: Display notifications

    User->>Main: bl issue comment notification add KEY COMMENT_ID --notified-user-id ID1
    Main->>Cmd: add(IssueCommentNotificationAddArgs)
    Cmd->>API: add_issue_comment_notifications(key, id, params)
    API->>Remote: POST /issues/{key}/comments/{id}/notifications
    Remote-->>API: Vec<IssueCommentNotification>
    API-->>Cmd: Created notifications
    Cmd->>Cmd: Format output (JSON or text)
    Cmd-->>User: Display created notifications
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

Poem

🐰 Count them comments, show them threads,
Notify the users who need to be read,
Four new commands, working with grace,
Issue comments in their proper place!
Hop along, the CLI runs swift and true! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.65% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main changes: adding CLI commands for issue comment counting, showing details, and managing comment notifications.
Description check ✅ Passed The PR description relates to the changeset by listing the four new CLI commands, referencing the linked issue (#46), and detailing which files were modified to implement these features.
Linked Issues check ✅ Passed All four planned commands from issue #46 are fully implemented: count, show, and notification list/add commands map to their respective API endpoints with correct parameters.
Out of Scope Changes check ✅ Passed All changes are tightly scoped to implementing the four commands from issue #46; no unrelated functionality or refactoring was introduced outside the stated objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/issue-comment-enhancements
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feature/issue-comment-enhancements
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

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

Adds new Backlog issue-comment capabilities to the bl CLI by introducing API support and wiring new subcommands for comment count, comment show, and comment notification list/add.

Changes:

  • Add Backlog API models + client/trait methods for issue comment count, comment fetch, and comment notifications (list/add).
  • Add CLI subcommands: bl issue comment count, show, and notification (list|add), including output formatting + JSON support.
  • Update existing command test mocks to satisfy the expanded BacklogApi trait.

Reviewed changes

Copilot reviewed 51 out of 51 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/main.rs Adds clap subcommands/wiring for issue comment count/show/notification list+add.
src/api/mod.rs Extends BacklogApi trait and BacklogClient impl with new issue-comment APIs.
src/api/issue.rs Adds response structs and BacklogClient methods + httpmock tests for new endpoints.
src/cmd/issue/comment/mod.rs Registers/re-exports new issue comment subcommand modules.
src/cmd/issue/comment/count.rs Implements bl issue comment count command and unit tests.
src/cmd/issue/comment/show.rs Implements bl issue comment show command and unit tests.
src/cmd/issue/comment/notification/mod.rs Adds notification subcommand module wiring.
src/cmd/issue/comment/notification/list.rs Implements bl issue comment notification list command and unit tests.
src/cmd/issue/comment/notification/add.rs Implements bl issue comment notification add command and unit tests.
src/cmd/issue/comment/add.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/issue/comment/list.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/issue/comment/update.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/issue/comment/delete.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/issue/attachment/list.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/issue/list.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/issue/show.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/issue/create.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/issue/update.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/issue/delete.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/issue/count.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/notification/count.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/notification/list.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/notification/read.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/notification/reset_unread.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/auth.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/project/activities.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/project/category.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/project/disk_usage.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/project/issue_type.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/project/list.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/project/show.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/project/status.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/project/user.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/project/version.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/space/activities.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/space/disk_usage.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/space/notification.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/space/show.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/team/list.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/team/show.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/user/activities.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/user/list.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/user/recently_viewed.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/user/show.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/wiki/attachment/list.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/wiki/create.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/wiki/delete.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/wiki/history.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/wiki/list.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/wiki/show.rs Updates tests’ MockApi to include new BacklogApi methods.
src/cmd/wiki/update.rs Updates tests’ MockApi to include new BacklogApi methods.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +453 to +466
/// Count comments on an issue
Count {
/// Issue ID or key
key: String,
/// Output as JSON
#[arg(long)]
json: bool,
},
/// Show a specific comment
Show {
/// Issue ID or key
key: String,
/// Comment ID
comment_id: u64,
Comment on lines +505 to +509
/// Manage comment notifications
Notification {
#[command(subcommand)]
action: IssueCommentNotificationCommands,
},
Comment on lines +515 to +532
List {
/// Issue ID or key
key: String,
/// Comment ID
comment_id: u64,
/// Output as JSON
#[arg(long)]
json: bool,
},
/// Add notifications for a comment
Add {
/// Issue ID or key
key: String,
/// Comment ID
comment_id: u64,
/// User ID to notify (repeatable)
#[arg(long = "notified-user-id", value_name = "ID")]
notified_user_ids: Vec<u64>,
Comment on lines +41 to +49
fn format_comment_row(c: &IssueComment) -> String {
let content = c.content.as_deref().unwrap_or("(no content)");
format!(
"[{}] {} ({}): {}",
c.id.to_string().cyan().bold(),
c.created_user.name,
c.created,
content
)
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
src/cmd/issue/comment/show.rs (1)

55-58: Remove unused imports.

Issue, IssueAttachment, IssueCommentCount, IssueCommentNotification, and IssueCount are imported but only IssueComment is used in this test module.

🧹 Suggested cleanup
     use super::*;
-    use crate::api::issue::{
-        Issue, IssueAttachment, IssueComment, IssueCommentCount, IssueCommentNotification,
-        IssueCount,
-    };
+    use crate::api::issue::IssueComment;
     use crate::cmd::issue::comment::list::sample_comment;
     use anyhow::anyhow;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cmd/issue/comment/show.rs` around lines 55 - 58, The import line in the
test module is importing unused symbols; remove Issue, IssueAttachment,
IssueCommentCount, IssueCommentNotification, and IssueCount from the use
statement so only IssueComment remains imported (i.e., change the use
crate::api::issue::{ Issue, IssueAttachment, IssueComment, IssueCommentCount,
IssueCommentNotification, IssueCount } to import only IssueComment).
src/cmd/issue/comment/notification/list.rs (1)

46-68: Consider moving test helpers inside the test module.

The #[cfg(test)] imports and sample_notification() helper are placed outside the tests module. While this works (and enables pub(crate) visibility for reuse in notification/add.rs), it's unconventional. If reuse is intended, this pattern is acceptable—just noting it differs from the typical placement inside mod tests.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cmd/issue/comment/notification/list.rs` around lines 46 - 68, The
test-only imports and helper function sample_notification (which constructs an
IssueCommentNotification) are declared at module scope; move the #[cfg(test)]
imports and the pub(crate) fn sample_notification() into a dedicated mod tests {
... } annotated with #[cfg(test)] (or alternatively keep it at module scope but
document why it must be shared), and if other test modules (e.g.,
notification/add.rs) need access, make the helper pub(crate) inside a
#[cfg(test)] mod tests so tests can reuse IssueCommentNotification construction
without leaving test code at top-level.
src/main.rs (1)

453-470: Use id_or_key for new positional args to keep CLI help consistent.

These new variants use key, so help output shows <KEY>. The existing command family and documented syntax use <ID_OR_KEY>. Aligning names improves CLI consistency and discoverability.

Suggested rename for consistent CLI argument labels
 enum IssueCommentCommands {
@@
     Count {
         /// Issue ID or key
-        key: String,
+        id_or_key: String,
@@
     Show {
         /// Issue ID or key
-        key: String,
+        id_or_key: String,
@@
 enum IssueCommentNotificationCommands {
@@
     List {
         /// Issue ID or key
-        key: String,
+        id_or_key: String,
@@
     Add {
         /// Issue ID or key
-        key: String,
+        id_or_key: String,
-                IssueCommentCommands::Count { key, json } => {
-                    cmd::issue::comment::count(&IssueCommentCountArgs::new(key, json))
+                IssueCommentCommands::Count { id_or_key, json } => {
+                    cmd::issue::comment::count(&IssueCommentCountArgs::new(id_or_key, json))
                 }
                 IssueCommentCommands::Show {
-                    key,
+                    id_or_key,
                     comment_id,
                     json,
-                } => cmd::issue::comment::show(&IssueCommentShowArgs::new(key, comment_id, json)),
+                } => cmd::issue::comment::show(&IssueCommentShowArgs::new(id_or_key, comment_id, json)),
@@
                     IssueCommentNotificationCommands::List {
-                        key,
+                        id_or_key,
                         comment_id,
                         json,
                     } => cmd::issue::comment::notification::list(
-                        &IssueCommentNotificationListArgs::new(key, comment_id, json),
+                        &IssueCommentNotificationListArgs::new(id_or_key, comment_id, json),
                     ),
                     IssueCommentNotificationCommands::Add {
-                        key,
+                        id_or_key,
                         comment_id,
                         notified_user_ids,
                         json,
                     } => cmd::issue::comment::notification::add(
                         &IssueCommentNotificationAddArgs::new(
-                            key,
+                            id_or_key,
                             comment_id,
                             notified_user_ids,
                             json,

Also applies to: 515-529

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main.rs` around lines 453 - 470, Rename the positional argument fields
named key to id_or_key in the CLI enum variants Count and Show so the help shows
<ID_OR_KEY> consistently; update the enum variants Count { key: String,
#[arg(long)] json: bool } and Show { key: String, comment_id: u64, #[arg(long)]
json: bool } to use id_or_key: String, then update all pattern matches and uses
of .key to .id_or_key (including the other similar variants around the 515-529
region) so compilation and logic continue working with the new field name.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/cmd/issue/comment/notification/list.rs`:
- Around line 46-68: The test-only imports and helper function
sample_notification (which constructs an IssueCommentNotification) are declared
at module scope; move the #[cfg(test)] imports and the pub(crate) fn
sample_notification() into a dedicated mod tests { ... } annotated with
#[cfg(test)] (or alternatively keep it at module scope but document why it must
be shared), and if other test modules (e.g., notification/add.rs) need access,
make the helper pub(crate) inside a #[cfg(test)] mod tests so tests can reuse
IssueCommentNotification construction without leaving test code at top-level.

In `@src/cmd/issue/comment/show.rs`:
- Around line 55-58: The import line in the test module is importing unused
symbols; remove Issue, IssueAttachment, IssueCommentCount,
IssueCommentNotification, and IssueCount from the use statement so only
IssueComment remains imported (i.e., change the use crate::api::issue::{ Issue,
IssueAttachment, IssueComment, IssueCommentCount, IssueCommentNotification,
IssueCount } to import only IssueComment).

In `@src/main.rs`:
- Around line 453-470: Rename the positional argument fields named key to
id_or_key in the CLI enum variants Count and Show so the help shows <ID_OR_KEY>
consistently; update the enum variants Count { key: String, #[arg(long)] json:
bool } and Show { key: String, comment_id: u64, #[arg(long)] json: bool } to use
id_or_key: String, then update all pattern matches and uses of .key to
.id_or_key (including the other similar variants around the 515-529 region) so
compilation and logic continue working with the new field name.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7579eeea-f4d5-41dc-a497-a6d98d1c24a9

📥 Commits

Reviewing files that changed from the base of the PR and between 8b899ec and 20394ff.

📒 Files selected for processing (51)
  • src/api/issue.rs
  • src/api/mod.rs
  • src/cmd/auth.rs
  • src/cmd/issue/attachment/list.rs
  • src/cmd/issue/comment/add.rs
  • src/cmd/issue/comment/count.rs
  • src/cmd/issue/comment/delete.rs
  • src/cmd/issue/comment/list.rs
  • src/cmd/issue/comment/mod.rs
  • src/cmd/issue/comment/notification/add.rs
  • src/cmd/issue/comment/notification/list.rs
  • src/cmd/issue/comment/notification/mod.rs
  • src/cmd/issue/comment/show.rs
  • src/cmd/issue/comment/update.rs
  • src/cmd/issue/count.rs
  • src/cmd/issue/create.rs
  • src/cmd/issue/delete.rs
  • src/cmd/issue/list.rs
  • src/cmd/issue/show.rs
  • src/cmd/issue/update.rs
  • src/cmd/notification/count.rs
  • src/cmd/notification/list.rs
  • src/cmd/notification/read.rs
  • src/cmd/notification/reset_unread.rs
  • src/cmd/project/activities.rs
  • src/cmd/project/category.rs
  • src/cmd/project/disk_usage.rs
  • src/cmd/project/issue_type.rs
  • src/cmd/project/list.rs
  • src/cmd/project/show.rs
  • src/cmd/project/status.rs
  • src/cmd/project/user.rs
  • src/cmd/project/version.rs
  • src/cmd/space/activities.rs
  • src/cmd/space/disk_usage.rs
  • src/cmd/space/notification.rs
  • src/cmd/space/show.rs
  • src/cmd/team/list.rs
  • src/cmd/team/show.rs
  • src/cmd/user/activities.rs
  • src/cmd/user/list.rs
  • src/cmd/user/recently_viewed.rs
  • src/cmd/user/show.rs
  • src/cmd/wiki/attachment/list.rs
  • src/cmd/wiki/create.rs
  • src/cmd/wiki/delete.rs
  • src/cmd/wiki/history.rs
  • src/cmd/wiki/list.rs
  • src/cmd/wiki/show.rs
  • src/cmd/wiki/update.rs
  • src/main.rs

@23prime 23prime closed this Mar 15, 2026
@23prime 23prime deleted the feature/issue-comment-enhancements branch March 15, 2026 03:49
@23prime 23prime restored the feature/issue-comment-enhancements branch March 15, 2026 03:50
@23prime 23prime reopened this Mar 15, 2026
@23prime 23prime marked this pull request as draft March 15, 2026 04:30
@23prime
Copy link
Owner Author

23prime commented Mar 15, 2026

Closing due to large conflicts with main. Will reimplement from scratch on current main.

@23prime 23prime closed this Mar 15, 2026
@23prime 23prime deleted the feature/issue-comment-enhancements branch March 15, 2026 09:43
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.

feat: bl issue comment enhancements (count / show / notifications)

2 participants