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:
Henry Estela 2026-03-20 13:53:08 -07:00
parent c45236912e
commit 2350b79bb5
No known key found for this signature in database
GPG Key ID: 90439853E9E235BA
2 changed files with 12 additions and 0 deletions

View File

@ -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({

View File

@ -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'] })
} }