Skip to content

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

Merged
kodiakhq[bot] merged 7 commits into
ClickHouse:mainfrom
gedaliakliger:agent/1781-tile-alert-opens-panel
Dec 3, 2026
Merged

kodiakhq[bot] merged 7 commits into
ClickHouse:mainfrom
gedaliakliger:agent/1781-tile-alert-opens-panel

Conversation

@gedaliakliger

@gedaliakliger gedaliakliger commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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

Reviewed by Cursor Bugbot for commit 8e02d3c. 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: 8e02d3c

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

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

1 posted as inline comment(s) on the changed lines. 2 P3 folded at the bottom.

🔵 2 P3 — no action needed before merge
  • 🔵 P3 packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:300 — This is a third copy of the new-alert construction (DEFAULT_TILE_ALERT plus the chart name) → The same { ...DEFAULT_TILE_ALERT, ...(name && { displayName: name }) } literal is already in ChartEditorControls.tsx:521 and RawSqlChartEditor.tsx:256. Per the REQUIRED DRY rule, add one helper (e.g. newTileAlert(name)) in packages/app/src/utils/alerts.ts next to DEFAULT_TILE_ALERT and use it in all three places, so the bell draft can't drift from what Add alert creates.
  • 🔵 P3 packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:291 — opensOnNewAlert restates the existing alert-availability checks by hand, and one of its clauses can never change the result → (enableAlerts ?? dashboardId != null) duplicates offersAlerts (line 481). !IS_LOCAL_MODE duplicates the showAlertButton gate in ChartEditorControls.tsx:192. getFormReferenceVariables(savedFormValue).length === 0 is already covered by savedChartConfigSupportsAlerts(chartConfig), which calls configUsesReferenceVariable (common-utils core/utils.ts:1837). Move offersAlerts above this point and build the condition from it. Drop the redundant reference-variable clause, so the bell draft and the Add alert button come from one source of truth.

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. No P0/P1: the change is a client-side UX routing fix over existing alert-save paths — no data-loss, crash, auth, or injection path. The one prior high-severity concern (bell-opened existing-alert edits failing to revert) was verified as a non-issue: react-hook-form deep-clones defaultValues/values, so the useRef(formValue.alert) snapshot stays pristine, and DBEditTimeChartForm.test.tsx:827 covers the edit→close→reopen→revert path.

🟡 P2 — recommended

  • packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:850 — After the specially-allowed first run, a re-run triggered by a granularity/display-type/source change while the auto-seeded draft alert still has an empty webhook is blocked by the resolver with no notification (the "Invalid Chart" toast lives inside the un-called runChart), silently freezing the preview and yanking focus to the webhook field until the alert is completed or the panel closed.
    • Fix: Let effect-driven auto-submits keep ignoring an untouched seeded draft alert on later runs, or discard the draft when the user never engages it.
    • adversarial, frontend-races, correctness
  • packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:291 — opensOnNewAlert re-derives alert eligibility with a predicate (getFormReferenceVariables, savedChartConfigSupportsAlerts, !IS_LOCAL_MODE) that diverges in shape from the editor's live alertsEnabled/showAlertButton gates, which also consider textUsesReferenceVariable; if they drift a draft could be seeded the editor won't surface, and it is only masked today by the supportsAlerts button gate.
    • Fix: Extract a shared eligibility predicate, or cross-link the three gates with a comment documenting the coupling.
    • maintainability, correctness
  • packages/app/src/DBDashboardPage.tsx:2570 — The new isEditingTileAlert reset branches (onEditClick, add-tile) exist specifically so the panel does not default open after the bell is used, yet no test covers the wiring: the page has no unit harness and the E2E only ever reopens via the alert button.
    • Fix: Add an E2E step that opens via the alert bell, closes, reopens via the edit (pencil) button, and asserts the alert panel is not open.
    • testing
🔵 P3 nitpicks (5)
  • packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:893 — The comment "The resolver only checks the alert" is inaccurate (chartFormResolver validates the whole zSavedChartConfig), and the first-run invalid handler unconditionally runs clearErrors('alert') + runChart({...getValues(), alert: undefined}) for any resolver error, so user alert-misconfigurations or a zod-only chart error can be run without feedback.
    • Fix: Scope the ignore branch to proceed only when the sole error is on alert and the draft is untouched.
    • correctness, adversarial
  • packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:850 — ignoresNewAlert names the mechanism rather than the intent ("skip alert validation on the first run").
    • Fix: Rename to something like skipsNewAlertValidation.
  • packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:304 — The ...(savedFormValue.name && { displayName: savedFormValue.name }) short-circuit spread of a possibly-empty string reads as a trick.
    • Fix: Use an explicit ternary ...(savedFormValue.name ? { displayName: savedFormValue.name } : {}).
    • kieran-typescript
  • packages/app/tests/e2e/features/alerts.spec.ts:266 — The new test uses raw page.getByTestId()/page.locator() directly in the spec, which tests/e2e/README.md forbids in favor of page objects (though the surrounding file already does this and the rule is not CI-enforced).
    • Fix: Route the alert-panel, confirm-button, display-name, and chart-container locators through the relevant page object.
    • project-standards
  • packages/app/src/components/DBEditTimeChartForm/__tests__/DBEditTimeChartForm.test.tsx:695 — "starts on a new alert for a chart it cannot run yet" only asserts the panel contains alert-details, which is also true for an existing alert, so it does not actually prove a new draft was seeded.
    • Fix: Assert the confirm button reads "Add alert" and/or the display name is seeded from the chart name.
    • testing

Reviewers (10): correctness, adversarial, testing, maintainability, project-standards, kieran-typescript, frontend-races, previous-comments, agent-native, learnings-researcher.

Testing gaps:

  • No test edits the seeded draft alert into an invalid state before the first run to confirm whether the error is surfaced or swallowed.
  • No test covers the second/subsequent run with an untouched auto-seeded draft still open (the preview-freeze path above).
  • Negative branches of opensOnNewAlert (IS_LOCAL_MODE, reference-variable present, savedChartConfigSupportsAlerts false) are untested, so draft-suppression in those cases is unverified.

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
Contributor 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
Contributor 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
Contributor 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

@pulpdrew pulpdrew left a comment

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.

LGTM, thanks for the contribution

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 — Discarding the bell-opened draft leaves the form dirty against its defaults, so the editor asks about unsaved changes when nothing changed

The draft alert goes into defaultValues/values, but closing the panel calls setValue('alert', undefined) (cancelAlertChanges, line ~1001). RHF then compares every later field change against defaults that still hold the draft, so isDirty stays true. Repro: click the bell, close the alert panel, type a character in the chart name and delete it, close the modal. EditTileModal (DBDashboardPage.tsx:1742) shows the 'Discard' confirm. Fix: keep defaultValues as savedFormValue and add the draft with setValue('alert', …) on mount, the way the Add alert button does (ChartEditorControls.tsx:520). The alternative is to drop the draft from the defaults when it is discarded.

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

@kodiakhq
kodiakhq Bot merged commit 25af112 into ClickHouse:main Dec 3, 2026
26 of 29 checks passed
@gedaliakliger
gedaliakliger deleted the agent/1781-tile-alert-opens-panel branch December 3, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

2 participants