Skip to content

Conversation

@naman79820
Copy link
Contributor

@naman79820 naman79820 commented Feb 8, 2026

Fixes #922

Describe the changes you have made in this PR

This PR fixes the drag-and-drop functionality in v1 that was broken due to incorrect module loading. The root cause was that v0's main.ts file was being loaded instead of v1's main.ts, which meant the circuit element modules were never properly initialized before components tried to use them.
image

Changes made:

  • Set Vite root to version-specific directory to ensure correct file loading
  • Update CSS import path in tutorials.scss to work with new root
  • Add filesystem access permission for parent directory in dev server
  • This fixes the issue where v0's files were loading instead of v1's files
  • Resolves drag-and-drop elements not working in v1 due to uninitialized modules

Screenshots of the UI changes (If any)

Before: Drag-and-drop not working, console errors when hovering/clicking circuit elements
image

After: Drag-and-drop working correctly
image


Code Understanding and AI Usage

Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?

  • No, I wrote all the code myself
  • Yes, I used AI assistance (continue below)

If you used AI assistance:

  • I have reviewed every single line of the AI-generated code
  • I can explain the purpose and logic of each function/component I added
  • I have tested edge cases and understand how the code handles them
  • I have modified the AI output to follow this project's coding standards and conventions

Explain your implementation approach:

Problem: When running v1 of the simulator, the drag-and-drop functionality for circuit elements was completely broken. The browser console showed errors like "modules[elementName] is not a constructor" and "Cannot read properties of undefined (reading 'prototype')".

Root Cause Analysis: Through debugging, I discovered that v0's main.ts file was being loaded instead of v1's main.ts (confirmed via import.meta.url showing /simulatorvue/v1/v0/src/main.ts). This happened because Vite was resolving file paths from the project root, causing the path aliases (#/ and @/) to incorrectly point to v0's source files even when VITE_SIM_VERSION was set to "v1".

Testing:

  • Verified v1 loads correctly and drag-and-drop works
  • Confirmed v0 still works as expected
  • Tested that modules are properly initialized before components mount
  • Checked build output paths are correct

Checklist before requesting a review

  • I have added proper PR title and linked to the issue
  • I have performed a self-review of my code
  • I can explain the purpose of every function, class, and logic block I added
  • I understand why my changes work and have tested them thoroughly
  • I have considered potential edge cases and how my code handles them
  • If it is a core feature, I have added thorough tests
  • My code follows the project's style guidelines and conventions

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

Summary by CodeRabbit

Release Notes

  • Chores
    • Updated stylesheet dependency import paths for improved consistency.
    • Modified build configuration settings to align project root with versioned output structure.

- Set Vite root to version-specific directory to ensure correct file loading
- Update CSS import path in tutorials.scss to work with new root
- Adjust build output directory to be relative to new root
- Add filesystem access permission for parent directory in dev server
- This fixes the issue where v0's files were loading instead of v1's files
- Resolves drag-and-drop elements not working in v1 due to uninitialized modules
@netlify
Copy link

netlify bot commented Feb 8, 2026

Deploy Preview for circuitverse ready!

Name Link
🔨 Latest commit d3c232a
🔍 Latest deploy log https://app.netlify.com/projects/circuitverse/deploys/6988aa01e984ba00087b55e0
😎 Deploy Preview https://deploy-preview-929--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: 47 (🔴 down 2 from production)
Accessibility: 73 (no change from production)
Best Practices: 92 (no change from production)
SEO: 82 (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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 8, 2026

Warning

Rate limit exceeded

@naman79820 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 36 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.

Walkthrough

The PR updates import paths for CSS dependencies from absolute root-based paths to relative paths across two SCSS files (tutorials.scss in both src and v1/src directories) and modifies the Vite configuration to adjust the project root based on the version variable and enable serving from parent directories. These changes address path resolution for the driver.js CSS dependency across different directory structures.

Possibly related PRs

  • Merge CSS and JS #788: Modifies Vite build configuration and CSS handling with similar changes to vite.config.ts and CSS import/serving behavior, suggesting related build system improvements.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly relates to the main change: fixing v1 drag-and-drop by correcting module initialization through Vite root configuration.
Linked Issues check ✅ Passed The PR successfully addresses issue #922 by fixing module initialization and ensuring v1's main.ts loads correctly, restoring drag-and-drop functionality.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing v1 module initialization: Vite config root adjustment, CSS import path updates, and filesystem access permissions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 1

🤖 Fix all issues with AI agents
In `@vite.config.ts`:
- Line 19: The Vite config sets root to `./${version}` which causes build.outDir
to be nested under the version folder; change the config to use a neutral root
(e.g., `.`) and explicitly set build.outDir to the version folder so outputs
land at dist/simulatorvue/<version>/ rather than
dist/simulatorvue/<version>/<version>/; update the vite.config.ts to remove or
change the `root` assignment (`root`) and add/update `build.outDir`
(`build.outDir`) to point at `./${version}` so Tauri's frontendDist matches the
expected flattened output.
🧹 Nitpick comments (1)
v1/src/styles/tutorials.scss (1)

10-10: Nit: trailing whitespace on this blank line.

Line 10 has trailing whitespace. Consider removing it.

@naman79820
Copy link
Contributor Author

@Nihal4777 @tachyons ready to review

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: Unable to Drag and Drop Circuit Elements in cv-frontend-vue v1

1 participant