Skip to content

[Bugfix #253] Fix mobile terminal input duplication from IME composition - #256

Merged
waleedkadous merged 2 commits into
mainfrom
builder/bugfix-253-mobile-typed-text-gets-duplica
Feb 14, 2026
Merged

waleedkadous merged 2 commits into
mainfrom
builder/bugfix-253-mobile-typed-text-gets-duplica

Conversation

@waleedkadous

Copy link
Copy Markdown
Contributor

Summary

Fixes #253

Root Cause

On mobile browsers, all keyboard input goes through IME composition. Some browsers fire both input and compositionend events, causing xterm.js to emit onData twice for the same keystroke. The onData handler in Terminal.tsx sent every call directly to the PTY via WebSocket, so the character was written to the shell twice and echoed back twice — appearing as duplicated text.

Fix

Track composition state by listening to compositionstart and compositionend events on xterm's hidden textarea element. During active IME composition (and for 100ms after compositionend), exact duplicate onData calls are suppressed. This only activates during composition, so desktop key repeat is unaffected.

Changes: packages/codev/dashboard/src/components/Terminal.tsx (+40 lines)

Test Plan

  • Added regression test (Terminal.ime-dedup.test.tsx, 5 tests)
  • Verified dedup works during IME composition
  • Verified different characters pass through during composition
  • Verified no dedup without composition (desktop key repeat safe)
  • Verified dedup window resets after 100ms timeout
  • All existing Terminal tests pass (23/23)
  • Build passes

Note: 4 pre-existing test failures exist on main (StatusPanel, init timeout, pty-session resume) — unrelated to this change.

On mobile browsers, all keyboard input goes through IME composition.
Some browsers fire both input and compositionend events, causing
xterm.js to emit onData twice for the same keystroke, resulting in
duplicated text. Track composition state via xterm's textarea and
skip exact duplicate onData calls during active composition.
Tests verify that duplicate onData calls during IME composition are
suppressed, different characters pass through, dedup is inactive
without composition, and the dedup window resets after timeout.
@waleedkadous

Copy link
Copy Markdown
Contributor Author

CI Status Note

All CI failures are pre-existing (also fail on main):

Unit Tests (4 failures):

  • StatusPanel.test.tsx (2) — UI text mismatch
  • init.test.ts — timeout
  • pty-session.test.ts — resume assertion

Tower Integration Tests (3 failures):

  • bugfix-202-stale-temp-projects.e2e.test.ts — polling timeout
  • tower-api.e2e.test.ts — SQLite activate polling timeout
  • tower-baseline.e2e.test.ts — tower proxy instances empty

None relate to Terminal/IME changes. Dashboard terminal tests all pass (23/23).

@waleedkadous
waleedkadous merged commit f87a45e into main Feb 14, 2026
5 of 7 checks passed
@waleedkadous
waleedkadous deleted the builder/bugfix-253-mobile-typed-text-gets-duplica branch February 14, 2026 14:20
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: typed text gets duplicated/echoed in terminal input

1 participant