diff --git a/surfsense_web/components/citation-panel/citation-panel.tsx b/surfsense_web/components/citation-panel/citation-panel.tsx
index 890ac11ac..9b9a9aaa9 100644
--- a/surfsense_web/components/citation-panel/citation-panel.tsx
+++ b/surfsense_web/components/citation-panel/citation-panel.tsx
@@ -46,6 +46,13 @@ export const CitationPanelContent: FC = ({
const cited = useMemo(() => data?.chunks.find((c) => c.id === chunkId) ?? null, [data, chunkId]);
+ const citedLineLabel = useMemo(() => {
+ const start = data?.cited_start_line;
+ const end = data?.cited_end_line;
+ if (start == null || end == null) return null;
+ return start === end ? `Line ${start}` : `Lines ${start}–${end}`;
+ }, [data?.cited_start_line, data?.cited_end_line]);
+
const totalChunks = data?.total_chunks ?? data?.chunks.length ?? 0;
const startIndex = data?.chunk_start_index ?? 0;
const hasMoreAbove = startIndex > 0;
@@ -75,10 +82,15 @@ export const CitationPanelContent: FC = ({
const handleOpenFullDocument = () => {
if (!data) return;
+ const hasLineAnchor = data.cited_start_line != null && data.cited_end_line != null;
openEditorPanel({
documentId: data.id,
searchSpaceId: data.search_space_id,
title: data.title,
+ highlightLines: hasLineAnchor
+ ? { start: data.cited_start_line as number, end: data.cited_end_line as number }
+ : null,
+ forceSourceView: hasLineAnchor,
});
};
@@ -110,6 +122,7 @@ export const CitationPanelContent: FC = ({
+ {citedLineLabel && {citedLineLabel}}
{totalChunks > 0 && {totalChunks} chunks}
{!isLoading && !error && data && (