feat: add frontend support for surfsense docs citations

This commit is contained in:
CREDO23 2026-01-09 18:21:59 +02:00
parent 3539b2a83d
commit abd3bace53
4 changed files with 43 additions and 15 deletions

View file

@ -34,6 +34,7 @@ interface SourceDetailPanelProps {
description?: string;
url?: string;
children?: ReactNode;
isDocsChunk?: boolean;
}
const formatDocumentType = (type: string) => {
@ -114,6 +115,7 @@ export function SourceDetailPanel({
description,
url,
children,
isDocsChunk = false,
}: SourceDetailPanelProps) {
const scrollAreaRef = useRef<HTMLDivElement>(null);
const hasScrolledRef = useRef(false); // Use ref to avoid stale closures
@ -132,8 +134,13 @@ export function SourceDetailPanel({
isLoading: isDocumentByChunkFetching,
error: documentByChunkFetchingError,
} = useQuery({
queryKey: cacheKeys.documents.byChunk(chunkId.toString()),
queryFn: () => documentsApiService.getDocumentByChunk({ chunk_id: chunkId }),
queryKey: isDocsChunk
? cacheKeys.documents.byChunk(`doc-${chunkId}`)
: cacheKeys.documents.byChunk(chunkId.toString()),
queryFn: () =>
isDocsChunk
? documentsApiService.getSurfsenseDocByChunk(chunkId)
: documentsApiService.getDocumentByChunk({ chunk_id: chunkId }),
enabled: !!chunkId && open,
staleTime: 5 * 60 * 1000,
});