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:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user