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:
Fusion
2026-04-17 15:38:32 -07:00
committed by gsxdsm
parent 47c0dc41e1
commit 57736beb06
8 changed files with 134 additions and 28 deletions

View File

@@ -109,6 +109,30 @@ describe("useChat", () => {
expect(result.current.sessions[1]?.id).toBe("session-002");
});
it("sendMessage is synchronous and returns void", async () => {
const session = makeSession({ id: "session-001", agentId: "agent-001" });
mockFetchChatSessions.mockResolvedValueOnce({ sessions: [session] });
mockFetchChatMessages.mockResolvedValueOnce({ messages: [] });
const { result } = renderHook(() => useChat("proj-123"));
await waitFor(() => {
expect(result.current.sessions).toHaveLength(1);
});
act(() => {
result.current.selectSession("session-001");
});
await waitFor(() => {
expect(result.current.activeSession?.id).toBe("session-001");
});
// sendMessage should return void (undefined), not a Promise
const sendResult = result.current.sendMessage("Hello");
expect(sendResult).toBeUndefined();
});
it("populates agentsMap on mount", async () => {
const { result } = renderHook(() => useChat("proj-123"));