From 0f836f173cfd1e0259c418bbe8d4b56af02634d7 Mon Sep 17 00:00:00 2001 From: BrianX Date: Thu, 16 Apr 2026 17:35:07 +0800 Subject: [PATCH] fix: revert broken IME input handling code Reverts the IME-related changes from v0.0.27-v0.0.29 that broke Chinese input in terminal TUI apps. The removed code (isComposing checks, composition event listeners) conflicted with xterm.js's built-in IME support, causing Chinese input to fail in TUI applications like Claude Code. xterm.js already handles IME input correctly out of the box - no additional handling is needed. Co-Authored-By: Claude Opus 4.5 --- ServerDeck/src/App.tsx | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/ServerDeck/src/App.tsx b/ServerDeck/src/App.tsx index aa9c02f..887ef16 100644 --- a/ServerDeck/src/App.tsx +++ b/ServerDeck/src/App.tsx @@ -297,15 +297,6 @@ function isTerminalViewportNearBottom(terminal: Terminal) { return activeBuffer.baseY - activeBuffer.viewportY <= 1; } -function clearDocumentSelection() { - const selection = window.getSelection(); - if (!selection || selection.rangeCount === 0) { - return; - } - - selection.removeAllRanges(); -} - const MAX_TERMINAL_BUFFER_CHUNKS = 800; const MAX_TERMINAL_BUFFER_CHARS = 400_000; @@ -2079,16 +2070,8 @@ export default function App() { terminal.open(terminalMountNode); const clearSelectionFrame = window.requestAnimationFrame(() => { terminal.clearSelection(); - clearDocumentSelection(); - terminal.focus(); }); - let isTerminalComposing = false; - terminal.attachCustomKeyEventHandler((event) => { - if (event.isComposing || event.keyCode === 229) { - return true; - } - const sequence = getTerminalControlSequence(event); if (!sequence) { return true; @@ -2112,26 +2095,8 @@ export default function App() { }); } - const terminalTextarea = terminal.textarea; - const handleCompositionStart = () => { - isTerminalComposing = true; - }; - const handleCompositionEnd = () => { - isTerminalComposing = false; - }; - terminalTextarea?.addEventListener("compositionstart", handleCompositionStart); - terminalTextarea?.addEventListener("compositionend", handleCompositionEnd); - const disposable = terminal.onData((data) => { sendActiveTerminalInput(data); - - if (data === "\r" && !isTerminalComposing) { - window.requestAnimationFrame(() => { - terminal.focus(); - terminal.clearSelection(); - clearDocumentSelection(); - }); - } }); let frameId: number | null = null; @@ -2166,8 +2131,6 @@ export default function App() { } window.cancelAnimationFrame(clearSelectionFrame); disposable.dispose(); - terminalTextarea?.removeEventListener("compositionstart", handleCompositionStart); - terminalTextarea?.removeEventListener("compositionend", handleCompositionEnd); terminal.dispose(); terminalRef.current = null; fitAddonRef.current = null;