Skip to content

feat(period): support absolute date ranges in --period flag#674

Merged
BYK merged 9 commits intomainfrom
feat/period-date-range-support
Apr 7, 2026
Merged

feat(period): support absolute date ranges in --period flag#674
BYK merged 9 commits intomainfrom
feat/period-date-range-support

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Apr 7, 2026

Summary

Overload the existing --period flag across all 8 time-scoped commands to accept absolute date ranges using gh-compatible syntax (e.g., gh search issues --created ">2023-01-01"), in addition to existing relative durations.

New syntax

Syntax Meaning Example
7d, 24h Relative (unchanged) --period 7d
date..date Full range --period "2024-01-01..2024-02-01"
date.. / ..date Open-ended --period "2024-01-01.."
>=date From (inclusive) --period ">=2024-01-01"
>date After (exclusive) --period ">2024-01-01"
<=date Through (inclusive) --period "<=2024-02-01"
<date Before (exclusive) --period "<2024-02-01"

Date formats: YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, with optional timezone.

Key design decisions

  • Single flag — no new --start/--end flags, avoids alias conflicts and --help clutter
  • Local timezone for date-only inputs — "2024-01-15" means the user's local midnight, not UTC
  • Exclusive operators shift dates>2024-01-15 (date-only) starts from Jan 16; >2024-01-15T12:00:00Z (datetime) passes through as-is
  • Follow mode validationlog list --follow rejects end-bounded ranges
  • Pagination cache — serialization normalizes to UTC for deterministic keys; >=2024-01-01 and 2024-01-01.. share the same cache entry

Affected commands (8)

trace list, span list, issue events, event list, issue list, trace logs, log list, dashboard view

Changes

  • New: src/lib/time-range.tsparsePeriod(), timeRangeToApiParams(), serializeTimeRange(), timeRangeToSeconds()
  • API layer: Added start?/end? to all option types in api/traces.ts, api/events.ts, api/issues.ts, api/logs.ts, api/dashboards.ts
  • Commands: All 8 commands parse period via parsePeriod(), spread API params via timeRangeToApiParams(), serialize for pagination via serializeTimeRange()
  • Tests: 67 new tests (34 unit + 33 property-based with fast-check)

Overload the existing --period flag across all 8 time-scoped commands
to accept absolute date ranges using gh-compatible syntax, in addition
to existing relative durations.

New formats: "2024-01-01..2024-02-01", ">=2024-01-01", ">2024-01-01",
"<=2024-02-01", "<2024-02-01", and open-ended "2024-01-01.." / "..2024-02-01".

- Add src/lib/time-range.ts with parsePeriod(), timeRangeToApiParams(),
  serializeTimeRange(), and timeRangeToSeconds()
- Add start/end params to all API function option types
- Update all 8 commands: trace list, span list, issue events, event list,
  issue list, trace logs, log list, dashboard view
- Date-only inputs use local timezone (not UTC)
- Exclusive operators (>, <) shift to next/prev day for date-only
- Follow mode rejects end-bounded ranges
- 67 tests (34 unit + 33 property-based)
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (period) Support absolute date ranges in --period flag by BYK in #674

Bug Fixes 🐛

Init

  • Run commands without shell to eliminate injection surface by betegon in #665
  • Use opendir for listDir and validate symlinks during traversal by betegon in #663
  • Rename 'Custom Metrics' feature label to 'Metrics' by MathurAditya724 in #659
  • Add reactFeatures to feature display info by MathurAditya724 in #658
  • Generate spinner messages from payload params instead of server detail by MathurAditya724 in #655

Other

  • (errors) Separate informational notes from actionable alternatives in ContextError by BYK in #651
  • (skill-gen) Eliminate manual maps to prevent undocumented commands by BYK in #670
  • Three bug fixes from Sentry telemetry (CLI-SC, CLI-QZ, CLI-WD) by cursor in #664
  • Fix set-commits --auto, document release workflow pitfalls by BYK in #650

Internal Changes 🔧

Init

  • Use guardNonInteractive for TTY check by betegon in #677
  • Use shared DRY_RUN_FLAG and add -n alias by betegon in #676
  • Reuse resolveOrg for offline-first org detection by betegon in #666
  • Use mdKvTable and renderMarkdown for wizard summary by betegon in #661

Other

  • Extract createProjectWithDsn to deduplicate project creation by betegon in #667
  • Regenerate skill files and command docs by github-actions[bot] in eb1b19e7

Other

  • Update custom.css by stevenplewis in #653

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/pr-preview/pr-674/

Built to branch gh-pages at 2026-04-07 11:11 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Codecov Results 📊

134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 89.72%. Project has 1459 uncovered lines.
❌ Project coverage is 95.5%. Comparing base (base) to head (head).

Files with missing lines (4)
File Patch % Lines
src/lib/api/dashboards.ts 33.33% ⚠️ 24 Missing
src/lib/api/traces.ts 50.00% ⚠️ 6 Missing
src/lib/time-range.ts 98.04% ⚠️ 4 Missing
src/lib/api/events.ts 0.00% ⚠️ 3 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    95.56%    95.50%    -0.06%
==========================================
  Files          222       223        +1
  Lines        32111     32414      +303
  Branches         0         0         —
==========================================
+ Hits         30686     30955      +269
- Misses        1425      1459       +34
- Partials         0         0         —

Generated by Codecov Action

BYK added 2 commits April 7, 2026 00:27
…Date parsing

Replace RELATIVE_PERIOD_RE, DATE_ONLY_RE, and HAS_TZ_RE with simpler
string-based checks and a parseRelativeParts() helper that uses
String.at(), Number(), and String.includes().
…one detection

Remove hasTimezone(), getLocalOffsetString(), and isDateOnly() in favor
of letting new Date() handle timezone interpretation natively. All
outputs are now UTC via .toISOString() — no manual offset string
construction.
@BYK BYK marked this pull request as ready for review April 7, 2026 01:03
- Fix statsPeriod/start+end conflict: API functions with fallback
  statsPeriod defaults now guard with start/end presence check
- Fix normalizeDateOnly day arithmetic: use local setDate/setHours
  instead of UTC round-trip to prevent date shift in extreme timezones
- Reject all absolute ranges with --follow, not just end-bounded
- Fix dashboard: use period (not statsPeriod) for WidgetQueryOptions,
  matching the expected interface field name
- Fix log list: add period context to empty-state message ("No logs
  found in the last 30d." / "No logs found in the specified range.")
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 285982c. Configure here.

BYK and others added 2 commits April 7, 2026 11:10
- Make PERIOD_BRIEF and all error message dates dynamic (relative to today)
- Use new Set(Object.keys(UNIT_SECONDS)) for PERIOD_UNITS
- Remove unnecessary ?? on .at(-1) (use as-cast, length pre-checked)
- Accept space separator as T alternative in datetime parsing
- Add test for space-separated datetime input
@BYK BYK merged commit 6edb045 into main Apr 7, 2026
27 checks passed
@BYK BYK deleted the feat/period-date-range-support branch April 7, 2026 11:24
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