You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10 lines
4.8 KiB
JSON

{
"title": "Exclude done tickets from nbd list by default",
"body": "## Summary\n\nChange `nbd list` to hide `done` tickets by default. Users must explicitly opt in\nvia `--filter status=done` or `--filter status=*` to see completed tickets.\n\nThis is a **breaking change in default behavior**.\n\nDepends on: `--filter` wired into `list` (ticket 887344).\n\n## Current behaviour\n\n`nbd list` shows ALL tickets regardless of status.\n\n## New behaviour\n\n| Command | Shows |\n|---|---|\n| `nbd list` | todo + in_progress only (done excluded) |\n| `nbd list --filter status=done` | done only |\n| `nbd list --filter status=*` | all tickets (all statuses) |\n| `nbd list --filter status=todo --filter status=in_progress` | todo and in_progress |\n| `nbd list --filter type=bug` | non-done bug tickets (done still excluded) |\n| `nbd list --filter type=bug --filter status=*` | all bug tickets including done |\n\nThe key rule: **if the user provides no `status` filter key, done tickets are excluded**.\nIf the user provides any `--filter status=...` argument, the explicit status filter\nis used as-is with no implicit exclusion.\n\n## Implementation (src/main.rs)\n\nIn `cmd_list`, after parsing the filter and loading tickets, apply the logic:\n\n```rust\nlet filter = filter::parse_filters(&filter_args)?;\nlet tickets = list_tickets(&root).await?;\n\nlet tickets: Vec<Ticket> = tickets\n .into_iter()\n .filter(|t| {\n // If no status filter was provided by the user, exclude done tickets.\n let status_ok = if filter.has_status_filter() {\n // User expressed intent about status: use their filter.\n filter.matches_status(t)\n } else {\n // Default: hide done tickets.\n t.status \\!= Status::Done\n };\n\n // Apply remaining filter keys (type, priority, title) regardless.\n status_ok && filter.matches_except_status(t)\n })\n .collect();\n```\n\nThis requires two additional methods on `TicketFilter` (add to `src/filter.rs`):\n\n```rust\n/// Returns true if the ticket's status matches any of the status patterns.\n/// Caller is responsible for only calling this when `has_status_filter()` is true.\npub fn matches_status(&self, ticket: &Ticket) -> bool;\n\n/// Returns true if the ticket matches all non-status filter groups (type, priority, title).\n/// The status group is intentionally excluded so callers can handle it separately.\npub fn matches_except_status(&self, ticket: &Ticket) -> bool;\n```\n\n## CLI help text update\n\nUpdate the `List` variant doc comment:\n\n```rust\n/// List tickets sorted by priority (highest first).\n///\n/// By default, tickets with status `done` are excluded. Use\n/// `--filter status=*` to include all tickets, or\n/// `--filter status=done` to show only completed tickets.\nList {\n #[arg(long = \"filter\", value_name = \"KEY=VALUE\")]\n filter: Vec<String>,\n},\n```\n\n## Existing tests that need updating\n\nThe integration test `list_shows_created_tickets` creates two tickets with default\nstatus (`todo`) and asserts both appear in `nbd list`. This test is unaffected because\nthe default tickets are not done. However, any future test that creates a ticket and\nimmediately lists without marking it done will still work.\n\nCheck: is there any existing test that creates a done ticket and expects it in `nbd list`?\nIf so, update that test to use `--filter status=done` or `--filter status=*`.\n\n## New integration tests to add (tests/integration.rs)\n\n- Create two tickets: one todo, one done. `nbd list` shows only the todo one.\n- Create two tickets: one todo, one done. `nbd list --filter status=done` shows only the done one.\n- Create two tickets: one todo, one done. `nbd list --filter status=*` shows both.\n- Create 3 tickets: bug/todo, bug/done, task/todo.\n `nbd list --filter type=bug` shows only bug/todo (done excluded by default).\n `nbd list --filter type=bug --filter status=*` shows both bug tickets.\n- `nbd list --json` does not include done tickets (verify JSON array length).\n- `nbd list --filter status=* --json` includes done tickets.\n\n## README update\n\nUpdate the \"List all tickets\" section in README.md:\n\n```\n### List all tickets\n\n```sh\nnbd list # excludes done tickets\nnbd list --filter status=* # all tickets including done\nnbd list --filter status=done # only completed tickets\nnbd list --filter type=bug # non-done bug tickets\nnbd list --json\n```\n```\n\n## Files touched\n\n- `src/main.rs` — `cmd_list` implementation and `List` help text\n- `src/filter.rs` — `matches_status`, `matches_except_status` methods\n- `src/tests.rs` — unit tests for new filter methods\n- `tests/integration.rs` — new tests, update any affected existing tests\n- `README.md` — updated usage section",
"priority": 7,
"status": "done",
"dependencies": [
"887344"
],
"ticket_type": "feature"
}