From d0bd17ed7e2e1aa099cada1cbaa99110a06bfd06 Mon Sep 17 00:00:00 2001 From: Josh Wright Date: Sun, 12 Apr 2026 11:59:31 -0400 Subject: [PATCH] Add system comments on close events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Manual close: "Manually closed." Auto-resolve: "Condition resolved — alert closed automatically." (reopen comments were already in place) Co-Authored-By: Claude Sonnet 4.6 --- src/app/alerts/[id]/AlertDetail.tsx | 5 ----- src/lib/db.ts | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/app/alerts/[id]/AlertDetail.tsx b/src/app/alerts/[id]/AlertDetail.tsx index 92a8f5d..4476ab1 100644 --- a/src/app/alerts/[id]/AlertDetail.tsx +++ b/src/app/alerts/[id]/AlertDetail.tsx @@ -230,11 +230,6 @@ export default function AlertDetail({ initialAlert }: { initialAlert: Alert }) { )} - {/* Media type */} - {alert.mediaType && ( - - )} - {/* User (for user-behavior alerts) */} {alert.userName && !alert.mediaTitle && ( diff --git a/src/lib/db.ts b/src/lib/db.ts index 1780013..b75b3e1 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -185,6 +185,12 @@ export function upsertAlerts(candidates: AlertCandidate[]): number { alert.closeReason = "resolved"; alert.closedAt = nowISO; alert.suppressedUntil = null; + alert.comments.push({ + id: store.nextCommentId++, + body: "Condition resolved — alert closed automatically.", + createdAt: nowISO, + author: "system", + }); } save(store); @@ -221,10 +227,17 @@ export function closeAlert(id: number): Alert | null { suppressedUntil = d.toISOString(); } + const now = new Date().toISOString(); alert.status = "closed"; alert.closeReason = "manual"; - alert.closedAt = new Date().toISOString(); + alert.closedAt = now; alert.suppressedUntil = suppressedUntil; + alert.comments.push({ + id: store.nextCommentId++, + body: "Manually closed.", + createdAt: now, + author: "system", + }); save(store); return toAlert(alert); }