Fix: Fixed share-log UI issues and log-template bugs (#9166)

### What problem does this PR solve?

Fix: Fixed share-log UI issues and log-template bugs #3221

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
chanx
2025-08-01 18:32:38 +08:00
committed by GitHub
parent 8fd12b670e
commit 01bf799a59
13 changed files with 331 additions and 89 deletions

View File

@ -25,21 +25,25 @@ export const AgentLogDetailModal: React.FC<CustomModalProps> = ({
const { data: canvasInfo } = useFetchAgent();
const shortMessage = useMemo(() => {
const content = derivedMessages[0]?.content || '';
if (derivedMessages?.length) {
const content = derivedMessages[0]?.content || '';
const chineseCharCount = (content.match(/[\u4e00-\u9fa5]/g) || []).length;
const totalLength = content.length;
const chineseCharCount = (content.match(/[\u4e00-\u9fa5]/g) || []).length;
const totalLength = content.length;
if (chineseCharCount > 0) {
if (totalLength > 15) {
return content.substring(0, 15) + '...';
if (chineseCharCount > 0) {
if (totalLength > 15) {
return content.substring(0, 15) + '...';
}
} else {
if (totalLength > 30) {
return content.substring(0, 30) + '...';
}
}
return content;
} else {
if (totalLength > 30) {
return content.substring(0, 30) + '...';
}
return '';
}
return content;
}, [derivedMessages]);
return (
@ -52,7 +56,7 @@ export const AgentLogDetailModal: React.FC<CustomModalProps> = ({
className="!w-[900px]"
>
<div className="flex items-start mb-4 flex-col gap-4 justify-start">
<div>
<div className="w-full">
{derivedMessages?.map((message, i) => {
return (
<MessageItem

View File

@ -147,7 +147,7 @@ const AgentLogPage: React.FC = () => {
setPagination((pre) => {
return {
...pre,
current: current ?? pre.current,
current: current ?? pre.pageSize ? 1 : pre.current,
pageSize: pageSize ?? pre.pageSize,
};
});
@ -196,8 +196,10 @@ const AgentLogPage: React.FC = () => {
const [openModal, setOpenModal] = useState(false);
const [modalData, setModalData] = useState<IAgentLogResponse>();
const showLogDetail = (item: IAgentLogResponse) => {
setModalData(item);
setOpenModal(true);
if (item?.round) {
setModalData(item);
setOpenModal(true);
}
};
return (

View File

@ -11,7 +11,7 @@ import { useSetModalState } from '@/hooks/common-hooks';
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
import { useFetchAgentTemplates, useSetAgent } from '@/hooks/use-agent-request';
import { IFlowTemplate } from '@/interfaces/database/flow';
import { useCallback, useEffect, useState } from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { CreateAgentDialog } from './create-agent-dialog';
import { TemplateCard } from './template-card';
@ -70,15 +70,19 @@ export default function AgentTemplates() {
],
);
const handleSiderBarChange = (keyword: string) => {
const tempList = list.filter(
(item, index) =>
item.canvas_type
?.toLocaleLowerCase()
.includes(keyword?.toLocaleLowerCase()) || index === 0,
);
setTemplateList(tempList);
setSelectMenuItem(keyword);
};
const tempListFilter = useMemo(() => {
if (!selectMenuItem) {
return templateList;
}
return templateList.filter(
(item, index) =>
item.canvas_type?.toLocaleLowerCase() ===
selectMenuItem?.toLocaleLowerCase() || index === 0,
);
}, [selectMenuItem, templateList]);
return (
<section>
<PageHeader>
@ -104,7 +108,7 @@ export default function AgentTemplates() {
<main className="flex-1 bg-text-title-invert/50 h-dvh">
<div className="grid gap-6 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 max-h-[94vh] overflow-auto px-8 pt-8">
{templateList?.map((x, index) => {
{tempListFilter?.map((x, index) => {
return (
<TemplateCard
isCreate={index === 0}