fix: make local knowledge bases ready for daily use

Knowledge selection was shared globally, document readiness overstated usable content, and important import and source-management paths exposed technical details or lacked safe recovery actions. Knowledge scope now persists per conversation, readiness reflects real processing channels, and the workspace guides users from creation and import into cited chat with controlled source actions.

Release note: 知识库现按对话保存使用范围,准确区分可用、处理中和失败文档,并提供更简洁的创建、检索测试、来源打开、删除确认和失败重试流程。
This commit is contained in:
mesalogo
2026-09-05 15:51:07 +08:00
parent d5fa0ec67c
commit dd8289fdef
29 changed files with 1395 additions and 87 deletions
+18 -1
View File
@@ -846,6 +846,8 @@ export class KnowledgeDatabase {
sourceCount: number
documentCount: number
indexedDocumentCount: number
processingDocumentCount: number
failedDocumentCount: number
}
> {
const rows = this.requireDatabase()
@@ -855,8 +857,15 @@ export class KnowledgeDatabase {
COUNT(DISTINCT d.id) AS document_count,
COUNT(DISTINCT CASE
WHEN COALESCE(json_extract(d.metadata, '$.status'), 'ready')
<> 'failed'
= 'ready'
THEN d.id END) AS indexed_document_count
,COUNT(DISTINCT CASE
WHEN json_extract(d.metadata, '$.status')
IN ('queued', 'parsing', 'indexing')
THEN d.id END) AS processing_document_count
,COUNT(DISTINCT CASE
WHEN json_extract(d.metadata, '$.status') = 'failed'
THEN d.id END) AS failed_document_count
FROM knowledge_bases kb
LEFT JOIN knowledge_sources s ON s.knowledge_base_id = kb.id
LEFT JOIN documents d ON d.knowledge_base_id = kb.id
@@ -872,6 +881,14 @@ export class KnowledgeDatabase {
indexedDocumentCount: asNumber(
row,
'indexed_document_count'
),
processingDocumentCount: asNumber(
row,
'processing_document_count'
),
failedDocumentCount: asNumber(
row,
'failed_document_count'
)
}
])