Fix: The save interface is continuously called without any operation being performed on the agent page. (#17576)

This commit is contained in:
balibabu
2026-07-31 11:23:12 +08:00
committed by GitHub
parent 0fe49688d1
commit 569a29500f
6 changed files with 24 additions and 9 deletions

View File

@@ -444,7 +444,10 @@ export const useResetAgent = () => {
return { data, loading, resetAgent: mutateAsync };
};
export const useSetAgent = (showMessage: boolean = true) => {
export const useSetAgent = (
showMessage: boolean = true,
skipInvalidation: boolean = false,
) => {
const { id } = useParams();
const queryClient = useQueryClient();
const {
@@ -483,7 +486,7 @@ export const useSetAgent = (showMessage: boolean = true) => {
queryClient.invalidateQueries({
queryKey: [AgentApiAction.FetchAgentListByPage],
});
if (agentId) {
if (agentId && !skipInvalidation) {
queryClient.invalidateQueries({
queryKey: [AgentApiAction.FetchAgentDetail, agentId],
});

View File

@@ -14,9 +14,12 @@ import { useParams } from 'react-router';
import useGraphStore from '../store';
import { useBuildDslData } from './use-build-dsl';
export const useSaveGraph = (showMessage: boolean = true) => {
export const useSaveGraph = (
showMessage: boolean = true,
skipInvalidation: boolean = false,
) => {
const { data } = useFetchAgent();
const { setAgent, loading } = useSetAgent(showMessage);
const { setAgent, loading } = useSetAgent(showMessage, skipInvalidation);
const { id } = useParams();
const { buildDslData } = useBuildDslData();
@@ -72,7 +75,7 @@ export const useWatchAgentChange = (chatDrawerVisible: boolean) => {
const [time, setTime] = useState<string>();
const nodes = useGraphStore((state) => state.nodes);
const edges = useGraphStore((state) => state.edges);
const { saveGraph } = useSaveGraph(false);
const { saveGraph } = useSaveGraph(false, true);
const { data: flowDetail } = useFetchAgent();
const setSaveTime = useCallback((updateTime: number) => {
@@ -86,7 +89,7 @@ export const useWatchAgentChange = (chatDrawerVisible: boolean) => {
const saveAgent = useCallback(async () => {
if (!chatDrawerVisible) {
const ret = await saveGraph();
setSaveTime(ret.data.update_time);
setSaveTime(ret.data.update_time ?? Date.now());
}
}, [chatDrawerVisible, saveGraph, setSaveTime]);

View File

@@ -94,6 +94,7 @@ export function WikiLeftPanel({
<Button
variant="ghost"
size="icon-sm"
className="ml-auto"
disabled={loading}
data-testid="wiki-clear-trigger"
>