Skip to content

fix(ui): prevent IME Enter from submitting rename and notes fields - #11067

Closed
nwparker wants to merge 2 commits into
stablyai:mainfrom
nwparker:nwparker/fix-ime-composition-enter
Closed

nwparker wants to merge 2 commits into
stablyai:mainfrom
nwparker:nwparker/fix-ime-composition-enter

Conversation

@nwparker

Copy link
Copy Markdown
Contributor

Description

Supersedes #10711 while preserving the original contributor commit and attribution. Prevents the Enter key used by CJK IMEs to confirm a conversion candidate from submitting project-group, host, file, worktree-name, issue, and notes inputs.

ELI5

When an IME turns typed phonetic text into a character, it first uses Enter to choose the character. Orca now waits for the next normal Enter before saving the form.

Fix proof

  • Added focused tests for isComposing, legacy keyCode === 229, and ordinary Enter in each affected surface.
  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/editor/EditorPanelHeaderPath.ime-enter.test.tsx src/renderer/src/components/editor/UntitledFileRenameDialog.ime-enter.test.tsx src/renderer/src/components/sidebar/HostRenameDialog.ime-enter.test.tsx src/renderer/src/components/sidebar/ProjectGroupNameDialog.ime-enter.test.tsx src/renderer/src/components/sidebar/WorktreeMetaDialog.ime-enter.test.tsx — 18 tests passed locally.

No-regression proof / trade-offs

Plain Enter remains covered and submits normally. The existing Cmd/Ctrl-aware screen-submit shortcut remains after the shared IME guard; native CJK IME behavior still needs manual desktop verification on macOS, Linux, and Windows.

Review

One independent native review loop: clean. It confirmed the guard precedes each explicit submit, the project-group form prevents implicit submit during composition, and no shortcut ordering conflict was found; reviewer target run reported 21/21 passing.

Performance and compatibility

The guard is a constant-time keydown predicate with no polling, I/O, or allocation-heavy path. It uses browser keyboard event state only; there are no SSH, folder-workspace, Git provider, or path behavior changes.

Evidence

No Electron screenshot was captured: the behavior is native IME interaction and the automated component tests are the available deterministic proof.

Links

Supersedes and credits #10711 (@makoto-developer). Related category issue: #10711.

0 regressions / risk: UNKNOWN — targeted automated regressions are green, but native IME confirmation remains to be exercised on all desktop platforms.

@coderabbitai

coderabbitai Bot commented Jul 28, 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: Pro Plus

Run ID: 74f56dc8-5c65-4594-9111-4674a3573d44

📥 Commits

Reviewing files that changed from the base of the PR and between 123181e857674d4f0018e406b7ad0b4adfd99e2d and b32d9af.

📒 Files selected for processing (13)
  • src/renderer/src/components/editor/EditorPanelHeaderPath.ime-enter.test.tsx
  • src/renderer/src/components/editor/EditorPanelHeaderPath.tsx
  • src/renderer/src/components/editor/UntitledFileRenameDialog.ime-enter.test.tsx
  • src/renderer/src/components/editor/UntitledFileRenameDialog.tsx
  • src/renderer/src/components/sidebar/HostRenameDialog.ime-enter.test.tsx
  • src/renderer/src/components/sidebar/HostRenameDialog.tsx
  • src/renderer/src/components/sidebar/ProjectGroupNameDialog.ime-enter.test.tsx
  • src/renderer/src/components/sidebar/ProjectGroupNameDialog.tsx
  • src/renderer/src/components/sidebar/WorktreeMetaDialog.ime-enter.test.tsx
  • src/renderer/src/components/sidebar/WorktreeMetaDialog.tsx
  • src/renderer/src/components/ui/dialog.tsx
  • src/renderer/src/lib/ime-composition-keyboard-event.test.ts
  • src/renderer/src/lib/ime-composition-keyboard-event.ts
🚧 Files skipped from review as they are similar to previous changes (13)
  • src/renderer/src/components/sidebar/HostRenameDialog.tsx
  • src/renderer/src/components/sidebar/ProjectGroupNameDialog.ime-enter.test.tsx
  • src/renderer/src/components/sidebar/WorktreeMetaDialog.ime-enter.test.tsx
  • src/renderer/src/components/sidebar/HostRenameDialog.ime-enter.test.tsx
  • src/renderer/src/components/editor/UntitledFileRenameDialog.ime-enter.test.tsx
  • src/renderer/src/lib/ime-composition-keyboard-event.ts
  • src/renderer/src/components/sidebar/WorktreeMetaDialog.tsx
  • src/renderer/src/components/editor/UntitledFileRenameDialog.tsx
  • src/renderer/src/lib/ime-composition-keyboard-event.test.ts
  • src/renderer/src/components/ui/dialog.tsx
  • src/renderer/src/components/editor/EditorPanelHeaderPath.ime-enter.test.tsx
  • src/renderer/src/components/editor/EditorPanelHeaderPath.tsx
  • src/renderer/src/components/sidebar/ProjectGroupNameDialog.tsx

📝 Walkthrough

Walkthrough

The IME keyboard event helper now accepts native and React keyboard events. Editor rename inputs, untitled-file rename fields, host and project-group rename dialogs, and worktree metadata inputs ignore composition key events. Shared dialog Escape handling also prevents closing during composition. New Vitest suites cover composing events, keyCode 229, normal Enter and Escape behavior, blur submission, modifier handling, and form submission.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.00% which is insufficient. The required threshold is 80.00%. 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 summarizes the main change: blocking IME Enter submissions in UI rename and notes fields.
Description check ✅ Passed The description is detailed and mostly matches the template’s intent, covering summary, testing, review, compatibility, and evidence.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@OrcaWin
OrcaWin force-pushed the nwparker/fix-ime-composition-enter branch from 0163a96 to dc873f2 Compare July 28, 2026 04:20

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

🧹 Nitpick comments (2)
src/renderer/src/components/editor/UntitledFileRenameDialog.tsx (1)

160-168: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate onKeyDown blocks — extract a shared handler.

The Name and Folder inputs now have byte-identical inline onKeyDown closures. Consider factoring this into one useCallback-memoized handler (similar to handleIssueKeyDown in WorktreeMetaDialog.tsx) and reusing it for both fields.

♻️ Proposed refactor
+  const handleFieldKeyDown = useCallback(
+    (e: React.KeyboardEvent<HTMLInputElement>) => {
+      if (isImeCompositionKeyDown(e)) {
+        return
+      }
+      if (e.key === 'Enter') {
+        e.preventDefault()
+        handleSubmit()
+      }
+    },
+    [handleSubmit]
+  )
+
   return (
     ...
               <Input
                 ref={setNameInputNode}
                 value={name}
                 onChange={(e) => {
                   setName(e.target.value)
                   setError(null)
                 }}
-                onKeyDown={(e) => {
-                  if (isImeCompositionKeyDown(e)) {
-                    return
-                  }
-                  if (e.key === 'Enter') {
-                    e.preventDefault()
-                    handleSubmit()
-                  }
-                }}
+                onKeyDown={handleFieldKeyDown}
                 ...
               />
     ...
               <Input
                 value={dir}
                 onChange={(e) => {
                   setDir(e.target.value)
                   setError(null)
                 }}
-                onKeyDown={(e) => {
-                  if (isImeCompositionKeyDown(e)) {
-                    return
-                  }
-                  if (e.key === 'Enter') {
-                    e.preventDefault()
-                    handleSubmit()
-                  }
-                }}
+                onKeyDown={handleFieldKeyDown}
                 className="h-8 text-xs"
               />

Also applies to: 192-200

src/renderer/src/components/sidebar/WorktreeMetaDialog.ime-enter.test.tsx (1)

71-92: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract shared IME keyboard-event test helpers.

All five new *.ime-enter.test.tsx files reimplement the same KeyboardEvent builder (with isComposing/legacy keyCode: 229 overrides) and, in three of them, an identical changeValue controlled-input setter. One shared module would avoid five copies drifting apart as IME edge cases are added. Per the path guideline against vague file names, name it after its concrete purpose rather than test-utils.

  • src/renderer/src/components/sidebar/WorktreeMetaDialog.ime-enter.test.tsx#L71-L92: import shared pressEnter/changeValue (accepting HTMLElement to cover both inputs and the textarea) instead of the local copies.
  • src/renderer/src/components/editor/EditorPanelHeaderPath.ime-enter.test.tsx#L81-L98: replace local pressKey with the shared helper (parameterized by key).
  • src/renderer/src/components/editor/UntitledFileRenameDialog.ime-enter.test.tsx#L50-L74: replace local pressEnter/changeValue with the shared helpers.
  • src/renderer/src/components/sidebar/HostRenameDialog.ime-enter.test.tsx#L50-L66: replace local pressEnter with the shared helper.
  • src/renderer/src/components/sidebar/ProjectGroupNameDialog.ime-enter.test.tsx#L48-L73: replace local pressEnter/changeValue with the shared helpers (keep the return-value variant used here for defaultPrevented assertions).
♻️ Proposed shared module
// src/renderer/src/lib/ime-composition-keyboard-event.test-helpers.ts
export function dispatchKeyDown(
  element: HTMLElement,
  key: string,
  init?: KeyboardEventInit & { keyCode?: number }
): KeyboardEvent {
  const event = new KeyboardEvent('keydown', { key, bubbles: true, cancelable: true, ...init })
  if (init?.keyCode !== undefined) {
    Object.defineProperty(event, 'keyCode', { value: init.keyCode })
  }
  element.dispatchEvent(event)
  return event
}

export function setControlledInputValue(input: HTMLInputElement, value: string): void {
  const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set
  setter?.call(input, value)
  input.dispatchEvent(new Event('input', { bubbles: true }))
}

Source: Path instructions


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5cc8d733-4818-42f4-9270-8a4f4255dd61

📥 Commits

Reviewing files that changed from the base of the PR and between badf911 and dc873f218635e55f386978630bdf63fe74913597.

📒 Files selected for processing (13)
  • src/renderer/src/components/editor/EditorPanelHeaderPath.ime-enter.test.tsx
  • src/renderer/src/components/editor/EditorPanelHeaderPath.tsx
  • src/renderer/src/components/editor/UntitledFileRenameDialog.ime-enter.test.tsx
  • src/renderer/src/components/editor/UntitledFileRenameDialog.tsx
  • src/renderer/src/components/sidebar/HostRenameDialog.ime-enter.test.tsx
  • src/renderer/src/components/sidebar/HostRenameDialog.tsx
  • src/renderer/src/components/sidebar/ProjectGroupNameDialog.ime-enter.test.tsx
  • src/renderer/src/components/sidebar/ProjectGroupNameDialog.tsx
  • src/renderer/src/components/sidebar/WorktreeMetaDialog.ime-enter.test.tsx
  • src/renderer/src/components/sidebar/WorktreeMetaDialog.tsx
  • src/renderer/src/components/ui/dialog.tsx
  • src/renderer/src/lib/ime-composition-keyboard-event.test.ts
  • src/renderer/src/lib/ime-composition-keyboard-event.ts

@OrcaWin
OrcaWin force-pushed the nwparker/fix-ime-composition-enter branch from dc873f2 to 123181e Compare July 28, 2026 05:50
makoto-developer and others added 2 commits July 28, 2026 12:55
A CJK IME fires a keydown for the Enter that only confirms a conversion
candidate. Five inputs committed on that keydown, saving a half-converted
value while the user was still typing:

- Project group name dialog (create/rename) — submitted the form implicitly
- Host rename dialog
- Worktree details dialog — display name, GH issue/PR, and the notes textarea,
  which saves on a plain Enter
- Untitled file rename dialog — file name and folder
- Editor header inline file rename

They now use the existing isImeCompositionKeyDown() helper, matching the
guards already in place for worktree titles, tabs, and the workspace name
field.
@nwparker

nwparker commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Landed, and then some — closing.

The predicate this PR introduced (src/renderer/src/lib/ime-composition-keyboard-event.ts) is on main and is now the shared gate for Enter-during-composition across the app. Where this PR covered 5 surfaces, main carries 42 .ime-enter.test files, plus ime-enter-gesture-ownership-contract.test.ts pinning the ownership rule itself so new dialogs cannot quietly skip it.

Both surfaces you targeted are covered: WorktreeMetaDialog (its Enter handling since extracted into worktree-meta-enter-handlers.ts) and ProjectGroupNameDialog, along with the editor rename paths.

Thanks — the framing that Enter-during-composition is an ownership question rather than a per-dialog bug is what made it generalize this far.

@nwparker nwparker closed this Aug 8, 2026
nwparker pushed a commit that referenced this pull request Oct 4, 2026
Restore IME Enter protection in workspace details by reusing the existing composition tracker. Reset Notes ownership at textarea detachment and preserve sizing behavior. Repair isolated native test-window delivery without changing the production foreground policy or original native input assertions.

Fixes #24097

Related contributor history: #10711, #11067, #13128, #13282.
Original implementation and macOS recordings: @setodeve, commit b30f095.
Verified on required stock Linux X11/Wayland checks and independent frozen-source review.

Co-authored-by: setodeve <keinick11@outlook.com>
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.

3 participants