Move the xterm.onData -> sendInput wiring (and the window resize listener) from a separate post-init effect into initTerminal itself, so they share the xterm instance's lifetime. Under StrictMode + Vite Fast Refresh the separate effect could re-run and attach a second listener to the same live xterm instance, producing per-character input doubling (every keystroke -> two pty.write calls -> shell echoes "aabbcc"). The handler now reads sendInput via a ref, so function-identity changes no longer require re-binding. Resize listener is removed at every xterm disposal site (tab switch, modal close, session-invalid replace, reinitialize). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
47 KiB
47 KiB