fix: Codex round 8 — respect IME composition before submitting answers

handleComposerKeyDown runs before useTextarea's composition guard, so with a
CJK/IME keyboard the Enter that commits an in-progress composition was being
intercepted and submitting the partial answer (and the composition buffer can
leave value empty mid-compose, mis-triggering digit/arrow steering too). Bail
at the top when composing — nativeEvent.isComposing, or key==='Process' /
keyCode===229 for Safari's inconsistent reporting — mirroring the existing
composer guard so the character commits normally.
This commit is contained in:
Danny Avila 2026-07-07 16:52:31 -04:00
parent 4e083da51e
commit b45c812030

View file

@ -278,6 +278,18 @@ export default function useAskAnswerMode(conversationId?: string | null) {
if (!active) {
return false;
}
/**
* Let IME composition commit normally: with a CJK keyboard, Enter
* commits the in-progress composition rather than submitting, and the
* composition buffer can leave `value` empty mid-compose so bail
* before ANY Enter-submit or digit/arrow steering. Mirrors the composer
* guard in `useTextarea` (Safari reports `isComposing` inconsistently,
* hence the `key`/`keyCode` fallbacks); this handler runs first, so the
* guard must live here too.
*/
if (e.nativeEvent.isComposing || e.key === 'Process' || e.keyCode === 229) {
return false;
}
const composerText = e.currentTarget.value;
if (composerText.trim().length > 0) {
// The composer IS the free-form answer box: Enter submits the typed