Skip to content

fix(file-explorer): ignore IME confirm Enter in the inline name input - #25038

Closed
kambarakun wants to merge 1 commit into
stablyai:mainfrom
kambarakun:fix/file-explorer-ime-enter
Closed

kambarakun wants to merge 1 commit into
stablyai:mainfrom
kambarakun:fix/file-explorer-ime-enter

Conversation

@kambarakun

@kambarakun kambarakun commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When you name a file in the File Explorer with a Japanese, Chinese or Korean keyboard, you first type the sounds, pick the right characters, and press Enter to say "yes, these characters". Orca treated that Enter as "I'm done, create the file", so the file was created before the name was finished. Now that Enter only confirms the characters, and the next Enter creates the file.

What Changed

  • Before: in the File Explorer's New File / New Folder / Rename input, the Enter that confirms an IME conversion also submitted the input. After typing 議事録 and confirming it there was no chance to add .md — a file named 議事録 already existed and the input was gone. An Escape that cancels a conversion dismissed the input the same way.
  • After: keys that belong to the input method are left to the input method. The conversion is confirmed, the input stays open, and a normal Enter / Escape submits / cancels exactly as before.
  • Mechanism: InlineInputRow (file-explorer-inline-input-row.tsx) acted on every Enter / Escape keydown. It now asks the existing shared tracker, useImeEnterGestureOwnership() together with isImeCompositionKeyDown(), before acting, and feeds the tracker keyup and compositionstart / compositionend. The tracker is reset on blur and whenever the keyed <input> element is replaced, so ownership cannot leak into the next input.

One production file (+17/−1) and one new test file. No new helper and no second composition state machine.

Why

People who type with an IME cannot give a file a name with an extension (or any name that needs more than one conversion) without the input firing early. This is the same bug class that #7081 fixed for the worktree / tab / window rename inputs (#6980); this input was missed.

Alternative considered: a plain isComposing guard on the keydown. It is smaller, but some input methods deliver the confirmation Enter twice and only mark the first one, so the unmarked follow-up would still submit. The shared gesture tracker already covers that, and docs/reference/ime-regression-checklist.md asks callers to reuse it rather than add another state machine, so the input is wired to it the same way #22627 does.

Linked Issue

Fixes #25035

Visual Proof

Captured from a hidden Electron window (e2e build, ORCA_BACKGROUND_LAUNCH=1, disposable repo). The script opens New File, drives a Chromium IME composition over CDP (Input.imeSetComposition, ぎじろく → 議事録), then sends the confirmation Enter as a keydown marked with keyCode 229. Same script for both runs; only the production file differs.

Before (main)

Before: the confirmation Enter closes the input and a file named 議事録 already exists

After (this PR)

After: the confirmation Enter leaves the input open, and a normal Enter then creates 議事録.md

What each run recorded:

Before (main) After (this PR)
Input after the confirmation Enter closed still open, value 議事録
Files on disk after the confirmation Enter 議事録 none
After typing .md and a normal Enter — 議事録.md created, input closed

Limit: the captures exercise Chromium's composition pipeline, not a native OS input method. Separately, both sides were checked by hand on macOS with a Japanese IME: the bug in the installed app (1.4.219), and the fix in a dev build of this branch. Windows and Linux were not tried.

No media is committed to this branch. The two screenshots are served from an assets-only branch on my fork, pinned by commit SHA.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Hand-tested on macOS with a Japanese IME in a dev build of this branch (pnpm dev, local git worktree): the confirmation Enter no longer submits the File Explorer name input. The same build was also exercised through the scripted hidden-window run above.

New file-explorer-inline-input-ime-enter.test.tsx (5 tests):

  • every marked confirmation Enter is ignored, and a plain Enter then submits the full name once;
  • the unmarked Enter that follows a confirmation is swallowed in both event orders (after keyup, and before it) until the carry expires;
  • ownership is released on blur even if compositionend never arrives;
  • ownership is dropped when the keyed input element is replaced without a blur;
  • an IME-owned Escape does not cancel, a normal Escape still does.

With the production change reverted, 3 of the 5 fail; the other two cover the tracker's lifetime (blur, keyed remount), which only exists after the change.

Run locally on macOS at 4109946:

pnpm test src/renderer/src/components/right-sidebar/file-explorer-inline-input-ime-enter.test.tsx src/renderer/src/components/right-sidebar/file-explorer-inline-input-outside-click.test.tsx src/renderer/src/components/right-sidebar/file-explorer-inline-rename-flow.test.tsx src/renderer/src/lib/ime-composition-keyboard-event.test.ts
pnpm tc
pnpm lint
pnpm run check:code-quality:changed

Results: 4 files / 24 tests passed; typecheck, lint and the changed-code quality gate passed. The full pnpm test and pnpm build were not run locally (the e2e-mode build used for the captures succeeded), so those are left to CI. Windows, Linux and SSH were not run; the Windows / Linux event order is covered by the component test only.

AI Disclosure

Produced with Claude Code under my direction: Claude Fable 5.1 for investigation, planning and review, Claude Opus for the implementation. The agent also captured the evidence above and drafted this description.

Review

Review summary from the AI agent (Claude Fable 5.1, reviewing the Opus implementation):

  • Cross-platform: no platform branch added. Both confirmation-Enter event orders are covered by tests. No shortcut, modifier or path handling is touched.
  • SSH / remote / local, folder workspaces: the change is DOM key handling inside the input. The submit and cancel callbacks, and everything behind them that creates or renames the file locally, over SSH or on a remote runtime, are unchanged, so every workspace kind gets the same behavior. No IPC, RPC or wire change.
  • Agents, integrations, git providers: not touched.
  • Performance: one hook instance per open inline input and three extra event handlers; no new subscriptions or renders.
  • UI quality: no markup, class or style change.
  • Security: the same value goes through the same submit path, only later; nothing new reaches the filesystem.
  • Tracker lifetime: the IME checklist asks for every ownership tracker to be cleared on blur or disposal. It is reset on blur and in the ref callback, which also covers a keyed remount and unmount.
  • Residual risk: a native input method whose event order differs from the two covered ones. Only macOS with a Japanese IME was exercised natively.

Independent reviews run locally on 4109946 before requesting review: Codex (read-only) and the CodeRabbit CLI. Both raised the same single point and nothing else. If an Enter marked only by keyCode 229 arrives after compositionend, so that neither the event nor the tracker says "composing", and an unmarked Enter follows, the first one is ignored but does not arm the carry, and the second one submits. That is true of the code as written. It is the shared tracker's arming rule rather than this call site: ComposerParentWorktreePicker on main is wired the same way. I left it unchanged for two reasons. I have no trace of an input method producing that order in Electron. And arming on a bare Enter/229 would instead swallow the real Enter for an input method that reports a non-composing Enter as 229 and then redispatches it. Changing that rule affects every caller and needs native traces, so it does not belong in a one-input fix. Happy to follow up separately if you want it.

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

Mobile is not affected (desktop renderer component only). No settings, persisted state or wire format is involved, so there is no backwards-compatibility surface.

X: @kambarakun

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • 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)

🤖 Generated with Claude Code

The File Explorer's New File / New Folder / Rename input submitted on every
Enter keydown, including the Enter that only confirms a CJK IME conversion,
so a name typed with a Japanese, Chinese or Korean input method was created
or renamed half-typed. Escape, which the IME uses to cancel a conversion,
dismissed the input the same way.

Route the input through the shared IME Enter gesture tracker so the marked
confirm Enter and its unmarked follow-up are both ignored, and clear the
tracker on blur and when the keyed input element is replaced.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@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 no longer submits the File Explorer name input — InlineInputRow now guards its keydown with the shared useImeEnterGestureOwnership() tracker plus isImeCompositionKeyDown(), and feeds the tracker compositionstart / compositionend / keyup. The submit and cancel callbacks are untouched, so behavior for a normal Enter / Escape is unchanged (src/renderer/src/components/right-sidebar/file-explorer-inline-input-row.tsx:154).
  • Ownership lifetime is bounded — the tracker is reset in the ref callback (covering a keyed remount that skips blur) and on blur, matching the recipe in docs/reference/ime-regression-checklist.md.
  • Five regression tests — marked confirms are ignored before a plain Enter submits with the full value, the unmarked redispatch is swallowed in both macOS and Windows/Linux event orders, and blur / keyed-remount release ownership. Test 1, 2, and 5 are exact-assertion tests that fail without the production change; I ran the file locally and all 5 pass.

The wiring matches the existing reference call site in ComposerParentWorktreePicker.tsx:312, so this is a reuse of the shared state machine rather than a second one. The residual keyCode-229-after-compositionend gap the author documented lives in the tracker's arming rule and is identical on main; correctly left out of this one-input fix.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2c3fccde-236d-49d6-af67-36907582ac07
📥 Commits

Reviewing files that changed from the base of the PR and between b601b98 and 4109946.

📒 Files selected for processing (2)
  • src/renderer/src/components/right-sidebar/file-explorer-inline-input-ime-enter.test.tsx
  • src/renderer/src/components/right-sidebar/file-explorer-inline-input-row.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

InlineInputRow now checks IME composition and gesture ownership before handling Enter or Escape. It forwards keyup and composition events to the ownership state and resets that state when the input changes or blurs. Tests cover composition-confirm Enter, redispatched Enter, blur and remount behavior, and composing Escape.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 41099

The change makes the File Explorer inline input ignore IME confirmation Enter and Escape, and it comes with focused tests. No concrete merge-blocking risk was found.

🚥 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 identifies the main change: preventing IME confirmation Enter from submitting the File Explorer inline name input.
Description check ✅ Passed The description covers the required sections, explains the user impact and implementation, links issue #25035, provides visual proof, and reports testing and platform limits. It also notes that the fu…
Linked Issues check ✅ Passed #25035 requires the File Explorer New File, New Folder, and Rename inputs to ignore IME-owned Enter and Escape events while preserving normal submit and cancel behavior. InlineInputRow now uses the …
Out of Scope Changes check ✅ Passed The production change is limited to IME keyboard handling in the shared File Explorer inline input. The added tests cover the behavior required by #25035. No unrelated changes appear in the whole-PR d…
  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@kambarakun

Copy link
Copy Markdown
Contributor Author

Superseded by #25480, which incorporates and extends this fix and has now been merged. My original commit and attribution were preserved there.

Closing this PR in favor of #25480. Thanks!

@kambarakun kambarakun closed this Oct 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]: File Explorer New File / New Folder / Rename input submits on Japanese/CJK IME confirmation Enter

1 participant