mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
21 lines
623 B
TypeScript
21 lines
623 B
TypeScript
// Bound pane-keyed draft/image caches: TUI/chat toggles need retention, but removed panes are never revisited.
|
|
// Delete-then-set keeps edited scopes recent; evict only the oldest untouched drafts.
|
|
export const NATIVE_CHAT_COMPOSER_SCOPE_CACHE_MAX = 128
|
|
|
|
export function setBoundedScopeCacheEntry<T>(
|
|
cache: Map<string, T>,
|
|
scopeKey: string,
|
|
value: T,
|
|
max = NATIVE_CHAT_COMPOSER_SCOPE_CACHE_MAX
|
|
): void {
|
|
cache.delete(scopeKey)
|
|
cache.set(scopeKey, value)
|
|
while (cache.size > max) {
|
|
const oldest = cache.keys().next().value
|
|
if (oldest === undefined) {
|
|
break
|
|
}
|
|
cache.delete(oldest)
|
|
}
|
|
}
|