Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): Improve added block positioning logic to handle collisions and dynamic dimensions size #8406

Conversation

Abhi1992002
Copy link
Contributor

Background #8268

These changes enhance the placement algorithm for new blocks, ensuring they don’t overlap with existing ones despite varying dimensions. They dynamically adjust block positions and the viewing canvas to optimize layout and visibility.

Changes 🏗️

  1. Added findNodeDimensions function to calculate the dimensions of all nodes.
  2. Introduced findNewlyAddedBlockCoordinates to determine the coordinates for newly added blocks.
  3. Implemented rectanglesOverlap to ensure that two nodes do not overlap.
  4. Enhanced functionality to zoom into a node immediately after it is added.
block.position.mp4

@Abhi1992002 Abhi1992002 requested a review from a team as a code owner October 23, 2024 11:10
@Abhi1992002 Abhi1992002 requested review from aarushik93 and majdyz and removed request for a team October 23, 2024 11:10
@github-actions github-actions bot added platform/frontend AutoGPT Platform - Front end platform/backend AutoGPT Platform - Back end size/l labels Oct 23, 2024
Copy link

PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

8268 - Fully compliant

Fully compliant requirements:

  • New blocks should be placed above existing ones
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Complex Logic
The new block positioning logic is complex and may need thorough testing to ensure it works correctly in all scenarios.

Performance Concern
The findNewlyAddedBlockCoordinates function uses nested loops and multiple collision checks, which might impact performance for large numbers of nodes.

State Management
The nodeDimensions state is updated on every render, which could lead to unnecessary re-renders and potential performance issues.

Copy link

netlify bot commented Oct 23, 2024

Deploy Preview for auto-gpt-docs ready!

Name Link
🔨 Latest commit 9a1d0ca
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/6718d9960a22ce000859dd7a
😎 Deploy Preview https://deploy-preview-8406--auto-gpt-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@aarushik93 aarushik93 changed the base branch from master to dev October 23, 2024 11:58
majdyz
majdyz previously approved these changes Oct 23, 2024
Copy link
Contributor

@majdyz majdyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really good! Thank you so much for this 👍
I left a few very minor code styling nits if you don't mind addressing it.
Otherwise, I'm happy to merge this PR.

autogpt_platform/frontend/src/components/Flow.tsx Outdated Show resolved Hide resolved
autogpt_platform/frontend/src/components/Flow.tsx Outdated Show resolved Hide resolved
autogpt_platform/frontend/src/components/Flow.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@majdyz majdyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@majdyz majdyz changed the title Improve block positioning logic to handle collisions and dynamic dime… feat(frontend): Improve added block positioning logic to handle collisions and dynamic dimensions size Oct 23, 2024
@majdyz majdyz enabled auto-merge (squash) October 23, 2024 22:16
@majdyz majdyz merged commit 8ded935 into Significant-Gravitas:dev Oct 23, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/backend AutoGPT Platform - Back end platform/frontend AutoGPT Platform - Front end Review effort [1-5]: 4 size/l
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants