diff --git a/src/renderer/src/components/native-chat/NativeChatComposerField.tsx b/src/renderer/src/components/native-chat/NativeChatComposerField.tsx index 6f954a60aa5..b255055dc9b 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerField.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerField.tsx @@ -4,6 +4,7 @@ import type { KeyboardEventHandler, RefObject } from 'react' +import { useLayoutEffect, useRef } from 'react' import { Image as ImageIcon, ImageOff, X } from 'lucide-react' import { translate } from '@/i18n/i18n' import { cn } from '@/lib/utils' @@ -97,6 +98,17 @@ export function NativeChatComposerField({ sessionOptionsSurface, sessionOptionsSnapshot }: NativeChatComposerFieldProps): React.JSX.Element { + const compositionActiveRef = useRef(false) + const pendingCompositionEnterRef = useRef(false) + + useLayoutEffect(() => { + const textarea = textareaRef.current + if (!textarea || compositionActiveRef.current || textarea.value === draft) { + return + } + textarea.value = draft + }, [draft, textareaRef]) + return (
{/* Extra bottom padding keeps the input box off the window rim. */} @@ -164,13 +176,50 @@ export function NativeChatComposerField({ ) : null}