feat(autolayout): add snap-to-grid support#3031
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryThis PR adds snap-to-grid functionality to the autolayout system and removes the unused YAML autolayout API route. Key Changes:
Implementation Quality: Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant API as API Route
participant AL as applyAutoLayout
participant PCD as prepareContainerDimensions
participant LBC as layoutBlocksCore
participant CP as calculatePositions
participant NP as normalizePositions
participant SNG as snapNodesToGrid
participant LC as layoutContainers
API->>API: Parse request with gridSize
API->>AL: applyAutoLayout(blocks, edges, options)
AL->>PCD: prepareContainerDimensions(blocks, edges, gridSize)
loop For each container (bottom-up)
PCD->>LBC: layoutBlocksCore(childBlocks, {gridSize})
LBC->>CP: calculatePositions(layers, edges)
CP-->>LBC: positioned nodes
LBC->>NP: normalizePositions(nodes)
NP-->>LBC: normalized dimensions
LBC->>SNG: snapNodesToGrid(nodes, gridSize)
SNG-->>LBC: updated dimensions
LBC-->>PCD: {nodes, dimensions}
PCD->>PCD: Update container width/height
end
PCD-->>AL: containers sized
AL->>LBC: layoutBlocksCore(rootBlocks, {gridSize})
LBC->>CP: calculatePositions(layers, edges)
CP-->>LBC: positioned nodes
LBC->>NP: normalizePositions(nodes)
NP-->>LBC: normalized dimensions
LBC->>SNG: snapNodesToGrid(nodes, gridSize)
SNG-->>LBC: snapped dimensions
LBC-->>AL: {nodes, dimensions}
AL->>LC: layoutContainers(blocks, edges, {gridSize})
loop For each container
LC->>LBC: layoutBlocksCore(childBlocks, {gridSize})
LBC->>CP: calculatePositions(layers, edges)
CP-->>LBC: positioned nodes
LBC->>NP: normalizePositions(nodes)
NP-->>LBC: normalized dimensions
LBC->>SNG: snapNodesToGrid(nodes, gridSize)
SNG-->>LBC: snapped dimensions
LBC-->>LC: {nodes, dimensions}
LC->>LC: Apply positions & update container dims
end
LC-->>AL: containers laid out
AL-->>API: {blocks: layoutedBlocks, success: true}
|
|
@greptile |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
6bdd8dc to
99386e8
Compare
|
@greptile |
Summary
gridSizeoption to autolayout that snaps block positions to grid multiplesType of Change
Testing
Tested manually
Checklist