Repository navigation
Conversation
…ckHouse#1781) Clicking the "Add Alert" icon on a dashboard tile opened the tile editor but not with the alert editor section shown -- the user still had to click "Add Alert" a second time inside the modal. The tile's onAddAlertClick prop existed but was never wired, so every alert entry point fell back to a plain edit. Wire onAddAlertClick on the no-alert bell (toolbar and collapsed menu) to open the editor with the tile's default alert already seeded, so the alert editor renders straight away. The seed mirrors the in-editor "Add Alert" button (including the display-name default) via a new pure withDefaultTileAlert helper. An existing alert is untouched, and local mode -- where alerts aren't offered -- falls back to a plain edit.
🦋 Changeset detectedLatest commit: 3edc440 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@eugeneo17 is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @eugeneo17, thanks for this. We limit outside contributors to 1 open pull request at a time, and you already have #3154 open. Reviewing several changes from one author at once is more than we can give proper attention to, and it tends to mean none of them land. I have closed this one to keep the queue honest — your branch and your work are untouched. Once that PR is merged or closed, reopen this and it will go through. |
Deep Review✅ No critical issues found. The change is small and well-scoped. The new 🟡 P2 -- recommended
🔵 P3 nitpicks (2)
Reviewers (5): correctness, testing, maintainability, kieran-typescript, project-standards. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
|
| onAddAlertClick={() => | ||
| setEditedTile( | ||
| // Local mode has no alerts (the in-editor "Add Alert" button is | ||
| // hidden there too), so fall back to a plain edit. | ||
| IS_LOCAL_MODE | ||
| ? chart | ||
| : { ...chart, config: withDefaultTileAlert(chart.config) }, | ||
| ) | ||
| } |
There was a problem hiding this comment.
The new tests only call
withDefaultTileAlert. They never click either Tile alert action or check the IS_LOCAL_MODE branch. A callback can be dropped from the toolbar or narrow-tile menu—the exact bug fixed here—while the suite stays green. Add a component or browser test that clicks both no-alert actions and checks that the alert editor opens. Cover the local fallback too.
Knowledge Base Used: Development and test workflows
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| chart={chart} | ||
| dateRange={searchedTimeRange} | ||
| onEditClick={() => setEditedTile(chart)} | ||
| onAddAlertClick={() => |
There was a problem hiding this comment.
🟠 major — Seeding only checks IS_LOCAL_MODE, so the bell opens an alert editor on temporary dashboards where alerts are deliberately not offered
The in-editor "Add Alert" button is gated on alertsEnabled && !IS_LOCAL_MODE (ChartEditorControls.tsx:494, RawSqlChartEditor.tsx:300), and alertsEnabled = enableAlerts ?? dashboardId != null (EditTimeChartForm.tsx:194) — EditTileModal passes no enableAlerts, so on /dashboards (a local/URL-state dashboard, dashboardId == null per dashboard.ts:259) the button is hidden. TileAlertEditor however renders on alert != null alone (ChartEditorControls.tsx:568, RawSqlChartEditor.tsx:371), so seeding here routes around that gate: on a temporary dashboard the bell now opens a full alert editor, and anything configured there is lost — onCreateDashboard (line 2835) POSTs tiles: [] and navigates away, so the tile and its alert are never persisted. Gate the seed on the same condition the editor uses: IS_LOCAL_MODE || dashboardId == null ? chart : {...} (dashboardId is already in scope at line 1878).
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
| if (config.alert != null) { | ||
| return config; | ||
| } | ||
| return { |
There was a problem hiding this comment.
🔵 minor — withDefaultTileAlert adds a third copy of the default-alert seed instead of reusing the existing one
The exact expression { ...DEFAULT_TILE_ALERT, ...(name && { displayName: name }) } already exists at ChartEditorControls.tsx:502 and RawSqlChartEditor.tsx:309; the new doc comment says it "mirrors" them, which is three hand-synced sources of truth for one concept (the repo's DRY rule is marked REQUIRED). Export a single defaultTileAlert(name?: string) from this module, call it from all three sites, and clamp the copied name with clampAlertDisplayName (@hyperdx/common-utils/dist/alerts), which exists precisely because chart names are uncapped while alertDisplayNameSchema caps at 512.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| variant="subtle" | ||
| size="sm" | ||
| onClick={onEditClick} | ||
| onClick={onAddAlertClick ?? onEditClick} |
There was a problem hiding this comment.
🔵 minor — onAddAlertClick ?? onEditClick fallback and the optional prop are unreachable
Tile is local to this file and has exactly one call site (line 2413), which always passes onAddAlertClick, so neither ?? branch (lines 911 and 1086) can ever fall back. Make the prop required (onAddAlertClick: () => void at line 456) and drop both ?? onEditClick fallbacks.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| }); | ||
| }); | ||
|
|
||
| describe('withDefaultTileAlert', () => { |
There was a problem hiding this comment.
🔵 minor — Tests cover the trivial helper but not the wiring that was actually broken
The four new cases all exercise the pure withDefaultTileAlert; nothing asserts the bug in the issue — that clicking the tile's bell opens the editor with the alert section visible — nor the IS_LOCAL_MODE fallback, so reverting onClick={onAddAlertClick ?? onEditClick} back to onEditClick keeps every test green. The e2e page object already exposes getTileButton('alerts') (packages/app/tests/e2e/page-objects/DashboardPage.ts:662), so a test that clicks it and expects the tile editor's alert section to be visible is cheap.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
PR Review
4 finding(s): 🔴 0 critical · 🟠 1 major · 🔵 3 minor 4 posted as inline comment(s) on the changed lines. Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
…3680) ## Summary The bell on a dashboard tile (and the alert item in a narrow tile's menu) called `onEditClick`, so it opened the same editor as **Edit**. Since #3222 the alert form lives in a side panel that opens only on request, so after clicking the bell you had to click **Add alert** or **Edit alert** again inside the editor. `Tile` has declared an `onAddAlertClick` prop since the v2 dashboard, but nothing wired it. - The tile's alert actions now call `onAlertClick`, which opens the tile editor with the new `defaultAlertPanelOpened`. - `EditTimeChartForm` then opens the alert panel from the start, on the tile's alert. A tile without one gets a new alert, filled in as the **Add alert** button fills it (`DEFAULT_TILE_ALERT` plus the tile name as display name), and the panel opens it as a draft, so closing the panel discards it, as with the button. - The new alert is only added where the editor offers alerts: a saved dashboard, not local mode, and `savedChartConfigSupportsAlerts`. On a temporary dashboard the bell still opens a plain editor. - Until the chart has run once, a run ignores the new alert: it has no webhook yet, and since the form's resolver checks only the alert, the first run would otherwise stop there and leave the preview empty. That run, whether automatic or by hand (a raw SQL tile with no source doesn't run on open), previews the chart without the alert and shows no alert errors. Later runs check the alert as before. eugeneo17's #3194 fixed this before the alert panel landed and was closed by the open-PR limit; its review is where the temporary-dashboard case came up. Checks run here: the five related suites (`DBEditTimeChartForm`, `AlertPanel`, `AlertPanelButton`, `TileAlertEditor`, `EditInlineAlertModal`, 95 tests), ESLint and Prettier on the changed files (no new warnings), `node scripts/ci/ratchet.mjs`, and `tsc --noEmit` on `packages/app`. Left to CI: lint and unit tests across packages, and E2E. No unit test covers the `DBDashboardPage` wiring, since the page has no component test harness; the E2E dashboard specs already reach the button through `getTileButton('alerts')`. ### Screenshots or video I couldn't capture these: local mode hides the tile alert editor (`yarn app:dev:local` and the Vercel preview), and the full stack needs Docker, which I don't have here. | Before | After | | :----- | :---- | | | | ### How to reproduce **Starting point:** `yarn dev` (alerts need the API), a saved dashboard with a Line or Number tile on the Logs source. **On `main`:** 1. Hover the tile and click its bell (**Add alert**). 2. The tile editor opens without the alert panel. **Add alert** has to be clicked again inside the editor. **On this branch:** 1. Click the tile's bell: the editor opens with the alert panel showing a new alert. **Add alert** under its fields confirms it; closing the panel discards it. 2. On a tile that has an alert, the bell opens the editor on that alert, with **Update alert**. 3. On a temporary dashboard (**New Dashboard** → **Temporary Dashboard**), add a Line tile and click its bell: the editor opens without an alert, as before. ### How to test on Vercel preview N/A: the tile alert editor is hidden in local mode, so the preview can't show it. ### References - Closes #1781 - Related PRs: #3194 (earlier fix, closed by the open-PR limit), #3222 (alert side panel) --- > [!NOTE] > **Low Risk** > UX wiring in the dashboard tile editor and alert form; no API, auth, or persistence logic changes beyond existing alert save flows. > > **Overview** > Dashboard tile **bell** actions no longer open the generic tile editor via `onEditClick`; they use a dedicated **`onAlertClick`** path that opens `EditTileModal` with **`defaultAlertPanelOpened`**, so the alert side panel is visible immediately (existing alert or a new draft). > > **`EditTimeChartForm`** honors that flag: tiles without an alert get a prefilled **`DEFAULT_TILE_ALERT`** draft (tile name as display name) and **`AlertPanelLayout`** opens as a draft that **`defaultIsDraft`** can discard on close. The first chart run **skips alert validation** when the draft has no webhook yet, so auto-run still loads a preview; normal edit still clears the alert-open flag. > > Temporary dashboards, local mode, and charts that cannot support alerts still open the editor **without** forcing the alert panel. Unit and E2E tests cover the new open/discard/run behavior. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 8e02d3c. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> Co-authored-by: Drew Davis <6097246+pulpdrew@users.noreply.github.com>
Summary
Fixes #1781. Clicking the Add Alert icon on a dashboard tile opened the tile
editor but left the alert editor hidden — the user still had to click Add
Alert a second time inside the modal to get to it.
The tile's
onAddAlertClickprop already existed but was never wired, so everyalert entry point fell back to a plain edit.
What changed
onAddAlertClickon the no-alert bell — both the tile toolbar and thecollapsed (narrow-tile) overflow menu — to open the editor with the tile's
default alert already seeded, so the alert editor renders immediately.
withDefaultTileAlertinpackages/app/src/utils/alerts.ts, mirroring the in-editor "Add Alert" button(including seeding the alert's display name from the chart name).
Behavior
which already shows the alert.
is hidden there too), falls back to a plain edit.
Tests
Unit coverage for
withDefaultTileAlertinpackages/app/src/utils/__tests__/alerts.test.ts: seeds the default (with thechart name as display name), omits the display name when the chart has none,
leaves an existing alert untouched (returns the same object), and does not
mutate the source config.
How to test on Vercel preview
Preview routes: /dashboards
Steps:
showing, pre-filled with the default alert — no second click needed.
editor showing that alert (unchanged).
References