Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

embedding in websites setting conversation_id requires hiding reset conversation button (#18623)

Junjie.Mb20313935602
diff --git a/web/app/components/base/chat/embedded-chatbot/context.tsx b/web/app/components/base/chat/embedded-chatbot/context.tsx
index eb5e9d697fd..fb00dbd64d2 100644
--- a/web/app/components/base/chat/embedded-chatbot/context.tsx
+++ b/web/app/components/base/chat/embedded-chatbot/context.tsx
@@ -39,6 +39,7 @@ export type EmbeddedChatbotContextValue = {
chatShouldReloadKey: string
isMobile: boolean
isInstalledApp: boolean
+ allowResetChat: boolean
appId?: string
handleFeedback: (messageId: string, feedback: Feedback) => void
currentChatInstanceRef: RefObject<{ handleStop: () => void }>
@@ -67,6 +68,7 @@ export const EmbeddedChatbotContext = createContext<EmbeddedChatbotContextValue>
chatShouldReloadKey: '',
isMobile: false,
isInstalledApp: false,
+ allowResetChat: true,
handleFeedback: noop,
currentChatInstanceRef: { current: { handleStop: noop } },
clearChatList: false,
diff --git a/web/app/components/base/chat/embedded-chatbot/header/index.tsx b/web/app/components/base/chat/embedded-chatbot/header/index.tsx
index d05e7a650c4..c38a4546dde 100644
--- a/web/app/components/base/chat/embedded-chatbot/header/index.tsx
+++ b/web/app/components/base/chat/embedded-chatbot/header/index.tsx
@@ -16,6 +16,7 @@ import cn from '@/utils/classnames'
export type IHeaderProps = {
isMobile?: boolean
+ allowResetChat?: boolean
customerIcon?: React.ReactNode
title: string
theme?: Theme
@@ -23,6 +24,7 @@ export type IHeaderProps = {
}
const Header: FC<IHeaderProps> = ({
isMobile,
+ allowResetChat,
customerIcon,
title,
theme,
@@ -57,7 +59,7 @@ const Header: FC<IHeaderProps> = ({
{currentConversationId && (
<Divider type='vertical' className='h-3.5' />
)}
- {currentConversationId && (
+ {currentConversationId && allowResetChat && (
<Tooltip
popupContent={t('share.chat.resetChat')}
>
@@ -89,7 +91,7 @@ const Header: FC<IHeaderProps> = ({
</div>
</div>
<div className='flex items-center gap-1'>
- {currentConversationId && (
+ {currentConversationId && allowResetChat && (
<Tooltip
popupContent={t('share.chat.resetChat')}
>
diff --git a/web/app/components/base/chat/embedded-chatbot/hooks.tsx b/web/app/components/base/chat/embedded-chatbot/hooks.tsx
index cfd2acb17fe..7efbc95dee5 100644
--- a/web/app/components/base/chat/embedded-chatbot/hooks.tsx
+++ b/web/app/components/base/chat/embedded-chatbot/hooks.tsx
@@ -111,6 +111,7 @@ export const useEmbeddedChatbot = () => {
const [conversationIdInfo, setConversationIdInfo] = useLocalStorageState<Record<string, Record<string, string>>>(CONVERSATION_ID_INFO, {
defaultValue: {},
})
+ const allowResetChat = !conversationId
const currentConversationId = useMemo(() => conversationIdInfo?.[appId || '']?.[userId || 'DEFAULT'] || conversationId || '',
[appId, conversationIdInfo, userId, conversationId])
const handleConversationIdInfoChange = useCallback((changeConversationId: string) => {
@@ -365,6 +366,7 @@ export const useEmbeddedChatbot = () => {
appInfoError,
appInfoLoading,
isInstalledApp,
+ allowResetChat,
appId,
currentConversationId,
currentConversationItem,
diff --git a/web/app/components/base/chat/embedded-chatbot/index.tsx b/web/app/components/base/chat/embedded-chatbot/index.tsx
index aaf59ca4e4f..96dff67bf4d 100644
--- a/web/app/components/base/chat/embedded-chatbot/index.tsx
+++ b/web/app/components/base/chat/embedded-chatbot/index.tsx
@@ -25,6 +25,7 @@ import cn from '@/utils/classnames'
const Chatbot = () => {
const {
isMobile,
+ allowResetChat,
appInfoError,
appInfoLoading,
appData,
@@ -90,6 +91,7 @@ const Chatbot = () => {
>
<Header
isMobile={isMobile}
+ allowResetChat={allowResetChat}
title={site?.title || ''}
customerIcon={isDify() ? difyIcon : ''}
theme={themeBuilder?.theme}
@@ -153,6 +155,7 @@ const EmbeddedChatbotWrapper = () => {
handleNewConversationCompleted,
chatShouldReloadKey,
isInstalledApp,
+ allowResetChat,
appId,
handleFeedback,
currentChatInstanceRef,
@@ -187,6 +190,7 @@ const EmbeddedChatbotWrapper = () => {
chatShouldReloadKey,
isMobile,
isInstalledApp,
+ allowResetChat,
appId,
handleFeedback,
currentChatInstanceRef,