Skip to content

Safari: CJK IME composition is aborted mid-input in web app prompt input #38674

Closed as not planned

Description

@powoct

Description

In the web app prompt input (packages/app/src/components/prompt-input.tsx), typing with a CJK IME in Safari gets cut off mid-composition: after a few keystrokes the half-composed text (raw pinyin / kana) is committed as plain text and the composition ends.

Root cause: the prompt input is a contenteditable that round-trips DOM -> state -> DOM on every input event (handleInput -> prompt.set(...) -> effect -> renderEditorWithCursor()). Safari aborts an active IME composition whenever the DOM or selection is mutated programmatically, and the existing guards don't hold there:

  • The effect guard if (composing()) return fails because Safari fires the first input event before compositionstart, so composing() is still false at that point (Chrome fires them in the opposite order).
  • The mirror.input flag only skips one write-back round; when isNormalizedEditor() is false (common mid-composition) renderEditorWithCursor() still rewrites the DOM.

Japanese IMEs that confirm bunsetsu-by-bunsetsu also fire compositionend + a new compositionstart mid-sentence; a rewrite landing in that gap cuts off the remaining segments the same way.

Related: #35746 covers the confirm-Enter mis-submit side. The same Safari event order breaks the isImeComposing guard in this input too: Safari fires compositionend before the confirming Enter keydown, so that event has isComposing === false and keyCode === 13 and none of the guard conditions match.

The standard approach (ProseMirror / CodeMirror / Lexical) is to freeze DOM->state->DOM syncing entirely during composition and do a single sync on compositionend. I have a patch for both problems and would like to submit a PR.

Plugins

No response

OpenCode version

v1.18.4 (code paths verified on main @ c9db6e9)

Steps to reproduce

  1. Open the opencode web app in Safari on macOS.
  2. Focus the prompt input and enable a Chinese pinyin or Japanese IME.
  3. Type a long phrase continuously, e.g. zhongwenshurufaceshi or きょうはいいてんきですね.
  4. The composition is aborted partway and half-composed text is committed. Pressing Enter to confirm a candidate also submits the message.

Not reproducible in Chrome (there compositionstart precedes the first input, and the confirming Enter keydown arrives with isComposing=true / keyCode=229 before compositionend).

Screenshot and/or share link

No response

Operating System

macOS (Safari)

Terminal

No response

Activity

  1. anyingiit commented on Aug 25, 2026

    @anyingiit

    Environment

    • OS: macOS 26.6 (25G72)
    • OpenCode Web: served by OpenCode server 1.18.23
    • Browser: Safari
    • IME: macOS built-in Simplified Chinese Pinyin

    Reproduction

    1. Open a new browser tab pointing to the OpenCode web app.
    2. Focus the v2 prompt input and enable the Chinese IME.
    3. Start typing continuously.

    Expected: Pinyin composes normally and can be confirmed.

    Actual: All letters except the last one are committed as plain English characters immediately; only the final keystroke remains in the composition. Chrome on the same machine does not exhibit this.

  2. Tarquinen commented on Oct 20, 2026

    @Tarquinen
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions