Skip to content

fix: duplicate/interleaved terminal text while typing on macOS#1

Merged
ohernandezdev merged 2 commits into
mainfrom
fix/macos-duplicate-typing
Jul 13, 2026
Merged

fix: duplicate/interleaved terminal text while typing on macOS#1
ohernandezdev merged 2 commits into
mainfrom
fix/macos-duplicate-typing

Conversation

@ohernandezdev

Copy link
Copy Markdown
Owner

Summary

Three independent, stacking causes were producing duplicated/interleaved
lines while typing in the embedded terminal, macOS-only (never on Windows):

  • Orphaned PTY reader thread: spawn_pty's reader only checked its
    session gen when tearing down (to skip emitting 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 inline "writing suggestions" (Safari/WebKit 18+, macOS
    Sequoia): silently re-emitted 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 capturing the exact bulk re-send.
    Fixed via writingsuggestions="false" on xterm.js's hidden input
    textarea (autocorrect="off" also set — a different WebKit feature,
    not sufficient on its own).
  • WKWebView: dead-key cancellation duplicates the dead char and drops the next key xtermjs/xterm.js#5894: on dead-key keyboard layouts (Spanish
    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 once
    xterm.js fixes it natively.

Also bumps the app version to 0.8.2.

Test plan

  • cargo check / tauri build --debug and tauri build (release) both compile clean
  • Reproduced the bug pre-fix with a debug write_pty/pty-output log,
    confirmed the bulk-resend mechanism
  • Manual testing typing in plain zsh and inside Claude Code sessions,
    release build, no recurrence after the writing-suggestions fix
  • Extended real-world daily use to confirm no regression

🤖 Generated with Claude Code

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.
@ohernandezdev ohernandezdev merged commit 83de576 into main Jul 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants