Skip to content

fix(native-chat): ignore IME confirmation Enter in the AskUserQuestion free-text field - #22627

Closed
nwparker wants to merge 1 commit into
mainfrom
nwparker/native-chat-question-ime-enter
Closed

nwparker wants to merge 1 commit into
mainfrom
nwparker/native-chat-question-ime-enter

Conversation

@nwparker

@nwparker nwparker commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​167 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​167
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​14 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​14

ELI5

When you answer an agent's question in native chat, there's an "Other" box for typing your own answer. Enter sends it.

Japanese, Chinese and Korean input also use Enter — to confirm which characters you meant. So for those users, the first Enter sent a half-finished answer instead of confirming the word. There was no way to type a CJK answer in that box.

What Changed

Before: typing にほんご in the Other field and pressing Enter to confirm the conversion submitted にほんご mid-composition, in whatever half-converted state it was in.

After: the confirming Enter confirms. A second, deliberate Enter sends.

Mechanism. The field's handler was a bare:

onKeyDown={(e) => {
  if (e.key === 'Enter') { e.preventDefault(); confirm(true) }
}}

with no composition check at all. It now asks the shared helper the rest of the app already uses, which is the right call rather than a hand-rolled isComposing test: that helper checks isComposing, keyCode === 229, and both again on nativeEvent, and pairs it with the gesture-ownership carry. That matters because the confirming Enter is delivered twice and only the first is marked — a simpler check lets the second one through and sends anyway.

Why this supersedes #19288

Opened by @tb-soshiro, whose fix and tests this keeps verbatim. Their fork now redirects to an account I cannot push to, so the work continues here with their commit and authorship preserved.

The only change is mechanical: their branch carried ~10,000 commits of old history and its CI had never run — the workflow runs sat unapproved from the day it opened, so only the automated reviewer ever executed. I cherry-picked their commit onto current main so CI runs on something current.

I verified the bug is still live before doing so: NativeChatQuestionCard.tsx on main still has the bare Enter handler, and the mobile question card has no Enter-submit handler, so this really was the one input in the app that got skipped.

Linked Issue

Fixes #17820

Supersedes #19288.

Visual Proof

N/A — this changes when a keystroke submits, not what is drawn. The before/after is covered by the tests below, which drive the real component with recorded CJK Enter shapes.

Testing

  • Automated tests added/updated
pnpm vitest run src/renderer/src/components/native-chat
  Test Files  186 passed (186)
  Tests       1867 passed (1867)

pnpm tc:web — clean

The author's seven new cases pin the marked Enter, the unmarked replay, and ordinary Enter still submitting. Restoring the old handler fails four of them.

AI Disclosure

Claude Opus 5 was used to verify the bug is still live on main, rebase the change onto current main, and re-run the suites. The fix and its tests are the original author's.

Review

One thing deliberately left out of scope: Shift+Enter also submits when nothing is being composed, which #17820 mentions. Widening this change to cover it would mix two behaviours; I would rather track it separately.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Renderer-only, one component. No platform-specific paths, no wire fields, no new permissions. Mobile is unaffected — its question card has no Enter-submit handler to fix.

Checklist

  • Small and focused
  • Explained what changed and why
  • Visual proof N/A with reason
  • Self-reviewed for correctness, security and performance
  • Cross-platform, SSH/remote and shortcut impact considered
  • Typecheck and targeted suites run locally; CI covers the rest

…n free-text field

The "Other" input submitted the answer on the Enter that only confirms a
CJK IME conversion candidate, so Japanese/Chinese/Korean users delivered a
half-converted string mid-composition. Guard the keydown with the shared
IME helpers (isComposing / keyCode 229, plus the gesture carry that covers
the unmarked Enter macOS redispatches after keyup), matching the other
Enter-to-commit inputs.

Fixes #17820

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NB7zwBTfSVwgYrnUzpXRYo
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The NativeChat question card now ignores Enter keydowns associated with IME composition or ownership of an IME Enter gesture. Other Enter keydowns still submit the free-text answer. Tests cover composition events, macOS-style key codes, redispatched Enter, focus-out, guard expiry, and plain Enter submission.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🟡 Moderate · up to 820d9

A 229-only IME confirmation followed by an unmarked Enter can submit the “Other” answer before the user deliberately submits it. Cover that sequence before merging unless the remaining risk is explicitly accepted.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: preventing IME confirmation Enter presses from submitting the native chat AskUserQuestion free-text field.
Description check ✅ Passed The description is complete and relevant. It includes the user impact, mechanism, rationale, linked issue, visual-proof explanation, testing results, AI disclosure, scope notes, and checklist status. …
Linked Issues check ✅ Passed Issue #17820 requires the CJK composition-confirming Enter to avoid submission and a later deliberate Enter to submit. NativeChatQuestionCard.tsx uses isImeCompositionKeyDown and `useImeEnterGestu…
Out of Scope Changes check ✅ Passed The changes are limited to the native chat question card and focused IME Enter tests. The helper integration and gesture tests directly support issue #17820. No unrelated product behavior is introduce…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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: Advanced

Run ID: dd7aaeb8-b175-4b5a-b1ef-1a384711b0e5

📥 Commits

Reviewing files that changed from the base of the PR and between 122b8c2 and 820d9f3.

📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/NativeChatQuestionCard.ime-enter.test.tsx
  • src/renderer/src/components/native-chat/NativeChatQuestionCard.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

onKeyDown={(e) => {
// Why: a CJK confirm Enter arrives twice and only the first is marked, so
// pair the marked check with the gesture carry (#17820).
if (imeEnter.ownsKeyDown(e) || isImeCompositionKeyDown(e)) {

@coderabbitai coderabbitai Bot Sep 24, 2026 •

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 | ⚡ Quick win

Arm gesture ownership for a 229-only confirmation Enter.

If an IME reports its confirmation Enter with keyCode === 229 but no composition flag or compositionstart, ownsKeyDown does not arm pendingEnter. isImeCompositionKeyDown ignores that first Enter, but a following unmarked Enter reaches confirm(true) and submits the answer. Update the shared gesture helper to carry this confirmation shape, and test both keydowns in one sequence.

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.

820d9f3 を macOS 26.5.2 / Electron 43.7.0、Apple 日本語-ローマ字入力で手入力確認しました。イベントハンドラや IME の状態を変更しない記録器で採取しています。

  • ライブ変換 OFF の 3 試行では、確定用の Enter 1 回でカードが残り、意図して押した次の Enter で「日本語」が送信され、返答が届きました。
  • 確定 Enter は毎回 key=Enter / keyCode=229 / isComposing=true で、ヘルパーも composing=true でした。このスレッドの「変換中フラグのない Enter/229」は、この 3 試行では観測していません。また、同じ確定操作からの通常 Enter/13 の再送も観測していません。
  • ON では別途、Enter 1 回後に約 13 秒待っても送信されないことを確認しました。その後、記録用コマンドの誤貼り付けを削除してから、追加の Enter 1 回で送信を確認しています。途中編集があるため、OFF の 3 試行とは分けて扱っています。

これは単一環境の観測で、指摘されたイベント列が他の入力方式や条件で発生する可能性を否定するものではありません。人工イベントでは、その指摘の順序で送信処理へ到達することも確認できており、今回の結果を指摘の解消とは扱っていません。

記録上 compositionend は isTrusted=false でしたが、原因は未確認です。手入力であったことは操作者の記録に基づきます。

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.

@kambarakun 詳細な検証と、結果の扱いについての説明をありがとうございます。

  • ライブ変換 OFF の3試行では、期待どおりの動作を確認できたと理解しました。ただし、確定 Enter には composition のフラグとヘルパーの状態があり、指摘した「フラグなし Enter/229」とは別の条件です。
  • ライブ変換 ON の結果は、途中編集を含むため、OFF の3試行とは分けて扱います。
  • 人工イベントでは指摘した順序で送信処理へ到達する一方、その順序が実機で発生することは未確認です。指摘は、実機で再現済みの不具合ではなく、特定のイベント列に対する未解消の懸念として扱います。

また、確定 Enter が常に二重に届くような説明は一般化しすぎでした。今回の実機観測は、その前提を裏付けていません。

compositionend の isTrusted=false は原因不明として扱います。この値だけで、手入力ではなかったとは判断しません。


✏️ Learnings added
Learnt from: kambarakun
Repo: stablyai/orca PR: 22627
File: src/renderer/src/components/native-chat/NativeChatQuestionCard.tsx:216-216
Timestamp: 2026-10-04T17:50:38.321Z
Learning: In reviews of src/renderer/src/components/native-chat/NativeChatQuestionCard.tsx and useImeEnterGestureOwnership, do not assume that a CJK IME confirmation Enter always produces an unmarked Enter replay. Distinguish observed native event sequences from synthetic sequences. Successful handling of a marked Enter/229 does not establish handling of an unmarked Enter/229 followed by Enter/13; synthetic reproduction of that sequence does not establish that it occurs in a real IME environment.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • IME-safe Enter in the question card's free-text row — NativeChatQuestionCard.tsx now routes the "Other" input's keydown through useImeEnterGestureOwnership / isImeCompositionKeyDown, so a CJK confirm Enter confirms instead of submitting mid-composition (#17820), and wires onKeyUp / onCompositionStart / onCompositionEnd plus onBlur reset for the two-keydown confirm gesture.
  • New focused suite — NativeChatQuestionCard.ime-enter.test.tsx pins the marked Enter, the macOS unmarked redispatch swallow, the later deliberate Enter submit, blur-released composition, and plain Enter still submitting.

Verification performed in this run

  • Ran the new suite plus the existing NativeChatQuestionCard suite: 14/14 pass.
  • Neutered the guard (if (false && …)) in place and re-ran: exactly 4 of the 7 new cases fail, matching the PR's claim — the tests exercise the real handler, not a mock path. Restored afterward (tree clean).
  • Ran the whole native-chat directory: 186 files / 1867 tests pass. pnpm run typecheck:web exits 0.
  • Confirmed the mobile claim: MobileNativeChatAsk.tsx has no Enter-submit handler, so it is genuinely unaffected.

The guard pattern matches the existing ComposerParentWorktreePicker integration, the onBlur reset correctly clears composition state so a subsequent Enter submits, and the deliberately out-of-scope Shift+Enter behavior is unchanged and documented.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker

nwparker commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — the linked issue (#17820) has been resolved on main by #28609 (ae8842306b), #30192 (a4a0e605ee). Thanks for the contribution!

@nwparker nwparker closed this Nov 5, 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.

[Bug]: AskUserQuestion "Other" free-text field submits on Japanese/CJK IME confirmation Enter (missing isComposing guard)

3 participants