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:
@@ -74,6 +74,7 @@ import {
|
||||
knowledgeChunkPageSchema,
|
||||
knowledgeChunksListInputSchema,
|
||||
knowledgeChunkUpdateInputSchema,
|
||||
knowledgeDocumentOpenInputSchema,
|
||||
knowledgeDocumentRebuildInputSchema,
|
||||
knowledgeLibraryRebuildInputSchema,
|
||||
knowledgeReferenceContextInputSchema,
|
||||
@@ -892,6 +893,8 @@ function getKnowledgeSnapshot(
|
||||
sourceCount: library.sourceCount,
|
||||
documentCount: library.documentCount,
|
||||
indexedDocumentCount: library.indexedDocumentCount,
|
||||
processingDocumentCount: library.processingDocumentCount,
|
||||
failedDocumentCount: library.failedDocumentCount,
|
||||
retrievalSettings: library.retrievalSettings,
|
||||
chunkingSettings: library.chunkingSettings,
|
||||
chunkingRebuildRequired: library.chunkingRebuildRequired,
|
||||
@@ -926,6 +929,9 @@ function getKnowledgeSnapshot(
|
||||
name: document.title,
|
||||
path: document.sourceLocation,
|
||||
status: document.status,
|
||||
textIndexStatus: document.textIndexStatus,
|
||||
vectorIndexStatus: document.vectorIndexStatus,
|
||||
graphIndexStatus: document.graphIndexStatus,
|
||||
indexProgress: document.status === 'ready' ? 100 : 0,
|
||||
chunkCount: document.chunkCount,
|
||||
size: document.size,
|
||||
@@ -7969,6 +7975,42 @@ export function registerIpcHandlers(
|
||||
}
|
||||
)
|
||||
|
||||
registerHandler(
|
||||
ipcChannels.knowledgeOpenDocumentSource,
|
||||
async (event, input: unknown) => {
|
||||
assertTrustedSender(event, window)
|
||||
const value = knowledgeDocumentOpenInputSchema.parse(input)
|
||||
const reference = knowledgeService.getDocumentSource(value)
|
||||
if (!reference) {
|
||||
throw new Error('文档来源不存在')
|
||||
}
|
||||
if (reference.source.type === 'url') {
|
||||
const target = new URL(reference.source.location)
|
||||
if (!['http:', 'https:'].includes(target.protocol)) {
|
||||
throw new Error('文档来源 URL 协议不受支持')
|
||||
}
|
||||
await shell.openExternal(target.href)
|
||||
return
|
||||
}
|
||||
const storedPath =
|
||||
reference.document.sourceLocation ?? reference.source.location
|
||||
if (!isAbsolute(storedPath)) {
|
||||
throw new Error('文档来源路径无效')
|
||||
}
|
||||
if ((await lstat(storedPath)).isSymbolicLink()) {
|
||||
throw new Error('文档来源不能是符号链接')
|
||||
}
|
||||
const targetPath = await realpath(storedPath)
|
||||
if (!(await stat(targetPath)).isFile()) {
|
||||
throw new Error('文档来源不是可打开的文件')
|
||||
}
|
||||
const openError = await shell.openPath(targetPath)
|
||||
if (openError) {
|
||||
throw new Error('无法打开文档来源')
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
registerHandler(
|
||||
ipcChannels.knowledgeReferenceContext,
|
||||
(event, input: unknown) => {
|
||||
|
||||
Reference in New Issue
Block a user