diff --git a/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts index 2ba020e8..6937ed4c 100644 --- a/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts +++ b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts @@ -167,3 +167,33 @@ export function hasNavigationGoal( ): item is { navigation_goal: unknown } { return item !== null && typeof item === "object" && "navigation_goal" in item; } + +// Branch evaluation types for conditional blocks +export type BranchEvaluation = { + branch_id: string; + branch_index: number; + criteria_type: "jinja2_template" | "prompt" | null; + original_expression: string | null; + rendered_expression: string | null; + result: boolean | null; + is_matched: boolean; + is_default: boolean; + next_block_label: string | null; + error: string | null; +}; + +export type ConditionalBlockOutput = { + evaluations?: Array; + matched_branch_index?: number | null; +}; + +export function hasEvaluations( + output: unknown, +): output is ConditionalBlockOutput { + return ( + output !== null && + typeof output === "object" && + "evaluations" in output && + Array.isArray((output as ConditionalBlockOutput).evaluations) + ); +} diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx index 815d72d3..600dead4 100644 --- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx +++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx @@ -18,6 +18,7 @@ import { isObserverThought, isThoughtItem, isWorkflowRunBlock, + hasEvaluations, WorkflowRunBlock, WorkflowRunTimelineItem, } from "../types/workflowRunTypes"; @@ -180,29 +181,100 @@ function WorkflowRunTimelineBlockItem({
{block.description}
) : null} {block.block_type === "conditional" && block.executed_branch_id && ( -
- {block.executed_branch_expression !== null && - block.executed_branch_expression !== undefined ? ( -
- Condition{" "} - - {block.executed_branch_expression} - {" "} - evaluated to{" "} - True +
+ {hasEvaluations(block.output) && block.output.evaluations ? ( + // New format: show all branch evaluations +
+ {block.output.evaluations.map((evaluation, index) => ( +
+ {evaluation.is_default ? ( +
+ Default branch + {evaluation.is_matched && ( + ✓ Matched + )} +
+ ) : ( +
+
+ + {evaluation.original_expression} + +
+ {evaluation.rendered_expression && + evaluation.rendered_expression !== + evaluation.original_expression && ( +
+ → rendered to{" "} + + {evaluation.rendered_expression} + +
+ )} +
+ evaluated to + + {evaluation.result ? "True" : "False"} + + {evaluation.is_matched && ( + ✓ Matched + )} +
+
+ )} + {evaluation.is_matched && evaluation.next_block_label && ( +
+ → Executing next block:{" "} + + {evaluation.next_block_label} + +
+ )} +
+ ))}
) : ( -
- No conditions matched, executing default branch -
- )} - {block.executed_branch_next_block && ( -
- → Executing next block:{" "} - - {block.executed_branch_next_block} - -
+ // Fallback: old format without evaluations array + <> + {block.executed_branch_expression !== null && + block.executed_branch_expression !== undefined ? ( +
+ Condition{" "} + + {block.executed_branch_expression} + {" "} + evaluated to{" "} + True +
+ ) : ( +
+ No conditions matched, executing default branch +
+ )} + {block.executed_branch_next_block && ( +
+ → Executing next block:{" "} + + {block.executed_branch_next_block} + +
+ )} + )}
)}