Add system comments on close events

Manual close: "Manually closed."
Auto-resolve: "Condition resolved — alert closed automatically."
(reopen comments were already in place)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-12 11:59:31 -04:00
parent 4b2c82cf90
commit d0bd17ed7e
2 changed files with 14 additions and 6 deletions

View File

@@ -230,11 +230,6 @@ export default function AlertDetail({ initialAlert }: { initialAlert: Alert }) {
<Chip label={`${isResolved ? "Resolved" : "Closed"} ${fullDate(alert.closedAt)}`} dim />
)}
{/* Media type */}
{alert.mediaType && (
<Chip label={alert.mediaType === "movie" ? "Movie" : "TV Show"} />
)}
{/* User (for user-behavior alerts) */}
{alert.userName && !alert.mediaTitle && (
<Chip label={alert.userName} />

View File

@@ -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);
}