bug: 工作流加载不会重复多次加载最新版本
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
function getImportPath(filename) {
|
||||
return `./${filename}`;
|
||||
}
|
||||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-D10zXUYF.js","copilot_web/vendor-markdown-CBmlBP6m.js","copilot_web/vendor-react-Dixhfmvb.js","copilot_web/message-components-B7JTmHko.js","copilot_web/input.js","copilot_web/assets/input-CRBDhXDN.css","copilot_web/fonts.css"].map(path => {
|
||||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-BQruZuRN.js","copilot_web/vendor-markdown-CBmlBP6m.js","copilot_web/vendor-react-Dixhfmvb.js","copilot_web/message-components-B7JTmHko.js","copilot_web/input.js","copilot_web/assets/input-CRBDhXDN.css","copilot_web/fonts.css"].map(path => {
|
||||
const apiBase = window.comfyAPI?.api?.api?.api_base;
|
||||
if (apiBase) {
|
||||
// 有 API base 时,使用完整路径
|
||||
@@ -11,4 +11,4 @@ function getImportPath(filename) {
|
||||
return `./${path}`;
|
||||
}
|
||||
}))))=>i.map(i=>d[i]);
|
||||
import{_ as a}from"./input.js";import{j as e}from"./vendor-markdown-CBmlBP6m.js";import{r as t,R as i}from"./vendor-react-Dixhfmvb.js";import{C as n}from"./message-components-B7JTmHko.js";const s={EXPLAIN_NODE:"copilot:explain-node",TOOLBOX_USAGE:"copilot:toolbox-usage",TOOLBOX_PARAMETERS:"copilot:toolbox-parameters",TOOLBOX_DOWNSTREAMNODES:"copilot:toolbox-downstreamnodes"},d=i.lazy(()=>a(()=>import(getImportPath("workflowChat-D10zXUYF.js")),__vite__mapDeps([0,1,2,3,4,5,6])).then(o=>({default:o.default})));function c(){const[o,r]=t.useState(!1);return t.useEffect(()=>{const l=()=>{r(!0)};return window.addEventListener(s.EXPLAIN_NODE,l),()=>window.removeEventListener(s.EXPLAIN_NODE,l)},[]),e.jsx(n,{children:e.jsx("div",{className:"h-full w-full flex flex-col",children:e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:e.jsx(d,{visible:!0,triggerUsage:o,onUsageTriggered:()=>r(!1)})})})})}const O=Object.freeze(Object.defineProperty({__proto__:null,default:c},Symbol.toStringTag,{value:"Module"}));export{O as A,s as C};
|
||||
import{_ as a}from"./input.js";import{j as e}from"./vendor-markdown-CBmlBP6m.js";import{r as t,R as i}from"./vendor-react-Dixhfmvb.js";import{C as n}from"./message-components-B7JTmHko.js";const s={EXPLAIN_NODE:"copilot:explain-node",TOOLBOX_USAGE:"copilot:toolbox-usage",TOOLBOX_PARAMETERS:"copilot:toolbox-parameters",TOOLBOX_DOWNSTREAMNODES:"copilot:toolbox-downstreamnodes"},d=i.lazy(()=>a(()=>import(getImportPath("workflowChat-BQruZuRN.js")),__vite__mapDeps([0,1,2,3,4,5,6])).then(o=>({default:o.default})));function c(){const[o,r]=t.useState(!1);return t.useEffect(()=>{const l=()=>{r(!0)};return window.addEventListener(s.EXPLAIN_NODE,l),()=>window.removeEventListener(s.EXPLAIN_NODE,l)},[]),e.jsx(n,{children:e.jsx("div",{className:"h-full w-full flex flex-col",children:e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:e.jsx(d,{visible:!0,triggerUsage:o,onUsageTriggered:()=>r(!1)})})})})}const O=Object.freeze(Object.defineProperty({__proto__:null,default:c},Symbol.toStringTag,{value:"Module"}));export{O as A,s as C};
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+26
-26
File diff suppressed because one or more lines are too long
@@ -212,29 +212,46 @@ export function MessageList({ messages, latestInput, onOptionClick, installedNod
|
||||
|
||||
// 处理工作流更新:实时更新画布
|
||||
if (workflowUpdateExt && workflowUpdateExt.data) {
|
||||
const workflowUpdateKey = `workflow_update_${message.id}`;
|
||||
if (!processedUpdates.current.has(workflowUpdateKey)) {
|
||||
const { workflow_data } = workflowUpdateExt.data;
|
||||
if (typeof window !== 'undefined' && (window as any).app && workflow_data) {
|
||||
try {
|
||||
// 导入通用的工作流应用函数
|
||||
import('../../utils/graphUtils').then(({ applyNewWorkflow }) => {
|
||||
const { workflow_data } = workflowUpdateExt.data;
|
||||
if (typeof window !== 'undefined' && (window as any).app && workflow_data) {
|
||||
// 使用更具体的key,包含workflow_data的hash以检测实际内容变化
|
||||
const contentHash = JSON.stringify(workflow_data).slice(0, 100); // 简单的内容标识
|
||||
const workflowUpdateKey = `workflow_update_${message.id}_${contentHash}`;
|
||||
|
||||
if (!processedUpdates.current.has(workflowUpdateKey)) {
|
||||
const applyWorkflowWithRetry = async (retryCount = 0) => {
|
||||
try {
|
||||
const { applyNewWorkflow } = await import('../../utils/graphUtils');
|
||||
const success = applyNewWorkflow(workflow_data);
|
||||
|
||||
if (success) {
|
||||
// console.log('[MessageList] Successfully applied workflow update');
|
||||
console.log('[MessageList] Successfully applied workflow update');
|
||||
// 标记该更新已处理(只有成功时才标记)
|
||||
processedUpdates.current.add(workflowUpdateKey);
|
||||
} else {
|
||||
// console.warn('[MessageList] Failed to apply workflow update');
|
||||
console.warn(`[MessageList] Failed to apply workflow update (attempt ${retryCount + 1})`);
|
||||
// 重试最多3次
|
||||
if (retryCount < 2) {
|
||||
setTimeout(() => {
|
||||
applyWorkflowWithRetry(retryCount + 1);
|
||||
}, 1000 * (retryCount + 1)); // 递增延迟:1s, 2s
|
||||
} else {
|
||||
console.error('[MessageList] Workflow update failed after 3 attempts');
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
// console.error('[MessageList] Failed to import graphUtils:', error);
|
||||
});
|
||||
} catch (error) {
|
||||
// console.error('[MessageList] Failed to update canvas:', error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`[MessageList] Error in workflow update (attempt ${retryCount + 1}):`, error);
|
||||
// 重试最多3次
|
||||
if (retryCount < 2) {
|
||||
setTimeout(() => {
|
||||
applyWorkflowWithRetry(retryCount + 1);
|
||||
}, 1000 * (retryCount + 1));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
applyWorkflowWithRetry();
|
||||
}
|
||||
// 标记该更新已处理
|
||||
processedUpdates.current.add(workflowUpdateKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,34 +266,48 @@ export function MessageList({ messages, latestInput, onOptionClick, installedNod
|
||||
// }
|
||||
// ]
|
||||
if (paramUpdateExt && paramUpdateExt.data) {
|
||||
const paramUpdateKey = `param_update_${message.id}`;
|
||||
if (!processedUpdates.current.has(paramUpdateKey)) {
|
||||
const { changes } = paramUpdateExt.data;
|
||||
if (typeof window !== 'undefined' && (window as any).app && changes) {
|
||||
try {
|
||||
// 导入通用的参数修改函数
|
||||
import('../../utils/graphUtils').then(({ applyParameterChanges }) => {
|
||||
const { changes } = paramUpdateExt.data;
|
||||
if (typeof window !== 'undefined' && (window as any).app && changes) {
|
||||
// 使用更具体的key,包含changes的hash以检测实际内容变化
|
||||
const contentHash = JSON.stringify(changes).slice(0, 100); // 简单的内容标识
|
||||
const paramUpdateKey = `param_update_${message.id}_${contentHash}`;
|
||||
|
||||
if (!processedUpdates.current.has(paramUpdateKey)) {
|
||||
const applyParamsWithRetry = async (retryCount = 0) => {
|
||||
try {
|
||||
const { applyParameterChanges } = await import('../../utils/graphUtils');
|
||||
// 支持单个change对象或changes数组
|
||||
const changesList = Array.isArray(changes) ? changes : [changes];
|
||||
const success = applyParameterChanges(changesList);
|
||||
|
||||
if (success) {
|
||||
// console.log(`[MessageList] Successfully applied ${changesList.length} parameter changes`);
|
||||
// changesList.forEach(change => {
|
||||
// console.log(`[MessageList] Updated parameter ${change.parameter} in node ${change.node_id} to:`, change.new_value);
|
||||
// });
|
||||
console.log(`[MessageList] Successfully applied ${changesList.length} parameter changes`);
|
||||
// 标记该更新已处理(只有成功时才标记)
|
||||
processedUpdates.current.add(paramUpdateKey);
|
||||
} else {
|
||||
// console.warn('[MessageList] Failed to apply some parameter changes');
|
||||
console.warn(`[MessageList] Failed to apply parameter changes (attempt ${retryCount + 1})`);
|
||||
// 重试最多3次
|
||||
if (retryCount < 2) {
|
||||
setTimeout(() => {
|
||||
applyParamsWithRetry(retryCount + 1);
|
||||
}, 1000 * (retryCount + 1)); // 递增延迟:1s, 2s
|
||||
} else {
|
||||
console.error('[MessageList] Parameter update failed after 3 attempts');
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
// console.error('[MessageList] Failed to import graphUtils:', error);
|
||||
});
|
||||
} catch (error) {
|
||||
// console.error('[MessageList] Failed to update canvas:', error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`[MessageList] Error in parameter update (attempt ${retryCount + 1}):`, error);
|
||||
// 重试最多3次
|
||||
if (retryCount < 2) {
|
||||
setTimeout(() => {
|
||||
applyParamsWithRetry(retryCount + 1);
|
||||
}, 1000 * (retryCount + 1));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
applyParamsWithRetry();
|
||||
}
|
||||
// 标记该更新已处理
|
||||
processedUpdates.current.add(paramUpdateKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user