RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
import { useCancelConversation } from '@/hooks/use-agent-request';
import { useCallback, useEffect } from 'react';
export function useStopMessage() {
const { cancelConversation } = useCancelConversation();
const stopMessage = useCallback(
(taskId?: string) => {
if (taskId) {
void cancelConversation(taskId).catch(() => undefined);
}
},
[cancelConversation],
);
return { stopMessage };
}
export function useStopMessageUnmount(chatVisible: boolean, taskId?: string) {
const { stopMessage } = useStopMessage();
const handleBeforeUnload = useCallback(() => {
if (chatVisible) {
stopMessage(taskId);
}
}, [chatVisible, stopMessage, taskId]);
useEffect(() => {
window.addEventListener('beforeunload', handleBeforeUnload);
return () => {
window.removeEventListener('beforeunload', handleBeforeUnload);
};
}, [handleBeforeUnload]);
return { stopMessage };
}