From 29586ce3848b556b3ae481197f64b4c16fa425de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Sat, 30 May 2026 22:26:56 +0800 Subject: [PATCH] fix: stabilize empty agentTaskNotifications to prevent scroll re-renders The "?? {}" fallback allocated a fresh object every render, defeating the React.memo barriers on ToolCallGroup and MessageBlock for sessions without agent task notifications, so every visible tool-call card re-rendered on each scroll frame. Reuse a module-level empty constant, mirroring EMPTY_MESSAGES. Co-Authored-By: Claude Opus 4.8 (1M context) --- desktop/src/components/chat/MessageList.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desktop/src/components/chat/MessageList.tsx b/desktop/src/components/chat/MessageList.tsx index e18c915d..91901d79 100644 --- a/desktop/src/components/chat/MessageList.tsx +++ b/desktop/src/components/chat/MessageList.tsx @@ -799,6 +799,7 @@ const VIRTUAL_MAX_ITEM_HEIGHT = 24_000 // convert those into bottom-scroll corrections. const CONTENT_RESIZE_FOLLOW_MIN_DELTA_PX = 2 const EMPTY_MESSAGES: UIMessage[] = [] +const EMPTY_AGENT_TASK_NOTIFICATIONS: Record = {} const CHAT_SCROLL_AREA_CLASS = [ 'chat-scroll-area', '[scrollbar-width:auto]', @@ -1222,7 +1223,7 @@ export function MessageList({ sessionId, compact = false }: MessageListProps = { const chatState = sessionState?.chatState ?? 'idle' const streamingText = sessionState?.streamingText ?? '' const activeThinkingId = sessionState?.activeThinkingId ?? null - const agentTaskNotifications = sessionState?.agentTaskNotifications ?? {} + const agentTaskNotifications = sessionState?.agentTaskNotifications ?? EMPTY_AGENT_TASK_NOTIFICATIONS const activeAskUserQuestionToolUseId = sessionState?.pendingPermission?.toolName === 'AskUserQuestion' ? sessionState.pendingPermission.toolUseId