mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
0c38124799
CopilotPopup built its `chatView` override inside a `useMemo` keyed on `width`/`height`. Consumers driving those props from a drag-to-resize handle (committing new dimensions on mouseup) minted a new component function per resize; rendering a new element type at that slot makes React unmount and remount the whole chat subtree. The remount resets scrollTop to 0, then `initial="smooth"` re-animates the message list top-to-bottom on every resize, from any scroll position. Give the override a stable module-scope identity and pass the popup shell props (header, toggle, width, height, clickOutsideToClose, defaultOpen) through React context. Resizing is now a plain style update on CopilotPopupView with no remount, so scroll position holds. Add a regression test asserting the chat subtree stays mounted (mount count stays at 1) across width/height changes: it fails on the prior code (one extra mount per resize) and passes with the fix.