From b5993d4f43079ab80982fde2aeaea71f556af1b5 Mon Sep 17 00:00:00 2001 From: iven Date: Sun, 5 Apr 2026 22:02:55 +0800 Subject: [PATCH] fix(desktop): sidebar tab animation + memory deduplication 1. Fix sidebar tab switching: replace containerVariants (staggerChildren without motion children) with simple fade variants. The previous staggerChildren:0.05 caused the container to stay at opacity:0 when switching to CloneManager because non-motion children couldn't participate in stagger animation. 2. Fix memory deduplication: add content+agentId based dedup check in fallbackMemory.store(). Previously same content was stored 4x with different IDs. Now updates importance/accessCount instead. --- desktop/src/components/Sidebar.tsx | 11 ++++++++-- .../intelligence-client/fallback-memory.ts | 21 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/desktop/src/components/Sidebar.tsx b/desktop/src/components/Sidebar.tsx index 9596641..2baa0f2 100644 --- a/desktop/src/components/Sidebar.tsx +++ b/desktop/src/components/Sidebar.tsx @@ -6,7 +6,14 @@ import { import { ConversationList } from './ConversationList'; import { CloneManager } from './CloneManager'; import { useChatStore } from '../store/chatStore'; -import { containerVariants, defaultTransition } from '../lib/animations'; +import { defaultTransition } from '../lib/animations'; + +// Simple fade variants for sidebar tab content (no staggerChildren) +const sidebarTabVariants = { + hidden: { opacity: 0 }, + visible: { opacity: 1, transition: { duration: 0.15 } }, + exit: { opacity: 0, transition: { duration: 0.1 } }, +}; export type MainViewType = 'chat' | 'automation' | 'skills'; @@ -109,7 +116,7 @@ export function Sidebar({ { const store = getFallbackStore(); + + // Content-based deduplication: update existing entry with same agentId + content + const normalizedContent = entry.content.trim().toLowerCase(); + const existingIdx = store.memories.findIndex( + m => m.agentId === entry.agent_id && m.content.trim().toLowerCase() === normalizedContent + ); + + if (existingIdx >= 0) { + // Update existing entry instead of creating duplicate + const existing = store.memories[existingIdx]; + store.memories[existingIdx] = { + ...existing, + importance: Math.max(existing.importance, entry.importance ?? 5), + lastAccessedAt: new Date().toISOString(), + accessCount: existing.accessCount + 1, + tags: [...new Set([...existing.tags, ...(entry.tags ?? [])])], + }; + saveFallbackStore(store); + return existing.id; + } + const id = `mem_${Date.now()}_${generateRandomString(6)}`; const now = new Date().toISOString();