feat(chat): add citation popover and chunk caching

Introduce ChatCitationFloat hover UI, session-scoped citation chunk cache,
and unified citation markdown handling for main chat and embed views.
This commit is contained in:
wizardchen
2026-06-16 00:49:25 +08:00
committed by lyingbug
parent ee1c3c732c
commit 05f39b859f
13 changed files with 909 additions and 482 deletions
+35
View File
@@ -0,0 +1,35 @@
export type CitationChunkCacheValue = { content: string; error?: string }
const chunkCache = new Map<string, CitationChunkCacheValue>()
export function makeCitationCacheKey(scope: string, chunkId: string): string {
return `${scope}::${chunkId}`
}
export function getCitationChunkCache(
scope: string,
chunkId: string,
): CitationChunkCacheValue | undefined {
return chunkCache.get(makeCitationCacheKey(scope, chunkId))
}
export function setCitationChunkCache(
scope: string,
chunkId: string,
value: CitationChunkCacheValue,
): void {
chunkCache.set(makeCitationCacheKey(scope, chunkId), value)
}
export function clearCitationChunkCache(scope?: string): void {
if (scope === undefined) {
chunkCache.clear()
return
}
const prefix = `${scope}::`
for (const key of chunkCache.keys()) {
if (key.startsWith(prefix)) {
chunkCache.delete(key)
}
}
}