feat: 优化问问微信检索性能与分析交互

- 补充 Worker、WCDB、sender、IPC、序列化时间账
- 增加 Agent 增量覆盖统计和重复检索停止条件
- 补充性能与交互回归测试
This commit is contained in:
Wxw-Gu
2026-08-07 15:28:45 +08:00
parent 43654bf0e2
commit 0b845db2e0
20 changed files with 1304 additions and 184 deletions
+33 -3
View File
@@ -44,9 +44,9 @@ describe('AI Search provider identity', () => {
requiresConsent: true,
recipient: 'https://first.example.test/v1'
})
expect(service.save({ ...provider('https://remote.example.test'), type: 'ollama' }).success).toBe(
true
)
expect(
service.save({ ...provider('https://remote.example.test'), type: 'ollama' }).success
).toBe(true)
expect(service.getAiSearchProviderStatus()).toMatchObject({ requiresConsent: true })
expect(service.save(provider('http://localhost:11434/')).success).toBe(true)
expect(service.getAiSearchProviderStatus()).toMatchObject({
@@ -97,4 +97,34 @@ describe('AI Search provider identity', () => {
expect(JSON.stringify(request)).not.toContain('messageId')
vi.unstubAllGlobals()
})
it('aborts the provider fetch when the caller cancels an AI request', async () => {
const service = new AIProviderService()
service.save(provider('http://127.0.0.1:11434'))
let fetchSignal: AbortSignal | undefined
const fetchMock = vi.fn(
(_url: string, init?: RequestInit) =>
new Promise<Response>((_resolve, reject) => {
fetchSignal = init?.signal || undefined
fetchSignal?.addEventListener('abort', () => reject(fetchSignal?.reason), { once: true })
})
)
vi.stubGlobal('fetch', fetchMock)
const controller = new AbortController()
try {
const result = service.chat(
[{ role: 'user', content: 'cancel this request' }],
undefined,
controller.signal
)
await vi.waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(1))
controller.abort(new DOMException('cancelled by test', 'AbortError'))
await expect(result).rejects.toMatchObject({ name: 'AbortError' })
expect(fetchSignal?.aborted).toBe(true)
} finally {
vi.unstubAllGlobals()
}
})
})