From b4c8f75378ff24e749b702a2ce7532163fea778a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Fri, 12 Jun 2026 22:34:17 +0800 Subject: [PATCH] feat: Display more execution process information of the `condition-node` in the execution details --- .../impl/base_condition_node.py | 66 ++++++++++++-- .../execution-detail-card/index.vue | 86 ++++++++++++++++++- ui/src/locales/lang/en-US/ai-chat.ts | 4 + ui/src/locales/lang/zh-CN/ai-chat.ts | 4 + ui/src/locales/lang/zh-Hant/ai-chat.ts | 4 + 5 files changed, 156 insertions(+), 8 deletions(-) diff --git a/apps/application/flow/step_node/condition_node/impl/base_condition_node.py b/apps/application/flow/step_node/condition_node/impl/base_condition_node.py index e0da03ace4c..239fe281f22 100644 --- a/apps/application/flow/step_node/condition_node/impl/base_condition_node.py +++ b/apps/application/flow/step_node/condition_node/impl/base_condition_node.py @@ -9,7 +9,7 @@ from typing import List from application.flow.i_step_node import NodeResult -from application.flow.compare import do_assertion +from application.flow.compare import _assertion from application.flow.step_node.condition_node.i_condition_node import IConditionNode @@ -17,21 +17,72 @@ class BaseConditionNode(IConditionNode): def save_context(self, details, workflow_manage): self.context['branch_id'] = details.get('branch_id') self.context['branch_name'] = details.get('branch_name') + self.context['branch_details'] = details.get('branch_details') self.context['exception_message'] = details.get('err_message') def execute(self, **kwargs) -> NodeResult: branch_list = self.node_params_serializer.data['branch'] - branch = self._execute(branch_list) - r = NodeResult({'branch_id': branch.get('id'), 'branch_name': branch.get('type')}, {}) + branch, branch_details = self._execute(branch_list) + r = NodeResult({ + 'branch_id': branch.get('id') if branch else None, + 'branch_name': branch.get('type') if branch else None, + 'branch_details': branch_details + }, {}) return r def _execute(self, branch_list: List): + branch_details = [] for branch in branch_list: - if self.branch_assertion(branch): - return branch + condition_details = self._evaluate_conditions(branch) + is_matched = all(cond.get('result', False) for cond in condition_details) if branch.get('condition') == 'and' else any(cond.get('result', False) for cond in condition_details) + + branch_details.append({ + 'id': branch.get('id'), + 'type': branch.get('type'), + 'condition_logic': branch.get('condition'), + 'is_matched': is_matched, + 'conditions': condition_details + }) + if is_matched: + return branch, branch_details + return None, branch_details - def branch_assertion(self, branch): - return do_assertion(self.workflow_manage, branch.get('condition'), branch.get('conditions')) + def _evaluate_conditions(self, branch): + condition_logic = branch.get('condition') + condition_list = branch.get('conditions', []) + condition_details = [] + + for condition in condition_list: + field_list = condition.get('field', []) + compare = condition.get('compare', '') + value = condition.get('value', '') + + try: + field_value = self.workflow_manage.get_reference_field(field_list[0], field_list[1:]) + except Exception: + field_value = None + + try: + evaluated_value = self.workflow_manage.generate_prompt(value) + except Exception: + evaluated_value = value + + result = _assertion(self.workflow_manage, field_list, compare, value) + + condition_details.append({ + 'field': field_list, + 'field_type': type(field_value).__name__ if field_value is not None else None, + 'field_value': field_value, + 'compare': compare, + 'target_type': type(evaluated_value).__name__ if evaluated_value is not None else None, + 'target_value': evaluated_value, + 'result': result + }) + + if (condition_logic == "and" and not result) or (condition_logic == 'or' and result): + break + + return condition_details def get_details(self, index: int, **kwargs): return { @@ -40,6 +91,7 @@ def get_details(self, index: int, **kwargs): 'run_time': self.context.get('run_time'), 'branch_id': self.context.get('branch_id'), 'branch_name': self.context.get('branch_name'), + 'branch_details': self.context.get('branch_details'), 'type': self.node.type, 'status': self.status, 'err_message': self.err_message, diff --git a/ui/src/components/execution-detail-card/index.vue b/ui/src/components/execution-detail-card/index.vue index f163b40c7a3..84861c12cfc 100644 --- a/ui/src/components/execution-detail-card/index.vue +++ b/ui/src/components/execution-detail-card/index.vue @@ -182,7 +182,43 @@ {{ $t('aiChat.executionDetails.conditionResult') }}