[HDX-3044] Add optional note field to alerts#2210
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: a5df19a The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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 |
E2E Test Results✅ All tests passed • 176 passed • 3 skipped • 1277s
Tests ran across 4 shards in parallel. |
81cd928 to
4c42e30
Compare
Add a freeform note/reason field to alerts that supports markdown formatting. This allows on-call responders to document alert reasoning, threshold history, and links to runbooks. - Add note field to Mongoose model, Zod schemas, and API responses - Add note textarea to saved-search and tile alert editors - Display notes on the alerts page in a collapsible section with markdown rendering - Update OpenAPI docs for external API v2 - Add E2E tests for note creation and display
Display IconBellFilled in red on saved-search alert modal tabs when the alert state is ALERT, matching the visual pattern used by AlertStatusIcon on dashboard tiles.
…g alerts Add IconBellFilled to the right of the Alerts button text on the search page when at least one alert in the saved search is in the ALERT state.
62946c0 to
1276b6b
Compare
…e target - Omit note field from external API response when null/undefined, matching the conditional spread pattern used for scheduleOffsetMinutes - Move data-testid from wrapper div to UnstyledButton so Playwright clicks the actual toggle handler
🔴 Tier 4 — CriticalTouches auth, data models, config, tasks, OTel pipeline, ClickHouse, or CI/CD. Why this tier:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
Deep ReviewScope: PR #2210 — Adds optional Reviewers (8): correctness, testing, maintainability, project-standards, agent-native, security, api-contract, kieran-typescript. ✅ No critical issues found. The change follows existing patterns (mirrors 🟡 P2 -- recommended
🔵 P3 nitpicks (4)
Reviewers (8): correctness, testing, maintainability, project-standards, agent-native, security, api-contract, kieran-typescript. Testing gaps:
|
… tests P1 fixes: - Extract AlertNoteField component with onChange empty→null transform - Seed note: null in form defaults to prevent uncontrolled→controlled - Restore nullable: true + add minLength/maxLength to OpenAPI note spec P2 fixes: - Gate ReactMarkdown behind opened state to prevent image fetch on paint - Add custom img component with referrerPolicy=no-referrer, loading=lazy - Add max(4096) to AlertsPageItemSchema.note to mirror server cap - Use alert._id as key in AlertCardList to preserve expand state on refetch P3 fixes: - Refactor makeAlert name/message/note to use ?? null Testing: - Add unit tests for note omit-when-null in external API transformer - Add internal API round-trip test for note create, update, and clear - Add toBeHidden assertion in tile E2E test before expanding note - Strengthen link assertions to verify href, target, and rel attributes
- External API now returns note: null (matching name/message siblings) instead of omitting the field - Extract alertNoteSchema in common-utils as single source of truth for note validation constraints (min(1), max(4096), nullish) - Use shared schema in AlertBaseObjectSchema, AlertsPageItemSchema, and backend alertSchema - Update unit and integration tests to expect note: null
Response to Deep Review P2 Items 7 and 8Item 7 — Zod schema unit tests for note boundaries: Skipping. The Item 8 — E2E test for edit/clear paths: Skipping. The create → update → clear round-trip is already covered by the integration test |
The AlertStatusIcon is shown alongside the webhook channel icon on alert tabs, not replacing it. This matches the additive pattern used on dashboard tiles and the app nav.
|
@dhable ignore the UI preview smoke failure for now. Working on it :) |
Response to Deep Review P0/P1 — silent note wipe on update
...(alert.note !== undefined && { note: alert.note ?? null }),The pre-existing Integration tests added for both the internal and external API confirming that a PUT without |
PR Review✅ No critical issues found. A few small observations (not blocking):
Nice touches:
|
| * nullable: true | ||
| * minLength: 1 | ||
| * maxLength: 4096 | ||
| * example: "Threshold raised from 50 to 100 on 2026-01-15. See [runbook](https://wiki.example.com/runbook)." |
There was a problem hiding this comment.
This link doesn't resolve to anything
Summary
Adds an optional freeform note/reason field to alerts, allowing on-call responders to document why an alert exists, threshold decision history, and links to runbooks. The note field supports markdown formatting.
Additionally, this PR brings the saved-search alert UX in line with dashboards by adding visual indicators for firing alerts:
AlertStatusIconcomponent (same pattern as dashboard tiles and app nav)Changes across the codebase:
notefield to Mongoose model, Zod validation schemas (sharedalertNoteSchemain common-utils + API), controller mapping, internal API response formatting, external API type + transformer, and OpenAPI docsAlertNoteFieldcomponent with empty→null onChange transform. Notes are displayed on the/alertspage in a collapsible section (hidden by default) with markdown rendering gated behind the expanded state. Custom<a>and<img>overrides for link security and referrer privacy.AlertStatusIconalongside the webhook channel icon. The Alerts button on the search page showsAlertStatusIconwhen alerts are configured.Screenshots or video
Screen.Recording.2026-05-06.at.2.09.59.PM.mov
How to test locally or on Vercel
Threshold set to **1**. See [runbook](https://example.com).), and create the alert/alerts— the alert row should show a "Note" toggleReferences