Skip to content

fix(app): open the alert panel from a dashboard tile's alert button - #3680

Open
gedaliakliger wants to merge 4 commits into
ClickHouse:mainfrom
gedaliakliger:agent/1781-tile-alert-opens-panel
Open

gedaliakliger wants to merge 4 commits into
ClickHouse:mainfrom
gedaliakliger:agent/1781-tile-alert-opens-panel

Conversation

@gedaliakliger

@gedaliakliger gedaliakliger commented Nov 16, 2026 •

Copy link
Copy Markdown

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


Note

Low Risk
UI-only workflow fix in the dashboard tile editor and alert panel, with broad unit test coverage and no auth or data-layer changes.

Overview
Dashboard tile bell actions (toolbar and narrow-tile menu) no longer open the generic tile editor via onEditClick. They call onAlertClick, which sets isEditingTileAlert and opens EditTileModal with defaultAlertPanelOpened.

EditTimeChartForm honors that flag: tiles with an alert open the side panel on that alert; eligible tiles without one get a DEFAULT_TILE_ALERT draft (tile name as display name) with AlertPanelLayout opened as a draft so closing discards it. The panel stays closed on surfaces that don't offer alerts (e.g. temporary dashboard / no dashboardId). Until the chart has run once, the first run strips the draft alert so missing-webhook validation doesn't block the preview.

AlertPanelLayout gains defaultIsDraft so an initially open draft behaves like Add alert when closed without confirming.

Reviewed by Cursor Bugbot for commit bf47224. Bugbot is set up for automated code reviews on this repo. Configure here.

The tile's bell opened the plain tile editor, so the alert panel needed a
second click. It now opens the editor on the tile's alert, or on a new draft
where the editor offers alerts.
@gedaliakliger
gedaliakliger requested a review from a team as a code owner November 16, 2026 17:41
@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

@gedaliakliger is attempting to deploy a commit to the HyperDX Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bf47224

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

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

getFormReferenceVariables(savedFormValue).length === 0 &&
!IS_LOCAL_MODE &&
savedChartConfigSupportsAlerts(chartConfig);
const formValue: ChartEditorFormState = useMemo(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 P2 — Putting the draft alert into the form's defaultValues makes discarding it look like an unsaved edit

formValue (with the draft alert) is passed as defaultValues/values, so RHF treats the draft as the saved state. When the user closes the panel, cancelAlertChanges(true) sets alert to undefined. From then on _getDirty() sees a difference from the defaults, so the next field edit, even one that is reverted, makes isDirty true. Closing the editor (EditTileModal.handleClose) then asks to discard changes on a tile the user never changed. Fix: keep savedFormValue as the form's defaults and add the draft after mount with setValue('alert', …) (the path the Add alert button already uses), so the defaults still match the saved tile.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I tested this and the draft in the defaults doesn't change when the discard prompt shows. With the bell unused and no alert on the tile, typing a character into Chart Name and deleting it already ends on onDirtyChange(true), so an edited-then-reverted field prompts on main too. I also tried the suggested setValue('alert', …) after mount: same result. Closing the draft panel with no other edit leaves isDirty false, since cancelAlertChanges sets the value without shouldDirty. Leaving it as is.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    priority. Reply with one sentence; if it is P0, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

4 finding(s): 🔴 0 P0/P1 · 🟡 2 P2 · 🔵 2 P3

1 posted as inline comment(s) on the changed lines. 2 P3 folded at the bottom. 1 unchanged from an earlier push (already inline above).

🔵 2 P3 — no action needed before merge
  • 🔵 P3 packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:300 — opensOnNewAlert restates the alert-availability gate a second time → The condition repeats alertsEnabled (enableAlerts ?? dashboardId != null plus the reference-variable check, line 437) and showAlertButton's !IS_LOCAL_MODE plus display-type support (ChartEditorControls.tsx:189). It computes them in its own way, from savedFormValue/chartConfig instead of the watched form state, so the gates can drift apart. Fix: pull out one helper (e.g. canOfferAlert(config, {enableAlerts, dashboardId})) and have alertsEnabled, showAlertButton, RawSqlChartEditor and opensOnNewAlert all call it.
  • 🔵 P3 packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:311 — Third copy of the new-alert construction {...DEFAULT_TILE_ALERT, displayName: name} → The same literal already lives in ChartEditorControls.tsx:518 and RawSqlChartEditor.tsx:253 (the Add alert handlers). Fix: add a makeDefaultTileAlert(name?: string) helper in @/utils/alerts and call it from all three, so the bell and the button can't fill different defaults.

Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

The change is sound: the seeded draft alert enters the form as defaultValues/values (so it never marks the form dirty), the opensOnNewAlert eligibility gate is complete, and ignoresNewAlert only suppresses alert validation on the first run. The prior Cursor Bugbot "existing alert edits may not revert" concern was independently re-traced and does not reproduce — alertSnapshotRef is seeded from the pristine saved alert at mount, and the revert path is covered by a test added in this branch.

🟡 P2 -- recommended

  • packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:816 -- After the first run flips ignoresNewAlert to false, an auto-seeded but untouched draft alert (no webhook) makes the whole-form resolver fail, so a later re-query from a granularity or display-type change is silently skipped and the preview goes stale while the panel is still open.
    • Fix: Treat a pristine, unconfirmed DEFAULT_TILE_ALERT draft as absent for preview re-runs (extend the ignoresNewAlert condition past the first run until the draft is dirtied or confirmed), or auto-discard the untouched draft when a chart field changes.
    • adversarial
  • packages/app/src/components/DBEditTimeChartForm/__tests__/DBEditTimeChartForm.test.tsx:651 -- The new tests only exercise the first-run validation skip; nothing asserts that alert validation resumes once queriedConfig is set, so a regression dropping && queriedConfig == null (always-skip) would pass every test.
    • Fix: Add a case that runs the chart once, then submits again with an empty-webhook draft and asserts the webhook error now blocks the run and focuses select-webhook.
    • testing, correctness, kieran-typescript
  • packages/app/src/DBDashboardPage.tsx:2555 -- The core wiring this PR adds (bell sets isEditingTileAlert=true, onEditClick/add-tile reset it to false, flag passed as defaultAlertPanelOpened) has no test; E2E only asserts the alert button is visible, never that clicking it opens the panel.
    • Fix: Add an interaction test that clicks tile-alerts-button-* and asserts the editor opens with the alert panel shown, versus the edit button opening a plain editor.
    • testing, previous-comments
🔵 P3 nitpicks (3)
  • packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:300 -- opensOnNewAlert re-derives the alert-eligibility gate (enableAlerts ?? dashboardId != null) plus the reference-variable check, duplicating the alertsEnabled value computed later in the same component and the showAlertButton gate in ChartEditorControls.tsx; three copies will drift when eligibility rules change.
    • Fix: Extract a single chartOffersAlerts(...) helper computed once and reused by opensOnNewAlert and the button gate.
    • maintainability, kieran-typescript, correctness
  • packages/app/src/DBDashboardPage.tsx:2550 -- isEditingTileAlert is never reset when the modal closes; it is safe only because every open path sets it before editedTile, so a future open path that forgets would leak a stale value into defaultAlertPanelOpened.
    • Fix: Reset setIsEditingTileAlert(false) alongside setEditedTile(undefined) on close so the invariant is self-enforcing.
    • correctness, maintainability
  • packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:304 -- The getFormReferenceVariables(savedFormValue).length === 0 check overlaps with savedChartConfigSupportsAlerts(chartConfig) (which already rejects reference-variable configs), so a reader must reason about why reference variables appear to be excluded twice.
    • Fix: Drop the redundant check if equivalent for this call site, or add a comment explaining why both are required.
    • maintainability, kieran-typescript

Reviewers (7): correctness, testing, maintainability, project-standards, kieran-typescript, adversarial, previous-comments.

Testing gaps:

  • Narrow-tile collapsed-menu alert item (onAlertClick via Menu.Item) is not exercised by any test.
  • The IS_LOCAL_MODE, savedChartConfigSupportsAlerts, and reference-variable branches of opensOnNewAlert lack dedicated fallback-to-plain-editor cases (only the dashboardId-undefined branch is covered).

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

@gedaliakliger

Copy link
Copy Markdown
Author

On the Deep Review P2 (DBDashboardPage.tsx:2535): no test renders DBDashboardPage today, and a harness for the page is wider than this fix, so I left the wiring to E2E, where dashboard.spec.ts already reaches the bell through getTileButton('alerts'). I can't run E2E here (no Docker), so I didn't add an assertion I couldn't run. The P3s about a shared eligibility helper and makeNewTileAlert touch ChartEditorControls.tsx and RawSqlChartEditor.tsx, which this PR doesn't change.

…rt-opens-panel

# Conflicts:
#	packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx
getFormReferenceVariables(savedFormValue).length === 0 &&
!IS_LOCAL_MODE &&
savedChartConfigSupportsAlerts(chartConfig);
const formValue: ChartEditorFormState = useMemo(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 P2 — The draft alert is put into the form's defaultValues, so discarding it makes an untouched tile count as edited

formValue, including the seeded alert, is passed as defaultValues/values to useForm. When the user closes the panel, cancelAlertChanges(true) sets alert to undefined, so the form no longer matches its defaults. The next dirty recompute (any field change, even one typed and then reverted) reports isDirty, and EditTileModal (DBDashboardPage.tsx:1737) then asks 'You have unsaved changes…' for a tile the user never changed. The Add alert button path doesn't have this problem because its defaults contain no alert. Fix: keep defaultValues equal to savedFormValue and seed the draft once on mount with setValue('alert', …), the same way onAddAlert does it. Add a test that closes the draft and checks that onDirtyChange is not reported as true.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Same finding as the thread above, and my answer there still holds: an edited-then-reverted field ends on onDirtyChange(true) on main too, with no alert involved, and seeding with setValue('alert', …) after mount gave the same result when I tried it. Closing the draft with no other edit leaves isDirty false. Leaving it as is.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 using high effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 6ea34c9. Configure here.

@gedaliakliger

Copy link
Copy Markdown
Author

This is the second round of bot findings, so I'm stopping here per AGENTS.md. Round two had no P0/P1: the Bugbot finding doesn't reproduce (test added in bf47224) and the P2 repeats the one answered above. Could a maintainer take a look at the scope when there's time? CI is still waiting on approval.

runChart,
// The resolver only checks the alert. The chart runs without it, and
// the alert's errors are neither shown nor focused.
ignoresNewAlert

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 P2 — The first-run bypass ignores every resolver error, not just alert errors

The onInvalid callback drops the errors argument and runs the chart whenever ignoresNewAlert is true. It rests on the comment's claim that the resolver checks only the alert, but chartFormResolver runs the whole zSavedChartConfig. If any non-alert field fails, the chart still runs and that error stays set in the form without being reported. Fix: only take the bypass when Object.keys(errors) is exactly ['alert']; otherwise fall through to the normal invalid handling.

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

This branch has not been deployed

No deployments
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.

Clicking the Add Alert Icon on a Dashboard Tile does not open the modal with the alert editor

1 participant