From cc6b46e8e586ac2a87dda8c229f6e5eede98abe6 Mon Sep 17 00:00:00 2001 From: Jimmy Wong Date: Tue, 5 Mar 2024 16:42:50 +0800 Subject: [PATCH 1/5] Update Comflowy Console styles and add LinearErrorParsingStrategy --- .../comflowy-console.module.scss | 3 +- .../comflowy-console/comflowy-console.tsx | 8 ++++- .../log-type-custom-nodes-import-result.tsx | 3 +- .../log-types/log-type-linear-shape-error.tsx | 17 +++++++++++ .../comflowy-console/comflowy-log-parser.ts | 29 ++++++++++++++++++- 5 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 apps/electron-frontend/src/components/comflowy-console/log-types/log-type-linear-shape-error.tsx diff --git a/apps/electron-frontend/src/components/comflowy-console/comflowy-console.module.scss b/apps/electron-frontend/src/components/comflowy-console/comflowy-console.module.scss index 5ff1dbe1..3aa7a846 100644 --- a/apps/electron-frontend/src/components/comflowy-console/comflowy-console.module.scss +++ b/apps/electron-frontend/src/components/comflowy-console/comflowy-console.module.scss @@ -28,8 +28,9 @@ padding-top: 4px; line-height: 1.4; font-size: 14px; - color: #A6A7AB; + color: #FFFFFF; word-break: break-word; + font-weight: 700; } } .log-content { diff --git a/apps/electron-frontend/src/components/comflowy-console/comflowy-console.tsx b/apps/electron-frontend/src/components/comflowy-console/comflowy-console.tsx index e2b5b96a..ad7cc7ae 100644 --- a/apps/electron-frontend/src/components/comflowy-console/comflowy-console.tsx +++ b/apps/electron-frontend/src/components/comflowy-console/comflowy-console.tsx @@ -8,6 +8,7 @@ import { LogTypeDefault } from "./log-types/log-type-default"; import { LogTypeCustomNodesImportResult } from "./log-types/log-type-custom-nodes-import-result"; import { LogTypeCustomNodesImportInfo } from "./log-types/log-type-custom-node-import-info"; import { LogTypeExecuteNodeError } from "./log-types/log-type-node-error"; +import { LogTypeLinearShapeError } from "./log-types/log-type-linear-shape-error"; /** * Comflowy Console Component * 1) start a websocket connetion with backend console module , and sync state from backend @@ -78,7 +79,12 @@ function ConsoleLog({log}: {log: ComflowyConsoleLog}) { LogCO = LogTypeCustomNodesImportInfo; break; case ComflowyConsoleLogTypes.EXECUTE_NODE_ERROR: - LogCO = LogTypeExecuteNodeError; + // 你可能会根据错误信息的不同,区分展示的错误类型组件 + if (log.message.includes("RuntimeError")) { + LogCO = LogTypeLinearShapeError; // 使用专门处理线性形状错误的组件 + } else { + LogCO = LogTypeExecuteNodeError; // 其他执行节点错误用现有组件处理 + } break; default: LogCO = LogTypeDefault; diff --git a/apps/electron-frontend/src/components/comflowy-console/log-types/log-type-custom-nodes-import-result.tsx b/apps/electron-frontend/src/components/comflowy-console/log-types/log-type-custom-nodes-import-result.tsx index fe1f401e..216a21ec 100644 --- a/apps/electron-frontend/src/components/comflowy-console/log-types/log-type-custom-nodes-import-result.tsx +++ b/apps/electron-frontend/src/components/comflowy-console/log-types/log-type-custom-nodes-import-result.tsx @@ -10,8 +10,9 @@ export function LogTypeCustomNodesImportResult({log}: {log: ComflowyConsoleLog}) const importFailedExtensions = log.data.failedImports || []; return ( 0 ? "warn" : "info"} title={`Load custom nodes ${importSuccessExtensions.length} success, ${importFailedExtensions.length} failed`} className={`log-type-custom-nodes-import-result`}> - {importSuccessExtensions.length > 0 &&
Successed: {importSuccessExtensions.join(", ")}
} + {/* {importSuccessExtensions.length > 0 &&
Successed: {importSuccessExtensions.join(", ")}
} */} {importFailedExtensions.length > 0 &&
Failed: {importFailedExtensions.join(", ")}
} + For details on the solution, please check: Comflowy FAQ
) } \ No newline at end of file diff --git a/apps/electron-frontend/src/components/comflowy-console/log-types/log-type-linear-shape-error.tsx b/apps/electron-frontend/src/components/comflowy-console/log-types/log-type-linear-shape-error.tsx new file mode 100644 index 00000000..1eb5588d --- /dev/null +++ b/apps/electron-frontend/src/components/comflowy-console/log-types/log-type-linear-shape-error.tsx @@ -0,0 +1,17 @@ +import { MessageViewer } from "../message-viewer"; +import { ComflowyConsoleLog } from "@comflowy/common/types/comflowy-console.types"; +import { Log } from './log'; + +/** + * Log type for linear shape errors + */ +export function LogTypeLinearShapeError({log}: {log: ComflowyConsoleLog}) { + return ( + +
+ Please switch all model files to the files from the same base model. + For details on the solution, please check: Comflowy FAQ +
+
+ ); +} \ No newline at end of file diff --git a/apps/node/src/modules/comflowy-console/comflowy-log-parser.ts b/apps/node/src/modules/comflowy-console/comflowy-log-parser.ts index b3695500..b8eee43a 100644 --- a/apps/node/src/modules/comflowy-console/comflowy-log-parser.ts +++ b/apps/node/src/modules/comflowy-console/comflowy-log-parser.ts @@ -162,9 +162,36 @@ class ExtensionImportParsingStrategy implements LogParsingStrategy { // ... more strategies for other log types ... +class LinearErrorParsingStrategy implements LogParsingStrategy { + private currentLogLines: string[] = []; + + parse(log: string): ComflowyConsoleLog[] { + const ret: ComflowyConsoleLog[] = []; + const linearShapeErrorRegex = /RuntimeError: linear\(\):/; + if (linearShapeErrorRegex.test(log)) { + this.currentLogLines.push(log); + const errorMatch = linearShapeErrorRegex.exec(log); + if (errorMatch) { + const errorMessage = `RuntimeError: ${errorMatch[0]}`; + ret.push({ + id: uuid(), + message: errorMessage, + data: { + type: ComflowyConsoleLogTypes.EXECUTE_NODE_ERROR, + level: "error", + createdAt: +new Date(), + } + }); + } + } + return ret; + } +} + const strategies: LogParsingStrategy[] = [ new ImportResultParsingStrategy(), new ExtensionImportParsingStrategy(), + new LinearErrorParsingStrategy(), ]; export function parseComflowyLogs(logs: string): ComflowyConsoleLog[] { @@ -191,6 +218,6 @@ export function parseComflowyLogsByLine(log: string): ComflowyConsoleLog[] { logList.push(...result); } } - return logList + return logList; } From b2fa067b038d54700e6a8f9a4559ec056240dce9 Mon Sep 17 00:00:00 2001 From: Jimmy Wong Date: Wed, 6 Mar 2024 18:11:52 +0800 Subject: [PATCH 2/5] fix modelConfig bug & add a different error type --- .../components/comflowy-console/comflowy-console.tsx | 10 ++++------ .../modules/comflowy-console/comflowy-log-parser.ts | 2 +- apps/node/src/modules/model-manager/install-model.ts | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/apps/electron-frontend/src/components/comflowy-console/comflowy-console.tsx b/apps/electron-frontend/src/components/comflowy-console/comflowy-console.tsx index ad7cc7ae..026eaf00 100644 --- a/apps/electron-frontend/src/components/comflowy-console/comflowy-console.tsx +++ b/apps/electron-frontend/src/components/comflowy-console/comflowy-console.tsx @@ -79,12 +79,10 @@ function ConsoleLog({log}: {log: ComflowyConsoleLog}) { LogCO = LogTypeCustomNodesImportInfo; break; case ComflowyConsoleLogTypes.EXECUTE_NODE_ERROR: - // 你可能会根据错误信息的不同,区分展示的错误类型组件 - if (log.message.includes("RuntimeError")) { - LogCO = LogTypeLinearShapeError; // 使用专门处理线性形状错误的组件 - } else { - LogCO = LogTypeExecuteNodeError; // 其他执行节点错误用现有组件处理 - } + LogCO = LogTypeExecuteNodeError; + break; + case ComflowyConsoleLogTypes.LINEAR_SHAPE_ERROR: + LogCO = LogTypeLinearShapeError; break; default: LogCO = LogTypeDefault; diff --git a/apps/node/src/modules/comflowy-console/comflowy-log-parser.ts b/apps/node/src/modules/comflowy-console/comflowy-log-parser.ts index b8eee43a..42b1f931 100644 --- a/apps/node/src/modules/comflowy-console/comflowy-log-parser.ts +++ b/apps/node/src/modules/comflowy-console/comflowy-log-parser.ts @@ -177,7 +177,7 @@ class LinearErrorParsingStrategy implements LogParsingStrategy { id: uuid(), message: errorMessage, data: { - type: ComflowyConsoleLogTypes.EXECUTE_NODE_ERROR, + type: ComflowyConsoleLogTypes.LINEAR_SHAPE_ERROR, level: "error", createdAt: +new Date(), } diff --git a/apps/node/src/modules/model-manager/install-model.ts b/apps/node/src/modules/model-manager/install-model.ts index e492e2b7..429747b1 100644 --- a/apps/node/src/modules/model-manager/install-model.ts +++ b/apps/node/src/modules/model-manager/install-model.ts @@ -49,14 +49,14 @@ import { comfyuiService } from "../comfyui/comfyui.service"; export async function downloadDefaultModel(): Promise { try { const modelConfig = { - "name": "v1-5-dream-shaper.ckpt", + "name": "v1-5-dream-shaper.safetensors", "type": "checkpoints", "base": "SD1.5", "sha": "879DB523C30D3B9017143D56705015E15A2CB5628762C11D086FED9538ABD7FD", "save_path": "default", "description": "Stable Diffusion 1.5 DreamShaper ", "reference": "https://civitai.com/models/4384?modelVersionId=128713", - "filename": "v1-5-dream-shaper.ckpt", + "filename": "v1-5-dream-shaper.safetensors", "url": "https://civitai.com/api/download/models/128713", "size": "4067.78M" } as MarketModel; @@ -67,7 +67,7 @@ export async function downloadDefaultModel(): Promise { return true; } - const fileName = "v1-5-dream-shaper.ckpt"; + const fileName = "v1-5-dream-shaper.safetensors"; const tmpOutputFile = path.resolve(getAppTmpDir(), fileName); console.log(tmpOutputFile, finalOutputFile); From d10e1035494a777b49e8941d31b8aa81e4d93c6b Mon Sep 17 00:00:00 2001 From: Jimmy Wong Date: Wed, 6 Mar 2024 20:06:13 +0800 Subject: [PATCH 3/5] ignore prompt validation errors --- .../src/modules/comflowy-console/comflowy-run-result-parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/node/src/modules/comflowy-console/comflowy-run-result-parser.ts b/apps/node/src/modules/comflowy-console/comflowy-run-result-parser.ts index 1f6d1710..00fe3752 100644 --- a/apps/node/src/modules/comflowy-console/comflowy-run-result-parser.ts +++ b/apps/node/src/modules/comflowy-console/comflowy-run-result-parser.ts @@ -29,7 +29,7 @@ export function parseComflowyRunErrors(worfklowInfo: PersistedWorkflowDocument, }); const { error } = runErrors; - if (error) { + if (error && error.message !== 'Prompt outputs failed validation') { // ignore prompt validation errors logList.push({ id: uuid(), message: error.message, From a9f28505a15ed7a0d713d2be30a90d97dccde1ec Mon Sep 17 00:00:00 2001 From: Jimmy Wong Date: Wed, 6 Mar 2024 20:16:49 +0800 Subject: [PATCH 4/5] When the plugins are all successfully imported, the notification is no longer displayed. --- .../comflowy-console/comflowy-log-parser.ts | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/apps/node/src/modules/comflowy-console/comflowy-log-parser.ts b/apps/node/src/modules/comflowy-console/comflowy-log-parser.ts index 42b1f931..0380505e 100644 --- a/apps/node/src/modules/comflowy-console/comflowy-log-parser.ts +++ b/apps/node/src/modules/comflowy-console/comflowy-log-parser.ts @@ -39,18 +39,20 @@ class ImportResultParsingStrategy implements LogParsingStrategy { } } - console.log("importResults", importResults, successfulImports, failedImports); - ret.push({ - id: uuid(), - message: `Import results: ${successfulImports.length} successful, ${failedImports.length} failed`, - data: { - type: ComflowyConsoleLogTypes.CUSTOM_NODES_IMPORT_RESULT, - level: "info", - createdAt: +new Date(), - successfulImports, - failedImports, - } - }); + if (failedImports.length > 0) { + console.log("importResults", importResults, successfulImports, failedImports); + ret.push({ + id: uuid(), + message: `Import results: ${successfulImports.length} successful, ${failedImports.length} failed`, + data: { + type: ComflowyConsoleLogTypes.CUSTOM_NODES_IMPORT_RESULT, + level: "info", + createdAt: +new Date(), + successfulImports, + failedImports, + } + }); + } } else { this.currentLogLines.push(log); } From 6d6d9716a6d8ef790ce98a66e0cdb1c2531143ad Mon Sep 17 00:00:00 2001 From: Jimmy Wong Date: Wed, 6 Mar 2024 21:03:52 +0800 Subject: [PATCH 5/5] Show only messages from the current workflow. --- .../comflowy-console/log-types/log-type-node-error.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/electron-frontend/src/components/comflowy-console/log-types/log-type-node-error.tsx b/apps/electron-frontend/src/components/comflowy-console/log-types/log-type-node-error.tsx index 5142bbab..4c3eee82 100644 --- a/apps/electron-frontend/src/components/comflowy-console/log-types/log-type-node-error.tsx +++ b/apps/electron-frontend/src/components/comflowy-console/log-types/log-type-node-error.tsx @@ -25,11 +25,16 @@ function WorkflowPageNodeError({ log }: { log: ComflowyConsoleLog }) { const nodes = useAppStore(st => st.nodes); const router = useRouter(); const currentWorkflowId = router.query.id; + + if (workflowId !== currentWorkflowId) { + return null; + } + const node = nodes.find(n => n.id === nodeId); const { setViewport, setCenter, zoomIn, zoomOut } = useReactFlow(); const storeApi = useStoreApi(); - if (!node || currentWorkflowId !== workflowId) { + if (!node) { return }