Skip to content

fix(cli): hide the composer hint while an IME composes - #150

Closed
kylin1020 wants to merge 1 commit into
mainfrom
fix/ime-placeholder-flicker
Closed

kylin1020 wants to merge 1 commit into
mainfrom
fix/ime-placeholder-flicker

Conversation

@kylin1020

Copy link
Copy Markdown
Collaborator

Problem

The composer hint (Ask Step to do anything …) is drawn whenever the editor's buffer is empty. An IME does not put its preedit in that buffer — the terminal holds it and paints it at the cursor itself. So while pinyin is being composed the buffer is still empty, the editor keeps rewriting the hint into the cells the terminal is also drawing the composing text into, and the two layers alternate on the same cells. The hint does not hide and the row flickers as you type.

Change

No terminal reports composition start or end to the application, and the preedit never reaches stdin, so the suppression has to be inferred from what does arrive. A printable keystroke that reaches the editor and leaves the buffer empty is exactly that signal: text the editor did not consume is still with the terminal.

  • Such a keystroke hides the hint for 500 ms and re-arms on the next one, so a whole composition stays covered rather than only its first stroke.
  • Committing into the buffer, or abandoning the composition and letting the timer expire, brings the hint back. The restore is on a deadline, so the composer cannot be left empty-but-hintless waiting for unrelated input to trigger a frame.
  • Keystrokes that type nothing (arrows, Escape, Ctrl chords, paste frames) do not arm it.
  • The bash-mode hints follow a typed !/!! prefix, which is already text, so they are unaffected.
  • A blurred editor never composes and cannot be repainted by the timer, so it always shows its hint.

Scope: apps/cli only. packages/tui is untouched — the product layer owns the Step composer's hint, and pi-tui keeps its own state machine.

Testing

  • apps/cli/test/step-editor.test.ts — four new cases: a composition stays hidden across keystrokes and the hint returns on the deadline, committed text and programmatic fills clear the state, non-composing keystrokes leave the hint alone, and the bash-mode hint survives the idle suppression.
  • apps/cli suite: 628 passed.
  • pnpm run check — passes.
  • ./test.sh — 3453 passed, 1 failed. The failure is test/subagent-invocation.test.ts:48, which spawns the CLI and hits a tsx createIpcServer EINVAL on its IPC pipe under the harness's env -i isolation. Verified pre-existing: a clean main tree fails identically in the same isolated environment, and the test passes outside it.

Notes

The 500 ms window is deliberately short — it only has to cover the gaps between the keystrokes of one composition. A slow typist entering their first character sees the hint step aside for half a second and come back; that is a smaller cost than the flicker, and it is the only observable that distinguishes a composition from typing without terminal cooperation.

The composer hint is drawn whenever the editor's buffer is empty. An IME
does not put its preedit in that buffer: the terminal holds it and paints
it at the cursor itself. So while pinyin is being composed the buffer is
still empty, the editor keeps rewriting the hint into the cells the
terminal is also drawing the composing text into, and the two layers
alternate on the same cells. Visually the hint does not hide and the row
flickers.

No terminal reports composition start or end to the application, so the
suppression has to be inferred. A printable keystroke that reaches the
editor and leaves the buffer empty is exactly that: text the editor did
not consume is still with the terminal. Such a keystroke hides the hint
for 500ms and re-arms on the next one, so a whole composition stays
covered; committing into the buffer, or abandoning the composition and
letting the timer expire, brings the hint back. Keystrokes that type
nothing (arrows, Escape, Ctrl chords) do not arm it, and the bash-mode
hints follow a typed `!` prefix, so they are unaffected.

Covered by four cases in step-editor.test.ts: a composition stays hidden
across keystrokes and the hint returns on the deadline, committed text
and programmatic fills clear the state, non-composing keystrokes leave the
hint alone, and the bash-mode hint survives the idle suppression.

Co-Authored-By: Claude <noreply@anthropic.com>
@kylin1020 kylin1020 closed this Sep 23, 2026
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.

1 participant