fix(flow): 修复Rhai脚本执行错误处理并优化变量解析逻辑
refactor(engine): 重构Rhai表达式错误处理为枚举类型 fix(script_rhai): 修正脚本文件读取和执行失败的错误返回 perf(testrun): 优化前端测试面板日志去重和显示逻辑
This commit is contained in:
@ -108,7 +108,23 @@ export const TestRunSidePanel: FC<TestRunSidePanelProps> = ({ visible, onCancel
|
||||
? customService.runStreamWS(values, {
|
||||
onNode: (evt) => {
|
||||
if (evt.ctx) setStreamCtx((prev: any) => ({ ...(prev || {}), ...(evt.ctx || {}) }));
|
||||
if (evt.logs && evt.logs.length) setStreamLogs((prev: string[]) => [...prev, ...evt.logs!]);
|
||||
if (evt.logs && evt.logs.length) {
|
||||
const normalizeLog = (s: string) => s.replace(/\r/g, '').trim();
|
||||
const dedupLogs = (arr: string[]) => {
|
||||
const seen = new Set<string>();
|
||||
const res: string[] = [];
|
||||
for (const s of arr) {
|
||||
const key = normalizeLog(s);
|
||||
if (!seen.has(key)) {
|
||||
seen.add(key);
|
||||
res.push(s);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
};
|
||||
const incoming = evt.logs!;
|
||||
setStreamLogs((prev) => dedupLogs([...(prev || []), ...incoming]));
|
||||
}
|
||||
},
|
||||
onError: (evt) => {
|
||||
const msg = evt.message || I18n.t('Run failed');
|
||||
@ -282,13 +298,18 @@ export const TestRunSidePanel: FC<TestRunSidePanelProps> = ({ visible, onCancel
|
||||
{/* 运行中(流式)时,直接在表单区域下方展示实时输出,而不是覆盖整块内容 */}
|
||||
{streamMode && isRunning && (
|
||||
<>
|
||||
<NodeStatusGroup title={I18n.t('Context') + ' (Live)'} data={streamCtx} optional disableCollapse />
|
||||
<NodeStatusGroup title={I18n.t('Logs') + ' (Live)'} data={streamLogs} optional disableCollapse />
|
||||
<NodeStatusGroup title={I18n.t('Context') + ' (Live)'} data={streamCtx} optional disableCollapse />
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 展示后端返回的执行信息:仅在非流式或流式已结束时显示,避免与实时输出重复 */}
|
||||
{(!streamMode || !isRunning) && (
|
||||
<>
|
||||
<NodeStatusGroup title={I18n.t('Logs')} data={result?.logs} optional disableCollapse />
|
||||
<NodeStatusGroup title={I18n.t('Context')} data={result?.ctx} optional disableCollapse />
|
||||
</>
|
||||
)}
|
||||
{/* 展示后端返回的执行信息 */}
|
||||
<NodeStatusGroup title={I18n.t('Context')} data={result?.ctx} optional disableCollapse />
|
||||
<NodeStatusGroup title={I18n.t('Logs')} data={result?.logs} optional disableCollapse />
|
||||
</div>
|
||||
);
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user