Skip to content

Commit 973a5c6

Browse files
authored
feat: local auto layout (#1144)
1 parent 78437c6 commit 973a5c6

File tree

3 files changed

+636
-23
lines changed

3 files changed

+636
-23
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/control-bar.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -736,20 +736,18 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
736736

737737
setIsAutoLayouting(true)
738738
try {
739-
// Use the shared auto layout utility for immediate frontend updates
740-
const { applyAutoLayoutAndUpdateStore } = await import('../../utils/auto-layout')
739+
// Use the LOCAL auto layout implementation for immediate frontend updates
740+
const { applyLocalAutoLayoutAndUpdateStore } = await import('../../utils/local-auto-layout')
741741

742-
const result = await applyAutoLayoutAndUpdateStore(activeWorkflowId!)
742+
const result = await applyLocalAutoLayoutAndUpdateStore(activeWorkflowId!)
743743

744744
if (result.success) {
745745
logger.info('Auto layout completed successfully')
746746
} else {
747747
logger.error('Auto layout failed:', result.error)
748-
// You could add a toast notification here if available
749748
}
750749
} catch (error) {
751750
logger.error('Auto layout error:', error)
752-
// You could add a toast notification here if available
753751
} finally {
754752
setIsAutoLayouting(false)
755753
}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/auto-layout.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@ import { createLogger } from '@/lib/logs/console/logger'
22

33
const logger = createLogger('AutoLayoutUtils')
44

5+
/**
6+
* Default auto layout options
7+
*/
8+
export const DEFAULT_AUTO_LAYOUT_OPTIONS: AutoLayoutOptions = {
9+
strategy: 'smart',
10+
direction: 'auto',
11+
spacing: {
12+
horizontal: 250,
13+
vertical: 200,
14+
layer: 350,
15+
},
16+
alignment: 'center',
17+
padding: {
18+
x: 125,
19+
y: 125,
20+
},
21+
}
22+
523
/**
624
* Auto layout options interface
725
*/
@@ -20,24 +38,6 @@ export interface AutoLayoutOptions {
2038
}
2139
}
2240

23-
/**
24-
* Default auto layout options
25-
*/
26-
const DEFAULT_AUTO_LAYOUT_OPTIONS: AutoLayoutOptions = {
27-
strategy: 'smart',
28-
direction: 'auto',
29-
spacing: {
30-
horizontal: 500,
31-
vertical: 400,
32-
layer: 700,
33-
},
34-
alignment: 'center',
35-
padding: {
36-
x: 250,
37-
y: 250,
38-
},
39-
}
40-
4141
/**
4242
* Apply auto layout to workflow blocks and update the store
4343
*/

0 commit comments

Comments
 (0)