Skip to content

fix: prevent wires from breaking or adding extra nodes unexpectedly #616

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

blazethunderstorm
Copy link

@blazethunderstorm blazethunderstorm commented Jun 25, 2025

Fixes #610

Describe the changes you have made in this PR -

This pull request fixes a bug in the Vue simulator where wires connecting nodes would sometimes break or add extra nodes on their own when users clicked or dragged near them. The update improves the wire handling logic to keep connections stable and prevent unwanted changes, making the circuit layout cleaner and easier to use.

Screenshots of the changes (If any) -

After --

wirefixed.mp4

Before --

wiresnotfixed.mp4

Note: Please check Allow edits from maintainers. if you would like us to assist in the PR.

Summary by CodeRabbit

  • Bug Fixes

    • Improved wire hit detection by allowing a small margin of error for coordinate matching, making it easier to select or interact with wires.
    • Prevented unnecessary node creation and redundant wire connections for smoother simulation performance.
    • Deferred the removal of disconnected wires to avoid abrupt changes during interactions.
  • Improvements

    • Enhanced reliability and accuracy in wire orientation and node alignment within the simulator.

Copy link
Contributor

coderabbitai bot commented Jun 25, 2025

Warning

Rate limit exceeded

@blazethunderstorm has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 51 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between ab7cfab and 5b1f31a.

📒 Files selected for processing (1)
  • src/simulator/src/wire.ts (6 hunks)

"""

Walkthrough

The Wire class in src/simulator/src/wire.ts was updated to improve type safety, coordinate comparison tolerance, node convergence logic, and wire deletion timing. The changes refine how wire orientation is determined, prevent unnecessary node creation, and defer wire deletion to avoid immediate side effects.

Changes

Files Change Summary
src/simulator/src/wire.ts Refined type property typing; improved coordinate proximity checks; deferred wire deletion; optimized node convergence and creation logic; updated method signatures and argument handling.

Assessment against linked issues

Objective Addressed Explanation
Prevent misalignment and unwanted node creation in wires (#610)
Improve wire convergence logic to avoid glitchy behavior (#610)
Refine coordinate checks for more robust wire interaction (#610)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related PRs

Suggested reviewers

  • Arnabdaz
    """
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@blazethunderstorm
Copy link
Author

@ThatDeparted2061 @Arnabdaz @niladrix719 pls review

Copy link

netlify bot commented Jun 25, 2025

Deploy Preview for circuitverse ready!

Name Link
🔨 Latest commit 5b1f31a
🔍 Latest deploy log https://app.netlify.com/projects/circuitverse/deploys/685c6dfc251c500008a5bb2f
😎 Deploy Preview https://deploy-preview-616--circuitverse.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 46 (🔴 down 1 from production)
Accessibility: 72 (no change from production)
Best Practices: 92 (no change from production)
SEO: 80 (no change from production)
PWA: -
View the detailed breakdown and full score reports

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/simulator/src/wire.ts (1)

1-270: Consider adding unit tests for the wire stability fixes.

While all the changes look good and directly address the PR objectives, consider adding unit tests to verify:

  • Wire type assignment for diagonal wires
  • Deferred deletion behavior
  • Hit detection with pixel tolerance
  • Prevention of self-convergence
  • Prevention of redundant node creation

This would help ensure these fixes remain stable in future updates.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d8ca00 and 1a80922.

📒 Files selected for processing (1)
  • src/simulator/src/wire.ts (8 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/simulator/src/wire.ts (1)
src/simulator/src/node.js (1)
  • Node (150-1034)
🔇 Additional comments (7)
src/simulator/src/wire.ts (7)

23-23: Good type safety improvement!

Explicitly typing the type property as a union type prevents invalid wire orientations and improves code maintainability.


44-46: Correct handling of wire orientation.

The explicit else if condition prevents diagonal wires from being incorrectly typed as horizontal, which aligns with the PR objective of preventing unexpected wire behavior.


57-59: Smart deferral of wire deletion.

Using setTimeout to defer deletion prevents potential race conditions during event handling, which helps maintain wire stability during user interactions.


103-111: Improved hit detection with pixel tolerance.

The 2-pixel threshold for coordinate comparison makes wire selection more user-friendly and prevents precision issues that could cause wires to break unexpectedly.


120-120: Critical fix preventing self-convergence.

The early return prevents a wire from converging with its own nodes, which directly addresses the issue of adding extra nodes unexpectedly.


212-217: Clean parameter organization.

Grouping related coordinate parameters improves code readability and aligns with the updated checkAndCreateNode signature.

Also applies to: 221-226


237-251: Excellent fix preventing redundant node creation.

The position checks before convergence prevent creating unnecessary nodes when the new node would be at the same location as an existing node. This directly solves the "adding extra nodes unexpectedly" issue mentioned in the PR objectives.

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.

🐞 Bug: Wires behaving abnormally — misalignment, unwanted node creation, and glitchy convergence
1 participant