fix: UAP flag renders cleanly when type/rationale absent

~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 <noreply@anthropic.com>
This commit is contained in:
Luiz Gustavo 2026-05-21 16:42:37 -03:00
parent b94f4869de
commit 5b62d0a3fe

View file

@ -190,7 +190,7 @@ function ChunkCard({
<span>p{fm.page}</span>
{fm.image_type && <span>· {fm.image_type}</span>}
{fm.ufo_anomaly_detected && (
<span className="text-[#00ff9c]">· 🛸 UAP: {fm.ufo_anomaly_type}</span>
<span className="text-[#00ff9c]">· 🛸 UAP: {(typeof fm.ufo_anomaly_type === "string" && fm.ufo_anomaly_type.trim() && fm.ufo_anomaly_type.toLowerCase() !== "null") ? fm.ufo_anomaly_type : "anomalia"}</span>
)}
</figcaption>
{(showEn || showPt) && (
@ -374,11 +374,24 @@ function ChunkCard({
{showEn && <p>{content_en}</p>}
{showPt && lang === "both" && <p className="mt-1 text-[#8896aa] text-sm">{content_pt}</p>}
{!showEn && showPt && <p>{content_pt}</p>}
{fm.ufo_anomaly_detected && (
<div className="mt-1 text-xs text-[#00ff9c] font-mono">
🛸 UAP flag: {fm.ufo_anomaly_type ?? "anomaly"} {fm.ufo_anomaly_rationale}
</div>
)}
{fm.ufo_anomaly_detected && <UapFlag fm={fm} />}
</div>
);
}
/** 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 (
<div className="mt-1 text-xs text-[#00ff9c] font-mono">
🛸 UAP flag: {type ?? "anomalia"}
{rationale ? `${rationale}` : ""}
</div>
);
}