fix(kb-ui): SensitivityBadge tolerates an unset/unknown level

A kb.list row can arrive without a sensitivity (a claim/note, or older data);
SENSITIVITY[level] was then undefined and reading .tone crashed the whole
object list. Fall back to a neutral badge — never defaulting an unknown value
to "Open", which would misstate exposure. (Surfaced building the standalone
webapp against a real corpus.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jules
2026-07-08 13:38:22 +10:00
parent c3dc237aa4
commit 03443590a2

View File

@@ -117,7 +117,16 @@ const SENSITIVITY: Record<Sensitivity, { label: string; tone: string; icon: Reac
};
export const SensitivityBadge: FC<{ level: Sensitivity; className?: string }> = ({ level, className }) => {
const s = SENSITIVITY[level];
// A row can arrive without a sensitivity (e.g. a claim/note, or older data);
// fall back to a neutral badge rather than crash — and never default an
// unknown value to "Open", which would misstate its exposure.
const s =
SENSITIVITY[level] ?? {
label: level ?? "—",
tone: "bg-muted text-muted-foreground",
icon: null,
title: "Sensitivity not set.",
};
return (
<Badge tone={s.tone} icon={s.icon} className={className} title={s.title}>
{s.label}