Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

  • Makes the autolayout code share all block dims with actual new canvas code.
  • Simplify file structure and remove dead code.

Type of Change

  • Other: Code Refactor

Testing

Tested manually with branching and subflows, and copilot edits.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Nov 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Nov 24, 2025 8:59pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 24, 2025

Greptile Overview

Greptile Summary

This PR refactors the autolayout system to use fixed block dimensions and centralize configuration management. The changes consolidate block dimension constants into a shared module (/lib/blocks/block-dimensions) that establishes a single source of truth for workflow block widths (250px), heights, and container dimensions. The refactor simplifies the autolayout architecture by removing complex layering and positioning modules (layering.ts, incremental.ts, positioning.ts) and replacing them with a streamlined core.ts implementation that uses topological sorting for layer assignment and overlap resolution. The new system eliminates code duplication by sharing dimension constants between the autolayout system and the actual canvas rendering code, ensuring consistency across the application. Multiple API endpoints and utility functions are updated to use the centralized constants, removing hardcoded magic numbers and improving maintainability.

Important Files Changed

Filename Score Overview
apps/sim/lib/blocks/block-dimensions.ts 5/5 New centralized constants file defining all workflow block dimensions and container sizes
apps/sim/lib/workflows/autolayout/core.ts 4/5 New core autolayout implementation with topological sorting and overlap resolution
apps/sim/lib/workflows/autolayout/constants.ts 5/5 Consolidated constants configuration for autolayout with re-exports from shared dimensions
apps/sim/lib/workflows/autolayout/targeted.ts 4/5 Major refactor using shared dimensions and core layout function, removing dead code
apps/sim/lib/workflows/autolayout/utils.ts 4/5 Updated to use centralized dimensions and added new utility functions for positioning
apps/sim/lib/workflows/autolayout/index.ts 4/5 Simplified main entry point removing dead code and streamlining function signatures
apps/sim/lib/workflows/autolayout/containers.ts 4/5 Refactored to use shared layoutBlocksCore function and centralized container dimensions
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-block-dimensions.ts 4/5 Refactored to re-export dimensions from centralized location for backwards compatibility
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-node-utilities.ts 5/5 Updated to use centralized dimension constants replacing hardcoded values
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/auto-layout-utils.ts 4/5 Simplified interface removing complex layout strategies and using centralized constants
apps/sim/app/api/workflows/[id]/autolayout/route.ts 4/5 Simplified API removing complex strategies and adding support for direct blocks/edges input
apps/sim/app/api/yaml/autolayout/route.ts 4/5 Major refactor removing unused options and streamlining configuration
apps/sim/lib/workflows/diff/diff-engine.ts 5/5 Replaced hardcoded spacing values with imported constants from autolayout module

Confidence score: 4/5

  • This PR is safe to merge with moderate confidence as it's primarily a refactoring effort that consolidates configuration
  • Score reflects the large scope of changes across many files and the deletion of significant amounts of code that could potentially break existing functionality if dependencies weren't properly updated
  • Pay close attention to the new core.ts implementation and ensure thorough testing of autolayout functionality with various workflow structures

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.

16 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@icecrasher321 icecrasher321 merged commit bbaf7e9 into staging Nov 24, 2025
9 checks passed
@waleedlatif1 waleedlatif1 deleted the improvment/autolayout-simplification branch November 26, 2025 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants