Skip to content

feat(dashboard): add revision history and restore commands#936

Open
MathurAditya724 wants to merge 3 commits intomainfrom
issue-935-dashboard-revision-history
Open

feat(dashboard): add revision history and restore commands#936
MathurAditya724 wants to merge 3 commits intomainfrom
issue-935-dashboard-revision-history

Conversation

@MathurAditya724
Copy link
Copy Markdown
Member

Add sentry dashboard revisions and sentry dashboard restore commands to support dashboard revision history.

  • revisions lists saved revisions for a dashboard with cursor-based pagination
  • restore reverts a dashboard to a specific revision by ID
  • history alias available for revisions

Closes #935

Add `sentry dashboard revisions` to list revision history for a dashboard
and `sentry dashboard restore` to revert to a previous revision.

- New API functions: listDashboardRevisionsPaginated, restoreDashboardRevision
- DashboardRevision type with Zod schema
- Full cursor-based pagination support for revisions list
- `history` alias for `revisions` subcommand

Fixes #935
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

PR Preview Action v1.8.1

QR code for preview link

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

Built to branch gh-pages at 2026-05-08 18:10 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@MathurAditya724
Copy link
Copy Markdown
Member Author

fix-ci: attempt 1 — dashboard revisions and dashboard restore missing from ORG_PROJECT_COMMANDS in complete.ts, causing the drift detection test to fail.

@MathurAditya724
Copy link
Copy Markdown
Member Author

fix-ci: added dashboard revisions and dashboard restore to ORG_PROJECT_COMMANDS in complete.ts. The drift detection test verifies all commands with org-positional placeholders are registered in the completion sets — the two new commands were missing. 431aac6

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Codecov Results 📊

6836 passed | Total: 6836 | 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 30.12%. Project has 14211 uncovered lines.
❌ Project coverage is 76.7%. Comparing base (base) to head (head).

Files with missing lines (3)
File Patch % Lines
src/commands/dashboard/revisions.ts 23.33% ⚠️ 138 Missing
src/commands/dashboard/restore.ts 41.05% ⚠️ 56 Missing
src/lib/api/dashboards.ts 9.52% ⚠️ 38 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    77.02%    76.70%    -0.32%
==========================================
  Files          317       319        +2
  Lines        60609     60997      +388
  Branches         0         0         —
==========================================
+ Hits         46684     46786      +102
- Misses       13925     14211      +286
- Partials         0         0         —

Generated by Codecov Action

@MathurAditya724 MathurAditya724 marked this pull request as ready for review May 8, 2026 18:02
@MathurAditya724
Copy link
Copy Markdown
Member Author

all CI checks green — lint, typecheck, unit tests, e2e, binary builds, and docs all pass. self-review looks clean: the two new commands follow existing dashboard command patterns, pagination and error handling are consistent, and completion sets are updated. marked ready for review.

Comment thread src/lib/api/dashboards.ts
Comment thread src/lib/api/dashboards.ts
Comment on lines +230 to +231
{ method: "POST", schema: DashboardDetailSchema }
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The pagination logic for the revisions command incorrectly saves the cursor when a --limit is met mid-page, causing items to be skipped on subsequent paginated requests.
Severity: HIGH

Suggested Fix

Implement a "bookmark" cursor mechanism similar to the sentry dashboard list command. This involves encoding the ID of the last processed item into the cursor, allowing the next fetch to resume from the exact point within a server-side page rather than skipping to the next one.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/lib/api/dashboards.ts#L230-L231

Potential issue: The manual pagination loop in the `sentry dashboard revisions` command
incorrectly handles pagination when a user-specified `--limit` is reached mid-page. The
code fetches full pages from the API, but if the limit is met partway through a page,
the cursor saved for the next run points to the start of the *next* API page. This
causes all remaining items from the current, partially-processed page to be skipped
entirely, leading to data loss for the user.

Also affects:

  • src/commands/dashboard/revisions.ts

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

not a real issue here. the bookmark cursor in dashboard list exists for client-side glob filtering, where items are skipped within a page. revisions has no client-side filtering — it sets perPage = Math.min(limit, API_MAX_PER_PAGE), so when limit <= 100 (the default is 25), the server page size matches the requested limit exactly and there's no mid-page break. for limit > 100 the behavior matches issue list and other commands that auto-paginate without bookmarks.

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.

Support dashboard revision history

1 participant