Skip to content

[Bug]: Cursor Agent IME preedit (.composition-view) paints one row below the prompt (Doubao / CJK) #14902

Closed

Description

@tplucky

Operating system

macOS

Orca version

v1.4.183

Details

Short summary

In a Cursor Agent pane, Doubao (and likely other CJK IMEs) paint the xterm.js .composition-view preedit one row below the prompt, while the software caret and the IME candidate window sit on the prompt row. After commit, text usually lands in the input; during composition it flashes under the status line.

This is specific to Cursor Agent's Ink TUI: the PTY cursor is left on the blank line after Ink's trailing \n, and Orca's installTerminalImeCandidateAnchor remaps only textarea, not .composition-view.

What happened?

New Cursor Agent session (header still visible):

Cursor Agent
v2026.08.11-e8db854
Tip: Try Cursor Grok 4.5 …

┌ input ─────────────────────────────────┐
│ → [P]lan, search, build anything       │  ← Ink software caret (correct)
│         ┌ 1 多发点  2 等分点 ┐           │  ← Doubao candidate (roughly correct)
└────────────────────────────────────────┘
Cursor Grok 4.6 Extra High Fast · ~/projects/agent · master
d'f'd                                        ← xterm .composition-view (wrong row)
  • Keyboard typing into the prompt is fine.
  • The visible block/underline caret is on P of the placeholder (correct).
  • Doubao's candidate bubble is near the prompt (textarea remapped).
  • The in-terminal preedit (d'f'd) is drawn under the status line.

On a later follow-up screen (Add a follow-up, header scrolled away) the same IME text can stay one row low even after commit, because the Cursor-agent heuristic bails out.

Does not reproduce in macOS Terminal.app / iTerm with the same cursor-agent binary.

How can we reproduce it?

  1. macOS, Orca 1.4.183, cursor-agent 2026.08.11-e8db854.
  2. Switch input source to Doubao IME (or another CJK IME that shows an in-terminal preedit).
  3. Open a new Cursor Agent pane. Confirm the top of the screen still has a full line Cursor Agent and the placeholder is Plan, search, build anything.
  4. Focus the prompt and start voice input (or type pinyin without committing).
  5. Observe:
    • caret stays on the prompt row
    • IME candidate window is near the prompt
    • preedit string appears one row below the status line
  6. Optional: send one turn so the UI becomes Add a follow-up and the Cursor Agent header scrolls off. Repeat step 4 — remapping often stops entirely.

Expected behavior

.composition-view and the hidden textarea should share the same Cursor Agent input anchor (→ + 1). Preedit should appear on the prompt row, at the software caret.

Related (not duplicates)

Root cause (from 1.4.183 asar)

Cursor Agent (Ink) renders the prompt, then writes a trailing \n. The PTY cursor sits on the blank line under the status. Ink draws its own caret inside the prompt.

Orca already special-cases this:

// resolveCursorAgentImeAnchor
CURSOR_AGENT_HEADER = "Cursor Agent"
CURSOR_AGENT_INPUT_MARKER = "→"
CURSOR_AGENT_EMPTY_PROMPT = "Plan, search, build anything"
CURSOR_AGENT_HEADER_SCAN_ROWS = 6

// only runs if PTY cursorX === 0 AND that row is blank
// then requires a full-line "Cursor Agent" in the top 6 visible rows
// then finds "→ " and remaps terminal.textarea

installTerminalImeCandidateAnchor moves only textarea.style.top/left.

xterm.js CompositionHelper.updateCompositionElements() then:

  1. Places .composition-view at buffer.x / buffer.y (the PTY cursor — the blank row).
  2. Moves textarea back to that same cell.
  3. Both sides use a deferred setTimeout(0), so they race. Result: candidate window can stay on the prompt (textarea last-wins) while .composition-view stays on the PTY row.

xterm.css even has: /* TODO: Composition position got messed up somewhere */.

Two extra heuristic holes that break follow-up / newer Cursor CLI:

  1. Header gate: after one turn the visible top is no longer a lone Cursor Agent line → hasCursorAgentHeader is false → remapping disabled.
  2. Empty prompt is hard-coded to Plan, search, build anything. Current follow-up placeholder is Add a follow-up, so the line is treated as already-typed and the column jumps to the end of the placeholder.

Suggested fix (Orca)

  1. In installTerminalImeCandidateAnchor, apply the same anchor to .composition-view (top/left/height/lineHeight), not just textarea.
  2. Re-apply after xterm's deferred updateCompositionElements (rAF or double rAF; current setTimeout(0) loses the race).
  3. Drop the “top 6 rows == Cursor Agent” requirement. Scan from the bottom for → (already done in findCursorAgentScreenInputAnchor).
  4. Treat Add a follow-up (and other empty placeholders) as empty, same as Plan, search, build anything.

The durable fix on the agent side is for Cursor CLI to CUP the real PTY cursor onto the prompt cell each frame. That is outside Orca; the four items above make the existing remapper actually win.

Environment

  • macOS
  • Orca 1.4.183 (TERM_PROGRAM=Orca, TERM=xterm-256color)
  • cursor-agent 2026.08.11-e8db854
  • Input method: Doubao IME (/Library/Input Methods/DoubaoIme.app) — in-terminal preedit + candidate window
  • Terminal settings at repro: default Cursor Agent pane (reproduced without relying on font/GPU tweaks)

Activity

  1. added
    os:macos
    on Aug 16, 2026
  2. AmethystLiang commented on Aug 16, 2026

    @AmethystLiang
    Contributor

    thanks for reporting. looking into it. there might already be a PR fixing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

os:macos

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions