Skip to content

Commit a138f55

Browse files
committed
fix(ui): clear prompt history cache by folder
1 parent 08128af commit a138f55

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

packages/ui/src/stores/instances.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ function removeInstance(id: string) {
581581
clearCacheForInstance(id)
582582
messageStoreBus.unregisterInstance(id)
583583
clearInstanceDraftPrompts(id)
584-
clearHistoryCache(id)
584+
clearHistoryCache(id, instance?.folder)
585585
syncHasInstancesFlag()
586586
}
587587

packages/ui/src/stores/message-history.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ const MAX_HISTORY = 100
99
const historyCache = new Map<string, string[]>()
1010
const historyLoadCache = new Map<string, Promise<string[]>>()
1111

12-
export function clearHistoryCache(instanceId: string): void {
13-
historyCache.delete(instanceId)
14-
historyLoadCache.delete(instanceId)
12+
export function clearHistoryCache(...keys: Array<string | null | undefined>): void {
13+
for (const key of keys) {
14+
if (!key) continue
15+
historyCache.delete(key)
16+
historyLoadCache.delete(key)
17+
}
1518
}
1619

1720
export async function addToHistory(instanceId: string, text: string): Promise<void> {

0 commit comments

Comments
 (0)