mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
feat(editor): Show logs panel in execution history page (#14477)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user