From 98ad18ba81cbcbc0ec79749b52c0fdb4c7be54da Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Wed, 8 Jan 2025 14:19:50 +0800 Subject: [PATCH] fix: agent log --- web/app/components/plugins/card/index.tsx | 4 +-- web/app/components/plugins/hooks.ts | 28 +++++++++++++++++++ .../components/plugins/plugin-item/index.tsx | 4 +-- .../workflow/run/agent-log/agent-log-item.tsx | 10 +++---- .../workflow/run/agent-log/agent-log-nav.tsx | 5 ++-- .../run/agent-log/agent-log-trigger.tsx | 4 ++- .../workflow/run/special-result-panel.tsx | 7 +++-- .../components/workflow/run/tracing-panel.tsx | 8 +++++- web/i18n/en-US/plugin.ts | 9 +++++- web/i18n/zh-Hans/plugin.ts | 7 +++++ web/service/use-plugins.ts | 2 +- 11 files changed, 71 insertions(+), 17 deletions(-) diff --git a/web/app/components/plugins/card/index.tsx b/web/app/components/plugins/card/index.tsx index ff86a3c39c..04ef0dd1ee 100644 --- a/web/app/components/plugins/card/index.tsx +++ b/web/app/components/plugins/card/index.tsx @@ -11,7 +11,7 @@ import Placeholder from './base/placeholder' import cn from '@/utils/classnames' import { useGetLanguage } from '@/context/i18n' import { getLanguage } from '@/i18n/language' -import { useCategories } from '../hooks' +import { useSingleCategories } from '../hooks' import { renderI18nObject } from '@/hooks/use-i18n' export type Props = { @@ -43,7 +43,7 @@ const Card = ({ }: Props) => { const defaultLocale = useGetLanguage() const locale = localeFromProps ? getLanguage(localeFromProps) : defaultLocale - const { categoriesMap } = useCategories() + const { categoriesMap } = useSingleCategories() const { category, type, name, org, label, brief, icon, verified } = payload const isBundle = !['plugin', 'model', 'tool', 'extension', 'agent_strategy'].includes(type) const cornerMark = isBundle ? categoriesMap.bundle?.label : categoriesMap[category]?.label diff --git a/web/app/components/plugins/hooks.ts b/web/app/components/plugins/hooks.ts index 7c3003497b..371b769019 100644 --- a/web/app/components/plugins/hooks.ts +++ b/web/app/components/plugins/hooks.ts @@ -64,3 +64,31 @@ export const useCategories = (translateFromOut?: TFunction) => { categoriesMap, } } + +export const useSingleCategories = (translateFromOut?: TFunction) => { + const { t: translation } = useTranslation() + const t = translateFromOut || translation + + const categories = categoryKeys.map((category) => { + if (category === 'agent') { + return { + name: 'agent_strategy', + label: t(`plugin.categorySingle.${category}`), + } + } + return { + name: category, + label: t(`plugin.categorySingle.${category}`), + } + }) + + const categoriesMap = categories.reduce((acc, category) => { + acc[category.name] = category + return acc + }, {} as Record) + + return { + categories, + categoriesMap, + } +} diff --git a/web/app/components/plugins/plugin-item/index.tsx b/web/app/components/plugins/plugin-item/index.tsx index ef564230ea..3dd520d39a 100644 --- a/web/app/components/plugins/plugin-item/index.tsx +++ b/web/app/components/plugins/plugin-item/index.tsx @@ -22,7 +22,7 @@ import cn from '@/utils/classnames' import { API_PREFIX, MARKETPLACE_URL_PREFIX } from '@/config' import { useInvalidateInstalledPluginList } from '@/service/use-plugins' import { useInvalidateAllBuiltInTools, useInvalidateAllToolProviders } from '@/service/use-tools' -import { useCategories } from '../hooks' +import { useSingleCategories } from '../hooks' import { useProviderContext } from '@/context/provider-context' import { useRenderI18nObject } from '@/hooks/use-i18n' @@ -36,7 +36,7 @@ const PluginItem: FC = ({ plugin, }) => { const { t } = useTranslation() - const { categoriesMap } = useCategories() + const { categoriesMap } = useSingleCategories() const currentPluginID = usePluginPageContext(v => v.currentPluginID) const setCurrentPluginID = usePluginPageContext(v => v.setCurrentPluginID) const invalidateInstalledPluginList = useInvalidateInstalledPluginList() diff --git a/web/app/components/workflow/run/agent-log/agent-log-item.tsx b/web/app/components/workflow/run/agent-log/agent-log-item.tsx index 26c734874d..8403dd68dc 100644 --- a/web/app/components/workflow/run/agent-log/agent-log-item.tsx +++ b/web/app/components/workflow/run/agent-log/agent-log-item.tsx @@ -30,26 +30,26 @@ const AgentLogItem = ({
setExpanded(!expanded)} > { expanded - ? - : + ? + : }
{label}
-
0.02s
+ {/*
0.02s
*/}
{ expanded && (
{ - !!children.length && ( + !!children?.length && ( { diff --git a/web/app/components/workflow/run/agent-log/agent-log-trigger.tsx b/web/app/components/workflow/run/agent-log/agent-log-trigger.tsx index 825f59f085..987c3afc2a 100644 --- a/web/app/components/workflow/run/agent-log/agent-log-trigger.tsx +++ b/web/app/components/workflow/run/agent-log/agent-log-trigger.tsx @@ -24,7 +24,9 @@ const AgentLogTrigger = ({
onShowAgentOrToolLog({ id: nodeInfo.id, children: agentLog || [] } as AgentLogItemWithChildren)} + onClick={() => { + onShowAgentOrToolLog({ id: nodeInfo.id, children: agentLog || [] } as AgentLogItemWithChildren) + }} > Detail diff --git a/web/app/components/workflow/run/special-result-panel.tsx b/web/app/components/workflow/run/special-result-panel.tsx index 52e3786fad..cdd77894f5 100644 --- a/web/app/components/workflow/run/special-result-panel.tsx +++ b/web/app/components/workflow/run/special-result-panel.tsx @@ -36,7 +36,10 @@ const SpecialResultPanel = ({ handleShowAgentOrToolLog, }: SpecialResultPanelProps) => { return ( - <> +
{ + e.stopPropagation() + e.nativeEvent.stopImmediatePropagation() + }}> { !!showRetryDetail && !!retryResultList?.length && setShowRetryDetailFalse && ( ) } - +
) } diff --git a/web/app/components/workflow/run/tracing-panel.tsx b/web/app/components/workflow/run/tracing-panel.tsx index d65b7b73eb..758e9cfcf8 100644 --- a/web/app/components/workflow/run/tracing-panel.tsx +++ b/web/app/components/workflow/run/tracing-panel.tsx @@ -166,7 +166,13 @@ const TracingPanel: FC = ({ } return ( -
+
{ + e.stopPropagation() + e.nativeEvent.stopImmediatePropagation() + }} + > {treeNodes.map(renderNode)}
) diff --git a/web/i18n/en-US/plugin.ts b/web/i18n/en-US/plugin.ts index b5c4688818..603b403435 100644 --- a/web/i18n/en-US/plugin.ts +++ b/web/i18n/en-US/plugin.ts @@ -3,10 +3,17 @@ const translation = { all: 'All', models: 'Models', tools: 'Tools', - agents: 'Agent Strategy', + agents: 'Agent Strategies', extensions: 'Extensions', bundles: 'Bundles', }, + categorySingle: { + model: 'Model', + tool: 'Tool', + agent: 'Agent Strategy', + extension: 'Extension', + bundle: 'Bundle', + }, search: 'Search', allCategories: 'All Categories', searchCategories: 'Search Categories', diff --git a/web/i18n/zh-Hans/plugin.ts b/web/i18n/zh-Hans/plugin.ts index 951e8e10be..55d7dd81f0 100644 --- a/web/i18n/zh-Hans/plugin.ts +++ b/web/i18n/zh-Hans/plugin.ts @@ -7,6 +7,13 @@ const translation = { extensions: '扩展', bundles: '插件集', }, + categorySingle: { + model: '模型', + tool: '工具', + agent: 'Agent 策略', + extension: '扩展', + bundle: '插件集', + }, search: '搜索', allCategories: '所有类别', searchCategories: '搜索类别', diff --git a/web/service/use-plugins.ts b/web/service/use-plugins.ts index f885efd761..a33ca9af46 100644 --- a/web/service/use-plugins.ts +++ b/web/service/use-plugins.ts @@ -365,7 +365,7 @@ export const usePluginTaskList = () => { queryKey: usePluginTaskListKey, queryFn: async () => { const currentData = await get<{ tasks: PluginTask[] }>('/workspaces/current/plugin/tasks?page=1&page_size=100') - const taskDone = currentData.tasks.every(task => task.status === TaskStatus.success) + const taskDone = currentData.tasks.every(task => task.status === TaskStatus.success || task.status === TaskStatus.failed) if (taskDone) setEnabled(false)