From 8b48fe94cdc5f64587e32b5b103e65aad75cfb80 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:03:29 +0100 Subject: [PATCH] fix: highlight the cited text when opening a file from the source list (#35167) Opening a file from the source list under an answer showed it with nothing highlighted, and a PDF opened at its first page instead of the cited one. This happened for any source with more than one paragraph. The source list now highlights the retrieved text and opens at the cited page again, as it did before paragraph citations. A plain citation chip in the answer still opens the whole source, as before. Fixes #35165 --- src/lib/components/chat/Messages/Citations.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/components/chat/Messages/Citations.svelte b/src/lib/components/chat/Messages/Citations.svelte index 58c366febe..5de7914416 100644 --- a/src/lib/components/chat/Messages/Citations.svelte +++ b/src/lib/components/chat/Messages/Citations.svelte @@ -64,7 +64,9 @@ // except for plain [1] on a source with numbered paragraphs: that cites it as a whole. const claimed = claim ? getClaimSpans(claim, fileSpans) : []; const wholeSource = - !cited.length && (citation.paragraphs ?? []).some((paragraphs: any[]) => paragraphs?.length); + typeof sourceId === 'string' && + !cited.length && + (citation.paragraphs ?? []).some((paragraphs: any[]) => paragraphs?.length); const marked = claimed.length ? claimed : wholeSource ? [] : fileSpans; const metadata = (marked[0] ?? spans[0])?.metadata ?? citation.metadata?.[0]; const fileName = String(metadata?.name ?? citation.source?.name ?? '');