Skip to content

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

Closed
tb-soshiro wants to merge 1 commit into
stablyai:mainfrom
tb-soshiro:fix/native-chat-question-ime-enter
Closed

tb-soshiro wants to merge 1 commit into
stablyai:mainfrom
tb-soshiro:fix/native-chat-question-ime-enter

Conversation

@tb-soshiro

@tb-soshiro tb-soshiro commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Japanese, Chinese and Korean keyboards use Enter to confirm a converted word before it is really typed. The "Other" answer box in the AskUserQuestion card treated that confirm-Enter as "send", so the answer was sent while the user was still choosing the word. Now that Enter only confirms the word, and the next Enter sends.

What Changed

  • NativeChatQuestionCard.tsx: the free-text ("Other") input's onKeyDown now returns early when the keydown belongs to the IME, using the existing helpers useImeEnterGestureOwnership + isImeCompositionKeyDown from @/lib/ime-composition-keyboard-event. The input also wires onKeyUp / onCompositionStart / onCompositionEnd so the gesture carry works, and onBlur={imeEnter.reset} so a composition that never sees compositionend (paste replaced it, the row unmounted) cannot leave the card swallowing every later Enter. This is the same pairing ComposerParentWorktreePicker uses, plus the blur reset NativeChatComposerField and the tab-bar search field already do.
  • NativeChatQuestionCard.ime-enter.test.tsx (new): seven cases. isComposing alone, isComposing + keyCode 229, keyCode 229 alone, and the macOS "marked Enter → keyup → unmarked Enter" sequence do not submit; the next deliberate Enter after the carry expires does submit; blur without compositionend releases ownership; a plain Enter still submits the typed text. Removing onKeyUp or onBlur from the input fails a test.

No behavior change for non-IME input: a plain Enter submits exactly as before, and an empty-field Enter stays a no-op.

Why

The handler only checked e.key === 'Enter', so the confirm keystroke and the submit keystroke were indistinguishable. Every other Enter-to-commit input in Orca (workspace name, rename fields, comment composer, search bar) already guards this; the question card was the one left out. Using the shared helpers rather than a bare isComposing check also covers macOS, where the confirm redispatches an unmarked Enter after keyup (see the comment in ime-composition-keyboard-event.ts).

Note: #17820 is assigned to @nwparker — apologies if this crosses an in-flight branch. It is a small, self-contained change, so I hope it is useful as-is; happy to close it in favor of yours otherwise.

Linked Issue

Fixes #17820

Visual Proof

Chat UI, Japanese locale, macOS. In the "Other" field, にほんご is typed through the IME and converted to 日本語 (underlined = still composing), then Enter is pressed to confirm the conversion.

After, with a real IME (Google Japanese Input), by hand:

Candidates open Converted, still composing After the confirming Enter
candidates converted stays open

The confirming Enter commits 日本語 into the field and nothing is sent; the card stays open with "Submit".

Before vs. after, same scripted input on both builds:

Composing 日本語 After the confirming Enter
Before (main) before: composing before: submitted mid-composition
Submitted immediately — the card flips to "Sending…" while the IME is still open.
After (this PR) after: composing after: stays open
Enter only confirms 日本語; the card stays open with "Submit".

A second, plain Enter then delivers the answer:

after: delivered on plain Enter

The before/after pair was captured on a pnpm dev build (before = the component hot-swapped to its main version). That composition was driven through CDP (Input.imeSetComposition + an Enter keydown with keyCode 229 while composing) so both runs are identical; the real-IME screenshots above show the same fixed build by hand.

Testing

  • macOS 26 (arm64), macOS built-in Japanese IME and Google Japanese Input, Claude Code in the Chat UI (terminal-backed path; the structured native chat path renders the same card).

  • Reproduced the bug on the released 1.4.197 build, then confirmed the fix on a pnpm dev build of this branch.

  • pnpm lint and pnpm typecheck pass locally. pnpm test: 7960 files / 73,846 tests pass; the one failing suite is config/scripts/workflow-ref-reachability.test.mjs, which needs git init --ref-format=reftable (git ≥ 2.45) and my machine has git 2.41 — unrelated to this change. pnpm build not run locally; relying on CI.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Claude Code (Claude Fable 5.1) drafted the change and tests; I reviewed the diff and did the manual IME verification.

Review

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 change; no platform, SSH/remote, or mobile impact beyond the desktop card. Benefits all CJK IME users (Japanese, Chinese Pinyin/Zhuyin, Korean).

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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 stablyai#17820

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

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 490b413f-3555-4099-9ed7-8b4ce7571534

📥 Commits

Reviewing files that changed from the base of the PR and between 9d29e68 and bc1202f.

📒 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; 9 remain after this review.


📝 Walkthrough

Walkthrough

NativeChatQuestionCard now detects IME composition Enter events and prevents them from confirming free-text answers. It tracks keydown, keyup, blur, composition start, and composition end events. New tests cover composing Enter events, macOS redispatch, ownership expiry, blur cleanup, and plain Enter submission.

Merge Risk: ⚪ Minimal · up to bc120

The free-text answer field now commits CJK IME conversions without submitting them, while normal Enter submission remains covered. No concrete merge-blocking risk remains.

🚥 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
Linked Issues check ✅ Passed The implementation satisfies issue #17820 by ignoring IME confirmation Enter events, handling macOS redispatch behavior, preserving normal Enter submission, and adding coverage for composition and res…
Out of Scope Changes check ✅ Passed The changes are limited to the native chat question card and focused tests for IME Enter handling. No unrelated code changes are identified.
Title check ✅ Passed The title clearly and concisely identifies the main fix: preventing IME confirmation Enter events from submitting the AskUserQuestion free-text field.
Description check ✅ Passed The description follows the repository template and includes the change, rationale, linked issue, visual proof, testing results, AI disclosure, scope notes, and completed checklist items.
  • Fix all pre-merge checks with AI

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.

@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 confirm-Enter guard on the free-text input — NativeChatQuestionCard.tsx now returns early from onKeyDown for IME-owned keydowns via imeEnter.ownsKeyDown(e) || isImeCompositionKeyDown(e), and wires onKeyUp, onCompositionStart, onCompositionEnd, and onBlur={imeEnter.reset}.
  • Seven-case happy-dom test — NativeChatQuestionCard.ime-enter.test.tsx covers isComposing, keyCode 229, the macOS unmarked-redispatch carry, carry expiry, blur-without-compositionend release, and the unaffected plain-Enter path.

The change is well-scoped and correctly reuses the shared IME helpers. The pairing matches ComposerParentWorktreePicker exactly (same ownsKeyDown || isImeCompositionKeyDown guard plus onKeyUp/onCompositionStart/onCompositionEnd), and the added onBlur={imeEnter.reset} is the same defensive reset NativeChatComposerField and the tab-bar search already use. The input here is controlled (value/onChange), so omitting the composer field's settleImeValue is correct. Non-IME input is unaffected (no isComposing, keyCode 13 falls through to the existing Enter path), and the assertions pin exact values, so they would fail without the guard, the onKeyUp wiring, or the blur reset.

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

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

Thanks for this — the explanation of how Japanese input actually works was the useful part, and it is exactly why the bug is easy to miss.

I checked and it is still broken on main: the answer field's Enter handler is a bare

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

with no composition check at all (NativeChatQuestionCard.tsx:208). Yours really was the one input in the app that got skipped — the mobile question card has no Enter-submit handler, so there is no second site to fix.

Reaching for the shared Enter helper rather than a plain "is something being composed" test was the right call. It also catches the case where the confirming Enter is delivered a second time without being marked, which a simpler check would let through and send.

Two process notes:

  • Your CI had never actually run — this is a fork PR and the workflow runs were sitting in action_required, so only the AI reviewer had executed. I have approved them; merging once they are green.
  • One of the automated reviewers asked for more doc comments on the new code. Please ignore that. Our guidance is short comments only where they explain something non-obvious, and the one you wrote does exactly that.

Separately, you are right that Shift+Enter also submits when nothing is being composed. I would rather not widen this change to cover it — I will track that on its own ticket.

Your branch is a couple of weeks old and still applies without a conflict, so there is nothing to rebase. Good to go.

@nwparker

Copy link
Copy Markdown
Contributor

Taking this over and continuing it in #22627, with your commit and authorship preserved. Nothing was wrong with the fix — it is kept verbatim.

Two mechanical reasons for a new PR:

  1. Your fork now redirects to a different account, so I can no longer push to this branch to finish it.
  2. This branch carried around ten thousand commits of older history, and its CI had never run — the workflow runs sat unapproved from the day you opened it, so only the automated reviewer ever executed. I cherry-picked your commit onto current main so the real suites run against something current.

I checked the bug is still live before doing any of that: the answer field's Enter handler on main is still a bare if (e.key === 'Enter') with no composition check, and the mobile question card has no Enter-submit handler — so yours really was the one input in the app that got skipped.

Reaching for the shared Enter helper instead of a plain "is something being composed" test was the right instinct, and I said so in the new PR. It catches the confirming Enter being delivered a second time unmarked, which a simpler check would let through and send.

One of the automated reviewers asked for more doc comments on the new code. That was wrong and I ignored it — our guidance is short comments only where they explain something non-obvious, which yours does.

You are right that Shift+Enter also submits when nothing is being composed. I left it out of scope deliberately and will track it separately rather than widen this.

Closing in favour of #22627. Thank you — the explanation of how Japanese input actually behaves is what made this easy to verify.

@nwparker nwparker closed this Sep 24, 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)

2 participants