Skip to content

Conversation

@Nakshatra480
Copy link
Contributor

@Nakshatra480 Nakshatra480 commented Feb 4, 2026

Fix Verilog Compilation Stuck Issue in Tauri Desktop App

Description

This PR resolves the issue where Verilog compilation would get stuck in the Tauri desktop application. The problem was caused by the use of relative URLs for the API endpoint, which are not resolved correctly in the Tauri environment, and CORS restrictions.

Changes

  • Tauri Detection & API URL: Added logic to detect the Tauri environment and force the use of the full absolute URL (https://circuitverse.org/api/v1/simulator/verilogcv) for Verilog compilation requests.
  • HTTP Plugin Integration: Implemented the @tauri-apps/plugin-http to bypass CORS restrictions inherent to the webview environment in Tauri.
  • Dependency Updates: Added @tauri-apps/plugin-http and updated cross-env to a Node-18 compatible version to fix build issues.
  • Capabilities Update: Updated src-tauri/capabilities/default.json to allow fetch requests to the CircuitVerse API.
  • Optimization: Refactored Verilog2CV.js to use cleaner, more concise async/await logic and improved error handling.

Fixes

Checklist

  • Tested on Tauri Desktop App
  • Verified Verilog compilation flow
  • CI checks passing

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced Verilog-to-circuit conversion with improved error handling and more descriptive error messages when compilation fails.
  • UI/UX Improvements

    • Refined mobile interface with context-aware toolbar button visibility that displays relevant controls based on your current operation mode.

@netlify
Copy link

netlify bot commented Feb 4, 2026

Deploy Preview for circuitverse ready!

Name Link
🔨 Latest commit 39b295e
🔍 Latest deploy log https://app.netlify.com/projects/circuitverse/deploys/6984ba4f301871000844c6ca
😎 Deploy Preview https://deploy-preview-919--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: 45 (🔴 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 4, 2026

Warning

Rate limit exceeded

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

This pull request introduces TAURI support for Verilog compilation. The changes include: adding a CircuitVerse API endpoint to the TAURI HTTP allowlist, converting the generateVerilogCircuit function to async with TAURI-aware HTTP request handling using a Tauri-specific fetch plugin, adding the @tauri-apps/plugin-http dependency, and adding conditional rendering guards to mobile toolbar buttons. Vue components also receive minor formatting updates.

Possibly related PRs

  • PR #380: Directly related as this PR reintroduces TAURI-specific integrations (Tauri HTTP plugin usage, isTauri imports, allowlist configuration) that were previously removed in that PR.
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Minor formatting changes in Vue components (Extra.vue, TestBenchPanel.vue, TimingDiagramPanel.vue, TimingDiagramMobile.vue) are out-of-scope refactoring not related to Verilog compilation fix objectives. Remove or separate formatting-only changes in Vue components; focus PR on core Verilog compilation fix (Verilog2CV.js, package.json, capabilities).
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title clearly summarizes the main fix: resolving Verilog compilation stuck issue in Tauri desktop app, which matches the PR's primary objective.
Linked Issues check ✅ Passed All coding objectives from issue #785 are met: Tauri detection added, absolute API URL configured, Tauri HTTP plugin integrated, capabilities updated, async/await with error handling implemented, and stuck UI state resolved.

✏️ 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 `@src-tauri/capabilities/default.json`:
- Around line 20-23: The allow-fetch list in src-tauri/capabilities/default.json
only lists the production Verilog endpoint but Verilog2CV.js builds the endpoint
from VITE_API_URL (see VITE_API_URL usage in Verilog2CV.js around lines
269–273), so Tauri can block non-prod hosts; fix by either adding all expected
dev/staging base URLs (and their /api/v1/simulator/verilogcv paths) to the
allow-fetch array in default.json, or modify Verilog2CV.js to use a hard-coded
production URL when running inside Tauri (detectable via TAURI env or process)
so the Tauri allow-list and the runtime endpoint always match.
🧹 Nitpick comments (1)
src/simulator/src/Verilog2CV.js (1)

269-274: Prefer robust URL joining to avoid double‑slash edge cases.

If VITE_API_URL ends with /, concatenation can yield //api/.... It usually works, but using URL keeps it clean and avoids subtle path issues.

Suggested refactor
-    let apiUrl = '/api/v1/simulator/verilogcv'
+    const apiPath = '/api/v1/simulator/verilogcv'
+    let apiUrl = apiPath
     if (isTauri()) {
         const baseUrl = import.meta.env.VITE_API_URL || 'https://circuitverse.org'
-        apiUrl = `${baseUrl}${apiUrl}`
+        apiUrl = new URL(apiPath, baseUrl).toString()
     }

@Nakshatra480 Nakshatra480 force-pushed the fix/verilog-compilation-tauri branch 3 times, most recently from 31e899f to 990551c Compare February 4, 2026 05:18
@Nakshatra480 Nakshatra480 force-pushed the fix/verilog-compilation-tauri branch 3 times, most recently from 195ae76 to 0f69be9 Compare February 4, 2026 05:32
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: 2

🤖 Fix all issues with AI agents
In `@package.json`:
- Line 59: The package.json currently pins "cross-env": "^10.1.0" which is
incompatible with Node 18; update the dependency entry for "cross-env" to a
Node-18-compatible version such as "^7.0.3" (change the value in package.json),
then reinstall/update lockfiles (npm install or yarn install) so
package-lock.json / yarn.lock reflect the change; ensure the project build
scripts that reference cross-env continue to work after the version change.

In `@src/simulator/src/Verilog2CV.js`:
- Around line 261-264: The async function generateVerilogCircuit currently
starts an fetch chain with .then() but does not return that promise, so callers
cannot await completion; update generateVerilogCircuit to either return the
fetch promise chain or (preferred) refactor to use await for clarity: await the
fetch call, await response.json()/text as appropriate, and await any subsequent
processing (look at the similar .then() chain around lines referenced 284-290)
and return the final result (or throw on error) so callers can await
generateVerilogCircuit; ensure references to generateVerilogCircuit and the
fetch/response handling are updated accordingly.
🧹 Nitpick comments (2)
src/simulator/src/Verilog2CV.js (2)

322-322: Use strict equality for status comparison.

Prefer === over == for type-safe comparison.

🔧 Suggested fix
-            if (error.status == 500) {
+            if (error.status === 500) {

62-66: Consider making saveVerilogCode async and awaiting generateVerilogCircuit.

Since generateVerilogCircuit is now async, calling it without await means saveVerilogCode returns before compilation completes. If callers need to know when compilation finishes (e.g., to sequence operations), this could cause subtle issues.

If fire-and-forget is intentional, this is acceptable since the UI feedback is handled within generateVerilogCircuit. Otherwise, consider:

♻️ Proposed change
-export function saveVerilogCode() {
+export async function saveVerilogCode() {
     var code = editor.getValue()
     globalScope.verilogMetadata.code = code
-    generateVerilogCircuit(code)
+    await generateVerilogCircuit(code)
 }

@Nakshatra480 Nakshatra480 force-pushed the fix/verilog-compilation-tauri branch 4 times, most recently from 5979357 to eb8dc4d Compare February 4, 2026 05:53
@Nakshatra480 Nakshatra480 force-pushed the fix/verilog-compilation-tauri branch from eb8dc4d to c66a86f Compare February 4, 2026 06:09
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/simulator/src/Verilog2CV.js (1)

1-5: ⚠️ Potential issue | 🔴 Critical

Missing import: scopeList is not defined.

scopeList is used on line 291 but not imported. This will cause a ReferenceError at runtime when attempting to delete sub-circuit scopes, breaking the Verilog compilation flow.

🐛 Proposed fix: Add scopeList to imports
 import {
     createNewCircuitScope,
     switchCircuit,
     changeCircuitName,
+    scopeList,
 } from './circuit'

Also applies to: 290-291

🤖 Fix all issues with AI agents
In `@src/simulator/src/Verilog2CV.js`:
- Around line 271-274: The empty catch in the isTauri() branch swallows plugin
import errors; update the block that assigns fetchFn (the code that does try {
fetchFn = (await import('@tauri-apps/plugin-http')).fetch } catch (e) {}) to log
the caught error (including e.message/stack) via console.error or the project's
logger and optionally include a clear message that the code will fall back to
window.fetch; ensure the symbol references are the existing isTauri() check and
the dynamic import('@tauri-apps/plugin-http').fetch so future failures are
visible for debugging.
🧹 Nitpick comments (1)
src/simulator/src/Verilog2CV.js (1)

311-313: Empty catch block obscures JSON parsing failures.

While msg has a fallback value, the empty catch block makes the intent unclear. Consider logging for debugging or adding a comment to indicate the intentional fallback behavior.

♻️ Proposed improvement
         else if (typeof error.json === 'function') {
-            try { msg = (await error.json()).message || msg } catch (e) {}
+            try {
+                msg = (await error.json()).message || msg
+            } catch {
+                // Response body not JSON-parseable, use existing msg
+            }
         }

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 `@src/simulator/src/Verilog2CV.js`:
- Around line 294-297: The loop that removes sub-circuit entries uses "for (var
id in scope.verilogMetadata.subCircuitScopeIds)" which iterates indices rather
than actual ID values; change it to iterate values (e.g., "for (const id of
scope.verilogMetadata.subCircuitScopeIds)" or use .forEach) so delete
scopeList[id] uses the real scope IDs; keep the surrounding calls
(scope.initialize() and resetting scope.verilogMetadata.subCircuitScopeIds = [])
as-is and only replace the loop iteration method in Verilog2CV.js.

@Nakshatra480 Nakshatra480 force-pushed the fix/verilog-compilation-tauri branch from 725c0a1 to 4f43452 Compare February 5, 2026 10:52
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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
v1/src/simulator/src/modules/ConstantVal.js (1)

46-50: ⚠️ Potential issue | 🟡 Minor

Duplicate generateVerilog() method definitions.

The class defines generateVerilog() twice (lines 46-50 and lines 170-172). In JavaScript, the second definition silently shadows the first. This appears unintentional—the first generates a localparam declaration while the second generates an assign statement with different syntax.

🔧 Proposed fix - remove the first definition
     this.label = ''
   }

-  generateVerilog() {
-      return `localparam [${this.bitWidth - 1}:0] ${this.verilogLabel}=${
-          this.bitWidth
-      }b'${this.state};`
-  }
-
   /**
    * `@memberof` ConstantVal

Also applies to: 170-172

src/simulator/src/modules/ConstantVal.js (1)

46-50: ⚠️ Potential issue | 🟡 Minor

Duplicate generateVerilog() method definitions.

Same issue as in the v1 version—the class has two generateVerilog() definitions. The second silently shadows the first.

🔧 Proposed fix - remove the first definition
     this.label = ''
   }

-  generateVerilog() {
-      return `localparam [${this.bitWidth - 1}:0] ${this.verilogLabel}=${
-          this.bitWidth
-      }b'${this.state};`
-  }
-
   /**
    * `@memberof` ConstantVal

Also applies to: 170-172

🤖 Fix all issues with AI agents
In `@package.json`:
- Around line 16-23: The dependency entry for `@tauri-apps/plugin-http` is set to
^2.5.7 which doesn't exist on npm and is incompatible with the project's Tauri
2.3.1; either change the `@tauri-apps/plugin-http` version in package.json to a
compatible release such as ^2.4.0 or upgrade the Tauri dependency to >=2.10.0 so
the plugin's peer requirements are met—update the "@tauri-apps/plugin-http"
version or the "tauri" dependency accordingly and run a fresh install to verify
resolution.

In `@v1/src/simulator/src/ux.js`:
- Around line 407-410: The forEach callback in exitFullView uses an
expression-bodied arrow (exitViewBtns.forEach(btn => btn.remove())) which
triggers the Biome lint rule; change it to a block-bodied arrow so there is no
implicit return, e.g. replace the callback with btn => { btn.remove(); } inside
the exitFullView function when iterating over elements selected by
'#exitViewBtn'.
🧹 Nitpick comments (9)
src/simulator/src/modules/Flag.js (1)

200-210: Pre-existing issue: duplicate helplink assignment.

Flag.prototype.helplink is assigned on lines 200–201 (#flag) and then immediately overwritten on lines 209–210 (#tunnel). The second assignment wins, so the help link likely points to the wrong documentation anchor. This isn't introduced by your PR, but worth fixing if you're already touching this file.

🔧 Suggested fix

Remove the duplicate assignment and keep only the correct one:

 Flag.prototype.tooltipText =
     'Flag ToolTip: Use this for debugging and plotting.'
 Flag.prototype.helplink =
     'https://docs.circuitverse.org/chapter4/chapter4-misc#flag'
 
-/**
- * `@memberof` Flag
- * Help URL
- * `@type` {string}
- * `@category` modules
- */
-Flag.prototype.helplink =
-    'https://docs.circuitverse.org/chapter4/chapter4-misc#tunnel'
src/simulator/src/modules/Input.js (1)

3-3: Optional: consolidate imports from the same module.

♻️ Suggested cleanup
-import Node, { findNode } from '../node'
+import Node, { findNode, dec2bin, bin2dec } from '../node'
@@
-import { dec2bin, bin2dec } from '../node'

Also applies to: 21-21

src/simulator/src/modules/Output.js (1)

2-2: Optional: consolidate imports from the same module.

♻️ Suggested cleanup
-import Node, { findNode } from '../node'
+import Node, { findNode, dec2bin } from '../node'
@@
-import { dec2bin } from '../node'

Also applies to: 8-8

src/simulator/src/testbench/testbenchOutput.js (1)

4-5: Optional: consolidate imports from the same module.

♻️ Suggested cleanup
-import Node, { findNode } from '../node'
-import { dec2bin } from '../node'
+import Node, { findNode, dec2bin } from '../node'
v1/src/simulator/src/modules/ConstantVal.js (1)

6-6: Unused import: dec2bin is imported but never used.

Only bin2dec is used in this file (in the resolve() method). The dec2bin import should be removed.

🧹 Proposed fix
-import { dec2bin, bin2dec } from '../node'
+import { bin2dec } from '../node'
build-desktop.js (2)

24-24: Move fs import to the top of the file with other imports.

The fs module is imported mid-file. For consistency and readability, group all imports at the top.

🧹 Proposed fix
 const os = require('os');
 const { execSync } = require('child_process');
+const fs = require('fs');


 function runCommand(command) {

And remove line 24:

 runCommand('npm run build')

-const fs = require('fs')
-
 if (!fs.existsSync('dist/index-cv.html')) {

1-1: Remove leading empty line.

Minor nit: the file starts with an unnecessary blank line.

src/simulator/src/modules/ConstantVal.js (1)

6-6: Unused import: dec2bin is imported but never used.

Same issue as in the v1 version—only bin2dec is used in this file.

🧹 Proposed fix
-import { dec2bin, bin2dec } from '../node'
+import { bin2dec } from '../node'
src/simulator/src/ux.js (1)

409-410: Static analysis warning: forEach callback implicitly returns a value.

While harmless (the return value is ignored), using block syntax clarifies intent and silences the linter.

🧹 Proposed fix
   const exitViewBtns = document.querySelectorAll('#exitViewBtn')
-  exitViewBtns.forEach(btn => btn.remove())
+  exitViewBtns.forEach(btn => { btn.remove() })

@Nakshatra480 Nakshatra480 force-pushed the fix/verilog-compilation-tauri branch from 4f43452 to 1a71ca6 Compare February 5, 2026 11:15
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
v1/src/simulator/src/ux.js (1)

255-258: ⚠️ Potential issue | 🟡 Minor

Typo in JSDoc comment.

The comment says "checkss" but should say "checks" (extra 's'). The src/simulator/src/ux.js version has this corrected.

📝 Proposed fix
 /**
- * checkss the input is safe or not
+ * checks the input is safe or not
  * `@param` {HTML} unsafe - the html which we wants to escape
  * `@category` ux
  */
🧹 Nitpick comments (1)
src/simulator/src/Verilog2CV.js (1)

123-140: Redundant DOM queries after null checks.

After retrieving elements into variables, the code queries the DOM again instead of using the cached reference. This pattern repeats throughout the function.

♻️ Proposed fix (example for one block)
         const code_window = document.getElementById('code-window')
-        if (code_window)
-            document.getElementById('code-window').style.display = 'block'
+        if (code_window) code_window.style.display = 'block'

         const elementPanel = document.querySelector('.elementPanel')
-        if (elementPanel)
-            document.querySelector('.elementPanel').style.display = 'none'
+        if (elementPanel) elementPanel.style.display = 'none'

Apply the same pattern to timingDiagramPanel, quickBtn, verilogEditorPanel, and their counterparts in the else block.

@Nakshatra480 Nakshatra480 marked this pull request as draft February 5, 2026 11:46
@Nakshatra480 Nakshatra480 marked this pull request as draft February 5, 2026 11:46
@Nakshatra480 Nakshatra480 force-pushed the fix/verilog-compilation-tauri branch from 1a71ca6 to d582544 Compare February 5, 2026 11:50
- Use absolute API URL (circuitverse.org) for Tauri to bypass relative URL issues
- Integrate @tauri-apps/plugin-http (v2.4.0) to bypass CORS in Tauri webview
- Add conditional logic with isTauri() for environment detection
- Improve error handling and user feedback

Fixes CircuitVerse#785
@Nakshatra480 Nakshatra480 force-pushed the fix/verilog-compilation-tauri branch from d582544 to 35b1403 Compare February 5, 2026 11:51
- Preserved @tauri-apps/plugin-http v2.4.0 from PR
- Accepted cross-env v10.1.0 upgrade from upstream
@Nakshatra480 Nakshatra480 marked this pull request as ready for review February 5, 2026 15:16
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: 2

🤖 Fix all issues with AI agents
In `@src/simulator/src/Verilog2CV.js`:
- Around line 311-313: The empty catch block around parsing error.json should
not be left blank; update the handler in Verilog2CV.js where you read error.json
(the block using "else if (typeof error.json === 'function')") to catch the
parsing exception into a variable (e) and at minimum log or debug that exception
(e.g., console.debug/console.warn or your logger) so the linter is satisfied and
parsing failures are surfaced; keep the existing behavior of falling back to the
existing msg when parsing fails.
- Around line 289-292: The code references scopeList in the block that calls
scope.initialize() and iterates scope.verilogMetadata.subCircuitScopeIds, but
scopeList is not imported causing a runtime ReferenceError; fix by adding an
import for scopeList at the top of this module (the same module that defines
Verilog2CV.js) so the loop "for (var id in
scope.verilogMetadata.subCircuitScopeIds) delete scopeList[id]" can access the
symbol, ensure the import uses the correct exported name (scopeList) from its
source module and matches surrounding import style.

@Nakshatra480 Nakshatra480 force-pushed the fix/verilog-compilation-tauri branch from 41f5abd to 0fd938e Compare February 5, 2026 15:33
@Nakshatra480
Copy link
Contributor Author

@Nihal4777 pls review these changes, issue is solved properly.
thanks for your time

@Nakshatra480 Nakshatra480 marked this pull request as draft February 7, 2026 10:53
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: [Tauri] The verilog code is stuck in compile phase

1 participant