mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Fix: Error 102 "Can't find dialog by ID" when embedding agent with from=agent** #11552 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -1,8 +1,10 @@
|
|||||||
import PdfSheet from '@/components/pdf-drawer';
|
import PdfSheet from '@/components/pdf-drawer';
|
||||||
import { useClickDrawer } from '@/components/pdf-drawer/hooks';
|
import { useClickDrawer } from '@/components/pdf-drawer/hooks';
|
||||||
import { MessageType } from '@/constants/chat';
|
import { MessageType, SharedFrom } from '@/constants/chat';
|
||||||
|
import { useFetchExternalAgentInputs } from '@/hooks/use-agent-request';
|
||||||
import { useFetchExternalChatInfo } from '@/hooks/use-chat-request';
|
import { useFetchExternalChatInfo } from '@/hooks/use-chat-request';
|
||||||
import i18n from '@/locales/config';
|
import i18n from '@/locales/config';
|
||||||
|
import { useSendNextSharedMessage } from '@/pages/agent/hooks/use-send-shared-message';
|
||||||
import { MessageCircle, Minimize2, Send, X } from 'lucide-react';
|
import { MessageCircle, Minimize2, Send, X } from 'lucide-react';
|
||||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
@ -20,7 +22,13 @@ const FloatingChatWidget = () => {
|
|||||||
const [isLoaded, setIsLoaded] = useState(false);
|
const [isLoaded, setIsLoaded] = useState(false);
|
||||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const { sharedId: conversationId, locale } = useGetSharedChatSearchParams();
|
const {
|
||||||
|
sharedId: conversationId,
|
||||||
|
locale,
|
||||||
|
from,
|
||||||
|
} = useGetSharedChatSearchParams();
|
||||||
|
|
||||||
|
const isFromAgent = from === SharedFrom.Agent;
|
||||||
|
|
||||||
// Check if we're in button-only mode or window-only mode
|
// Check if we're in button-only mode or window-only mode
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
@ -34,7 +42,7 @@ const FloatingChatWidget = () => {
|
|||||||
sendLoading,
|
sendLoading,
|
||||||
derivedMessages,
|
derivedMessages,
|
||||||
hasError,
|
hasError,
|
||||||
} = useSendSharedMessage();
|
} = (isFromAgent ? useSendNextSharedMessage : useSendSharedMessage)(() => {});
|
||||||
|
|
||||||
// Sync our local input with the hook's value when needed
|
// Sync our local input with the hook's value when needed
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -43,7 +51,11 @@ const FloatingChatWidget = () => {
|
|||||||
}
|
}
|
||||||
}, [hookValue, inputValue]);
|
}, [hookValue, inputValue]);
|
||||||
|
|
||||||
const { data: chatInfo } = useFetchExternalChatInfo();
|
const { data } = (
|
||||||
|
isFromAgent ? useFetchExternalAgentInputs : useFetchExternalChatInfo
|
||||||
|
)();
|
||||||
|
|
||||||
|
const title = data.title;
|
||||||
|
|
||||||
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
|
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
|
||||||
useClickDrawer();
|
useClickDrawer();
|
||||||
@ -372,7 +384,7 @@ const FloatingChatWidget = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3 className="font-semibold text-sm">
|
<h3 className="font-semibold text-sm">
|
||||||
{chatInfo?.title || 'Chat Support'}
|
{title || 'Chat Support'}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-xs text-blue-100">
|
<p className="text-xs text-blue-100">
|
||||||
We typically reply instantly
|
We typically reply instantly
|
||||||
@ -494,6 +506,7 @@ const FloatingChatWidget = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{visible && (
|
||||||
<PdfSheet
|
<PdfSheet
|
||||||
visible={visible}
|
visible={visible}
|
||||||
hideModal={hideModal}
|
hideModal={hideModal}
|
||||||
@ -502,6 +515,7 @@ const FloatingChatWidget = () => {
|
|||||||
width={'100vw'}
|
width={'100vw'}
|
||||||
height={'100vh'}
|
height={'100vh'}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
} // Full mode - render everything together (original behavior)
|
} // Full mode - render everything together (original behavior)
|
||||||
@ -524,7 +538,7 @@ const FloatingChatWidget = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3 className="font-semibold text-sm">
|
<h3 className="font-semibold text-sm">
|
||||||
{chatInfo?.title || 'Chat Support'}
|
{title || 'Chat Support'}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-xs text-blue-100">
|
<p className="text-xs text-blue-100">
|
||||||
We typically reply instantly
|
We typically reply instantly
|
||||||
|
|||||||
@ -127,12 +127,14 @@ function AgentChatBox() {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
|
{visible && (
|
||||||
<PdfSheet
|
<PdfSheet
|
||||||
visible={visible}
|
visible={visible}
|
||||||
hideModal={hideModal}
|
hideModal={hideModal}
|
||||||
documentId={documentId}
|
documentId={documentId}
|
||||||
chunk={selectedChunk}
|
chunk={selectedChunk}
|
||||||
></PdfSheet>
|
></PdfSheet>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user