From 5b62d0a3feb56e6076ca3b2c0e7c51023b64376c Mon Sep 17 00:00:00 2001 From: Luiz Gustavo Date: Thu, 21 May 2026 16:42:37 -0300 Subject: [PATCH] fix: UAP flag renders cleanly when type/rationale absent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ~414 chunks have ufo_anomaly_detected=true but no type/rationale (extraction left them null), so the flag rendered "UAP flag: anomaly โ€”" with a dangling em-dash. Build the label from the parts that exist: fall back to "anomalia" for a missing type and omit the "โ€”" when there's no rationale. The flag still shows (the chunk genuinely contains UAP content), just without the noise. Co-Authored-By: Claude Opus 4.7 --- web/components/doc-renderer-v2.tsx | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/web/components/doc-renderer-v2.tsx b/web/components/doc-renderer-v2.tsx index 54af0e2..196be1f 100644 --- a/web/components/doc-renderer-v2.tsx +++ b/web/components/doc-renderer-v2.tsx @@ -190,7 +190,7 @@ function ChunkCard({ p{fm.page} {fm.image_type && ยท {fm.image_type}} {fm.ufo_anomaly_detected && ( - ยท ๐Ÿ›ธ UAP: {fm.ufo_anomaly_type} + ยท ๐Ÿ›ธ UAP: {(typeof fm.ufo_anomaly_type === "string" && fm.ufo_anomaly_type.trim() && fm.ufo_anomaly_type.toLowerCase() !== "null") ? fm.ufo_anomaly_type : "anomalia"} )} {(showEn || showPt) && ( @@ -374,11 +374,24 @@ function ChunkCard({ {showEn &&

{content_en}

} {showPt && lang === "both" &&

{content_pt}

} {!showEn && showPt &&

{content_pt}

} - {fm.ufo_anomaly_detected && ( -
- ๐Ÿ›ธ UAP flag: {fm.ufo_anomaly_type ?? "anomaly"} โ€” {fm.ufo_anomaly_rationale} -
- )} + {fm.ufo_anomaly_detected && } + + ); +} + +/** UAP anomaly flag โ€” shows type and/or rationale, omitting parts that are + * absent so an uncharacterized flag doesn't render a dangling "anomaly โ€”". */ +function UapFlag({ fm }: { fm: ParsedChunk["fm"] }) { + const clean = (v: unknown) => { + const s = typeof v === "string" ? v.trim() : ""; + return s && s.toLowerCase() !== "null" ? s : null; + }; + const type = clean(fm.ufo_anomaly_type); + const rationale = clean(fm.ufo_anomaly_rationale); + return ( +
+ ๐Ÿ›ธ UAP flag: {type ?? "anomalia"} + {rationale ? ` โ€” ${rationale}` : ""}
); }