Skip to content

WEN-31: preserve IME input while issue editor loads#5637

Open
beastpu wants to merge 2 commits into
multica-ai:mainfrom
beastpu:fix/5617-ime-composer-focus
Open

WEN-31: preserve IME input while issue editor loads#5637
beastpu wants to merge 2 commits into
multica-ai:mainfrom
beastpu:fix/5617-ime-composer-focus

Conversation

@beastpu

@beastpu beastpu commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #5617.

This is a real product bug: empty issue comment and reply composers rendered a focusable static shell, mounted Tiptap asynchronously after intent, then replaced the focused shell when Tiptap reported ready. Replacing that node during a Chinese/Japanese/Korean IME composition cancels the native composition and splits input such as wo instead of . Agent-query rerenders preserve the editor node; the shell-to-editor handoff is the failing boundary.

The fix keeps lazy editor initialization, but makes the handoff shell a native textarea that can receive input. Tiptap mounts hidden in the background. If IME composition overlaps readiness in either order, the swap waits for compositionend; completed shell text is adopted into Tiptap and focus lands at the end. Main comments and thread replies share the behavior.

Multica work item: WEN-31

Related Issue

Fixes #5617

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Refactor / code improvement (no behavior change)
  • Documentation update
  • Tests (adding or improving test coverage)
  • CI / infrastructure

Changes Made

  • packages/views/editor/use-lazy-editor.ts: preserve an editable stand-in across IME composition, including the boundary where readiness and composition start are batched in the reverse order; adopt pending text before the swap and focus the live editor at the end.
  • packages/views/editor/content-editor.tsx: expose an explicit end-focus operation for handoff callers.
  • packages/views/issues/components/comment-input.tsx: use an editable, draft-aware native handoff shell for the main composer.
  • packages/views/issues/components/reply-input.tsx: apply the same handoff to thread replies.
  • Hook, real-editor, and component regression tests cover both readiness/composition orderings, ordinary startup input, both composer entry points, content adoption, focus, and existing upload behavior.

How to Test

  1. Open an issue with an empty comment composer and switch to a Chinese IME.
  2. Focus the composer and start typing wo immediately while the rich editor initializes.
  3. Verify composition is not interrupted, is preserved, and subsequent input is appended after it. Repeat in a thread reply.
  4. Repeat with ordinary non-IME text typed immediately after focus; verify no startup characters are lost.

Automated verification run after review fixes:

  • pnpm -C packages/views exec vitest run issues/components/comment-composers.test.tsx editor/use-lazy-editor.test.ts editor/content-editor.test.tsx — 59/59 passed.
  • pnpm --filter @multica/views typecheck — passed.
  • pnpm --filter @multica/views lint — 0 errors; 19 pre-existing warnings in untouched files.
  • pnpm --filter @multica/views test — 234 files, 2687/2687 tests passed.

Checklist

  • I have included a thinking path that traces from project context to this change
  • I have run tests locally and they pass
  • I have added or updated tests where applicable
  • If this change affects the UI, I have included before/after screenshots
  • I have updated relevant documentation to reflect my changes (inline lifecycle contract; no user documentation is affected)
  • If I added a new runtime / coding tool / UI tab, I synced the change to landing copy and relevant docs (N/A)
  • If this PR touches Chinese product copy, I checked it against the Chinese conventions (N/A; no copy changed)
  • I have considered and documented any risks above
  • I will address all reviewer comments before requesting merge

Risks considered

  • The performance optimization remains intact: untouched composers avoid Tiptap mount cost until focus, and the real editor initializes hidden after intent.
  • Plain input received during the short startup window is adopted through the editor's existing Markdown pipeline.
  • File-only activation still queues uploads and does not steal focus.
  • The native textarea preserves keyboard and screen-reader text-entry semantics during initialization.
  • Review specifically tested both event orderings: composition already active when ready arrives, and ready queued before composition starts in the same React batch.

AI Disclosure

AI tool used: OpenAI Codex (Multica Agent)

Prompt / approach: Investigated GitHub #5617 on current main, isolated the shell-to-editor focus transfer, wrote delayed-readiness IME regressions, implemented a composition-aware handoff, then reviewed the PR as an external change. That review found the reverse-order batched ready/composition-start gap, demonstrated it with a failing test on the original PR commit, patched it, added ordinary-input and real-editor contract tests, and reran targeted plus package-wide verification.

Screenshots (optional)

Not included: the visible layout is unchanged; the regression is an IME/focus timing boundary covered by deterministic component and hook tests.

Co-authored-by: multica-agent <github@multica.ai>
@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

@beastpu is attempting to deploy a commit to the IndexLabs Team on Vercel.

A member of the Team first needs to authorize it.

Co-authored-by: multica-agent <github@multica.ai>
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]: Issue comment input briefly loses focus while agents load, interrupting IME input

1 participant