Skip to content

Commit 4239810

Browse files
authored
feat(ux): added auto-layout for workflows (#443)
* added auto-layout * cleanup & fixes * disable auto-format during debugging & during execution * nits, acknowledged PR comments
1 parent a919631 commit 4239810

4 files changed

Lines changed: 1025 additions & 137 deletions

File tree

apps/sim/app/w/[id]/components/control-bar/control-bar.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ChevronDown,
99
Copy,
1010
History,
11+
Layers,
1112
Loader2,
1213
Play,
1314
SkipForward,
@@ -698,6 +699,37 @@ export function ControlBar() {
698699
</Tooltip>
699700
)
700701

702+
/**
703+
* Render auto-layout button
704+
*/
705+
const renderAutoLayoutButton = () => {
706+
const handleAutoLayoutClick = () => {
707+
if (isExecuting || isMultiRunning || isDebugging) {
708+
return
709+
}
710+
711+
window.dispatchEvent(new CustomEvent('trigger-auto-layout'))
712+
}
713+
714+
return (
715+
<Tooltip>
716+
<TooltipTrigger asChild>
717+
<Button
718+
variant='ghost'
719+
size='icon'
720+
onClick={handleAutoLayoutClick}
721+
className='hover:text-primary'
722+
disabled={isExecuting || isMultiRunning || isDebugging}
723+
>
724+
<Layers className='h-5 w-5' />
725+
<span className='sr-only'>Auto Layout</span>
726+
</Button>
727+
</TooltipTrigger>
728+
<TooltipContent command='Shift+L'>Auto Layout</TooltipContent>
729+
</Tooltip>
730+
)
731+
}
732+
701733
/**
702734
* Render debug mode controls
703735
*/
@@ -975,6 +1007,7 @@ export function ControlBar() {
9751007
{renderHistoryDropdown()}
9761008
{renderNotificationsDropdown()}
9771009
{renderDuplicateButton()}
1010+
{renderAutoLayoutButton()}
9781011
{renderDebugModeToggle()}
9791012
{/* {renderPublishButton()} */}
9801013
{renderDeployButton()}

apps/sim/app/w/[id]/components/workflow-edge/workflow-edge.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ export const WorkflowEdge = ({
1212
data,
1313
style,
1414
}: EdgeProps) => {
15-
const isHorizontal = sourcePosition === 'right' || sourcePosition === 'left'
16-
1715
const [edgePath, labelX, labelY] = getSmoothStepPath({
1816
sourceX,
1917
sourceY,
@@ -22,7 +20,7 @@ export const WorkflowEdge = ({
2220
targetY,
2321
targetPosition,
2422
borderRadius: 8,
25-
offset: isHorizontal ? 30 : 20,
23+
offset: 10,
2624
})
2725

2826
// Use the directly provided isSelected flag instead of computing it

0 commit comments

Comments
 (0)