fix(FN-2011): keep chat input responsive during streaming
- Make useChat and useQuickChat sendMessage synchronous and update consumers to call it without awaiting - Allow ChatView and QuickChatFAB inputs to remain editable while responses stream - Keep quick chat send disabled during active streaming to prevent concurrent sends - Add hook and component tests for synchronous sendMessage and non-blocking input behavior
This commit is contained in:
@@ -536,9 +536,9 @@ export function QuickChatFAB({ projectId, addToast, showFAB = true, open, onOpen
|
||||
return "Select a model to start chatting";
|
||||
}, [chatMode, selectedAgent, selectedModelTag]);
|
||||
|
||||
const inputDisabled = !hasChatTarget || !activeSession || sessionsLoading || isStreaming;
|
||||
const inputDisabled = !hasChatTarget || !activeSession || sessionsLoading;
|
||||
|
||||
const handleSendMessage = useCallback(async () => {
|
||||
const handleSendMessage = useCallback(() => {
|
||||
const trimmed = messageInput.trim();
|
||||
if (!trimmed || inputDisabled) return;
|
||||
|
||||
@@ -546,7 +546,7 @@ export function QuickChatFAB({ projectId, addToast, showFAB = true, open, onOpen
|
||||
setMentionPopupVisible(false);
|
||||
setMentionFilter("");
|
||||
setMentionStartPos(-1);
|
||||
await sendMessage(trimmed);
|
||||
sendMessage(trimmed);
|
||||
}, [sendMessage, inputDisabled, messageInput]);
|
||||
|
||||
const updateMentionState = useCallback((value: string, cursorPos: number) => {
|
||||
@@ -929,7 +929,7 @@ export function QuickChatFAB({ projectId, addToast, showFAB = true, open, onOpen
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void handleSendMessage()}
|
||||
disabled={inputDisabled || messageInput.trim().length === 0}
|
||||
disabled={inputDisabled || isStreaming || messageInput.trim().length === 0}
|
||||
data-testid="quick-chat-send"
|
||||
>
|
||||
<Send size={16} />
|
||||
|
||||
Reference in New Issue
Block a user