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:
@@ -230,11 +230,6 @@ export default function AlertDetail({ initialAlert }: { initialAlert: Alert }) {
|
|||||||
<Chip label={`${isResolved ? "Resolved" : "Closed"} ${fullDate(alert.closedAt)}`} dim />
|
<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) */}
|
{/* User (for user-behavior alerts) */}
|
||||||
{alert.userName && !alert.mediaTitle && (
|
{alert.userName && !alert.mediaTitle && (
|
||||||
<Chip label={alert.userName} />
|
<Chip label={alert.userName} />
|
||||||
|
|||||||
@@ -185,6 +185,12 @@ export function upsertAlerts(candidates: AlertCandidate[]): number {
|
|||||||
alert.closeReason = "resolved";
|
alert.closeReason = "resolved";
|
||||||
alert.closedAt = nowISO;
|
alert.closedAt = nowISO;
|
||||||
alert.suppressedUntil = null;
|
alert.suppressedUntil = null;
|
||||||
|
alert.comments.push({
|
||||||
|
id: store.nextCommentId++,
|
||||||
|
body: "Condition resolved — alert closed automatically.",
|
||||||
|
createdAt: nowISO,
|
||||||
|
author: "system",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
save(store);
|
save(store);
|
||||||
@@ -221,10 +227,17 @@ export function closeAlert(id: number): Alert | null {
|
|||||||
suppressedUntil = d.toISOString();
|
suppressedUntil = d.toISOString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const now = new Date().toISOString();
|
||||||
alert.status = "closed";
|
alert.status = "closed";
|
||||||
alert.closeReason = "manual";
|
alert.closeReason = "manual";
|
||||||
alert.closedAt = new Date().toISOString();
|
alert.closedAt = now;
|
||||||
alert.suppressedUntil = suppressedUntil;
|
alert.suppressedUntil = suppressedUntil;
|
||||||
|
alert.comments.push({
|
||||||
|
id: store.nextCommentId++,
|
||||||
|
body: "Manually closed.",
|
||||||
|
createdAt: now,
|
||||||
|
author: "system",
|
||||||
|
});
|
||||||
save(store);
|
save(store);
|
||||||
return toAlert(alert);
|
return toAlert(alert);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user