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
+14 -1
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);
}