Creating a new terminal tab caused every pty data chunk (including keystroke echo) to render twice in xterm. The connect-effect's `contextChanged` dep flips true→false in the same render cycle as the new connection: the effect re-runs, React calls cleanup which closed the still-CONNECTING WS without nulling its handlers, then connect() opens a fresh WS. The ghost socket's onmessage continued firing on the shared `onDataCallbacksRef` Set, delivering each chunk twice (and producing the "WebSocket is closed before the connection is established" warning). Null onopen/onmessage/onclose/onerror in both cleanup() and connect()'s pre-close branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
17 KiB
17 KiB