Skip to content

Commit

Permalink
Merge pull request #220 from 6174/update-new-error-notification
Browse files Browse the repository at this point in the history
Update Comflowy Console styles and add LinearErrorParsingStrategy
  • Loading branch information
6174 authored Mar 6, 2024
2 parents 1de8b53 + 6d6d971 commit 12609b8
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -78,7 +79,10 @@ function ConsoleLog({log}: {log: ComflowyConsoleLog}) {
LogCO = LogTypeCustomNodesImportInfo;
break;
case ComflowyConsoleLogTypes.EXECUTE_NODE_ERROR:
LogCO = LogTypeExecuteNodeError;
LogCO = LogTypeExecuteNodeError;
break;
case ComflowyConsoleLogTypes.LINEAR_SHAPE_ERROR:
LogCO = LogTypeLinearShapeError;
break;
default:
LogCO = LogTypeDefault;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ export function LogTypeCustomNodesImportResult({log}: {log: ComflowyConsoleLog})
const importFailedExtensions = log.data.failedImports || [];
return (
<Log log={log} level={importFailedExtensions.length > 0 ? "warn" : "info"} title={`Load custom nodes ${importSuccessExtensions.length} success, ${importFailedExtensions.length} failed`} className={`log-type-custom-nodes-import-result`}>
{importSuccessExtensions.length > 0 && <div>Successed: {importSuccessExtensions.join(", ")}</div>}
{/* {importSuccessExtensions.length > 0 && <div>Successed: {importSuccessExtensions.join(", ")}</div>} */}
{importFailedExtensions.length > 0 && <div>Failed: {importFailedExtensions.join(", ")}</div>}
For details on the solution, please check: <a href="https://www.comflowy.com/blog/comflowy-faq#extension" target="_blank">Comflowy FAQ</a>
</Log>
)
}
Original file line number Diff line number Diff line change
@@ -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 (
<Log log={log} level="error" title="Using multiple different base models" className={`log-type-linear-shape-error`}>
<div>
Please switch all model files to the files from the same base model.
For details on the solution, please check: <a href="https://www.comflowy.com/blog/comflowy-faq#multiple-different-base-models" target="_blank">Comflowy FAQ</a>
</div>
</Log>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 <LogTypeDefault log={log} />
}

Expand Down
55 changes: 42 additions & 13 deletions apps/node/src/modules/comflowy-console/comflowy-log-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -162,9 +164,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.LINEAR_SHAPE_ERROR,
level: "error",
createdAt: +new Date(),
}
});
}
}
return ret;
}
}

const strategies: LogParsingStrategy[] = [
new ImportResultParsingStrategy(),
new ExtensionImportParsingStrategy(),
new LinearErrorParsingStrategy(),
];

export function parseComflowyLogs(logs: string): ComflowyConsoleLog[] {
Expand All @@ -191,6 +220,6 @@ export function parseComflowyLogsByLine(log: string): ComflowyConsoleLog[] {
logList.push(...result);
}
}
return logList
return logList;
}

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 12609b8

Please sign in to comment.