Skip to content

Commit dfa4b77

Browse files
authored
fix clicking nested workflow (#11391)
## Description Fix clicking nested workflows in the sidepanel. Previously, clicking "View Nested Graph" on a workflow node inside an already-open nested workflow panel would throw a runtime error (`TypeError: n is not a function`). Additionally, even if the click succeeded, the graph wouldn't update - only the title would change. **Changes:** - Updated `WorkflowNestedNode` to use `useWorkflowStepDetail` directly instead of going through `WorkflowNestedGraphContext`, which wasn't available inside the nested graph panel - Added a `key` prop to `ReactFlowProvider` in the step detail panel to force React to remount the graph when switching between nested workflows, ensuring the nodes/edges reinitialize with the new data ## Related Issue(s) #11385 ## Type of Change - [x] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [ ] Test update ## Checklist - [x] I have made corresponding changes to the documentation (if applicable) - [ ] I have added tests that prove my fix is effective or that my feature works <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed a runtime error that occurred when clicking "View Nested Graph" in nested workflow panels. * Improved graph updating behavior when switching between different nested workflows. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 20e411a commit dfa4b77

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

.changeset/common-hoops-lose.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@mastra/playground-ui': patch
3+
---
4+
5+
Fix clicking nested workflows in sidepanel: resolve runtime error when clicking "View Nested Graph" inside an already-open nested workflow panel, and ensure the graph updates when switching between nested workflows.

packages/playground-ui/src/domains/workflows/components/workflow-step-detail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function WorkflowStepDetailContent() {
5252
{stepDetail.type === 'map-config' && stepDetail.mapConfig && <CodeDialogContent data={stepDetail.mapConfig} />}
5353
{stepDetail.type === 'nested-graph' && stepDetail.nestedGraph && (
5454
<div className="h-full min-h-[400px]">
55-
<ReactFlowProvider>
55+
<ReactFlowProvider key={stepDetail.nestedGraph.fullStep}>
5656
<WorkflowNestedGraph
5757
stepGraph={stepDetail.nestedGraph.stepGraph}
5858
open={true}

packages/playground-ui/src/domains/workflows/workflow/workflow-nested-node.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { CircleDashed, HourglassIcon, Loader2, PauseIcon, ShieldAlert } from 'lu
44
import { SerializedStepFlowEntry } from '@mastra/core/workflows';
55

66
import { cn } from '@/lib/utils';
7-
import { useContext } from 'react';
8-
import { WorkflowNestedGraphContext } from '../context/workflow-nested-graph-context';
7+
import { useWorkflowStepDetail } from '../context/workflow-step-detail-context';
98
import { useCurrentRun } from '../context/use-current-run';
109
import { CheckIcon, CrossIcon, Icon } from '@/ds/icons';
1110
import { Txt } from '@/ds/components/Txt';
@@ -41,7 +40,7 @@ export function WorkflowNestedNode({
4140
stepsFlow,
4241
}: NodeProps<NestedNode> & WorkflowNestedNodeProps) {
4342
const { steps } = useCurrentRun();
44-
const { showNestedGraph } = useContext(WorkflowNestedGraphContext);
43+
const { showNestedGraph } = useWorkflowStepDetail();
4544

4645
const {
4746
label,

0 commit comments

Comments
 (0)