mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-04-03 07:19:27 +02: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) {
|
if (fileUploaderRef.current) {
|
||||||
fileUploaderRef.current.clear()
|
fileUploaderRef.current.clear()
|
||||||
}
|
}
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['embed-jobs'] })
|
||||||
},
|
},
|
||||||
onError: (error: any) => {
|
onError: (error: any) => {
|
||||||
addNotification({
|
addNotification({
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
|
import { useEffect, useRef } from 'react'
|
||||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import api from '~/lib/api'
|
import api from '~/lib/api'
|
||||||
|
|
||||||
const useEmbedJobs = (props: { enabled?: boolean } = {}) => {
|
const useEmbedJobs = (props: { enabled?: boolean } = {}) => {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const prevCountRef = useRef<number>(0)
|
||||||
|
|
||||||
const queryData = useQuery({
|
const queryData = useQuery({
|
||||||
queryKey: ['embed-jobs'],
|
queryKey: ['embed-jobs'],
|
||||||
|
|
@ -15,6 +17,15 @@ const useEmbedJobs = (props: { enabled?: boolean } = {}) => {
|
||||||
enabled: props.enabled ?? true,
|
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 = () => {
|
const invalidate = () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['embed-jobs'] })
|
queryClient.invalidateQueries({ queryKey: ['embed-jobs'] })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user