Repository navigation
test(terminal): pin that the CJK block is the preedit overlay, not the cursor - #15242
Conversation
📝 WalkthroughWalkthroughAdded Vitest and Playwright regression coverage for CJK cursor placement, wide-glyph rendering, cursor-style precedence, cursor opacity, and Korean IME composition. The tests configure xterm instances, mock canvas measurements, synchronize rendering, inspect cell state, simulate composition events, validate overlay dimensions and styling, verify final commits, and select the related E2E test for terminal IME changes. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-cjk-cursor-cell-placement.test.ts (1)
2-16: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueKeep both test headers concise.
Replace issue-analysis prose with a one-line regression description.
src/renderer/src/components/terminal-pane/terminal-cjk-cursor-cell-placement.test.ts#L2-L16: reduce the header to the CJK cursor-placement regression condition.src/renderer/src/components/terminal-pane/terminal-cursor-appearance-precedence.test.ts#L2-L13: reduce the header to the cursor-precedence regression condition.As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 53ff5e4a-de23-496a-90fe-018459130531
📥 Commits
Reviewing files that changed from the base of the PR and between 9a41119 and 45b0b757a607f334b971215adfd9aaac4f8dc050.
📒 Files selected for processing (3)
src/renderer/src/components/terminal-pane/terminal-cjk-cursor-cell-placement.test.tssrc/renderer/src/components/terminal-pane/terminal-cursor-appearance-precedence.test.tssrc/renderer/src/components/terminal-pane/terminal-ime-xterm-trailing-preedit-occlusion.test.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 1 remains after this review.
45b0b75 to
30051b9
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-cjk-cursor-cell-placement.test.ts (1)
2-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep the test comments concise. Retain only the non-obvious regression contract; remove the report narrative and implementation walkthrough. The test names and assertions already document the covered cursor positions, renderer scope, synchronization, and IME behavior.
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 10221abb-c04d-4f9a-8c69-6bb642239190
📥 Commits
Reviewing files that changed from the base of the PR and between 45b0b757a607f334b971215adfd9aaac4f8dc050 and 30051b9.
📒 Files selected for processing (4)
.github/workflows/pr.ymlsrc/renderer/src/components/terminal-pane/terminal-cjk-cursor-cell-placement.test.tssrc/renderer/src/components/terminal-pane/terminal-cursor-appearance-precedence.test.tstests/e2e/terminal-korean-endofrow-preedit-cell-span.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/components/terminal-pane/terminal-cursor-appearance-precedence.test.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 2 remain after this review.
| async function sampleOpenComposition(page: Page): Promise<MidlinePreeditOcclusionSample> { | ||
| await expect | ||
| .poll( | ||
| async () => { | ||
| const overlay = await samplePreeditOverlay(page) | ||
| return overlay.active && overlay.rect.width > 0 && overlay.text === '가' | ||
| }, | ||
| { message: 'the preedit never reached the overlay at a non-zero size' } | ||
| ) | ||
| .toBe(true) | ||
| return sampleMidlinePreeditOcclusion(page) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Capture one validated preedit snapshot.
Lines 44-45 validate one overlay sample. Line 50 reads a separate sample. A repaint can occur between these calls, as the comment in this function states. The assertions can then run against inactive or zero-size geometry.
Capture the overlay state and occlusion measurements in one probe. Retry until that combined sample is valid.
| // 안녕하세요 is ten cells, so the cursor lands at the end of the row with nothing after it — | ||
| // the shape #12729 hits, and the one where the overlay carries the preedit alone. | ||
| await writeToActiveTerminal(orcaPage, '\x1b[2J\x1b[H안녕하세요') | ||
| await setImeComposition(arena.session, '가') | ||
|
|
||
| const sample = await sampleOpenComposition(orcaPage) | ||
| expect(sample.rowTailFromCursor, 'text still sits after the cursor').toBe('') | ||
| expect(sample.cursorColumn, 'the cursor is not at the end of the committed run').toBe(10) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
arena_file='tests/e2e/terminal-ime-pane-arena.ts'
ast-grep outline "$arena_file" --match openTerminalImePaneArena --view expanded
rg -n -C 5 --glob '*.ts' \
'openTerminalImePaneArena|\.resize\(|\bcols\b|\bcolumns\b' \
tests/e2eRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- arena ---'
cat -n tests/e2e/terminal-ime-pane-arena.ts | sed -n '1,90p'
printf '%s\n' '--- target test ---'
cat -n tests/e2e/terminal-korean-endofrow-preedit-cell-span.spec.ts | sed -n '1,110p'
printf '%s\n' '--- arena callers and explicit sizing ---'
rg -n -C 3 --glob '*.ts' \
'openTerminalImePaneArena|terminal\.resize\([^)]*10|resize\(\s*10|cols:\s*10|columns:\s*10' \
tests/e2eRepository: stablyai/orca
Length of output: 25745
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import re
arena = Path("tests/e2e/terminal-ime-pane-arena.ts").read_text()
match = re.search(
r"export async function openTerminalImePaneArena\b.*?(?=\nexport |\Z)",
arena,
re.S,
)
if not match:
raise SystemExit("openTerminalImePaneArena was not found")
body = match.group(0)
print("openTerminalImePaneArena calls terminal.resize:", bool(re.search(r"\bresize\s*\(", body)))
print("openTerminalImePaneArena fixes a ten-column grid:", bool(re.search(r"\b(?:cols|columns)\s*[:=]\s*10\b", body)))
test = Path("tests/e2e/terminal-korean-endofrow-preedit-cell-span.spec.ts").read_text()
print("test writes ten-cell Hangul text:", "안녕하세요" in test)
print("test asserts cursorColumn === 10:", "cursorColumn" in test and ".toBe(10)" in test)
PYRepository: stablyai/orca
Length of output: 339
Fix the end-of-row setup.
Resize the terminal to 10 columns before writing 안녕하세요. cursorColumn === 10 proves only the committed text length, not that the cursor is in the terminal's last column.
30051b9 to
66a1be6
Compare
…e cursor A report described the cursor sitting on a wide character's first cell and hiding its right half, with cursor style and opacity settings ignored. Neither defect reproduces. Replaying the reporter's own captured byte stream leaves the cursor at column 11, exactly where the application asked, with correct wide and continuation cells. A block cursor also cannot hide half a glyph: it inverts the cell and the syllable renders inside the cursor span. The black block is the IME preedit overlay. macOS 2-set Korean keeps the trailing syllable composing until a terminator, so it sits in an opaque absolutely-positioned box over the grid rather than in the buffer. That box took stock upstream colours, black on white. It explains what no cursor theory can: the block appears at the composing cursor cell, no cursor option reaches it, it is identical with GPU acceleration off since it is a DOM node above both renderers, Latin never triggers it because Latin opens no composition, and Enter clears it because Enter commits the composition. Already fixed by the overlay theming in #15014, which landed a day after the reported release, so the fix ships in the next one. Tests only, no production change. Two pin the negative results so the cursor explanation cannot be re-derived, and one pins the actual mechanism at end of row, beside the existing mid-line arm. Separately confirmed and not fixed here: the WebGL renderer drops the cursor colour's alpha, so terminal cursor opacity genuinely does nothing for a block cursor, which is the default style on the default renderer. That is in the webgl addon rather than in xterm or in our code. Refs #12729
… the overlay Review of the first pass found one assertion that could not fail. It set options.cursorStyle and then read decPrivateModes.cursorStyle, which are separate fields with separate storage, so it pinned that writing one does not clobber the other. Deleting the precedence expression from both renderers left it green. It now asserts the rendered cursor class: the option style renders, a DECSCUSR overrides it, and the reset hands control back. That fails if the precedence is removed. The overlay's rendered width is the one measurement in the report that argues against our explanation, and no test here could reach it, because the unit environment performs no layout. Adds an end-of-row browser arm beside the existing mid-line one, asserting a single composing Hangul syllable spans about two cells. That settles whether the block the reporter measured at one cell can be this overlay. Also scopes two DOM queries to the test container rather than the document, and attaches the render listener before writing so a missed render fails instead of hanging to timeout. Records in the file header what it does not establish: composing the opacity into the theme is not the same as it reaching the screen, since the webgl renderer drops the cursor colour's alpha for a block cursor. Refs #12729
66a1be6 to
a0dff39
Compare
…e cursor (stablyai#15242) * test(terminal): pin that the CJK block is the preedit overlay, not the cursor A report described the cursor sitting on a wide character's first cell and hiding its right half, with cursor style and opacity settings ignored. Neither defect reproduces. Replaying the reporter's own captured byte stream leaves the cursor at column 11, exactly where the application asked, with correct wide and continuation cells. A block cursor also cannot hide half a glyph: it inverts the cell and the syllable renders inside the cursor span. The black block is the IME preedit overlay. macOS 2-set Korean keeps the trailing syllable composing until a terminator, so it sits in an opaque absolutely-positioned box over the grid rather than in the buffer. That box took stock upstream colours, black on white. It explains what no cursor theory can: the block appears at the composing cursor cell, no cursor option reaches it, it is identical with GPU acceleration off since it is a DOM node above both renderers, Latin never triggers it because Latin opens no composition, and Enter clears it because Enter commits the composition. Already fixed by the overlay theming in stablyai#15014, which landed a day after the reported release, so the fix ships in the next one. Tests only, no production change. Two pin the negative results so the cursor explanation cannot be re-derived, and one pins the actual mechanism at end of row, beside the existing mid-line arm. Separately confirmed and not fixed here: the WebGL renderer drops the cursor colour's alpha, so terminal cursor opacity genuinely does nothing for a block cursor, which is the default style on the default renderer. That is in the webgl addon rather than in xterm or in our code. Refs stablyai#12729 * test(terminal): make the cursor precedence assertion real and measure the overlay Review of the first pass found one assertion that could not fail. It set options.cursorStyle and then read decPrivateModes.cursorStyle, which are separate fields with separate storage, so it pinned that writing one does not clobber the other. Deleting the precedence expression from both renderers left it green. It now asserts the rendered cursor class: the option style renders, a DECSCUSR overrides it, and the reset hands control back. That fails if the precedence is removed. The overlay's rendered width is the one measurement in the report that argues against our explanation, and no test here could reach it, because the unit environment performs no layout. Adds an end-of-row browser arm beside the existing mid-line one, asserting a single composing Hangul syllable spans about two cells. That settles whether the block the reporter measured at one cell can be this overlay. Also scopes two DOM queries to the test container rather than the document, and attaches the render listener before writing so a missed render fails instead of hanging to timeout. Records in the file header what it does not establish: composing the opacity into the theme is not the same as it reaching the screen, since the webgl renderer drops the cursor colour's alpha for a block cursor. Refs stablyai#12729
…e cursor (stablyai#15242) * test(terminal): pin that the CJK block is the preedit overlay, not the cursor A report described the cursor sitting on a wide character's first cell and hiding its right half, with cursor style and opacity settings ignored. Neither defect reproduces. Replaying the reporter's own captured byte stream leaves the cursor at column 11, exactly where the application asked, with correct wide and continuation cells. A block cursor also cannot hide half a glyph: it inverts the cell and the syllable renders inside the cursor span. The black block is the IME preedit overlay. macOS 2-set Korean keeps the trailing syllable composing until a terminator, so it sits in an opaque absolutely-positioned box over the grid rather than in the buffer. That box took stock upstream colours, black on white. It explains what no cursor theory can: the block appears at the composing cursor cell, no cursor option reaches it, it is identical with GPU acceleration off since it is a DOM node above both renderers, Latin never triggers it because Latin opens no composition, and Enter clears it because Enter commits the composition. Already fixed by the overlay theming in stablyai#15014, which landed a day after the reported release, so the fix ships in the next one. Tests only, no production change. Two pin the negative results so the cursor explanation cannot be re-derived, and one pins the actual mechanism at end of row, beside the existing mid-line arm. Separately confirmed and not fixed here: the WebGL renderer drops the cursor colour's alpha, so terminal cursor opacity genuinely does nothing for a block cursor, which is the default style on the default renderer. That is in the webgl addon rather than in xterm or in our code. Refs stablyai#12729 * test(terminal): make the cursor precedence assertion real and measure the overlay Review of the first pass found one assertion that could not fail. It set options.cursorStyle and then read decPrivateModes.cursorStyle, which are separate fields with separate storage, so it pinned that writing one does not clobber the other. Deleting the precedence expression from both renderers left it green. It now asserts the rendered cursor class: the option style renders, a DECSCUSR overrides it, and the reset hands control back. That fails if the precedence is removed. The overlay's rendered width is the one measurement in the report that argues against our explanation, and no test here could reach it, because the unit environment performs no layout. Adds an end-of-row browser arm beside the existing mid-line one, asserting a single composing Hangul syllable spans about two cells. That settles whether the block the reporter measured at one cell can be this overlay. Also scopes two DOM queries to the test container rather than the document, and attaches the render listener before writing so a missed render fails instead of hanging to timeout. Records in the file header what it does not establish: composing the opacity into the theme is not the same as it reaching the screen, since the webgl renderer drops the cursor colour's alpha for a block cursor. Refs stablyai#12729
…e cursor (stablyai#15242) * test(terminal): pin that the CJK block is the preedit overlay, not the cursor A report described the cursor sitting on a wide character's first cell and hiding its right half, with cursor style and opacity settings ignored. Neither defect reproduces. Replaying the reporter's own captured byte stream leaves the cursor at column 11, exactly where the application asked, with correct wide and continuation cells. A block cursor also cannot hide half a glyph: it inverts the cell and the syllable renders inside the cursor span. The black block is the IME preedit overlay. macOS 2-set Korean keeps the trailing syllable composing until a terminator, so it sits in an opaque absolutely-positioned box over the grid rather than in the buffer. That box took stock upstream colours, black on white. It explains what no cursor theory can: the block appears at the composing cursor cell, no cursor option reaches it, it is identical with GPU acceleration off since it is a DOM node above both renderers, Latin never triggers it because Latin opens no composition, and Enter clears it because Enter commits the composition. Already fixed by the overlay theming in stablyai#15014, which landed a day after the reported release, so the fix ships in the next one. Tests only, no production change. Two pin the negative results so the cursor explanation cannot be re-derived, and one pins the actual mechanism at end of row, beside the existing mid-line arm. Separately confirmed and not fixed here: the WebGL renderer drops the cursor colour's alpha, so terminal cursor opacity genuinely does nothing for a block cursor, which is the default style on the default renderer. That is in the webgl addon rather than in xterm or in our code. Refs stablyai#12729 * test(terminal): make the cursor precedence assertion real and measure the overlay Review of the first pass found one assertion that could not fail. It set options.cursorStyle and then read decPrivateModes.cursorStyle, which are separate fields with separate storage, so it pinned that writing one does not clobber the other. Deleting the precedence expression from both renderers left it green. It now asserts the rendered cursor class: the option style renders, a DECSCUSR overrides it, and the reset hands control back. That fails if the precedence is removed. The overlay's rendered width is the one measurement in the report that argues against our explanation, and no test here could reach it, because the unit environment performs no layout. Adds an end-of-row browser arm beside the existing mid-line one, asserting a single composing Hangul syllable spans about two cells. That settles whether the block the reporter measured at one cell can be this overlay. Also scopes two DOM queries to the test container rather than the document, and attaches the render listener before writing so a missed render fails instead of hanging to timeout. Records in the file header what it does not establish: composing the opacity into the theme is not the same as it reaching the screen, since the webgl renderer drops the cursor colour's alpha for a block cursor. Refs stablyai#12729
Refs #12729.
Neither claimed defect reproduces. The black block is not the cursor — it is the IME preedit overlay, and it was already fixed by #15014, which landed the day after the reported release.
Tests only; no production change.
Defect 1 — cursor on the wide char's first cell: does not reproduce
Replaying the reporter's own captured stream (
ESC[?25l ESC[H ESC[2C ESC[24B 가나다라 ESC[30;1H ESC[25;11H ESC[?25h):buffer.cursorX === 10— column 11, exactly whatCSI 25;11Hrequested. Not cell 8.가:2 ·:0 나:2 ·:0 다:2 ·:0 라:2 ·:0textContent === '라')And the structural point: a block cursor inverts a cell, it does not mask it. It cannot hide half a glyph. That alone rules out every cursor-based explanation of "the right half is never drawn."
Defect 2 — cursor style/opacity ignored: not a plumbing bug
The settings path is intact end to end — explicit
barsurvives write and reload,applyTerminalAppearancewritescursorStyleto every mounted pane, opacity composes torgba(...), and all 30 builtin themes definecursor, so the gate never silently drops it.Two real findings, neither being the reported symptom:
DECSCUSRfrom the running program outranks the setting (decPrivateModes.cursorStyle ?? options.cursorStyle). Prompt frameworks emit this on every redraw. Correct terminal behaviour and matches other terminals — but it is the honest answer whenever someone says "my cursor setting does nothing."rgba >> 8 & 16777215). The DOM renderer keeps it. This is upstream in the webgl addon, not in xterm or in our code, and is left alone here.What is actually happening
macOS 2-set Korean keeps the trailing syllable composing until a terminator. After typing
가나다라only가나다has reached the pty;라lives in.composition-view, an opaque absolutely-positioned box anchored at the cursor cell and painted over the grid.In v1.4.184 that box used stock upstream colours —
background: #000; color: #FFF. That is the black block.It accounts for every observation, including the ones no cursor theory can:
The follow-up comment's "it is not composition state" was inferred from "Enter fixes it" — but Enter is precisely the terminator that ends the composition.
Already fixed
453237cc57c(#15014, 2026-08-17) themes the overlay fromoptions.themewith the alpha dropped, and renders the row tail it covers.So the answer to the reporter is "fixed, ships in the next release" — plus the separate upstream opacity gap above.
The tests
terminal-cjk-cursor-cell-placement.test.ts— pins defect 1's negative result so the cursor explanation cannot be re-derivedterminal-cursor-appearance-precedence.test.ts— settings round-trip, opacity composition, and DECSCUSR precedence including the reset handing control backterminal-ime-xterm-trailing-preedit-occlusion.test.ts— pins the real mechanism: only가나다reaches the pty while라sits in a themed overlay at the cursor cell, cleared on commit. The theming assertion is the arm with teeth against 1.4.184, where the inline background was never set at all. Sits beside fix(terminal): render the row tail the IME preedit overlay covers #15014's existing mid-line arm; this is the end-of-row arm, which is the shape this issue hits.The strongest evidence, and the one measurement that argues against us
What actually rules out the cursor is structural, not arithmetic: a block cursor spans the whole wide glyph. Under the WebGL renderer — the default on macOS —
lastCursorX = cursorX + cell.getWidth() - 1and the fill runsx >= cursorX && x <= lastCursorX(addon-webglWebglRenderer.ts:550,552). The DOM renderer puts the syllable inside the cursor span. So "the cursor covers one cell of a two-cell glyph" fails on both renderers. That closes it far harder than any pixel sum.I want to retract an argument that appeared in an earlier draft of this description, because it was wrong and it dismissed careful work:
23 + 8×14 = 135calculation has no discriminating power. Cell index 8 is column 9, which is the reporter's own stated cursor column. Both theories put the block's left edge at the same pixel. It restates their number rather than explaining it.With 14px standing on its own, the reported block width of 14px is exactly one cell — and the overlay would be two.
.composition-viewsets nowidth, onlymaxWidth, and iswhite-space: nowrap(CompositionHelper.ts:875-876), so a view holding one Hangul syllable renders about 28px.That is the only measured quantity in the report that discriminates between the two explanations, and it points away from the overlay.
I still believe the overlay explanation, because it accounts for six independent observations that no cursor theory can, and because a block cursor provably cannot mask half a glyph. The most likely reading is that "Cell width (from the cursor block)" is ambiguous about which block was measured. But that is a mis-measurement hypothesis, and it should be stated as one rather than waved away.
Not verified
No visual confirmation — this rests on the structural argument above, the observations no cursor theory explains, and the code path, not on a screenshot.
The disputed width is settleable and is not settled here. happy-dom performs no layout, so every geometry assertion in these tests is attribute-level; the overlay's rendered width — the exact number the diagnosis turns on — cannot be asserted anywhere in this PR. The tooling already exists:
tests/e2e/terminal-ime-preedit-overlay-probe.tsalready returnsgetBoundingClientRect().widthfor.composition-view. An end-of-row arm alongside the existing mid-line spec, asserting a single Hangul syllable renders about two cells wide, would resolve 14 vs 28 outright. That is the highest-value follow-up and it is nearly free.