feat: add bl issue comment count/show and comment notification commands#59
feat: add bl issue comment count/show and comment notification commands#59
Conversation
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.
📝 WalkthroughWalkthroughThis 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
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
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
✨ Simplify code
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
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, andnotification (list|add), including output formatting + JSON support. - Update existing command test mocks to satisfy the expanded
BacklogApitrait.
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.
| /// 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, |
| /// Manage comment notifications | ||
| Notification { | ||
| #[command(subcommand)] | ||
| action: IssueCommentNotificationCommands, | ||
| }, |
| 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>, |
| 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 | ||
| ) |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/cmd/issue/comment/show.rs (1)
55-58: Remove unused imports.
Issue,IssueAttachment,IssueCommentCount,IssueCommentNotification, andIssueCountare imported but onlyIssueCommentis 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 andsample_notification()helper are placed outside thetestsmodule. While this works (and enablespub(crate)visibility for reuse innotification/add.rs), it's unconventional. If reuse is intended, this pattern is acceptable—just noting it differs from the typical placement insidemod 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: Useid_or_keyfor 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
📒 Files selected for processing (51)
src/api/issue.rssrc/api/mod.rssrc/cmd/auth.rssrc/cmd/issue/attachment/list.rssrc/cmd/issue/comment/add.rssrc/cmd/issue/comment/count.rssrc/cmd/issue/comment/delete.rssrc/cmd/issue/comment/list.rssrc/cmd/issue/comment/mod.rssrc/cmd/issue/comment/notification/add.rssrc/cmd/issue/comment/notification/list.rssrc/cmd/issue/comment/notification/mod.rssrc/cmd/issue/comment/show.rssrc/cmd/issue/comment/update.rssrc/cmd/issue/count.rssrc/cmd/issue/create.rssrc/cmd/issue/delete.rssrc/cmd/issue/list.rssrc/cmd/issue/show.rssrc/cmd/issue/update.rssrc/cmd/notification/count.rssrc/cmd/notification/list.rssrc/cmd/notification/read.rssrc/cmd/notification/reset_unread.rssrc/cmd/project/activities.rssrc/cmd/project/category.rssrc/cmd/project/disk_usage.rssrc/cmd/project/issue_type.rssrc/cmd/project/list.rssrc/cmd/project/show.rssrc/cmd/project/status.rssrc/cmd/project/user.rssrc/cmd/project/version.rssrc/cmd/space/activities.rssrc/cmd/space/disk_usage.rssrc/cmd/space/notification.rssrc/cmd/space/show.rssrc/cmd/team/list.rssrc/cmd/team/show.rssrc/cmd/user/activities.rssrc/cmd/user/list.rssrc/cmd/user/recently_viewed.rssrc/cmd/user/show.rssrc/cmd/wiki/attachment/list.rssrc/cmd/wiki/create.rssrc/cmd/wiki/delete.rssrc/cmd/wiki/history.rssrc/cmd/wiki/list.rssrc/cmd/wiki/show.rssrc/cmd/wiki/update.rssrc/main.rs
|
Closing due to large conflicts with main. Will reimplement from scratch on current main. |
Checklist
mainSummary
bl issue comment count <key>bl issue comment show <key> <comment-id>bl issue comment notification list <key> <comment-id>bl issue comment notification add <key> <comment-id>Reason for change
Closes #46
Changes
src/api/issue.rs—IssueCommentCount,IssueCommentNotificationstructs + 4 new methodssrc/api/mod.rs— trait + implsrc/cmd/issue/comment/count.rs,show.rs,notification/src/main.rs— clap wiringNotes
None.