agentAnimationCache.ts1.1 KBView on GitHub
/**
 * Agent Animation Cache Utilities
 *
 * Tracks which animations have already played to prevent re-animation on scroll/remount.
 * Caches are cleared when agent canvas opens (fresh start) or closes (free memory).
 */

// Track which state icons have already animated their entrance
const animatedStateIcons = new Set<string>();

// Track which messages have already been animated (typewriter effect)
const animatedMessages = new Set<string>();

/**
 * Clear the animated state icons cache.
 * Called when agent canvas opens or closes.
 */
export function clearAnimatedStateIconsCache() {
  animatedStateIcons.clear();
}

/**
 * Clear the animated messages cache.
 * Called when agent canvas opens or closes.
 */
export function clearAnimatedMessagesCache() {
  animatedMessages.clear();
}

/**
 * Check if a message has already been animated.
 */
export function hasAnimatedMessage(key=[redacted] boolean {
  return animatedMessages.has(key);
}

/**
 * Mark a message as animated.
 */
export function markMessageAnimated(key=[redacted] void {
  animatedMessages.add(key);
}