Repository navigation
fix(terminal): stop a Hangul-terminating digit being eaten as a candidate pick - #15429
Conversation
📝 WalkthroughWalkthroughThe change tracks whether the active IME preedit contains Hangul characters. Terminal keyboard handling passes this state to the bypass policy. Candidate-digit suppression and native default prevention use a shared Hangul-aware predicate. Tests cover Hangul terminating digits, Linux orphan-keyup handling, stale preedit state, composition resets, and Pinyin candidate selection. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…date pick A digit typed immediately after a Hangul syllable is dropped in the terminal on Wayland. Typing 아1 produces 아. The syllable composes and commits correctly; only the keystroke that ends it is lost. Reproduced on Ubuntu 24.04, GNOME Shell 46, ibus-hangul 1.5.5, in a nested Wayland session with real key injection. The pty receives 아 on Wayland and 아1 under X11 on the same machine with the same engine, and a GTK client in the same Wayland session receives 아1 - so the compositor, the input method and the digit are all behaving. The difference is where the digit is delivered. Under X11 ibus-hangul swallows it into the preedit and commits 아1 as composition text. Under Wayland it commits 아 and lets the digit through as an ordinary key - and the jamo before it arrive with no keydown at all, only keyups. That orphaned keyup is what breaks it. A plain letter keyup with no matching keydown arms a 1500ms window in which a bare digit is treated as a candidate selection, because a Pinyin engine indexes its candidate list by digit. The digit lands microseconds later, inside the window, and is suppressed. The window disarms after exactly one digit, which is why the syllable survives and only the terminating key vanishes. A Hangul engine has no numbered candidates over its preedit - a digit ends the syllable and is literal text - so the guard was spending its one suppression on a keystroke meant for the shell. The tracker now records whether the current preedit is Hangul and the guard declines. Read from compositionupdate rather than compositionend: a Pinyin preedit is the Latin spelling being narrowed while its commit is the Han text, so reading the commit would misclassify Pinyin and reopen the bugs the guard was added for. Space is untouched; only digits are reclassified. Verified A/B/A on that machine: unfixed drops the digit, this change preserves it, reverting drops it again, three runs each. The X11 case and both existing ibus-hangul specs still pass. Closes #15299
cf47b68 to
606e2e8
Compare
…emption Review of the #15299 fix found the Hangul classification could not be retired and that it exempted more than the reported bug. The flag was written only on a non-empty compositionupdate and cleared only on blur, so it latched for the whole focus session. Switching input engine (Hangul -> Pinyin) under fcitx/ibus moves no DOM focus, and the #8241 orphan-digit path emits no composition and no input events, so nothing could refresh or clear it. The stale flag then turned the #8241/#7543 Pinyin candidate-digit guard off silently and permanently - the regression those guards exist to prevent. It now expires against lastCompositionEventAt on the same staleness window as the neighbouring guards, and compositionstart clears it because the following compositionupdate re-reads the preedit script. It is deliberately not cleared on compositionend or on input: the bug is a digit arriving after the commit, and both recordings deliver the commit's own insertText before it. Clearing on either reverts the fix - the orphan-window test fails when input clears it. The exemption also gated suppressCandidateKey as a whole, so it fired during a live composition as well. That is broader than the bug, which is exclusively a digit after compositionend, and it is unsafe: the earlier claim that no Hangul engine indexes candidates by digit over a preedit is wrong. ibus-hangul's Hanja conversion (Hanja key / F9) puts a numbered lookup table over a live Hangul preedit, and its symbol table behaves the same. Only the orphan-keyup guard - which arms off a bare keyup and cannot see which engine produced it - now declines. The tests drove a shape neither recording produces: an empty compositionupdate immediately before compositionend, which armed the 250ms post-composition window. The Wayland reproduction has no empty update, and the X11 fixture follows its empty update with deleteContentBackward + insertText, which disarms that window. The suite now follows the recorded trace, asserts the 250ms window never arms, and covers both the expiry and the live-preedit Hanja case. Refs #15299
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3906366a-68c4-41a1-9354-997099478890
📥 Commits
Reviewing files that changed from the base of the PR and between cf47b68b8f424335ed0fa99631d2b943da28c8e3 and 4ca2526.
📒 Files selected for processing (3)
src/renderer/src/components/terminal-pane/terminal-ime-composition-tracker.tssrc/renderer/src/components/terminal-pane/terminal-ime-hangul-terminating-digit.test.tssrc/renderer/src/components/terminal-pane/xterm-bypass-policy.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| // Jamo, compatibility jamo, extended jamo, and precomposed syllables — every | ||
| // form a Hangul preedit can take while a syllable is being assembled. | ||
| const HANGUL_PREEDIT_PATTERN = /[ᄀ-ᇿ-ꥠ-가-힣]/ |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- candidate files ---'
fd -i 'terminal-ime-composition-tracker|terminal-ime.*test|composition.*test' . || true
printf '%s\n' '--- tracker outline ---'
tracker=$(fd -i -t f 'terminal-ime-composition-tracker' . | head -n 1)
if [ -n "${tracker:-}" ]; then
ast-grep outline "$tracker" || true
printf '%s\n' '--- tracker source ---'
cat -n "$tracker"
fi
printf '%s\n' '--- tracker references and Hangul classification ---'
rg -n -C 4 'HANGUL_PREEDIT_PATTERN|isHangulPreedit|orphan|terminating digit|composition tracker|preedit' . \
-g '*.{ts,tsx,js,jsx}' || trueRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- terminal IME files ---'
fd -i -t f 'terminal-ime' src/renderer/src/components/terminal-pane | sort
printf '%s\n' '--- exact tracker path ---'
tracker='src/renderer/src/components/terminal-pane/terminal-ime-composition-tracker.ts'
test -f "$tracker" && cat -n "$tracker"
printf '%s\n' '--- focused references ---'
rg -n -C 5 'HANGUL_PREEDIT_PATTERN|isHangulPreedit|orphan|pending.*digit|digit' \
src/renderer/src/components/terminal-pane/terminal-ime-composition-tracker.ts \
src/renderer/src/components/terminal-pane \
-g 'terminal-ime*.ts' -g 'terminal-ime*.tsx' -g 'terminal-ime*.test.ts' \
--glob '!**/node_modules/**' | head -n 500Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- tracker API consumers ---'
rg -n -C 8 'isHangulPreedit\(\)|isHangulPreedit' src/renderer/src --glob '*.{ts,tsx}' \
| head -n 300
printf '%s\n' '--- tracker tests ---'
cat -n src/renderer/src/components/terminal-pane/terminal-ime-composition-tracker.test.ts
printf '%s\n' '--- Hangul terminating-digit test ---'
cat -n src/renderer/src/components/terminal-pane/terminal-ime-hangul-terminating-digit.test.ts
printf '%s\n' '--- Hangul code point names and ranges ---'
python3 - <<'PY'
import unicodedata
ranges = [
('U+1100..U+11FF', 0x1100, 0x11ff),
('U+3130..U+318F', 0x3130, 0x318f),
('U+A960..U+A97F', 0xa960, 0xa97f),
('U+AC00..U+D7A3', 0xac00, 0xd7a3),
('U+D7B0..U+D7FF', 0xd7b0, 0xd7ff),
('U+FFA0..U+FFDC', 0xffa0, 0xffdc),
]
for label, start, end in ranges:
assigned = [(cp, unicodedata.name(chr(cp), '<unassigned>')) for cp in range(start, end + 1)
if unicodedata.name(chr(cp), None)]
print(label, 'assigned=', len(assigned), 'first=', assigned[:2], 'last=', assigned[-2:])
PYRepository: stablyai/orca
Length of output: 41148
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- keyboard suppression policy ---'
rg -n -C 12 'function shouldSuppressTerminalImeKeyboardEvent|shouldSuppressTerminalImeKeyboardEvent|hangulPreedit|linuxOrphanCandidateDigitGuardActive' \
src/renderer/src/components/terminal-pane/xterm-bypass-policy.ts \
src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
printf '%s\n' '--- policy structure ---'
ast-grep outline src/renderer/src/components/terminal-pane/xterm-bypass-policy.ts || true
cat -n src/renderer/src/components/terminal-pane/xterm-bypass-policy.ts | sed -n '1,240p'
printf '%s\n' '--- Unicode block metadata from local Unicode database ---'
python3 - <<'PY'
import unicodedata
for cp in (0xD7B0, 0xD7FF, 0xFFA0, 0xFFDC):
ch = chr(cp)
print(f'U+{cp:04X}', unicodedata.name(ch), 'category=', unicodedata.category(ch))
PY
printf '%s\n' '--- repository fixture/test references to omitted ranges ---'
rg -n -S 'D7B0|D7FF|FFA0|FFDC|ᇰ|ힰ|ᅠ|ᅵ|Halfwidth Hangul|Jamo Extended-B' \
src/renderer __fixtures__ tests 2>/dev/null | head -n 200 || trueRepository: stablyai/orca
Length of output: 26206
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- exact code-point behavior of the current and proposed patterns ---'
node - <<'JS'
const current = /[ᄀ-ᇿ-ꥠ-가-힣]/
const proposed = /[\u1100-\u11ff\u3130-\u318f\ua960-\ua97f\uac00-\ud7a3\ud7b0-\ud7ff\uffa0-\uffdc]/
for (const cp of [0x1100, 0x3130, 0xa960, 0xac00, 0xd7b0, 0xd7ff, 0xffa0, 0xffdc]) {
const char = String.fromCodePoint(cp)
console.log(
`U+${cp.toString(16).toUpperCase().padStart(4, '0')}`,
JSON.stringify(char),
`current=${current.test(char)}`,
`proposed=${proposed.test(char)}`
)
}
JS
printf '%s\n' '--- assigned code points in the omitted blocks ---'
python3 - <<'PY'
import unicodedata
for label, start, end in [
('Hangul Jamo Extended-B block', 0xD7B0, 0xD7FF),
('Halfwidth Hangul Jamo block range', 0xFFA0, 0xFFDC),
]:
assigned = [cp for cp in range(start, end + 1) if unicodedata.name(chr(cp), None)]
print(label, f'U+{start:04X}-U+{end:04X}', 'assigned_count=', len(assigned))
if assigned:
print(' assigned_span=', f'U+{min(assigned):04X}-U+{max(assigned):04X}')
PYRepository: stablyai/orca
Length of output: 770
🌐 Web query:
Unicode 17.0 Core Specification Chapter 18 Hangul Jamo Extended-B U+D7B0 U+D7FF Halfwidth Hangul Jamo U+FFA0 U+FFDC
💡 Result:
In the Unicode 17.0 standard, the specified ranges are categorized as follows: Hangul Jamo Extended-B (U+D7B0–U+D7FF) This block is part of the Basic Multilingual Plane (BMP) and contains 72 assigned code points used for archaic Hangul jamo (specifically positional jungseong and jongseong) [1][2][3]. These characters are designed for use with composed Hangul syllables, particularly those not required for standard modern Korean [2]. Halfwidth Hangul Jamo (U+FFA0–U+FFDC) These characters are located within the Halfwidth and Fullwidth Forms block (U+FF00–U+FFEF) [4]. This range encodes halfwidth variants of compatibility jamo characters [5][4]. They were included in Unicode primarily to ensure lossless translation (round-trip compatibility) with legacy character encodings, such as IBM code page 933, which utilized Shift Out/Shift In mechanisms to toggle between single-byte and double-byte character sets [4]. Unicode Specification Context Chapter 18 of the Unicode Standard (East Asia) provides broader context regarding the Hangul script [6][7]. It notes that Hangul jamos are grouped into syllabic blocks that, while visually resembling Chinese ideographs, are not directly influenced by them [6]. The standard specifies that conjoining jamo behavior (governed by the rules in Section 3.12) is the primary method for representing Korean, while compatibility jamos (including the halfwidth forms) and precomposed syllables are also supported for specific legacy and compatibility requirements [6].
Citations:
- 1: https://www.unicode.org/charts/PDF/UD7B0.pdf
- 2: https://en.wikipedia.org/wiki/Hangul_Jamo_Extended-B
- 3: https://www.compart.com/en/unicode/block/U+D7B0
- 4: https://en.wikipedia.org/wiki/Halfwidth_and_Fullwidth_Forms_(Unicode_block)
- 5: https://unicode.org/charts/PDF/UFF00.pdf
- 6: https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-18/
- 7: https://unicode.org/versions/Unicode15.0.0/ch18.pdf
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- exact code-point behavior of the current and proposed patterns ---'
node - <<'JS'
const current = /[ᄀ-ᇿ-ꥠ-가-힣]/
const proposed = /[\u1100-\u11ff\u3130-\u318f\ua960-\ua97f\uaC00-\ud7a3\ud7b0-\ud7ff\uffa0-\uffdc]/
for (const cp of [0x1100, 0x3130, 0xa960, 0xac00, 0xd7b0, 0xd7ff, 0xffa0, 0xffdc]) {
const char = String.fromCodePoint(cp)
console.log(
`U+${cp.toString(16).toUpperCase().padStart(4, '0')}`,
JSON.stringify(char),
`current=${current.test(char)}`,
`proposed=${proposed.test(char)}`
)
}
JS
printf '%s\n' '--- assigned code points in the omitted blocks ---'
python3 - <<'PY'
import unicodedata
for label, start, end in [
('Hangul Jamo Extended-B block', 0xD7B0, 0xD7FF),
('Halfwidth Hangul Jamo block range', 0xFFA0, 0xFFDC),
]:
assigned = [cp for cp in range(start, end + 1) if unicodedata.name(chr(cp), None)]
print(label, f'U+{start:04X}-U+{end:04X}', 'assigned_count=', len(assigned))
if assigned:
print(' assigned_span=', f'U+{min(assigned):04X}-U+{max(assigned):04X}')
PYRepository: stablyai/orca
Length of output: 770
Extend Hangul preedit detection to the omitted ranges.
HANGUL_PREEDIT_PATTERN misses Hangul Jamo Extended-B (U+D7B0–U+D7FF) and Halfwidth Hangul Jamo (U+FFA0–U+FFDC). For either range, isHangulPreedit() returns false, so the Linux orphan-digit guard can suppress a terminating digit. Add both ranges and regression cases.
|
Readiness review found a P0 in the first version of this fix, now corrected here. P0 — the Hangul classification latched. P1 — the exemption was broader than the bug. It gated Measured on real hardware (ibus-hangul 1.5.5, IBus 1.5.29-rc2), with the candidate table visually confirmed open:
Same harness both rows, so the absence is a real negative. ibus consumes the Hanja digit on both platforms, meaning the P1 was not exploitable in practice — the narrowing is defence-in-depth plus a correction to a false comment. The digit's keyup does arrive as a real Verification: 4/4 mutations of the load-bearing lines each fail a test (previously, deleting the exemption at the old |
…date pick (stablyai#15429) * fix(terminal): stop a Hangul-terminating digit being eaten as a candidate pick A digit typed immediately after a Hangul syllable is dropped in the terminal on Wayland. Typing 아1 produces 아. The syllable composes and commits correctly; only the keystroke that ends it is lost. Reproduced on Ubuntu 24.04, GNOME Shell 46, ibus-hangul 1.5.5, in a nested Wayland session with real key injection. The pty receives 아 on Wayland and 아1 under X11 on the same machine with the same engine, and a GTK client in the same Wayland session receives 아1 - so the compositor, the input method and the digit are all behaving. The difference is where the digit is delivered. Under X11 ibus-hangul swallows it into the preedit and commits 아1 as composition text. Under Wayland it commits 아 and lets the digit through as an ordinary key - and the jamo before it arrive with no keydown at all, only keyups. That orphaned keyup is what breaks it. A plain letter keyup with no matching keydown arms a 1500ms window in which a bare digit is treated as a candidate selection, because a Pinyin engine indexes its candidate list by digit. The digit lands microseconds later, inside the window, and is suppressed. The window disarms after exactly one digit, which is why the syllable survives and only the terminating key vanishes. A Hangul engine has no numbered candidates over its preedit - a digit ends the syllable and is literal text - so the guard was spending its one suppression on a keystroke meant for the shell. The tracker now records whether the current preedit is Hangul and the guard declines. Read from compositionupdate rather than compositionend: a Pinyin preedit is the Latin spelling being narrowed while its commit is the Han text, so reading the commit would misclassify Pinyin and reopen the bugs the guard was added for. Space is untouched; only digits are reclassified. Verified A/B/A on that machine: unfixed drops the digit, this change preserves it, reverting drops it again, three runs each. The X11 case and both existing ibus-hangul specs still pass. Closes stablyai#15299 * fix(terminal): expire the Hangul preedit flag and narrow its digit exemption Review of the stablyai#15299 fix found the Hangul classification could not be retired and that it exempted more than the reported bug. The flag was written only on a non-empty compositionupdate and cleared only on blur, so it latched for the whole focus session. Switching input engine (Hangul -> Pinyin) under fcitx/ibus moves no DOM focus, and the stablyai#8241 orphan-digit path emits no composition and no input events, so nothing could refresh or clear it. The stale flag then turned the stablyai#8241/stablyai#7543 Pinyin candidate-digit guard off silently and permanently - the regression those guards exist to prevent. It now expires against lastCompositionEventAt on the same staleness window as the neighbouring guards, and compositionstart clears it because the following compositionupdate re-reads the preedit script. It is deliberately not cleared on compositionend or on input: the bug is a digit arriving after the commit, and both recordings deliver the commit's own insertText before it. Clearing on either reverts the fix - the orphan-window test fails when input clears it. The exemption also gated suppressCandidateKey as a whole, so it fired during a live composition as well. That is broader than the bug, which is exclusively a digit after compositionend, and it is unsafe: the earlier claim that no Hangul engine indexes candidates by digit over a preedit is wrong. ibus-hangul's Hanja conversion (Hanja key / F9) puts a numbered lookup table over a live Hangul preedit, and its symbol table behaves the same. Only the orphan-keyup guard - which arms off a bare keyup and cannot see which engine produced it - now declines. The tests drove a shape neither recording produces: an empty compositionupdate immediately before compositionend, which armed the 250ms post-composition window. The Wayland reproduction has no empty update, and the X11 fixture follows its empty update with deleteContentBackward + insertText, which disarms that window. The suite now follows the recorded trace, asserts the 250ms window never arms, and covers both the expiry and the live-preedit Hanja case. Refs stablyai#15299
…date pick (stablyai#15429) * fix(terminal): stop a Hangul-terminating digit being eaten as a candidate pick A digit typed immediately after a Hangul syllable is dropped in the terminal on Wayland. Typing 아1 produces 아. The syllable composes and commits correctly; only the keystroke that ends it is lost. Reproduced on Ubuntu 24.04, GNOME Shell 46, ibus-hangul 1.5.5, in a nested Wayland session with real key injection. The pty receives 아 on Wayland and 아1 under X11 on the same machine with the same engine, and a GTK client in the same Wayland session receives 아1 - so the compositor, the input method and the digit are all behaving. The difference is where the digit is delivered. Under X11 ibus-hangul swallows it into the preedit and commits 아1 as composition text. Under Wayland it commits 아 and lets the digit through as an ordinary key - and the jamo before it arrive with no keydown at all, only keyups. That orphaned keyup is what breaks it. A plain letter keyup with no matching keydown arms a 1500ms window in which a bare digit is treated as a candidate selection, because a Pinyin engine indexes its candidate list by digit. The digit lands microseconds later, inside the window, and is suppressed. The window disarms after exactly one digit, which is why the syllable survives and only the terminating key vanishes. A Hangul engine has no numbered candidates over its preedit - a digit ends the syllable and is literal text - so the guard was spending its one suppression on a keystroke meant for the shell. The tracker now records whether the current preedit is Hangul and the guard declines. Read from compositionupdate rather than compositionend: a Pinyin preedit is the Latin spelling being narrowed while its commit is the Han text, so reading the commit would misclassify Pinyin and reopen the bugs the guard was added for. Space is untouched; only digits are reclassified. Verified A/B/A on that machine: unfixed drops the digit, this change preserves it, reverting drops it again, three runs each. The X11 case and both existing ibus-hangul specs still pass. Closes stablyai#15299 * fix(terminal): expire the Hangul preedit flag and narrow its digit exemption Review of the stablyai#15299 fix found the Hangul classification could not be retired and that it exempted more than the reported bug. The flag was written only on a non-empty compositionupdate and cleared only on blur, so it latched for the whole focus session. Switching input engine (Hangul -> Pinyin) under fcitx/ibus moves no DOM focus, and the stablyai#8241 orphan-digit path emits no composition and no input events, so nothing could refresh or clear it. The stale flag then turned the stablyai#8241/stablyai#7543 Pinyin candidate-digit guard off silently and permanently - the regression those guards exist to prevent. It now expires against lastCompositionEventAt on the same staleness window as the neighbouring guards, and compositionstart clears it because the following compositionupdate re-reads the preedit script. It is deliberately not cleared on compositionend or on input: the bug is a digit arriving after the commit, and both recordings deliver the commit's own insertText before it. Clearing on either reverts the fix - the orphan-window test fails when input clears it. The exemption also gated suppressCandidateKey as a whole, so it fired during a live composition as well. That is broader than the bug, which is exclusively a digit after compositionend, and it is unsafe: the earlier claim that no Hangul engine indexes candidates by digit over a preedit is wrong. ibus-hangul's Hanja conversion (Hanja key / F9) puts a numbered lookup table over a live Hangul preedit, and its symbol table behaves the same. Only the orphan-keyup guard - which arms off a bare keyup and cannot see which engine produced it - now declines. The tests drove a shape neither recording produces: an empty compositionupdate immediately before compositionend, which armed the 250ms post-composition window. The Wayland reproduction has no empty update, and the X11 fixture follows its empty update with deleteContentBackward + insertText, which disarms that window. The suite now follows the recorded trace, asserts the 250ms window never arms, and covers both the expiry and the live-preedit Hanja case. Refs stablyai#15299
…date pick (stablyai#15429) * fix(terminal): stop a Hangul-terminating digit being eaten as a candidate pick A digit typed immediately after a Hangul syllable is dropped in the terminal on Wayland. Typing 아1 produces 아. The syllable composes and commits correctly; only the keystroke that ends it is lost. Reproduced on Ubuntu 24.04, GNOME Shell 46, ibus-hangul 1.5.5, in a nested Wayland session with real key injection. The pty receives 아 on Wayland and 아1 under X11 on the same machine with the same engine, and a GTK client in the same Wayland session receives 아1 - so the compositor, the input method and the digit are all behaving. The difference is where the digit is delivered. Under X11 ibus-hangul swallows it into the preedit and commits 아1 as composition text. Under Wayland it commits 아 and lets the digit through as an ordinary key - and the jamo before it arrive with no keydown at all, only keyups. That orphaned keyup is what breaks it. A plain letter keyup with no matching keydown arms a 1500ms window in which a bare digit is treated as a candidate selection, because a Pinyin engine indexes its candidate list by digit. The digit lands microseconds later, inside the window, and is suppressed. The window disarms after exactly one digit, which is why the syllable survives and only the terminating key vanishes. A Hangul engine has no numbered candidates over its preedit - a digit ends the syllable and is literal text - so the guard was spending its one suppression on a keystroke meant for the shell. The tracker now records whether the current preedit is Hangul and the guard declines. Read from compositionupdate rather than compositionend: a Pinyin preedit is the Latin spelling being narrowed while its commit is the Han text, so reading the commit would misclassify Pinyin and reopen the bugs the guard was added for. Space is untouched; only digits are reclassified. Verified A/B/A on that machine: unfixed drops the digit, this change preserves it, reverting drops it again, three runs each. The X11 case and both existing ibus-hangul specs still pass. Closes stablyai#15299 * fix(terminal): expire the Hangul preedit flag and narrow its digit exemption Review of the stablyai#15299 fix found the Hangul classification could not be retired and that it exempted more than the reported bug. The flag was written only on a non-empty compositionupdate and cleared only on blur, so it latched for the whole focus session. Switching input engine (Hangul -> Pinyin) under fcitx/ibus moves no DOM focus, and the stablyai#8241 orphan-digit path emits no composition and no input events, so nothing could refresh or clear it. The stale flag then turned the stablyai#8241/stablyai#7543 Pinyin candidate-digit guard off silently and permanently - the regression those guards exist to prevent. It now expires against lastCompositionEventAt on the same staleness window as the neighbouring guards, and compositionstart clears it because the following compositionupdate re-reads the preedit script. It is deliberately not cleared on compositionend or on input: the bug is a digit arriving after the commit, and both recordings deliver the commit's own insertText before it. Clearing on either reverts the fix - the orphan-window test fails when input clears it. The exemption also gated suppressCandidateKey as a whole, so it fired during a live composition as well. That is broader than the bug, which is exclusively a digit after compositionend, and it is unsafe: the earlier claim that no Hangul engine indexes candidates by digit over a preedit is wrong. ibus-hangul's Hanja conversion (Hanja key / F9) puts a numbered lookup table over a live Hangul preedit, and its symbol table behaves the same. Only the orphan-keyup guard - which arms off a bare keyup and cannot see which engine produced it - now declines. The tests drove a shape neither recording produces: an empty compositionupdate immediately before compositionend, which armed the 250ms post-composition window. The Wayland reproduction has no empty update, and the X11 fixture follows its empty update with deleteContentBackward + insertText, which disarms that window. The suite now follows the recorded trace, asserts the 250ms window never arms, and covers both the expiry and the live-preedit Hanja case. Refs stablyai#15299
Closes #15299 — a digit typed immediately after a Hangul syllable is dropped in the terminal on Wayland. Typing
아1produces아. The syllable composes and commits correctly; only the keystroke that ends it is lost.Reproduced and fixed under measurement, on Ubuntu 24.04 / GNOME Shell 46 / ibus-hangul 1.5.5, in a nested Wayland session with real key injection through the compositor.
아\n×3--enable-wayland-ime --wayland-text-input-version=3아\n×3아1\n×3아1×3The compositor, the input method and the digit are all fine. Orca's terminal is the only thing that loses it.
Why Wayland and not X11
The two paths deliver the digit differently, and the traces show it plainly.
X11 — ibus-hangul swallows the digit into the preedit and commits
아1as composition text:Wayland — it commits
아and lets the digit through as an ordinary key. And the jamo before it arrive with no keydown at all, only keyups:Root cause
That orphaned keyup is what breaks it.
terminal-ime-linux-candidate-state.ts:175sees a plain-letter keyup with no pending keydown for thatcodeand arms a 1500 ms window in which a bare digit is treated as a candidate selection — because a Pinyin engine indexes its candidate list by digit (#7543, #8241).The digit lands microseconds later, inside that window, and is suppressed. The window disarms after exactly one digit, which is why the syllable survives and only the terminating key vanishes.
A Hangul engine has no numbered candidates over its preedit. The guard was spending its one suppression on a keystroke meant for the shell.
The fix
The composition tracker records whether the current preedit is Hangul; the guard declines to claim a digit that preedit has already made literal.
Read from
compositionupdate, nevercompositionend— a Pinyin preedit is the Latin spelling being narrowed while its commit is the Han text, so reading the commit would misclassify Pinyin and reopen the bugs the guard exists for. A test pins that. Space is untouched; only digits are reclassified.Two things the earlier draft of this PR got wrong
Both were corrected by the reproduction rather than by argument:
compositionupdate, and every update in this trace carries data (ㅇ,아,아). The orphan-keyup guard is solely responsible.keydownwithkeyCode 49andisComposing=false, so xterm's_keyDownSeencheck is never reached — Orca's policy suppresses the key before xterm's handler runs. That path is not what the reporter hits.Verification
A/B/A on the reproducing machine: unfixed drops the digit, this change preserves it, reverting drops it again — three runs each, deterministic.
The oracle is the literal byte stream: a
nodeprocess on the pty echoes each line as hex,ec9584 0abroken versusec9584 31 0afixed.terminal.onDataagrees independently.orca terminal readwas deliberately not used — it accumulates the stream and stacks output, and would have shown a false result.No regression: the X11 case still passes with the fix, and both existing
terminal-ibus-hangul-native.spec.tscases pass at 5 repetitions.config/patches/untouched — no xterm change was needed.Also cleared
PR #14469 is not the cause, contrary to the initial hypothesis.
resolveNonLatinControlChordInputreturnsnullunlessctrlKeyis set, only claimsKey[A-Z]codes, and requires a codepoint above0x7f— a bare1fails all three gates.Follow-up worth having
The reproduction harness exists and is reusable, but lives on a scratch machine rather than in the repo. It is the first setup we have that can drive a real IME through a real compositor, and three IME issues this week were unreproducible without one. Details are in the issue thread; the spec is injector-agnostic and parameterised by keys and expected text, so other IME bugs can reuse it unchanged.