chat record

This commit is contained in:
StyleZhang 2024-03-17 09:53:16 +08:00
parent 552ccb058b
commit cd01c890e1
4 changed files with 41 additions and 9 deletions

View File

@ -0,0 +1,20 @@
import { memo } from 'react'
import UserInput from './debug-and-preview/user-input'
import Chat from '@/app/components/base/chat/chat'
const ChatRecord = () => {
return (
<Chat
config={{} as any}
chatList={[]}
chatContainerclassName='px-4'
chatContainerInnerClassName='pt-6'
chatFooterClassName='px-4 rounded-b-2xl'
chatFooterInnerClassName='pb-4'
chatNode={<UserInput />}
allToolIcons={{}}
/>
)
}
export default memo(ChatRecord)

View File

@ -3,7 +3,6 @@ import {
useRef, useRef,
} from 'react' } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { useStore } from '../../store'
import ChatWrapper from './chat-wrapper' import ChatWrapper from './chat-wrapper'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import { RefreshCcw01 } from '@/app/components/base/icons/src/vender/line/arrows' import { RefreshCcw01 } from '@/app/components/base/icons/src/vender/line/arrows'
@ -14,16 +13,14 @@ export type ChatWrapperRefType = {
const DebugAndPreview = () => { const DebugAndPreview = () => {
const { t } = useTranslation() const { t } = useTranslation()
const chatRef = useRef({ handleRestart: () => {} }) const chatRef = useRef({ handleRestart: () => {} })
const showRunHistory = useStore(s => s.showRunHistory)
return ( return (
<div <div
className={` className={`
flex flex-col h-full border border-black/[0.02] shadow-xl flex flex-col w-[400px] rounded-l-2xl h-full border border-black/[0.02] shadow-xl
${showRunHistory ? 'w-[320px] rounded-2xl' : 'w-[400px] rounded-l-2xl'}
`} `}
style={{ style={{
background: showRunHistory ? 'white' : 'linear-gradient(156deg, rgba(242, 244, 247, 0.80) 0%, rgba(242, 244, 247, 0.00) 99.43%), var(--white, #FFF)', background: 'linear-gradient(156deg, rgba(242, 244, 247, 0.80) 0%, rgba(242, 244, 247, 0.00) 99.43%), var(--white, #FFF)',
}} }}
> >
<div className='shrink-0 flex items-center justify-between px-4 pt-3 pb-2 font-semibold text-gray-900'> <div className='shrink-0 flex items-center justify-between px-4 pt-3 pb-2 font-semibold text-gray-900'>

View File

@ -30,9 +30,9 @@ const Panel: FC = () => {
return { return {
showWorkflowInfoPanel: !isChatMode && !selectedNode && !runningStatus, showWorkflowInfoPanel: !isChatMode && !selectedNode && !runningStatus,
showNodePanel: !!selectedNode && !runningStatus, showNodePanel: !!selectedNode && !runningStatus,
showDebugAndPreviewPanel: isChatMode && runningStatus, showDebugAndPreviewPanel: isChatMode && runningStatus && !showRunHistory,
} }
}, [selectedNode, isChatMode, runningStatus]) }, [selectedNode, isChatMode, runningStatus, showRunHistory])
return ( return (
<div <div
@ -51,6 +51,11 @@ const Panel: FC = () => {
<Record /> <Record />
) )
} }
{
runningStatus && isChatMode && showRunHistory && (
<Record />
)
}
{ {
showNodePanel && ( showNodePanel && (
<NodePanel {...selectedNode!} /> <NodePanel {...selectedNode!} />

View File

@ -1,17 +1,27 @@
import { memo } from 'react' import { memo } from 'react'
import { useIsChatMode } from '../hooks'
import Run from '../run' import Run from '../run'
import { useStore } from '../store' import { useStore } from '../store'
import ChatRecord from './chat-record'
const Record = () => { const Record = () => {
const isChatMode = useIsChatMode()
const currentSequenceNumber = useStore(s => s.currentSequenceNumber) const currentSequenceNumber = useStore(s => s.currentSequenceNumber)
const workflowRunId = useStore(s => s.workflowRunId) const workflowRunId = useStore(s => s.workflowRunId)
return ( return (
<div className='flex flex-col w-[400px] h-full rounded-2xl border-[0.5px] border-gray-200 shadow-xl bg-white'> <div className={`
flex flex-col h-full rounded-2xl border-[0.5px] border-gray-200 shadow-xl bg-white
${isChatMode ? 'w-[320px]' : 'w-[400px]'}
`}>
<div className='flex items-center justify-between p-4 pb-1 text-base font-semibold text-gray-900'> <div className='flex items-center justify-between p-4 pb-1 text-base font-semibold text-gray-900'>
{`Test Run#${currentSequenceNumber}`} {`Test Run#${currentSequenceNumber}`}
</div> </div>
<Run runID={workflowRunId} /> {
isChatMode
? <ChatRecord />
: <Run runID={workflowRunId} />
}
</div> </div>
) )
} }