fix(autolayout): align by handle#2277
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryThis PR refactors the autolayout algorithm to fix visual edge misalignment issues by implementing handle-based positioning instead of block-boundary alignment. The changes centralize handle position constants in a shared module and update the autolayout core to calculate precise Y positions for connection handles based on block type (condition, error, subflow). Instead of aligning blocks by their boundaries using generic alignment options (start/center/end), the system now positions blocks so their source and target handles align perfectly, eliminating curved edges that previously appeared when handles were misaligned. The refactor involves removing the obsolete Important Files Changed
Confidence score: 4/5
Sequence DiagramsequenceDiagram
participant User
participant AutoLayout as "Autolayout System"
participant Core as "Layout Core"
participant Utils as "Layout Utils"
participant HandleCalc as "Handle Calculator"
participant Blocks as "Block Store"
User->>AutoLayout: "Trigger layout with edge alignment fix"
AutoLayout->>Utils: "prepareContainerDimensions()"
Utils->>Core: "layoutBlocksCore() for containers"
Core->>Utils: "getBlockMetrics() for each container"
Utils-->>Core: "Return block metrics"
Core->>HandleCalc: "calculateSubflowDepths()"
HandleCalc-->>Core: "Return subflow depth map"
Core-->>Utils: "Return container dimensions"
Utils-->>AutoLayout: "Container dimensions prepared"
AutoLayout->>Core: "assignLayers() with subflow depths"
Core->>Core: "Build adjacency graph from edges"
Core->>Core: "Topological sort with Kahn's algorithm"
loop "For each node with incoming edges"
Core->>Core: "Check if edge is from subflow end handle"
alt "Edge from subflow end"
Core->>Core: "Add subflow internal depth to layer calculation"
else "Regular edge"
Core->>Core: "Use standard layer + 1"
end
end
Core-->>AutoLayout: "Return nodes with layer assignments"
AutoLayout->>Core: "calculatePositions() with handle alignment"
Core->>Core: "Calculate cumulative X positions per layer"
loop "For each layer > 0"
Core->>HandleCalc: "getSourceHandleYOffset() for predecessor"
HandleCalc->>HandleCalc: "Check block type and handle ID"
alt "Error handle"
HandleCalc->>HandleCalc: "Calculate from block bottom"
else "Subflow start handle"
HandleCalc->>HandleCalc: "Use SUBFLOW_START_Y_OFFSET"
else "Condition handle"
HandleCalc->>HandleCalc: "Parse conditions and calculate row offset"
else "Default handle"
HandleCalc->>HandleCalc: "Use DEFAULT_Y_OFFSET"
end
HandleCalc-->>Core: "Return source handle Y position"
Core->>HandleCalc: "getTargetHandleYOffset() for current node"
HandleCalc-->>Core: "Return target handle Y position"
Core->>Core: "Align target handle to source handle Y"
end
Core->>Core: "resolveVerticalOverlaps()"
Core->>Core: "normalizePositions()"
Core-->>AutoLayout: "Return positioned nodes with handle alignment"
AutoLayout->>Blocks: "updateBlockLayoutMetrics()"
Blocks-->>AutoLayout: "Blocks updated with new positions"
AutoLayout-->>User: "Layout complete with aligned edges"
|
|
@greptile |
… docs, mcp, autolayout improvements (#2286) * fix(mcp): prevent redundant MCP server discovery calls at runtime, use cached tool schema instead (#2273) * fix(mcp): prevent redundant MCP server discovery calls at runtime, use cached tool schema instead * added backfill, added loading state for tools in settings > mcp * fix tool inp * feat(rate-limiter): token bucket algorithm (#2270) * fix(ratelimit): make deployed chat rate limited * improvement(rate-limiter): use token bucket algo * update docs * fix * fix type * fix db rate limiter * address greptile comments * feat(i18n): update translations (#2275) Co-authored-by: icecrasher321 <[email protected]> * fix(tools): updated kalshi and polymarket tools to accurately reflect outputs (#2274) * feat(i18n): update translations (#2276) Co-authored-by: waleedlatif1 <[email protected]> * fix(autolayout): align by handle (#2277) * fix(autolayout): align by handle * use shared constants everywhere * cleanup * fix(copilot): fix custom tools (#2278) * Fix title custom tool * Checkpoitn (broken) * Fix custom tool flash * Edit workflow returns null fix * Works * Fix lint * fix(ime): prevent form submission during IME composition steps (#2279) * fix(ui): prevent form submission during IME composition steps * chore(gitignore): add IntelliJ IDE files to .gitignore --------- Co-authored-by: Vikhyath Mondreti <[email protected]> Co-authored-by: Waleed <[email protected]> Co-authored-by: waleedlatif1 <[email protected]> * feat(ui): logs, kb, emcn (#2207) * feat(kb): emcn alignment; sidebar: popover primary; settings-modal: expand * feat: EMCN breadcrumb; improvement(KB): UI * fix: hydration error * improvement(KB): UI * feat: emcn modal sizing, KB tags; refactor: deleted old sidebar * feat(logs): UI * fix: add documents modal name * feat: logs, emcn, cursorrules; refactor: logs * feat: dashboard * feat: notifications; improvement: logs details * fixed random rectangle on canvas * fixed the name of the file to align * fix build --------- Co-authored-by: waleed <[email protected]> * fix(creds): glitch allowing multiple credentials in an integration (#2282) * improvement: custom tools modal, logs-details (#2283) * fix(docs): fix copy page button and header hook (#2284) * improvement(chat): add the ability to download files from the deployed chat (#2280) * added teams download and chat download file * Removed comments * removed comments * component structure and download all * removed comments * cleanup code * fix empty files case * small fix * fix(container): resize heuristic improvement (#2285) * estimate block height for resize based on subblocks * fix hydration error * make more conservative --------- Co-authored-by: Vikhyath Mondreti <[email protected]> Co-authored-by: icecrasher321 <[email protected]> Co-authored-by: waleedlatif1 <[email protected]> Co-authored-by: Siddharth Ganesan <[email protected]> Co-authored-by: mosa <[email protected]> Co-authored-by: Emir Karabeg <[email protected]> Co-authored-by: Adam Gough <[email protected]>
Summary
Align by handle to make sure there aren't curved edges when they should be aligned cleanly.
Type of Change
Testing
Tested manually
Checklist