fix(typing): stop indicator on blur and chat switch
Some checks are pending
CI / test (push) Has started running

This commit is contained in:
2026-03-08 20:05:23 +03:00
parent 1a3a54cfb9
commit c5b90bc91c

View File

@@ -108,6 +108,7 @@ export function MessageComposer() {
const pointerUpHandlerRef = useRef<((event: globalThis.PointerEvent) => void) | null>(null);
const recordingStateRef = useRef<RecordingState>("idle");
const lastEditingMessageIdRef = useRef<number | null>(null);
const prevActiveChatIdRef = useRef<number | null>(null);
const [isUploading, setIsUploading] = useState(false);
const [uploadProgress, setUploadProgress] = useState(0);
@@ -255,6 +256,15 @@ export function MessageComposer() {
}
}, [activeChatId]);
useEffect(() => {
const prev = prevActiveChatIdRef.current;
if (prev && prev !== activeChatId) {
const ws = getWs();
ws?.send(JSON.stringify({ event: "typing_stop", payload: { chat_id: prev } }));
}
prevActiveChatIdRef.current = activeChatId;
}, [activeChatId]);
useEffect(() => {
const onVisibility = () => {
if (document.visibilityState === "hidden" && recordingStateRef.current === "recording") {
@@ -1297,6 +1307,11 @@ export function MessageComposer() {
sendRealtimeChatEvent(next.trim().length > 0 ? "typing_start" : "typing_stop");
}
}}
onBlur={() => {
if (activeChatId) {
sendRealtimeChatEvent("typing_stop");
}
}}
/>
{hasTextToSend ? (