GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(app): keep the composer editor inert during IME composition by Mirac1eSky · Pull Request #55295 · anomalyco/opencode Conversation
|
|
The following comment was made by an LLM, it may be inaccurate: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I couldn't verify this. The bug needs a real IME in a desktop browser, and I can only drive the TUI here. Typecheck passes, and the composer tests pass with the package's test:unit flags. Public API: unchanged (only the in-app composer controller gets new members).
Concerns:
compositionend, onInput ignores every input, including plain input that isn't part of a composition. Korean IMEs end the current syllable and insert the next character (a space, ?, @, …) in the same keystroke. Their input event arrives inside that window and is skipped. The stored prompt then lacks that character until the next input event. If Enter comes right after, the message is sent without it, and a @ typed this way doesn't open the context popover. The sync done on compositionend reads the DOM before that character is inserted.onKeyDown drops Escape, Ctrl+G, shell-mode Backspace and history arrows for 100 ms after any composition. Because it also checks keyCode === 229, it drops them always on Android keyboards, which report 229 for most keys. A tighter guard would help: only treat Enter as an IME confirmation, and keep onInput working for input that isn't part of a composition.suggestions/machine.ts is unchanged, and the machine already ignored Enter when composing was true, so both tests pass on the base. packages/app/AGENTS.md asks that a regression test fail before the fix. Please drop them, or replace them with a test that drives the editor's composition events.Could you also share a short video or before/after recordings on Safari and Chrome? Ideally include a Korean IME, given the first point.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // here re-renders mid-composition and splits it into per-letter | ||
| // micro compositions. State is reconciled once by the | ||
| // compositionend write-back. | ||
| if (event.isComposing || props.controller.imeActive()) return |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
imeActive() stays true for 100 ms after compositionend, so this also drops input that isn't part of a composition. Korean IMEs end the composition and insert the next character (a space, ?, @) in the same keystroke, and that input event lands here with isComposing === false. The compositionend sync has already run, before that character was inserted, so the store misses it until the next input. A quick Enter then sends the prompt without it. Gating only on event.isComposing / the active composing flag would avoid this.
This returns early for every key in the post-composition window, and for any key reporting keyCode === 229. Android soft keyboards report 229 for most keys. So Escape (stop / cancel queue edit), Ctrl+G, shell-mode Backspace and history arrows are ignored there, and for 100 ms after every composition on desktop. Since the goal is to keep the confirming Enter from submitting, could the window apply only to Enter (and maybe Tab)?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| expect(result.handled).toBe(row.handled ?? false) | ||
| }) | ||
|
|
||
| test("ignores Enter while IME composition is active", () => { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
machine.ts isn't changed in this PR, and it already ignored Enter when composing is true, so both tests pass on the base and don't cover the fix (see the regression-test rule in packages/app/AGENTS.md). Please drop them, or test the editor's composition handling instead.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Data point from a WKWebView host, on the released 2.0.32 — still reproducible, and your event-order diagnosis is the one that matches. I maintain a macOS Tauri app that embeds the web UI in native child webviews. A user typing a pinyin prompt and pressing Enter to confirm the candidate sent the message, and the message body carried the raw pinyin ( I checked the shipped bundle rather than the sources: the composer in Because the page is not ours, we had to patch the engine view from the host for now: a document-start script redefines One question about the 100 ms window: the typematic minimum is ~30 ms, so a user who commits a candidate and immediately presses Enter to send can land inside the window and have the send ignored. We used 10 ms, which only has to outlive WebKit's runloop turn. If 100 ms comes from a measured input method, which one? If it is headroom rather than a measurement, a shorter window (or scoping it to On testing: this does not need a real IME. Dispatching |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. Both earlier points are fixed. onInput now skips input only while a composition is actually in progress. The guard after compositionend is 10 ms and covers only Enter and Tab, and keyCode 229 is only checked for those two keys. The machine tests that passed on the base are gone.
I still couldn't verify this on a real IME, so a short before/after recording on Safari and Chrome would help. The new browser test file and the packages/app typecheck pass. Public API: unchanged.
One remaining point is the new test file (see inline). It is large for what it checks, and its result depends on real time.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return Object.assign(new Event("input"), { isComposing: init.isComposing ?? false }) as InputEvent | ||
| } | ||
|
|
||
| const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This file only calls the controller helpers (imeComposing / imeInserting) with hand-built events, so it doesn't exercise the editor handlers that use them. It also depends on real time. The sleep(5) / sleep(35) calls race the 10 ms window. The keyCode 13 assertion on line 64 passes only if onCompositionEnd and the next call run within 10 ms, which can fail on a loaded CI runner. packages/app/AGENTS.md asks for one test per contract and no timing-sensitive tests. Could you cut it to two or three cases that don't depend on wall-clock time? For example: Enter confirming a candidate is ignored, input after compositionend is accepted, and Escape is not swallowed. Driving them through the ComposerEditor element would be better still.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @yusiwen — the WKWebView trace and the On the 100 ms: it was inherited as-is from the V1 fix (#44826), which I had only verified with Chinese IMEs — headroom, not a measurement. I've now re-tested the guard by driving the actual composer controller with synthetic composition/keyboard events (zh pinyin, ja, ko sequences, plus typematic-speed follow-ups), and 10 ms covers the compositionend→keydown runloop turn while leaving a fast second Enter intact. Your measured 10 ms is now the window. Pushed a revision addressing all three inline concerns:
Verified locally this time: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Done — cut to three cases, no wall-clock. The guard reads On the recording: the machine-observable behavior is now covered by the deterministic tests above, and the released-build behavior was already traced end-to-end on real IMEs in @yusiwen's WKWebView measurements. Happy to add a recording if a maintainer feels it's still needed. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the tests are fixed. They are down to three cases and pin performance.now() instead of sleeping, so they no longer depend on real time. The new IME test file and the packages/app typecheck pass. Public API: unchanged.
I still couldn't try this with a real IME, so a short recording on Safari and Chrome would still help.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Data point: same root cause on Android (non-CJK IME) — word suggestions/autocorrect never appear Environment
SymptomTyping works, but the keyboard never shows its word suggestions and never autocorrects in the composer. The same keyboard does show suggestions in a plain Checked, not the cause
Hypothesis = what this PR fixesEach composition keystroke triggers Ask
Related: #57740 (Gboard voice typing blocked in the same composer), #39632, #49448, #38674 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @khativari — yes, this is within the intended scope of the fix. The guard is not CJK-specific: it follows the browser's composition lifecycle and keeps the editor inert for any active IME composition. If HeliBoard/Gboard maintains a composing region for the current word, this PR now avoids the operations that can reset it: the per-composition Testing the current PR head (
If it still fails, an event trace for one word containing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ready to test on a physical Android device: Brave + HeliBoard, plus Gboard as a second pass (both on the current PR head What I need to get there:
I'll run your checklist under both keyboards: suggestions stay visible while typing a word, picking a suggestion replaces the whole word, autocorrect on Space, Enter and Backspace still behave normally. If it still fails, I'll send the event trace for one word ( |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Typing CJK with an IME in the V2 composer breaks on the first keystroke: the first letter is committed as literal text and only the rest reaches the candidate window (e.g. 'ceshi' -> 测试 turns into 'c' + 'eshi'). anomalyco#39632, anomalyco#49448, anomalyco#38674. Root cause: the composer editor reacts to every composition keystroke (onInput -> store write, keydown -> dispatch, keyup -> selection sync) and can rewrite the contentEditable DOM mid-composition. A DOM or selection mutation while a composition is active makes the browser abort it, committing whatever partial text exists as plain input. The editor is now fully inert while a composition is in flight and during a 100ms window after compositionend: no input handling, no keydown dispatch, no cursor sync, no editor DOM rewrites. State is reconciled once from the DOM on compositionend. The confirming Enter of an IME candidate can no longer submit the message either. Ports the V1 fix from anomalyco#44826 to the V2 composer, as requested when that PR was closed. Co-authored-by: powoct <[email protected]> Refs anomalyco#39632 Refs anomalyco#49448 Refs anomalyco#38674
- Confirm window 100ms -> 10ms, scoped to Enter/Tab; other keys (Escape, arrows) and Android keyCode-229 events are unaffected - onInput gated only while a composition is in flight, so the same-keystroke character Korean IMEs insert after compositionend reaches the store - Drop the two machine tests that passed on base; add editor-level regression tests driving the real controller with synthetic composition events (zh/ja/ko + typematic-speed follow-up)
…tracts Pin performance.now instead of sleeping: the guard reads the monotonic clock on purpose, so wall-clock sleeps raced the 10ms confirm window on loaded CI runners. Three tests now cover the same contracts (confirm Enter guarded / fast send allowed, input gated only mid-composition, non-confirm keys and Android 229 unaffected). Each fails against the previous revision.
60fc0c4 to
c247e42
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The rebase onto the latest dev looks clean. The IME guard still runs before the new flushFocus() and history-preview code in onKeyDown. The IME test file, the composer tests and typecheck:tsc pass, and I have no new concerns. Public API: unchanged.
I still couldn't try this with a real IME, so a short recording on Safari and Chrome would still help.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.