hermes-agent/ui-tui/src/__tests__
brooklyn! 9fb40e6a3d
fix(tui): restrict fast-echo bypass to ASCII so Vietnamese/CJK/IME input renders correctly (#26011)
* fix(tui): restrict fast-echo bypass to ASCII so Vietnamese/CJK/IME input renders correctly

The composer's fast-echo path (canFastAppend / canFastBackspace) writes
characters straight to stdout to skip an Ink re-render on the hot
typing path. The previous guard only checked
'stringWidth(text) === text.length', which lets a lot of non-ASCII
through:

  - Vietnamese precomposed letters (ề, ắ, ờ, ự, ...) report width 1 and
    length 1, but a Vietnamese Telex / IME stack produces them across
    multiple keystrokes; the intermediate composition state must be
    drawn by Ink so the rendered cell, the stored value, and the
    cursor column stay in lockstep when the final commit replaces the
    preview.
  - NFD combining marks (U+0300..U+036F) are zero-width but length 1,
    so even a passing equality lets them slip and silently desync the
    cell column.
  - CJK/East-Asian wide and emoji rejected only because their length
    differs, but the boundary was shape-shaped, not intent-shaped.

User-visible bug from the original report:
  Example: eê noiói nge neène
  -> the bypass committed the IME preview char before the diacritic
     replaced it, leaving doubled letters on screen.

Fix: gate fast-echo on pure printable ASCII (0x20-0x7e). The
performance-critical English typing path is unchanged; everything else
goes through the normal Ink render path so layout stays accurate.

Also extracts the shape preconditions as pure exported helpers
(canFastAppendShape / canFastBackspaceShape) so the regression matrix
is testable without spinning up a TextInput.

Tests: ui-tui/src/__tests__/textInputFastEcho.test.ts adds 20 cases
covering ASCII still works, Vietnamese precomposed + NFD, CJK, emoji,
NBSP / Latin-1, ANSI / control bytes, multi-line, and end-of-line
preconditions. Verified RED on the previous guard (11 of 20 fail) and
GREEN on the new guard.

Refs: #5221, #7443, #17602, #17603 (similar wide-char rendering bugs).

* docs(tui): clarify Vietnamese char terminology in regression comment

Address Copilot review: 'single byte width' implied UTF-8 byte semantics,
but the relevant property is JS code units (`text.length === 1`) and
display width (`stringWidth === 1`). Reworded to match.
2026-05-15 09:41:50 -05:00
..
asCommandDispatch.test.ts fix(tui): slash.exec _pending_input commands, tool ANSI, terminal title 2026-04-18 09:30:48 -07:00
clipboard.test.ts fix(tui): improve clipboard copy fallbacks 2026-05-05 03:59:00 -07:00
constants.test.ts test(tui): tighten redraw hotkey review follow-ups 2026-04-27 12:30:40 -05:00
createGatewayEventHandler.test.ts feat(tui): render self-improvement review summaries in the transcript 2026-04-30 14:07:22 -07:00
createSlashHandler.test.ts fix: keep tui /quit behavior aligned with cli exit flow 2026-05-08 16:48:24 -07:00
details.test.ts fix(tui): apply details mode live 2026-04-26 13:34:33 -05:00
emoji.test.ts fix(tui): inject VS16 so text-default emoji render as color glyphs 2026-04-21 15:52:39 -05:00
externalLink.test.ts feat(ui-tui): resolve markdown links to readable page titles (#24013) 2026-05-11 14:16:31 -07:00
forceTruecolor.test.ts fix(tui): normalize legacy Terminal.app colors (#17695) 2026-04-29 20:13:49 -07:00
gatewayClient.test.ts feat(tui): support attaching to an existing gateway (#21978) 2026-05-08 12:12:38 -07:00
markdown.test.ts feat(ui-tui): resolve markdown links to readable page titles (#24013) 2026-05-11 14:16:31 -07:00
mathUnicode.test.ts fix: account for latex 2026-04-28 21:20:43 -04:00
messages.test.ts fix(tui): preserve prompt separator width (#19340) 2026-05-04 09:58:40 -07:00
osc52.test.ts fix(tui): raise picker selection contrast with inverse + bold 2026-04-21 14:31:21 -05:00
paths.test.ts feat(tui): append git branch to cwd label in status bar 2026-04-18 17:17:05 -05:00
platform.test.ts fix(tui): respect voice.record_key config (supersedes #19028, #19339) (#19835) 2026-05-04 15:49:28 -07:00
precisionWheel.test.ts fix(tui): steady transcript scrollbar (#20917) 2026-05-06 14:50:31 -07:00
providers.test.ts chore(tui): /clean pass — inline one-off locals, tighten ConfirmPrompt 2026-04-19 07:55:38 -05:00
reasoning.test.ts fix(tui): filter thinking status noise 2026-04-26 13:59:56 -05:00
rpc.test.ts fix(ui-tui): surface RPC errors and guard invalid gateway responses 2026-04-13 14:17:52 -05:00
scroll.test.ts fix(tui): refresh scroll height at cached bottom 2026-05-07 05:48:19 -07:00
slashParity.test.ts test(tui): skip slash parity matrix when Python registry is unavailable 2026-04-27 13:19:11 -05:00
stateIsolation.test.ts fix(tui): isolate turn state from app render 2026-04-26 15:40:38 -05:00
statusBarTicker.test.ts feat(tui): segment turns with rule above non-first user msgs; trim ticker dead space (#21846) 2026-05-08 05:12:09 -07:00
streamingMarkdown.test.ts Merge remote-tracking branch 'origin/main' into fix/markdown 2026-04-28 22:01:02 -04:00
subagentTree.test.ts style(debug): add missing blank line between LogSnapshot and helpers 2026-04-22 16:34:05 -05:00
syntax.test.ts fix(tui): restore macOS copy behavior and theme polish (#17131) 2026-04-28 18:47:14 -05:00
terminalModes.test.ts fix(tui): tighten SGR fragment matching 2026-04-30 17:50:49 -05:00
terminalParity.test.ts fix(tui): restore macOS copy behavior and theme polish (#17131) 2026-04-28 18:47:14 -05:00
terminalSetup.test.ts style(tui): apply npm run fix 2026-04-28 22:18:26 -05:00
text.test.ts perf(tui): cache stringWidth/wrapText/sliceAnsi + skip-slice when line fits clip 2026-04-26 19:28:09 -05:00
textInputFastEcho.test.ts fix(tui): restrict fast-echo bypass to ASCII so Vietnamese/CJK/IME input renders correctly (#26011) 2026-05-15 09:41:50 -05:00
textInputLineNav.test.ts fix(tui): up-arrow inside a multi-line buffer moves cursor, not history 2026-04-21 18:31:35 -05:00
textInputPassThrough.test.ts fix(tui): respect voice.record_key config (supersedes #19028, #19339) (#19835) 2026-05-04 15:49:28 -07:00
textInputRightClick.test.ts fix(tui): right-click copies selection, only pastes when no selection 2026-05-10 16:06:33 -07:00
textInputWrap.test.ts fix(tui): word-wrap composer input (#17651) 2026-04-29 16:55:49 -07:00
theme.test.ts fix(tui): honor skin highlight colors (#20895) 2026-05-06 14:01:56 -07:00
turnStore.test.ts chore(tui): remove dead branch cleanup code 2026-04-26 21:54:24 -05:00
useCompletion.test.ts fix(tui): complete absolute paths as paths 2026-05-04 16:14:40 -07:00
useComposerState.test.ts fix(tui): raise picker selection contrast with inverse + bold 2026-04-21 14:31:21 -05:00
useConfigSync.test.ts fix(tui): respect voice.record_key config (supersedes #19028, #19339) (#19835) 2026-05-04 15:49:28 -07:00
useInputHandlers.test.ts fix(tui): restore voice push-to-talk parity (#20897) 2026-05-06 15:49:59 -07:00
useQueue.test.ts fix(tui): copilot review on #16707 — naming, label consistency, esc priority 2026-04-27 15:37:54 -05:00
useSessionLifecycle.test.ts fix(tui): report actual session on exit 2026-04-27 08:52:12 -07:00
useVirtualHistoryHeights.test.ts perf(tui): lazily seed virtual history heights (#16523) 2026-04-27 07:55:45 -07:00
viewport.test.ts fix(tui): stabilize sticky prompt tracking 2026-04-28 22:10:40 -05:00
viewportStore.test.ts fix(tui): steady transcript scrollbar (#20917) 2026-05-06 14:50:31 -07:00
virtualHeights.test.ts feat(tui): segment turns with rule above non-first user msgs; trim ticker dead space (#21846) 2026-05-08 05:12:09 -07:00
virtualHistoryClamp.test.ts fix(tui): stabilize live progress rendering 2026-04-26 15:23:43 -05:00
virtualHistoryOffsetCache.test.ts fix(tui): refresh virtual offsets after row resize (#20898) 2026-05-06 13:54:46 -07:00
wheelAccel.test.ts chore(tui): /clean recent perf work — KISS/DRY pass 2026-04-26 20:38:47 -05:00