@@ -28,6 +28,7 @@ import { Code } from "@/components/settings/code";
2828import { Page , PageHeader } from "@/components/page" ;
2929import { buttonClass , focusRing , inputClass , linkButton , primaryButton , secondaryButton } from "@/components/ui" ;
3030import { Select } from "@/components/select" ;
31+ import { formatDate } from "@/components/list/time" ;
3132import {
3233 Chip ,
3334 DetailBlock ,
@@ -82,6 +83,27 @@ function plural(n: number, one: string, many = `${one}s`): string {
8283 return `${ n . toLocaleString ( ) } ${ n === 1 ? one : many } ` ;
8384}
8485
86+ const DAY_MS = 86_400_000 ;
87+
88+ /**
89+ * Whether a finding is quiet, in words: "Quiet for 3 days. Resolves on its own
90+ * Nov 5 unless seen again." for an open one with no line for a day or more,
91+ * "Resolved on its own Nov 5 (no new lines for 3 days)." once the analyzer
92+ * resolved it; null otherwise.
93+ */
94+ function quietWords ( f : LogFinding , now = Date . now ( ) ) : string | null {
95+ if ( f . status === "fixed" && f . resolved_at && f . fix ?. state !== "merged" ) {
96+ const why = f . resolved_reason ?. replace ( / ^ R e s o l v e d : \s * / , "" ) ;
97+ return `Resolved on its own ${ formatDate ( f . resolved_at ) } ${ why ? ` (${ why } )` : "" } .` ;
98+ }
99+ if ( ( f . status === "new" || f . status === "acknowledged" ) && f . resolves_at && f . last_seen ) {
100+ const quiet = Math . floor ( ( now - Date . parse ( f . last_seen ) ) / DAY_MS ) ;
101+ if ( ! ( quiet >= 1 ) ) return null ;
102+ return `Quiet for ${ plural ( quiet , "day" ) } . Resolves on its own ${ formatDate ( f . resolves_at ) } unless seen again.` ;
103+ }
104+ return null ;
105+ }
106+
85107function errorText ( e : unknown , fallback : string ) : string {
86108 return e instanceof Error && e . message && ! / ^ A P I \d + / . test ( e . message ) ? e . message : fallback ;
87109}
@@ -467,7 +489,7 @@ function FindingRow({
467489 status = { look }
468490 title = { f . title }
469491 titleText = { f . title }
470- quiet = { f . status === "ignored" }
492+ quiet = { f . status === "ignored" || ( f . status === "fixed" && ! ! f . resolved_at ) }
471493 meta = { [
472494 < span key = "g" title = { f . log_group } className = "font-medium text-zinc-300" >
473495 { serviceName ( f . log_group ) }
@@ -478,11 +500,12 @@ function FindingRow({
478500 f . reopened_at ? `seen again ${ timeAgo ( f . reopened_at ) } after it was resolved` : null ,
479501 f . repo ? < span key = "r" > { f . repo } </ span > : null ,
480502 ] }
481- summary = { fixWords ( f ) ?? autoNote ?? undefined }
503+ summary = { fixWords ( f ) ?? autoNote ?? quietWords ( f ) ?? undefined }
482504 summaryTone = { f . fix ? ( f . fix . state === "merged" ? "success" : f . fix . state === "failed" || f . fix . state === "pr_closed" ? "attention" : "live" ) : "muted" }
483505 chips = {
484506 < >
485- < Chip tone = { sev . tone } > { sev . label } </ Chip >
507+ { /* A resolved finding's severity is history: shown, not alarming. */ }
508+ < Chip tone = { f . status === "fixed" || f . status === "ignored" ? "neutral" : sev . tone } > { sev . label } </ Chip >
486509 < StatusText look = { look } />
487510 { f . fix ?. auto && < Chip tone = "info" title = "Started automatically from this finding" > Auto</ Chip > }
488511 { link }
@@ -571,6 +594,11 @@ function FindingDetail({
571594 </ ul >
572595 </ DetailBlock >
573596 ) }
597+ { quietWords ( f ) && (
598+ < DetailBlock title = "Quiet" >
599+ < p className = "text-zinc-300" data-testid = "finding-quiet" > { quietWords ( f ) } </ p >
600+ </ DetailBlock >
601+ ) }
574602 { f . suggested_action && (
575603 < DetailBlock title = "Recommendation" >
576604 < p className = "text-zinc-300" > { f . suggested_action } </ p >
0 commit comments