Skip to content

fix(terminal): align Cursor Agent IME preedit anchor - #14982

Merged
nwparker merged 1 commit into
mainfrom
nwparker/cursor-agent-ime-preedit-anchor
Aug 17, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/cursor-agent-ime-preedit-anchor

Conversation

@nwparker

@nwparker nwparker commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​58
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​32

Fixes #14902

Summary

  • recognize Cursor Agent follow-up prompts after the header scrolls away
  • keep xterm's visible composition overlay aligned with the corrected IME textarea anchor
  • retain Cursor Agent recognition for typed follow-ups without affecting ordinary terminal cursor positioning

Validation

  • 17 focused IME anchor tests
  • 92 related terminal IME tests
  • pnpm typecheck
  • pnpm lint
  • M4 Air Electron/CDP validation on the exact commit: textarea and .composition-view both moved from PTY cursor row 304px to prompt row 112px, with matching rects

M4 Air visual proof

The visible preedit ni is rendered directly on the → Add a follow-up prompt row.

orca-14902-m4-after.png

Validation gap

The M4 Air did not have Cursor Agent installed or an enabled CJK input source. The rendered Cursor Agent screen and composition lifecycle were exercised through xterm in the exact dev build; a physical Cursor Agent + native IME keystroke pass was not possible on that machine.

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change expands Cursor Agent IME anchor detection to support both initial and follow-up prompts. It adds persistent Cursor Agent state for later composition updates. The candidate anchor now positions and sizes xterm’s .composition-view alongside the textarea. Deferred corrections reapply Cursor Agent-specific positioning. Tests cover ordinary shell output, scrolled follow-up prompts, deferred overlay correction, and subsequent Cursor Agent composition updates.

Merge Risk: 🟡 Moderate · up to 6f39e

After using Cursor Agent once, later ordinary terminal output beginning with → may cause the IME composition overlay to appear in the wrong location. This is a bounded but concrete terminal-input correctness issue that should be fixed or explicitly accepted before merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the fix and validation, but it omits several required template sections and provides only after-state visual proof. Add the required ELI5, What Changed, Why, and checklist sections, plus before-and-after visual proof or an applicable N/A explanation.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the terminal change and the Cursor Agent IME preedit anchoring fix.
Linked Issues check ✅ Passed For [#14902], the changes align textarea and .composition-view anchors, support follow-up prompts, and preserve ordinary terminal positioning.
Out of Scope Changes check ✅ Passed All changes are limited to Cursor Agent IME anchor resolution, composition overlay positioning, and focused tests for issue [#14902].
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c3b212c2-aa55-4cb6-9487-0096956ee3e7

📥 Commits

Reviewing files that changed from the base of the PR and between a324ee2 and 6f39e1e.

📒 Files selected for processing (4)
  • src/renderer/src/lib/pane-manager/terminal-ime-anchor.test.ts
  • src/renderer/src/lib/pane-manager/terminal-ime-anchor.ts
  • src/renderer/src/lib/pane-manager/terminal-ime-candidate-anchor.test.ts
  • src/renderer/src/lib/pane-manager/terminal-ime-candidate-anchor.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 7 remain after this review.

Comment on lines +103 to +105
knownCursorAgent: cursorAgentSeen
})
cursorAgentSeen ||= cursorAgentAnchor !== null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Scope Cursor Agent detection to the active Cursor Agent context.

cursorAgentSeen remains true for the lifetime of this installation. After one Cursor Agent composition, any later non-empty → line can resolve as Cursor Agent input, even when the terminal has returned to ordinary output. This moves the textarea and composition view away from the terminal cursor.

Reset this state when the Cursor Agent context ends, or derive it from durable session metadata. Add a regression test that switches from a recognized Cursor Agent screen to ordinary → output. This preserves normal terminal positioning outside Cursor Agent contexts.

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.

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

1 participant