feat(editor): Show logs panel in execution history page (#14477)

This commit is contained in:
Suguru Inoue
2025-04-15 13:26:02 +02:00
committed by GitHub
parent dfc40397c1
commit ed19f0f39b
27 changed files with 596 additions and 165 deletions

View File

@@ -1,5 +1,6 @@
import { type LlmTokenUsageData, type IAiDataContent } from '@/Interface';
import { type LlmTokenUsageData, type IAiDataContent, type INodeUi } from '@/Interface';
import {
AGENT_LANGCHAIN_NODE_TYPE,
type IRunData,
type INodeExecutionData,
type ITaskData,
@@ -226,6 +227,46 @@ export function formatTokenUsageCount(
return usage.isEstimate ? `~${count}` : count.toLocaleString();
}
export function findLogEntryToAutoSelect(
tree: TreeNode[],
nodesByName: Record<string, INodeUi>,
runData: IRunData,
): TreeNode | undefined {
return findLogEntryToAutoSelectRec(tree, nodesByName, runData, 0);
}
function findLogEntryToAutoSelectRec(
tree: TreeNode[],
nodesByName: Record<string, INodeUi>,
runData: IRunData,
depth: number,
): TreeNode | undefined {
for (const entry of tree) {
const taskData = runData[entry.node]?.[entry.runIndex];
if (taskData?.error) {
return entry;
}
const childAutoSelect = findLogEntryToAutoSelectRec(
entry.children,
nodesByName,
runData,
depth + 1,
);
if (childAutoSelect) {
return childAutoSelect;
}
if (nodesByName[entry.node]?.type === AGENT_LANGCHAIN_NODE_TYPE) {
return entry;
}
}
return depth === 0 ? tree[0] : undefined;
}
export function createLogEntries(workflow: Workflow, runData: IRunData) {
const runs = Object.entries(runData)
.filter(([nodeName]) => workflow.getChildNodes(nodeName, 'ALL_NON_MAIN').length === 0)