mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 03:29:25 +01:00
fix(ai-chat): small PDFs did not show up in queue or stored files
this was seen when using LM Studio
This commit is contained in:
parent
c45236912e
commit
2350b79bb5
|
|
@ -46,6 +46,7 @@ export default function KnowledgeBaseModal({ aiAssistantName = "AI Assistant", o
|
|||
if (fileUploaderRef.current) {
|
||||
fileUploaderRef.current.clear()
|
||||
}
|
||||
queryClient.invalidateQueries({ queryKey: ['embed-jobs'] })
|
||||
},
|
||||
onError: (error: any) => {
|
||||
addNotification({
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import { useEffect, useRef } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import api from '~/lib/api'
|
||||
|
||||
const useEmbedJobs = (props: { enabled?: boolean } = {}) => {
|
||||
const queryClient = useQueryClient()
|
||||
const prevCountRef = useRef<number>(0)
|
||||
|
||||
const queryData = useQuery({
|
||||
queryKey: ['embed-jobs'],
|
||||
|
|
@ -15,6 +17,15 @@ const useEmbedJobs = (props: { enabled?: boolean } = {}) => {
|
|||
enabled: props.enabled ?? true,
|
||||
})
|
||||
|
||||
// When jobs drain to zero, refresh stored files so they appear without reopening the modal
|
||||
useEffect(() => {
|
||||
const currentCount = queryData.data?.length ?? 0
|
||||
if (prevCountRef.current > 0 && currentCount === 0) {
|
||||
queryClient.invalidateQueries({ queryKey: ['storedFiles'] })
|
||||
}
|
||||
prevCountRef.current = currentCount
|
||||
}, [queryData.data, queryClient])
|
||||
|
||||
const invalidate = () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['embed-jobs'] })
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user