Skip to content

feat(scans): add --status / --scan-type / --since / --until to scans list#282

Merged
sachiniyer merged 2 commits intomainfrom
siyer/scans-list-filtering
May 6, 2026
Merged

feat(scans): add --status / --scan-type / --since / --until to scans list#282
sachiniyer merged 2 commits intomainfrom
siyer/scans-list-filtering

Conversation

@sachiniyer
Copy link
Copy Markdown
Contributor

Summary

The scans list cards already render Status and Scan Type, but you couldn't filter on either. Triage prompts like "failed scans in the last 24h" had to fall through to grepping --format json.

Add four filter flags to scans list:

Flag Type Notes
--status in-progress | complete | failed | dlq WorkflowStatus
--scan-type default | recent-changes ScanType
--since duration / ISO date / RFC3339 shares parse_time_spec with bugs list
--until same as --since resolves against the same now so windows read as one interval

WorkflowStatus and ScanType get clap::ValueEnum impls so they work as flag values.

Implementation

The scans API has no server-side filtering today (only repo_id/limit/offset), so any active filter forces an all-fetch path — same shape as the bugs --vulns / --introduced-by plumbing: paginate server-side to gather every scan, filter the combined set, then re-paginate client-side for output. Bare scans list (no filter) still hits the cheap single-page server fetch and is byte-equivalent to before.

Stacking

This PR is stacked on #275 (siyer/bugs-list-since-until) so it can reuse parse_time_spec. If #275 merges first, PR6 rebases cleanly; if PR6 lands first, the eventual merge conflict is just "both branches add the same util."

Testing

Automated, run locally and passing:

  • cargo test — full suite green. 9 new tests in src/commands/scans.rs::tests:
    • filter_no_filters_returns_all
    • filter_by_status_failed, filter_by_status_complete
    • filter_by_scan_type_default, filter_by_scan_type_recent_changes
    • filter_combines_status_and_scan_type_as_and
    • filter_since_inclusive_lower_bound, filter_until_inclusive_upper_bound
    • filter_window_with_status (status + since combined)
  • cargo clippy -- -D warnings — clean
  • cargo fmt --check — clean
  • cargo xtask check — clean (HELP.md regenerated for the new flags)

Manual end-to-end against live API (usedetail/detail):

  • scans list … --status complete --limit 5total=124, every workflowStatus == "complete"
  • scans list … --status failed --limit 5total=13, first item workflowStatus == "failed"
  • scans list … --scan-type recent-changes --limit 5total=75, every scanType == "recentChanges"
  • scans list … --status complete --scan-type default --since 7d --limit 5total=1, both filters satisfied ✅
  • scans list … --since garbageError: invalid --since value: could not parse 'garbage' as a duration (e.g. 1d, 24h), a date (YYYY-MM-DD), or an RFC3339 timestamp
  • Bare scans list usedetail/detail --format json --limit 3 (regression) → total=137, page=1 — single-page server fetch unchanged

🤖 Generated with Claude Code

@sachiniyer sachiniyer temporarily deployed to integration-tests May 6, 2026 21:11 — with GitHub Actions Inactive
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

@sachiniyer sachiniyer temporarily deployed to integration-tests May 6, 2026 21:13 — with GitHub Actions Inactive
@sachiniyer sachiniyer force-pushed the siyer/bugs-list-since-until branch from 99e3862 to a808e75 Compare May 6, 2026 22:39
@sachiniyer sachiniyer changed the base branch from siyer/bugs-list-since-until to graphite-base/282 May 6, 2026 22:43
@sachiniyer sachiniyer force-pushed the siyer/scans-list-filtering branch from e8bf8f1 to 44fd3fb Compare May 6, 2026 22:43
@sachiniyer sachiniyer temporarily deployed to integration-tests May 6, 2026 22:43 — with GitHub Actions Inactive
@sachiniyer sachiniyer temporarily deployed to integration-tests May 6, 2026 22:43 — with GitHub Actions Inactive
@sachiniyer sachiniyer changed the base branch from graphite-base/282 to siyer/bugs-list-multi-status May 6, 2026 22:43
Copy link
Copy Markdown
Contributor Author

sachiniyer commented May 6, 2026

sachiniyer and others added 2 commits May 6, 2026 16:03
…list

The scans list cards already render `Status` and `Scan Type`, but
you couldn't filter on either. Triage prompts like "failed scans
in the last 24h" had to fall through to grep over `--format json`.

Add four filter flags to `scans list`:
  --status      WorkflowStatus  (in-progress | complete | failed | dlq)
  --scan-type   ScanType        (default | recent-changes)
  --since       duration / ISO date / RFC3339
  --until       same as --since

The scans API has no server-side filtering today, so any active
filter forces an all-fetch path (mirroring the bugs / vulns
plumbing): the CLI paginates server-side to gather every scan,
filters the combined set, then re-paginates client-side. Bare
`scans list` (no filter) still hits the cheap single-page server
fetch and is byte-equivalent to before.

Reuses `parse_time_spec` from PR3 (`siyer/bugs-list-since-until`)
— this PR is stacked on that branch. If PR3 merges first, PR6
rebases cleanly; if PR6 lands first, the PR3 conflict is just
"both branches add the same util."

`WorkflowStatus` and `ScanType` get `clap::ValueEnum` impls so they
work as flag values.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI's rustfmt insisted the long `f.iter().map(...).collect()` chains
in three filter_scans tests get broken across multiple lines. Local
fmt missed it — different version. Let CI's view win.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sachiniyer sachiniyer changed the base branch from siyer/bugs-list-multi-status to main May 6, 2026 23:04
@sachiniyer sachiniyer force-pushed the siyer/scans-list-filtering branch from e5d5b9a to 8980b32 Compare May 6, 2026 23:04
@sachiniyer sachiniyer enabled auto-merge (squash) May 6, 2026 23:04
@sachiniyer sachiniyer temporarily deployed to integration-tests May 6, 2026 23:04 — with GitHub Actions Inactive
@sachiniyer sachiniyer merged commit 6ab434c into main May 6, 2026
12 of 13 checks passed
@sachiniyer sachiniyer deleted the siyer/scans-list-filtering branch May 6, 2026 23:08
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