Skip to content

feat(dashboard): add dashboard list, view, and create commands#406

Open
betegon wants to merge 10 commits intomainfrom
feat/dashboard-commands-core
Open

feat(dashboard): add dashboard list, view, and create commands#406
betegon wants to merge 10 commits intomainfrom
feat/dashboard-commands-core

Conversation

@betegon
Copy link
Member

@betegon betegon commented Mar 12, 2026

Summary

  • Add sentry dashboard list — list dashboards with --web and --json support
  • Add sentry dashboard view — view dashboard detail by numeric ID or title (case-insensitive match)
  • Add sentry dashboard create — create dashboards with optional inline --widget-* flags for quick widget creation
  • Add dashboard API client functions (listDashboards, getDashboard, createDashboard, updateDashboard)
  • Add Zod-validated aggregate function and search filter constants for spans/discover datasets
  • Add parseAggregate() / parseSortExpression() shorthand for CLI-friendly aggregate syntax (e.g. countcount(), p95:span.durationp95(span.duration))
  • Add auto-layout engine that packs widgets into the 6-column grid

Split from #401. Widget commands (add/edit/delete) follow in a stacked PR.

Test plan

  • bun run typecheck — no new type errors
  • bun run lint — passes
  • bun test test/types/dashboard.test.ts — 53 tests pass (enum constants, schema validation, parseAggregate, parseSortExpression, prepareWidgetQueries)

🤖 Generated with Claude Code

@github-actions
Copy link
Contributor

github-actions bot commented Mar 12, 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 ✨

Init

  • Add --team flag to relay team selection to project creation by MathurAditya724 in #403
  • Enforce canonical feature display order by betegon in #388
  • Accept multiple delimiter formats for --features flag by betegon in #386
  • Add git safety checks before wizard modifies files by betegon in #379
  • Add experimental warning before wizard runs by betegon in #378
  • Add init command for guided Sentry project setup by betegon in #283

Issue List

  • Auto-compact when table exceeds terminal height by BYK in #395
  • Redesign table to match Sentry web UI by BYK in #372

Other

  • (dashboard) Add dashboard list, view, and create commands by betegon in #406
  • (trial) Auto-prompt for Seer trial + sentry trial list/start commands by BYK in #399
  • Support SENTRY_HOST as alias for SENTRY_URL by betegon in #409
  • Add --dry-run flag to mutating commands by BYK in #387
  • Return-based output with OutputConfig on buildCommand by BYK in #380
  • Add --fields flag for context-window-friendly JSON output by BYK in #373
  • Magic @ selectors (@latest, @most_frequent) for issue commands by BYK in #371
  • Input hardening against agent hallucinations by BYK in #370
  • Add response caching for read-only API calls by BYK in #330

Bug Fixes 🐛

Init

  • Remove implementation detail from help text by betegon in #385
  • Truncate uncommitted file list to first 5 entries by MathurAditya724 in #381

Other

  • (api) Convert --data to query params for GET requests by BYK in #383
  • (docs) Remove double borders and fix column alignment on landing page tables by betegon in #369
  • Show human-friendly names in trial list and surface plan trials by BYK in #412
  • Add trace ID validation to trace view + UUID dash-stripping by BYK in #375

Documentation 📚

  • Update credential storage docs and remove stale config.json references by betegon in #408

Internal Changes 🔧

Init

  • Remove --force flag by betegon in #377
  • Remove dead determine-pm step label by betegon in #374

Other

  • (log/list) Convert non-follow paths to return CommandOutput by BYK in #410
  • Convert list command handlers to return data instead of writing stdout by BYK in #404
  • Split api-client.ts into focused domain modules by BYK in #405
  • Migrate non-streaming commands to CommandOutput with markdown rendering by BYK in #398
  • Convert Tier 2-3 commands to return-based output and consola by BYK in #394
  • Convert remaining Tier 1 commands to return-based output by BYK in #382
  • Converge Tier 1 commands to writeOutput helper by BYK in #376

Other

  • Minify JSON on read and pretty-print on write in init local ops by MathurAditya724 in #396

🤖 This preview updates automatically when you update the PR.

Dashboard API functions now live in src/lib/api/dashboards.ts following
the domain module pattern from #405.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@betegon betegon force-pushed the feat/dashboard-commands-core branch from 02c23d0 to f05f91a Compare March 13, 2026 09:39
@github-actions
Copy link
Contributor

github-actions bot commented Mar 13, 2026

Codecov Results 📊

104 passed | Total: 104 | 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 95.83%. Project has 729 uncovered lines.
❌ Project coverage is 96.65%. Comparing base (base) to head (head).

Files with missing lines (3)
File Patch % Lines
human.ts 96.44% ⚠️ 45 Missing
dashboards.ts 12.12% ⚠️ 29 Missing
dashboard.ts 99.33% ⚠️ 2 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    96.68%    96.65%    -0.03%
==========================================
  Files          159       166        +7
  Lines        21011     21779      +768
  Branches         0         0         —
==========================================
+ Hits         20314     21050      +736
- Misses         697       729       +32
- Partials         0         0         —

Generated by Codecov Action

@betegon betegon marked this pull request as ready for review March 13, 2026 10:06
betegon and others added 3 commits March 13, 2026 12:08
…end existing test suites

Add ~46 new tests covering dashboard commands (list, create, resolve),
URL builders (property-based), human formatters, and type utilities
(assignDefaultLayout, stripWidgetServerFields).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Convert list from buildListCommand to buildCommand with return-based output
- Extract formatDashboardListHuman for human-readable table rendering
- Add --fresh flag to both list and view commands
- Update list tests to include fresh flag

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…olve.ts

Align parseDashboardPositionalArgs with the established codebase pattern
used in event/view, trace/view, trace/logs, and dashboard/create.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
betegon and others added 4 commits March 13, 2026 12:32
updateDashboard has no callers in the core dashboard commands (list,
view, create). It will be added back when widget commands are introduced.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…etServerFields

These functions are only needed for widget update operations (add/edit/delete),
which are not part of the core dashboard commands (list, view, create).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ner to list

- Title column renders as markdown link to dashboard URL (clickable in terminal)
- Add --limit flag (default 30) with per_page passed to API
- Wrap fetch in withProgress() for "Fetching dashboards..." spinner
- Add jsonTransform to keep JSON output as plain array

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@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.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Dashboard view URL uses wrong singular path segment
    • Changed buildDashboardUrl to use /dashboards/ (plural) instead of /dashboard/ (singular) to match Sentry's routing.

Create PR

Or push these changes by commenting:

@cursor push 1285439136
Preview (1285439136)
diff --git a/src/lib/sentry-urls.ts b/src/lib/sentry-urls.ts
--- a/src/lib/sentry-urls.ts
+++ b/src/lib/sentry-urls.ts
@@ -189,9 +189,9 @@
   dashboardId: string
 ): string {
   if (isSaaS()) {
-    return `${getOrgBaseUrl(orgSlug)}/dashboard/${dashboardId}/`;
+    return `${getOrgBaseUrl(orgSlug)}/dashboards/${dashboardId}/`;
   }
-  return `${getSentryBaseUrl()}/organizations/${orgSlug}/dashboard/${dashboardId}/`;
+  return `${getSentryBaseUrl()}/organizations/${orgSlug}/dashboards/${dashboardId}/`;
 }
 
 /**

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

return `${getOrgBaseUrl(orgSlug)}/dashboard/${dashboardId}/`;
}
return `${getSentryBaseUrl()}/organizations/${orgSlug}/dashboard/${dashboardId}/`;
}
Copy link

Choose a reason for hiding this comment

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

Dashboard view URL uses wrong singular path segment

High Severity

buildDashboardUrl generates URLs with /dashboard/ (singular) but Sentry's web app routes specific dashboards under /dashboards/{id}/ (plural), the same base as the list page. This means every dashboard URL produced by the view, create, and list commands will be broken — linking users to a non-existent path. buildDashboardsListUrl correctly uses /dashboards/ but buildDashboardUrl inconsistently uses /dashboard/.

Fix in Cursor Fix in Web

Replace invisible OSC 8 terminal hyperlink on title with a visible
muted URL on a second line, so it's auto-clickable by the terminal.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@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.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

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

return ref;
}

const dashboards = await listDashboards(orgSlug);
Copy link

Choose a reason for hiding this comment

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

Title-based dashboard lookup limited to first API page

Medium Severity

resolveDashboardId calls listDashboards(orgSlug) without specifying a perPage parameter when resolving a dashboard by title. This means it only searches through the API's default page size (typically ~20 items). Organizations with many dashboards will get a false "not found" error for dashboards beyond the first page, along with a misleading "Available dashboards" list that only shows the first page of results.

Fix in Cursor Fix in Web

@cursor
Copy link

cursor bot commented Mar 13, 2026

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Unused prepareDashboardForUpdate function never called
    • Removed the unused function as it was never imported or called anywhere in the codebase

Create PR

Or push these changes by commenting:

@cursor push 6ffef7f85b
Preview (6ffef7f85b)
diff --git a/src/types/dashboard.ts b/src/types/dashboard.ts
--- a/src/types/dashboard.ts
+++ b/src/types/dashboard.ts
@@ -565,23 +565,3 @@
 
   return cleaned;
 }
-
-/**
- * Prepare a full dashboard for PUT update.
- * Strips server-generated fields from all widgets while preserving
- * widgetType, displayType, and layout.
- *
- * @param dashboard - Dashboard detail from GET response
- * @returns Object with title and cleaned widgets, ready for PUT body
- */
-export function prepareDashboardForUpdate(dashboard: DashboardDetail): {
-  title: string;
-  widgets: DashboardWidget[];
-  projects?: number[];
-} {
-  return {
-    title: dashboard.title,
-    widgets: (dashboard.widgets ?? []).map(stripWidgetServerFields),
-    projects: dashboard.projects,
-  };
-}

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

@betegon betegon requested a review from BYK March 13, 2026 12:45
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