From 2f378cb7c3fb523ced372c2bc68938d0fd0c01de Mon Sep 17 00:00:00 2001 From: Taylor Ho Date: Thu, 21 May 2026 00:18:34 -0700 Subject: [PATCH] fix: debounce item list (300ms) so name + membership changes batch into one animation --- .../features/channels/ui/QuickAddAgentPopover.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/desktop/src/features/channels/ui/QuickAddAgentPopover.tsx b/desktop/src/features/channels/ui/QuickAddAgentPopover.tsx index 882dd759be..8c06139c41 100644 --- a/desktop/src/features/channels/ui/QuickAddAgentPopover.tsx +++ b/desktop/src/features/channels/ui/QuickAddAgentPopover.tsx @@ -225,6 +225,13 @@ export function QuickAddAgentPopover({ return result; }, [managedAgents, personas, channelMemberPubkeys, recentIds]); + // Debounce item list so rapid query invalidations (name + membership) batch + const [debouncedItems, setDebouncedItems] = React.useState(items); + React.useEffect(() => { + const timer = setTimeout(() => setDebouncedItems(items), 300); + return () => clearTimeout(timer); + }, [items]); + // Reset state when popover closes React.useEffect(() => { @@ -607,7 +614,7 @@ export function QuickAddAgentPopover({
- ) : items.length === 0 ? ( + ) : debouncedItems.length === 0 ? (
No agents available.
@@ -617,7 +624,7 @@ export function QuickAddAgentPopover({ className="py-1" role="listbox" > - {items.map((item) => { + {debouncedItems.map((item) => { const itemKey = getItemKey(item); const isInChannel = item.kind === "running-in-channel"; const isItemPending = @@ -625,7 +632,7 @@ export function QuickAddAgentPopover({ const isSelected = selectedKeys.has(itemKey); return ( - +