fix(sync,rag): keep restored rows, reconcile after tombstone pruning, reject partial knowledge docs, surface RAG indexing failures

This commit is contained in:
Yun Chan 2026-09-28 02:16:14 +09:00
parent bbaf1e0a99
commit 3a46437f28
13 changed files with 1630 additions and 448 deletions

View file

@ -11,6 +11,7 @@ import { isImeComposingEvent } from '../utils/keyboard'
import { d3roPalette, d3roFontSans, d3roTypo, d3roRadius, d3roShadow } from '@d3ro/ui/theme'
import { useI18n } from '@d3ro/i18n'
import type { RAGDocument, RAGQueryResult, RAGIndexProgress } from '@d3ro/core/types'
import { ErrorCode } from '@d3ro/core/errors'
type KnowledgeView = 'kb' | 'insights'
@ -46,15 +47,21 @@ export function KnowledgeBasePage(): React.ReactElement {
loadDocuments()
}
})
const unsubComplete = window.electronAPI.rag.onIndexComplete(() => {
// 색인 실행이 끝나면(성공·실패 무관) 진행 표시를 내리고, 문서가 끝내 색인되지 않았으면 알린다.
const unsubComplete = window.electronAPI.rag.onIndexComplete((data) => {
setIndexProgress(null)
loadDocuments()
void window.electronAPI.rag.getDocuments().then((resp) => {
if (!resp.success) return
setDocuments(resp.data)
const doc = resp.data.find((d) => d.id === data.documentId)
if (doc && !doc.indexed) setAddError(t('mobile.knowledge.error.indexUnavailable'))
})
})
return () => {
unsubProgress()
unsubComplete()
}
}, [loadDocuments])
}, [loadDocuments, t])
const isAddingRef = useRef(false)
@ -87,7 +94,10 @@ export function KnowledgeBasePage(): React.ReactElement {
)
const handleReindex = useCallback(async (docId: string) => {
await window.electronAPI.rag.reindex(docId)
setAddError(null)
const resp = await window.electronAPI.rag.reindex(docId)
// 임베딩 실패는 rag:indexComplete 뒤 문서 상태로 알린다. 그 밖의 실패(문서 없음·파싱 실패)만 여기서 보인다.
if (!resp.success && resp.error.code !== ErrorCode.RAGEmbeddingFailed) setAddError(resp.error.message)
}, [])
const handleQuery = useCallback(async () => {