feat: incident updates with a status, public or internal
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 6m54s
ci / test (pull_request) Successful in 12m15s
ci / build (pull_request) Successful in 11m0s
ci / image (pull_request) Successful in 4m23s

Outages open and close with their monitor; now people can say what is
going on. An incident gets an optional title and updates, each with a
status (investigating, identified, monitoring, resolved) and a Markdown
message, shown on status pages or kept as an internal note. The incident
shows the latest update's status, resolved once its monitor recovered.

The console lists title and status and has a page per incident with its
timeline (outage, updates, recovery) and, for incidents.write in the
monitor's group, forms to post updates and set the title. Status pages
show title, status and public updates. API: GET/PATCH
/org/incidents/:id, POST and DELETE /org/incidents/:id/updates; the
incident list carries title and status; the organization export
includes the updates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-23 23:38:07 +01:00
1 parent 6f0cf59406
commit 43a04e99b1
27 files changed
+2753 -908

No files matched your search

+96 -5
View File
@@ -286,6 +286,9 @@ type IncidentRow struct {
Duration string
Open bool
Cause []string
// Title and Status are what the organization said about it.
Title string
Status string
}
// MonitorDetailView is the data of a monitor page.
@@ -496,15 +499,14 @@ templ incidentList(rows []IncidentRow, showMonitor bool) {
for _, r := range rows {
<li class="py-2.5">
<div class="flex flex-wrap items-baseline gap-x-4 gap-y-1">
if r.Open {
<span class="font-medium text-down">{ i18n.T(ctx, "incidents.ongoing") }</span>
} else {
<span class="text-up">{ i18n.T(ctx, "incidents.resolved") }</span>
@incidentStatusLabel(r.Status, r.Open)
if r.Title != "" {
<a href={ templ.SafeURL("/incidents/" + r.ID) } class="font-medium hover:underline">{ r.Title }</a>
}
if showMonitor {
<a href={ templ.SafeURL("/monitors/" + r.MonitorID) } class="hover:underline">{ r.Monitor }</a>
}
<span class="font-mono text-xs text-muted">{ r.Started }</span>
<a href={ templ.SafeURL("/incidents/" + r.ID) } class="font-mono text-xs text-muted hover:text-ink">{ r.Started }</a>
<span class="ml-auto font-mono text-xs">{ r.Duration }</span>
</div>
if len(r.Cause) > 0 {
@@ -1365,3 +1367,92 @@ func providerGroups(ps []ProviderOption) []string {
}
return out
}
// IncidentDetailPage tells the story of one incident and lets people with
// incidents.write add to it.
templ IncidentDetailPage(p Page, me Me, v IncidentDetailView) {
@consoleShell(p, me) {
<p class="mb-2 text-sm"><a href="/incidents" class="text-muted hover:text-ink">{ "← " + i18n.T(ctx, "incidents.all") }</a></p>
<h1 class="mb-2 text-xl font-semibold">
if v.Row.Title != "" {
{ v.Row.Title }
} else {
{ v.Row.Monitor }
}
</h1>
<div class="mb-8 flex flex-wrap items-baseline gap-x-4 gap-y-1 text-sm">
@incidentStatusLabel(v.Row.Status, v.Row.Open)
<a href={ templ.SafeURL("/monitors/" + v.Row.MonitorID) } class="hover:underline">{ v.Row.Monitor }</a>
<span class="font-mono text-xs text-muted">{ v.Row.Started + " · " + v.Row.Duration }</span>
</div>
<div class="grid gap-12 md:grid-cols-[1fr_20rem]">
<section>
@sectionHeading("incident.timeline")
<ol class="space-y-5 border-l border-rule pl-5">
for _, e := range v.Timeline {
<li>
switch e.Kind {
case "update":
<p class="flex flex-wrap items-baseline gap-x-3 text-xs">
@incidentStatusLabel(e.Status, true)
<span class="font-mono text-muted">{ e.At }</span>
if e.Author != "" {
<span class="text-muted">{ e.Author }</span>
}
if !e.Public {
<span class="border border-rule px-1 text-muted">{ i18n.T(ctx, "incident.internal") }</span>
}
if v.CanWrite {
<button type="button" data-delete={ "/org/incidents/" + v.Row.ID + "/updates/" + e.ID } data-confirm={ i18n.T(ctx, "incident.delete_confirm") } class="ml-auto text-muted hover:text-down">{ i18n.T(ctx, "incident.delete") }</button>
}
</p>
<div class="legal-text mt-1 text-sm">
@templ.Raw(e.HTML)
</div>
case "resolved":
<p class="text-xs"><span class="text-up">{ i18n.T(ctx, "incident.recovered") }</span> <span class="font-mono text-muted">{ e.At }</span></p>
default:
<p class="text-xs"><span class="text-down">{ i18n.T(ctx, "incident.began") }</span> <span class="font-mono text-muted">{ e.At }</span></p>
if len(v.Row.Cause) > 0 {
<p class="mt-1 font-mono text-xs text-muted">{ strings.Join(v.Row.Cause, " · ") }</p>
}
}
</li>
}
</ol>
</section>
if v.CanWrite {
<aside>
@sectionHeading("incident.post_update")
<form data-api={ "/org/incidents/" + v.Row.ID + "/updates" } data-next={ "/incidents/" + v.Row.ID }>
@formError()
<label class="mb-4 block">
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "incident.status") }</span>
<select name="status" class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm">
for _, st := range IncidentStatuses {
<option value={ st } selected?={ st == v.NextStatus }>{ i18n.T(ctx, "incident.status."+st) }</option>
}
</select>
</label>
<div class="mb-4">
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "incident.message") }</span>
@MarkdownEditor("message", "", 6, 5000, MarkdownInline)
</div>
@checkbox(i18n.T(ctx, "incident.public"), "public", true)
<p class="-mt-2 mb-4 ml-6 text-xs text-muted">{ i18n.T(ctx, "incident.public_hint") }</p>
@submit(i18n.T(ctx, "incident.post"))
</form>
<div class="mt-10">
@sectionHeading("incident.title_heading")
<form data-api={ "/org/incidents/" + v.Row.ID } data-method="patch" data-next={ "/incidents/" + v.Row.ID }>
@formError()
@valueField(i18n.T(ctx, "incident.title_label"), "title", v.Row.Title, i18n.T(ctx, "incident.title_placeholder"), false)
<p class="-mt-2 mb-4 text-xs text-muted">{ i18n.T(ctx, "incident.title_hint") }</p>
@submit(i18n.T(ctx, "common.save"))
</form>
</div>
</aside>
}
</div>
}
}