From 323f8da202cdad92e13788111ec41f745d01df91 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Fri, 4 Sep 2026 23:17:14 +0200 Subject: [PATCH] fix: show relevance badge for single-source citations (#29647) A response with exactly one citation never showed its relevance badge, even though the source carried a perfectly valid score. Adding a second citation made the badge appear for that same source, so the score looked like it came and went at random. calculateShowRelevance hides relevance when a result set mixes distance metrics (cosine in -1..1 next to unbounded L2), since those numbers are not comparable. With a single distance that check degenerates: distances.length - 1 is 0, so the "all but one are out of range" clause matches whatever the value is, and the score is hidden. A lone distance cannot be a mix of two metrics, so it now returns before the outlier check runs. Sets of two or more distances behave exactly as before, mixed-metric sets are still suppressed. Fixes #29646 --- src/lib/components/chat/Messages/Citations.svelte | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/components/chat/Messages/Citations.svelte b/src/lib/components/chat/Messages/Citations.svelte index 59f056362b..2fc78c7535 100644 --- a/src/lib/components/chat/Messages/Citations.svelte +++ b/src/lib/components/chat/Messages/Citations.svelte @@ -80,6 +80,11 @@ return false; } + // A single distance cannot be an outlier + if (distances.length === 1) { + return true; + } + if ( (inRange === distances.length - 1 && outOfRange === 1) || (outOfRange === distances.length - 1 && inRange === 1)