Commit acd51c5
fix(webview): resolve memory leak in ChatView by stabilizing callback props (#3926)
* fix(webview): resolve memory leak in ChatView by stabilizing callback props
- Stabilize handleSendMessage using clineAskRef to prevent frequent re-creation
- Stabilize toggleRowExpansion by extracting handleSetExpandedRow and managing dependencies
- Re-integrate scrolling logic into useEffect hook to avoid destabilizing callbacks
- Add everVisibleMessagesTsRef to reduce unnecessary ChatRow remounts by Virtuoso
- Update onToggleExpand signature to accept timestamp parameter for better stability
- Remove diagnostic console.log statements used for debugging callback changes
These changes address detached DOM elements memory leak caused by frequent
callback re-creation triggering unnecessary component re-renders and preventing
proper garbage collection of chat message DOM nodes.
* comment correct TTL
---------
Co-authored-by: Daniel <[email protected]>1 parent dde71d2 commit acd51c5
File tree
4 files changed
+151
-106
lines changed- webview-ui
- src/components/chat
4 files changed
+151
-106
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
73 | | - | |
74 | 74 | | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
106 | 111 | | |
107 | 112 | | |
108 | 113 | | |
| |||
302 | 307 | | |
303 | 308 | | |
304 | 309 | | |
305 | | - | |
| 310 | + | |
306 | 311 | | |
307 | 312 | | |
308 | 313 | | |
| |||
328 | 333 | | |
329 | 334 | | |
330 | 335 | | |
331 | | - | |
| 336 | + | |
332 | 337 | | |
333 | 338 | | |
334 | 339 | | |
| |||
350 | 355 | | |
351 | 356 | | |
352 | 357 | | |
353 | | - | |
| 358 | + | |
354 | 359 | | |
355 | 360 | | |
356 | 361 | | |
| |||
389 | 394 | | |
390 | 395 | | |
391 | 396 | | |
392 | | - | |
| 397 | + | |
393 | 398 | | |
394 | 399 | | |
395 | 400 | | |
| |||
435 | 440 | | |
436 | 441 | | |
437 | 442 | | |
438 | | - | |
| 443 | + | |
439 | 444 | | |
440 | 445 | | |
441 | 446 | | |
| |||
455 | 460 | | |
456 | 461 | | |
457 | 462 | | |
458 | | - | |
| 463 | + | |
459 | 464 | | |
460 | 465 | | |
461 | 466 | | |
| |||
475 | 480 | | |
476 | 481 | | |
477 | 482 | | |
478 | | - | |
| 483 | + | |
479 | 484 | | |
480 | 485 | | |
481 | 486 | | |
| |||
495 | 500 | | |
496 | 501 | | |
497 | 502 | | |
498 | | - | |
| 503 | + | |
499 | 504 | | |
500 | 505 | | |
501 | 506 | | |
| |||
525 | 530 | | |
526 | 531 | | |
527 | 532 | | |
528 | | - | |
| 533 | + | |
529 | 534 | | |
530 | 535 | | |
531 | 536 | | |
| |||
813 | 818 | | |
814 | 819 | | |
815 | 820 | | |
816 | | - | |
| 821 | + | |
817 | 822 | | |
818 | 823 | | |
819 | 824 | | |
| |||
852 | 857 | | |
853 | 858 | | |
854 | 859 | | |
855 | | - | |
| 860 | + | |
856 | 861 | | |
857 | 862 | | |
858 | 863 | | |
| |||
898 | 903 | | |
899 | 904 | | |
900 | 905 | | |
901 | | - | |
| 906 | + | |
902 | 907 | | |
903 | 908 | | |
904 | 909 | | |
| |||
945 | 950 | | |
946 | 951 | | |
947 | 952 | | |
948 | | - | |
| 953 | + | |
949 | 954 | | |
950 | 955 | | |
951 | 956 | | |
| |||
1105 | 1110 | | |
1106 | 1111 | | |
1107 | 1112 | | |
1108 | | - | |
| 1113 | + | |
1109 | 1114 | | |
1110 | 1115 | | |
1111 | 1116 | | |
| |||
0 commit comments