feat(notifications): add structured category enum to dispatcher and history (#774)

Introduce a NotificationCategory string-literal union (11 values) and
thread it through dispatchAlert as a required second argument. All
callers (DockerEventService, AutoHealService, ImageUpdateService,
MonitorService, PolicyEnforcement, policyGate, SchedulerService,
imageUpdates route) pass an explicit category at every call site,
giving TypeScript compile-time enforcement that no new emit site can
be added without choosing a category.

DatabaseService gains an idempotent migration that adds a nullable
category TEXT column to notification_history; existing rows keep
category=NULL (displayed as Uncategorized in the UI). The
getNotificationHistory method accepts an optional category filter
that is forwarded from the GET /api/notifications/history route via
a ?category= query param.

NotificationPanel gains a category Select dropdown so users can
filter history by category. The frontend types mirror the backend
union so API responses are type-safe end-to-end.

All 75 test files (1410 tests) updated to the new 4-arg dispatchAlert
signature and passing.
This commit is contained in:
Anso
2026-04-25 13:55:07 -04:00
committed by GitHub
parent a74564fd61
commit 44dba59cab
20 changed files with 250 additions and 134 deletions
+6 -5
View File
@@ -242,9 +242,9 @@ export class AutoHealService {
NotificationService.getInstance()
.dispatchAlert(
'info',
'autoheal_triggered',
`Auto-Heal: Restarted ${containerName} on stack ${policy.stack_name} after being unhealthy for ${policy.unhealthy_duration_mins} minute(s).`,
policy.stack_name,
containerName,
{ stackName: policy.stack_name, containerName },
)
.catch(err => console.error('[AutoHeal] notification dispatch failed:', err));
} catch (err) {
@@ -266,9 +266,9 @@ export class AutoHealService {
NotificationService.getInstance()
.dispatchAlert(
'warning',
'autoheal_triggered',
`Auto-Heal: Failed to restart ${containerName} on stack ${policy.stack_name}. Error: ${errorMsg}`,
policy.stack_name,
containerName,
{ stackName: policy.stack_name, containerName },
)
.catch(e => console.error('[AutoHeal] notification dispatch failed:', e));
@@ -299,8 +299,9 @@ export class AutoHealService {
NotificationService.getInstance()
.dispatchAlert(
'warning',
'autoheal_triggered',
`Auto-Heal: Policy for ${policy.stack_name}${policy.service_name ? '/' + policy.service_name : ''} has been auto-disabled after ${failures} consecutive failures.`,
policy.stack_name,
{ stackName: policy.stack_name },
)
.catch(e => console.error('[AutoHeal] notification dispatch failed:', e));
}