diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index 4fa921f443..4e22273268 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -68,6 +68,7 @@ interface ChatRowContentProps extends Omit {} const ChatRow = memo( (props: ChatRowProps) => { const { isLast, onHeightChange, message } = props + // Store the previous height to compare with the current height // This allows us to detect changes without causing re-renders const prevHeightRef = useRef(0) diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 44eeb33b66..d4670d7aa2 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -160,7 +160,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction combineApiRequests(combineCommandSequences(messages.slice(1))), [messages]) + const modifiedMessages = useMemo(() => { + return combineApiRequests(combineCommandSequences(messages.slice(1))) + }, [messages]) // Has to be after api_req_finished are all reduced into api_req_started messages. const apiMetrics = useMemo(() => getApiMetrics(modifiedMessages), [modifiedMessages]) @@ -1521,6 +1523,10 @@ const ChatViewComponent: React.ForwardRefRenderFunction modifiedMessages.at(-1), [modifiedMessages]) + + // Properly memoized itemContent callback with stable dependencies const itemContent = useCallback( (index: number, messageOrGroup: ClineMessage | ClineMessage[]) => { // browser session group @@ -1529,7 +1535,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction expandedRows[messageTs] ?? false} @@ -1549,12 +1555,12 @@ const ChatViewComponent: React.ForwardRefRenderFunction