From 920a0339287ea5f45a46b21cb2e0981a7ca4feb3 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Wed, 21 Oct 2026 00:42:44 -0700 Subject: [PATCH] fix(native-chat): typing fast after focus moves keeps keys in order (#31203) * fix(native-chat): typing fast after focus moves keeps keys in order Typing a burst right after focus left the composer (Move Tab to Split, a paired chat, a click on the transcript) could scramble the first letters: "Reply exactly" came out as "Rply exactly...e". The first key was routed into the composer programmatically: focus moved at once, but the caret was set a frame later from a position computed before the key. The next keys landed natively, then that late caret write pulled the caret back. Quote "Add to chat" and picker completion had the same deferred caret write. Each programmatic write now puts the text and caret into the editor in one synchronous step, read from the editor's live value, then focuses it. No write happens while an IME composition owns the field. * fix(native-chat): retain saved chips after synchronous composer edits --- ...NativeChatComposer.resume-command.test.tsx | 3 +- .../native-chat/NativeChatComposer.tsx | 3 +- ...tPromptEditor.paragraph-selection.test.tsx | 3 +- .../native-chat/native-chat-composer-input.ts | 11 +++ ...ve-chat-prompt-editor-store-value.test.tsx | 77 ++++++++++++------- .../use-native-chat-composer-handle.ts | 5 +- .../use-native-chat-picker-state.test.tsx | 1 + .../use-native-chat-picker-state.ts | 35 ++++++--- .../use-native-chat-typed-insertion.ts | 28 +++---- 9 files changed, 109 insertions(+), 57 deletions(-) diff --git a/src/renderer/src/components/native-chat/NativeChatComposer.resume-command.test.tsx b/src/renderer/src/components/native-chat/NativeChatComposer.resume-command.test.tsx index e7672514e25..da02a707470 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposer.resume-command.test.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposer.resume-command.test.tsx @@ -60,7 +60,8 @@ vi.mock('./use-native-chat-draft', () => ({ vi.mock('./NativeChatComposerField', () => ({ NativeChatComposerField: (props: FieldProps) => { mocks.fieldProps = props - return