Skip to content

Workflow runs in side panel #11669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Apr 24, 2025
Merged

Workflow runs in side panel #11669

merged 28 commits into from
Apr 24, 2025

Conversation

Devessier
Copy link
Contributor

@Devessier Devessier commented Apr 22, 2025

@Devessier Devessier force-pushed the workflow-runs-in-side-panel branch from 3495b8c to e8c45a6 Compare April 22, 2025 15:14
Comment on lines -64 to -69
set(
activeTabIdComponentState.atomFamily({
instanceId: WORKFLOW_RUN_STEP_SIDE_PANEL_TAB_LIST_COMPONENT_ID,
}),
null,
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed as we now the page's id as the tab list id.

const activeTabId = useRecoilComponentValueV2(
activeTabIdComponentState,
WORKFLOW_RUN_STEP_SIDE_PANEL_TAB_LIST_COMPONENT_ID,
commandMenuPageComponentInstance.instanceId,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to this, the tab is scoped to the side panel's page. The tab will automatically reset when opening a new node in the side panel.

@@ -145,7 +145,7 @@ export const useRecordShowContainerTabs = (
tabs: {
workflow: {
title: 'Flow',
position: 0,
position: 101,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do as with the other object specific layouts: position it after the fields in the side panel.

Comment on lines +17 to +20
const { success, data: record } = useMemo(
() => workflowRunSchema.safeParse(rawRecord),
[rawRecord],
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memoize to prevent useEffect unwanted re-runs.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR implements workflow run visualization in the side panel, with support for form steps and improved diagram rendering management.

  • Added /packages/twenty-front/src/modules/workflow/workflow-diagram/states/workflowDiagramStatusState.ts to manage diagram rendering phases ('computing-diagram', 'computing-dimensions', 'done')
  • Added e2e tests in /packages/twenty-e2e-testing/tests/workflow-run.spec.ts for workflow run visualization and form step handling
  • Added useSetInitialWorkflowRunRightDrawerTab hook to manage initial tab selection based on execution status
  • Optimized workflow run validation with useMemo in useWorkflowRun.ts
  • Improved viewport management with right drawer in WorkflowDiagramCanvasBase.tsx

19 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +121 to +124
// 1. Exit the dropdown
await workflowRunNameCell.click();
// 2. Actually open the workflow run in the side panel
await workflowRunNameCell.click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Double click on workflowRunNameCell could be flaky. Consider using a more reliable way to exit dropdown and open side panel, or add wait conditions between clicks.

Comment on lines +20 to 25
if (
!isDefined(workflowRun) ||
workflowDiagramStatus === 'computing-diagram'
) {
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider showing a loading spinner or skeleton instead of returning null during computation

Comment on lines +222 to +224
if (!isDefined(containerRef.current)) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Early return without calling onInit() could lead to missed initialization. Consider calling onInit() even if containerRef is not defined

Comment on lines 12 to 71
const setInitialWorkflowRunRightDrawerTab = useRecoilCallback(
({ snapshot, set }) =>
({
workflowSelectedNode,
stepExecutionStatus,
}: {
workflowSelectedNode: string;
stepExecutionStatus: WorkflowDiagramRunStatus;
}) => {
const commandMenuPageInfo = getSnapshotValue(
snapshot,
commandMenuPageInfoState,
);

const activeWorkflowRunRightDrawerTab = getSnapshotValue(
snapshot,
activeTabIdComponentState.atomFamily({
instanceId: commandMenuPageInfo.instanceId,
}),
) as WorkflowRunTabId | null;

const isInputTabDisabled = getIsInputTabDisabled({
stepExecutionStatus,
workflowSelectedNode,
});
const isOutputTabDisabled = getIsOutputTabDisabled({
stepExecutionStatus,
});

if (isNull(activeWorkflowRunRightDrawerTab)) {
const defaultTabId = isOutputTabDisabled
? WorkflowRunTabId.NODE
: WorkflowRunTabId.OUTPUT;

set(
activeTabIdComponentState.atomFamily({
instanceId: commandMenuPageInfo.instanceId,
}),
defaultTabId,
);

return;
}

if (
(isInputTabDisabled &&
activeWorkflowRunRightDrawerTab === WorkflowRunTabId.INPUT) ||
(isOutputTabDisabled &&
activeWorkflowRunRightDrawerTab === WorkflowRunTabId.OUTPUT)
) {
set(
activeTabIdComponentState.atomFamily({
instanceId: commandMenuPageInfo.instanceId,
}),
WorkflowRunTabId.NODE,
);
}
},
[],
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Dependencies array is empty but the callback uses external functions getIsInputTabDisabled and getIsOutputTabDisabled. Consider adding these as dependencies

Comment on lines +37 to +38
expect(result.nodes[0].selected).toBe(true);
expect(result.nodes[1].selected).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Test should verify that all other nodes are deselected, not just node[1].

Suggested change
expect(result.nodes[0].selected).toBe(true);
expect(result.nodes[1].selected).toBe(false);
expect(result.nodes[0].selected).toBe(true);
expect(result.nodes.slice(1).every(node => !node.selected)).toBe(true);

}
| undefined
>({
key: 'workflowStepIdToOpenByDefaultState',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Key name 'workflowStepIdToOpenByDefaultState' doesn't match variable name 'workflowRunStepToOpenByDefaultState'. Consider using consistent naming.

Comment on lines +13 to +18
if (node.id === nodeIdToSelect) {
return {
...node,
selected: true,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: This only sets selected=true but never sets selected=false for other nodes. Could lead to multiple selected nodes.

Suggested change
if (node.id === nodeIdToSelect) {
return {
...node,
selected: true,
};
}
if (node.id === nodeIdToSelect) {
return {
...node,
selected: true,
};
}
return {
...node,
selected: false,
};

Copy link
Contributor

@thomtrp thomtrp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work 💪 small comments but LGTM!

@Devessier Devessier merged commit cc21155 into main Apr 24, 2025
51 checks passed
@Devessier Devessier deleted the workflow-runs-in-side-panel branch April 24, 2025 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Workflows] Properly integrate the Workflow Runs in the side panel [Forms] Improve auto-opening Form step in workflow runs
2 participants