Browse Source

Feat/regenrate conversation in embeded window (#1708)

crazywoola 1 year ago
parent
commit
8b0100523b

File diff suppressed because it is too large
+ 6 - 0
web/app/components/app/chat/icon-component/index.tsx


+ 14 - 0
web/app/components/share/chatbot/index.tsx

@@ -534,6 +534,19 @@ const Main: FC<IMainProps> = ({
     createNewChat()
   }
 
+  const handleConversationIdChange = (id: string) => {
+    if (id === '-1') {
+      createNewChat()
+      setConversationIdChangeBecauseOfNew(true)
+    }
+    else {
+      setConversationIdChangeBecauseOfNew(false)
+    }
+    // trigger handleConversationSwitch
+    setCurrConversationId(id, appId)
+    setIsShowSuggestion(false)
+  }
+
   const difyIcon = (
     <LogoHeader />
   )
@@ -556,6 +569,7 @@ const Main: FC<IMainProps> = ({
         icon_background={siteInfo.icon_background}
         isEmbedScene={true}
         isMobile={isMobile}
+        onCreateNewChat={() => handleConversationIdChange('-1')}
       />
 
       <div className={'flex bg-white overflow-hidden'}>

+ 15 - 2
web/app/components/share/header.tsx

@@ -4,7 +4,10 @@ import {
   Bars3Icon,
   PencilSquareIcon,
 } from '@heroicons/react/24/solid'
+import { useTranslation } from 'react-i18next'
 import AppIcon from '@/app/components/base/app-icon'
+import { ReplayIcon } from '@/app/components/app/chat/icon-component'
+import Tooltip from '@/app/components/base/tooltip'
 
 export type IHeaderProps = {
   title: string
@@ -26,6 +29,7 @@ const Header: FC<IHeaderProps> = ({
   onShowSideBar,
   onCreateNewChat,
 }) => {
+  const { t } = useTranslation()
   if (!isMobile)
     return null
 
@@ -37,7 +41,6 @@ const Header: FC<IHeaderProps> = ({
           bg-gradient-to-r from-blue-600 to-sky-500
         `}
       >
-        <div></div>
         <div className="flex items-center space-x-2">
           {customerIcon || <AppIcon size="small" icon={icon} background={icon_background} />}
           <div
@@ -46,7 +49,17 @@ const Header: FC<IHeaderProps> = ({
             {title}
           </div>
         </div>
-        <div></div>
+        <Tooltip
+          selector={'embed-scene-restart-button'}
+          htmlContent={t('share.chat.resetChat')}
+          position='top'
+        >
+          <div className='flex cursor-pointer hover:rounded-lg hover:bg-black/5 w-8 h-8 items-center justify-center' onClick={() => {
+            onCreateNewChat?.()
+          }}>
+            <ReplayIcon className="h-4 w-4 text-sm font-bold text-white" />
+          </div>
+        </Tooltip>
       </div>
     )
   }

+ 1 - 0
web/i18n/lang/share-app.en.ts

@@ -9,6 +9,7 @@ const translation = {
     pinnedTitle: 'Pinned',
     unpinnedTitle: 'Chats',
     newChatDefaultName: 'New conversation',
+    resetChat: 'Reset conversation',
     powerBy: 'Powered by',
     prompt: 'Prompt',
     privatePromptConfigTitle: 'Conversation settings',

+ 1 - 0
web/i18n/lang/share-app.zh.ts

@@ -9,6 +9,7 @@ const translation = {
     pinnedTitle: '已置顶',
     unpinnedTitle: '对话列表',
     newChatDefaultName: '新的对话',
+    resetChat: '重置对话',
     powerBy: 'Powered by',
     prompt: '提示词',
     privatePromptConfigTitle: '对话设置',

File diff suppressed because it is too large
+ 176 - 574
web/yarn.lock