Skip to content

[Bugfix #517] Fix mobile duplicate letters and extra periods - #520

Merged
waleedkadous merged 2 commits into
mainfrom
builder/bugfix-517-mobile-duplicate-letters-and-e
Feb 22, 2026
Merged

waleedkadous merged 2 commits into
mainfrom
builder/bugfix-517-mobile-duplicate-letters-and-e

Conversation

@waleedkadous

Copy link
Copy Markdown
Contributor

Summary

Fixes #517

Root Cause

The previous mobile input deduplication used a User Agent regex (/Android|iPhone|iPad|iPod/i) to detect mobile devices. This had two problems:

  1. iPads not detected: iPadOS 13+ sends a desktop User Agent (Macintosh; Intel Mac OS X), so the regex never matched. The dedup was never activated on iPads.
  2. No composition awareness: The dedup was always-on for matched devices but off for everything else, with no knowledge of when IME composition was actually happening.

Fix

Replaced the UA-based approach with two complementary dedup triggers:

  1. Composition event tracking — Listens for compositionstart/compositionend on xterm's textarea. Deduplicates during and within 150ms after IME composition. Works on ALL platforms (catches mobile + desktop CJK input).
  2. pointer:coarse media query — Always-on dedup for touch/soft-keyboard devices. Catches delayed duplicates that arrive outside the composition window (e.g. near line wraps). Correctly detects iPads, Android tablets, and any touch device.

Key design choice: Using (pointer: coarse) instead of UA sniffing correctly identifies soft-keyboard devices without false-positives on touch-screen laptops (which report pointer: fine since mouse/trackpad is the primary pointer).

Test Plan

  • Added 4 new regression tests for touch device dedup (iPad scenario)
  • Updated 5 existing IME composition dedup tests
  • Verified desktop key repeat is not affected (no composition → no dedup)
  • All 31 terminal-related tests pass (9 IME dedup + 8 input filter + 14 virtual keyboard)
  • TypeScript compiles clean
  • CMAP review

CMAP Review

…cking + pointer:coarse

The previous mobile input deduplication used a User Agent regex to detect
mobile devices. This failed on iPads (iPadOS 13+ sends desktop UA) and
lacked composition awareness.

New approach uses two complementary triggers:
1. Composition event tracking on xterm's textarea — deduplicates during
   and shortly after IME composition (works on all platforms)
2. pointer:coarse media query — always-on dedup for touch devices,
   catching delayed duplicates outside the composition window

This correctly handles iPads, Android tablets, and any soft keyboard
device without affecting desktop key repeat.
- Restore original matchMedia in afterEach to prevent test isolation leak
- Add comment documenting iPad + external keyboard tradeoff
@waleedkadous
waleedkadous merged commit 6d3f816 into main Feb 22, 2026
6 checks passed
@waleedkadous
waleedkadous deleted the builder/bugfix-517-mobile-duplicate-letters-and-e branch February 22, 2026 19:34
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.

Mobile: duplicate letters and extra periods when typing

1 participant