feat(web): 文档查询意图补充风险过滤与 X 天前范围

- aiDocumentQueryIntent 新增风险等级过滤(无/高/中/低/有风险)与 N 天前日期范围解析
- aiDocumentQueryModel/aiConversationHtmlRenderer 渲染适配风险过滤标签
- useWorkbenchAiDocumentQueryFlow/aiWorkbenchConversationStore 会话流转适配命令意图
- 更新 ai-document-query-model/ai-conversation-html-renderer/assistant-session-draft-delete 测试
This commit is contained in:
caoxiaozhu
2026-06-24 22:59:05 +08:00
parent 3eb78d343a
commit e5b03c6601
8 changed files with 517 additions and 39 deletions

View File

@@ -5,6 +5,7 @@ import { fileURLToPath } from 'node:url'
import {
markAiWorkbenchConversationDraftDeleted,
markAiWorkbenchConversationDocumentDeleted,
loadAiWorkbenchConversationHistory,
saveAiWorkbenchConversation
} from '../src/utils/aiWorkbenchConversationStore.js'
@@ -120,6 +121,54 @@ test('deleting an application draft marks AI workbench detail links as unavailab
assert.equal(loadAiWorkbenchConversationHistory(user)[0].messages.length, 2)
})
test('deleted document detail links are disabled for reopened AI conversations', () => {
installWindowStub()
const user = { username: 'zhangsan@example.com' }
saveAiWorkbenchConversation(user, {
id: 'conversation-document-delete-candidate',
title: '删除申请单草稿',
messages: [
{
id: 'assistant-document-candidates',
role: 'assistant',
content: [
'### 已查询到相关单据',
'',
'[进入详情确认删除](#ai-open-document-detail:claim_id%3Dclaim-draft-2%26claim_no%3DAP-DRAFT-002)'
].join('\n')
}
]
})
const nextHistory = markAiWorkbenchConversationDocumentDeleted(user, {
claimId: 'claim-draft-2',
claimNo: 'AP-DRAFT-002'
})
const conversation = nextHistory.find((item) => item.id === 'conversation-document-delete-candidate')
assert.ok(conversation)
assert.match(conversation.messages[0].content, /#ai-deleted-document-detail:/)
assert.doesNotMatch(conversation.messages[0].content, /#ai-open-document-detail:/)
assert.match(conversation.messages[0].content, /\[单据已删除\]/)
assert.match(conversation.messages.at(-1).content, /单据 AP-DRAFT-002 已经删除或不可访问/)
assert.match(conversation.messages.at(-1).content, /该历史入口已失效,请返回单据列表重新查询/)
assert.equal(loadAiWorkbenchConversationHistory(user)[0].messages.length, 2)
})
test('AI workbench validates document detail links before opening stale history entries', () => {
const aiMode = readFileSync(
fileURLToPath(new URL('../src/composables/workbenchAiMode/usePersonalWorkbenchAiMode.js', import.meta.url)),
'utf8'
)
assert.match(aiMode, /fetchExpenseClaimDetail/)
assert.match(aiMode, /markAiWorkbenchConversationDocumentDeleted/)
assert.match(aiMode, /async function handleAiAnswerMarkdownClick/)
assert.match(aiMode, /await ensureAiDocumentDetailStillAvailable/)
assert.match(aiMode, /已将这条历史入口标记为不可查看/)
})
test('saving a draft keeps the financial assistant open for continued work', () => {
const appShellScript = readFileSync(
fileURLToPath(new URL('../src/composables/useAppShell.js', import.meta.url)),