ChatGPTNextWeb / ChatGPTNextWeb/NextChat

关于messages重复渲染的问题

Open
#5,837 5 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
88.8k
Forks
59.1k
PR merge metrics
No merged PRs in 30d

Description

### 🥰 需求描述

I have verified this project, and when there are many conversations and chats, the browser will get stuck and the memory will skyrocket. After checking the general reasons, I found that it is because all Message-items on the page will be rendered repeatedly when returning from each Q&A. I added console.log() to message.map, and found that message-item would be repeatedly rendered about 10 times when entering the page for the first time. When text stream was output, message-item would be repeatedly rendered and the number of rendering times was the length of text stream.
![image](https://github.com/user-attachments/assets/7962f21d-82db-4c14-982e-2ed0dd8b04fb)
![image](https://github.com/user-attachments/assets/baabde9b-940f-4dc2-b6e8-dc7c021a95cb)

When there are 20-40 chats in a session or when the length of each text stream is much longer, the whole system freezes.

### 🧐 解决方案

Do not over-render, update only the corresponding message-item each time the text stream returns, and do not render the other message-items repeatedly

### 📝 补充信息

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.