diff --git a/web/app/components/base/chat/chat/hooks.ts b/web/app/components/base/chat/chat/hooks.ts index 37b6de654c5f73..6242105e85acff 100644 --- a/web/app/components/base/chat/chat/hooks.ts +++ b/web/app/components/base/chat/chat/hooks.ts @@ -19,6 +19,7 @@ import { useToastContext } from '@/app/components/base/toast' import { ssePost } from '@/service/base' import { replaceStringWithValues } from '@/app/components/app/configuration/prompt-value-panel' import type { Annotation } from '@/models/log' +import { WorkflowRunningStatus } from '@/app/components/workflow/types' type GetAbortController = (abortController: AbortController) => void type SendCallback = { @@ -429,6 +430,52 @@ export const useChat = ( }) handleUpdateChatList(newChatList) }, + onWorkflowStarted: ({ workflow_run_id, task_id }) => { + taskIdRef.current = task_id + responseItem.workflow_run_id = workflow_run_id + responseItem.workflowProcess = { + status: WorkflowRunningStatus.Running, + tracing: [], + } + handleUpdateChatList(produce(chatListRef.current, (draft) => { + const currentIndex = draft.findIndex(item => item.id === responseItem.id) + draft[currentIndex] = { + ...draft[currentIndex], + ...responseItem, + } + })) + }, + onWorkflowFinished: ({ data }) => { + responseItem.workflowProcess!.status = data.status as WorkflowRunningStatus + handleUpdateChatList(produce(chatListRef.current, (draft) => { + const currentIndex = draft.findIndex(item => item.id === responseItem.id) + draft[currentIndex] = { + ...draft[currentIndex], + ...responseItem, + } + })) + }, + onNodeStarted: ({ data }) => { + responseItem.workflowProcess!.tracing!.push(data as any) + handleUpdateChatList(produce(chatListRef.current, (draft) => { + const currentIndex = draft.findIndex(item => item.id === responseItem.id) + draft[currentIndex] = { + ...draft[currentIndex], + ...responseItem, + } + })) + }, + onNodeFinished: ({ data }) => { + const currentIndex = responseItem.workflowProcess!.tracing!.findIndex(item => item.node_id === data.node_id) + responseItem.workflowProcess!.tracing[currentIndex] = data as any + handleUpdateChatList(produce(chatListRef.current, (draft) => { + const currentIndex = draft.findIndex(item => item.id === responseItem.id) + draft[currentIndex] = { + ...draft[currentIndex], + ...responseItem, + } + })) + }, }) return true }, [ diff --git a/web/app/components/header/nav/nav-selector/index.tsx b/web/app/components/header/nav/nav-selector/index.tsx index 15da5885d99080..8afcbf66a0c15f 100644 --- a/web/app/components/header/nav/nav-selector/index.tsx +++ b/web/app/components/header/nav/nav-selector/index.tsx @@ -1,6 +1,6 @@ 'use client' import { useCallback } from 'react' -import { ChevronDownIcon, PlusIcon } from '@heroicons/react/24/solid' +import cn from 'classnames' import { Menu } from '@headlessui/react' import { useRouter } from 'next/navigation' import { debounce } from 'lodash-es' @@ -8,6 +8,8 @@ import Indicator from '../../indicator' import AppIcon from '@/app/components/base/app-icon' import { useAppContext } from '@/context/app-context' import { useStore as useAppStore } from '@/app/components/app/store' +import { ChevronDown } from '@/app/components/base/icons/src/vender/line/arrows' +import { Plus } from '@/app/components/base/icons/src/vender/line/general' export type NavItem = { id: string @@ -24,11 +26,6 @@ export type INavSelectorProps = { onLoadmore?: () => void } -const itemClassName = ` - flex items-center w-full h-10 px-3 text-gray-700 text-[14px] - rounded-lg font-normal hover:bg-gray-100 cursor-pointer truncate -` - const NavSelector = ({ curNav, navs, createText, onCreate, onLoadmore }: INavSelectorProps) => { const router = useRouter() const { isCurrentWorkspaceManager } = useAppContext() @@ -46,67 +43,58 @@ const NavSelector = ({ curNav, navs, createText, onCreate, onLoadmore }: INavSel return (