From e97f588d70226127fa09d4891b2e24c04d40af7d Mon Sep 17 00:00:00 2001 From: Victor <70475442+vsolano9@users.noreply.github.com> Date: Sun, 23 Aug 2026 17:00:49 +0200 Subject: [PATCH] fix(search): use canonical severity labels Use the shared long-form severity vocabulary in the search filter and type the range as SeverityLevel values. Preserve the existing range interaction while eliminating the private label map that had drifted from case pages. Closes AgentPostmortem/agentpostmortem#30 --- components/post/SearchResults.tsx | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/components/post/SearchResults.tsx b/components/post/SearchResults.tsx index 4c0ea0a..765c806 100644 --- a/components/post/SearchResults.tsx +++ b/components/post/SearchResults.tsx @@ -4,6 +4,11 @@ import { useState, useEffect, useRef } from "react"; import Link from "next/link"; import { PostCard } from "@/components/post/PostCard"; import { AGENTS } from "@/lib/constants/agents"; +import { + isSeverityLevel, + SEVERITY_LABELS, + type SeverityLevel, +} from "@/lib/constants/severity"; import type { Post } from "@/types"; import { ChevronDownIcon, ChevronUpIcon } from "@/components/ui/icons"; @@ -11,13 +16,7 @@ interface SearchResponse { posts?: Post[]; } -const SEVERITY_LABELS: Record = { - 1: "Minimal", - 2: "Low", - 3: "Moderate", - 4: "Severe", - 5: "Critical", -}; +const SEVERITY_LEVELS: SeverityLevel[] = [1, 2, 3, 4, 5]; export function SearchResults({ initialQuery, @@ -28,8 +27,8 @@ export function SearchResults({ }) { const [query, setQuery] = useState(initialQuery); const [agentFilter, setAgentFilter] = useState(""); - const [minSeverity, setMinSeverity] = useState(1); - const [maxSeverity, setMaxSeverity] = useState(5); + const [minSeverity, setMinSeverity] = useState(1); + const [maxSeverity, setMaxSeverity] = useState(5); const [filtersOpen, setFiltersOpen] = useState(false); const [results, setResults] = useState(initialResults); @@ -211,7 +210,7 @@ export function SearchResults({ aria-labelledby="filter-severity-label" className="flex gap-1" > - {[1, 2, 3, 4, 5].map((lvl) => { + {SEVERITY_LEVELS.map((lvl) => { const inRange = lvl >= minSeverity && lvl <= maxSeverity; return (