desktop: Chinese IME composition loses trailing characters in the prompt composer

Aberta
#66,985 2 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
72/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
react, typescript
Domínio
desktop, frontend

Direção de pesquisa

Start with packages/app/src/composer/editor/editor.tsx, focusing on the input, keyup, effect, and renderComposerEditor() paths described in the issue. Reproduce with the iFlytek Chinese IME in the OpenCode desktop app and confirm which DOM or selection update aborts composition. The change is done when the composer remains inert during active composition, while normal input and cursor synchronization still work.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

area/desktop platform/windows type/bug version/v2
Description
Summary

Typing Chinese with 讯飞输入法 (iFlytek IME) in the OpenCode desktop prompt composer intermittently loses the trailing characters that are still in the IME composition buffer. After typing a segment and continuing, the last few pinyin/candidate characters disappear before they are selected or committed. Previously committed text remains. This happens often enough to make Chinese input unusable.

Expected behavior

The IME composition stays active until a candidate is selected/committed; no composing characters are discarded.

Actual behavior

The trailing characters of the active composition vanish. The composition is aborted and the uncommitted pinyin/candidate text is lost; earlier committed text is not affected.

Root cause analysis

This matches the known V2 composer IME issue: the contenteditable editor handles every input/key event during composition and can rewrite its DOM mid-composition.

  • packages/app/src/composer/editor/editor.tsx runs onInput for every input event, including composition updates, and writes the parsed DOM into the composer store.
  • onKeyUp syncs the cursor on every key, including composition keys.
  • A createEffect compares the DOM with the store and calls renderComposerEditor() (editor.replaceChildren(...)) when they differ.
  • Mutating the DOM or selection during an active IME composition makes the browser abort the composition and discard the uncommitted text.
Related
  • #39632: IME composition breaks on the first keystroke in the v2 prompt input
  • #38674: CJK IME composition aborted mid-input (DOM rewrite during composition)
  • #55295: fix(app): keep the composer editor inert during IME composition (closed unmerged; commit f59b00c is not in 2.4.2)
Workaround

Typing Chinese in an external editor and pasting it into the composer works; pasting bypasses IME composition.

Notes
  • Hex voice input is not installed/running on this machine, so its Ctrl+Space hotkey is not involved.
  • No relevant errors in the logs; this is a DOM/IME lifecycle issue, not a server error.
Plugins

superpowers@git+https://github.com/obra/superpowers.git

OpenCode version

2.4.2 (desktop app; bundled CLI 2.4.2)

Steps to reproduce
  1. Open a new session in the OpenCode desktop app (2.4.2).
  2. Focus the prompt composer and switch 讯飞输入法 (iFlytek IME) to Chinese mode.
  3. Type and commit a short phrase.
  4. Continue typing another phrase without confirming the IME candidates.
  5. After a few more keystrokes, the trailing characters in the composition disappear before candidate selection. Earlier committed text remains.

Intermittent but frequent; longer compositions trigger it more often.

Screenshot

No screenshot available (intermittent text loss; textual reproduction above).

Operating System

Windows 10.0.19045 (win32 x64)

Terminal

OpenCode Desktop app (not a terminal client)

Linguagem predominante
TypeScript
Estrelas
230k
Forks
31.3k
Merge médio
5h 32min
PRs com merge (30d)
453

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de anomalyco/opencode

Todas as issues de anomalyco/opencode

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.