fix: duplicate/interleaved terminal text while typing on macOS#1
Merged
Conversation
Three independent causes were stacking to produce duplicated lines while typing in the embedded terminal, macOS-only: - spawn_pty's reader thread only checked its session `gen` when tearing down (to skip pty-exit for a superseded session), not on every `pty-output` emit. A webview reload reusing a session id left the orphaned reader still emitting into whatever tab now owns that id. Now every emit checks `gen` and the orphan stops as soon as it's superseded. - WKWebView's inline "writing suggestions" (Safari/WebKit 18+, macOS Sequoia) were silently re-emitting the whole line typed so far as a single onData chunk mid-typing, which the shell echoed back as a duplicate. Confirmed with a debug write_pty log showing the exact bulk re-send. Fixed via `writingsuggestions="false"` on xterm.js's hidden input textarea (`autocorrect="off"` also set as related hardening — a different WebKit feature, not sufficient on its own). - xtermjs/xterm.js#5894: on dead-key keyboard layouts (Spanish included), WKWebView duplicates the dead-key char and drops the following key. Upstream issue, no native fix yet — ported the reporter's addon-based workaround (src/xtermDeadKeyAddon.ts). Also bumps the app version to 0.8.2.
CI runs cargo check --locked, which refuses to touch the lock file — the afkode package entry was still pinned at 0.8.1 after reverting an unrelated notify-rust downgrade I'd made locally to work around an outdated rustc, causing both the macOS and Windows check jobs to fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three independent, stacking causes were producing duplicated/interleaved
lines while typing in the embedded terminal, macOS-only (never on Windows):
spawn_pty's reader only checked itssession
genwhen tearing down (to skip emittingpty-exitfor asuperseded session), not on every
pty-outputemit. A webview reloadreusing a session id left the orphaned reader still emitting into
whatever tab now owns that id — now every emit checks
genand theorphan stops as soon as it's superseded.
Sequoia): silently re-emitted the whole line typed so far as a single
onDatachunk mid-typing, which the shell echoed back as a duplicate.Confirmed with a debug
write_ptylog capturing the exact bulk re-send.Fixed via
writingsuggestions="false"on xterm.js's hidden inputtextarea (
autocorrect="off"also set — a different WebKit feature,not sufficient on its own).
included), WKWebView duplicates the dead-key char and drops the
following key. No native upstream fix yet — ported the reporter's
addon-based workaround (
src/xtermDeadKeyAddon.ts), removable oncexterm.js fixes it natively.
Also bumps the app version to 0.8.2.
Test plan
cargo check/tauri build --debugandtauri build(release) both compile cleanwrite_pty/pty-outputlog,confirmed the bulk-resend mechanism
release build, no recurrence after the writing-suggestions fix
🤖 Generated with Claude Code