Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion apps/desktop/src/app/chat/composer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export function ChatBar({
const [focusRequestId, setFocusRequestId] = useState(0)
const dragDepthRef = useRef(0)
const composingRef = useRef(false) // true during IME composition (CJK input)
const [composingVersion, setComposingVersion] = useState(0)
const lastSpokenIdRef = useRef<string | null>(null)

const narrow = useMediaQuery('(max-width: 30rem)')
Expand All @@ -162,7 +163,7 @@ export function ChatBar({
const slash = useSlashCompletions({ gateway: gateway ?? null })

const stacked = expanded || narrow || tight
const hasComposerPayload = draft.trim().length > 0 || attachments.length > 0
const hasComposerPayload = draft.trim().length > 0 || attachments.length > 0 || (editorRef.current && composerPlainText(editorRef.current).trim().length > 0)
const canSubmit = busy || hasComposerPayload
const editingQueuedPrompt = queueEdit ? (queuedPrompts.find(entry => entry.id === queueEdit.entryId) ?? null) : null
const busyAction = busy && hasComposerPayload ? 'queue' : 'stop'
Expand Down Expand Up @@ -1210,9 +1211,20 @@ export function ChatBar({
onBlur={() => window.setTimeout(closeTrigger, 80)}
onCompositionEnd={() => {
composingRef.current = false
// Update draft from editor content when composition ends
const editor = editorRef.current
if (editor) {
const text = composerPlainText(editor)
if (text !== draftRef.current) {
draftRef.current = text
aui.composer().setText(text)
}
}
setComposingVersion(v => v + 1)
}}
onCompositionStart={() => {
composingRef.current = true
setComposingVersion(v => v + 1)
}}
onDragOver={handleInputDragOver}
onDrop={handleInputDrop}
Expand Down