fix: navbar Help menu links not opening in desktop app#980
fix: navbar Help menu links not opening in desktop app#980abhiraj75 wants to merge 6 commits intoCircuitVerse:mainfrom
Conversation
✅ Deploy Preview for circuitverse ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
WalkthroughAdds capability to open external URLs from the desktop app. A new permission entry Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/components/Navbar/NavbarLinks/NavbarLink/NavbarLink2.vue`:
- Line 77: The label generation using Date.now() in NavbarLink2.vue (const label
= `help-${Date.now()}`) can collide on rapid clicks and may include
non-alphanumeric characters; replace it with a deterministic, module-level
incremental counter (e.g., declare a let helpLabelCounter = 0 at module scope)
and generate labels like `help-${++helpLabelCounter}` to guarantee uniqueness
and alphanumeric-only values; update any references that use this label so they
continue to receive the new counter-based value.
- Line 77: The current label creation uses Date.now() which can collide under
rapid clicks; replace it with a module-scoped monotonic counter (e.g., declare a
top-level let helpWindowCounter = 0) and build the WebviewWindow label using an
incremented counter (e.g., `help-${++helpWindowCounter}`) where the label is
currently created (the `label` const in the handler that constructs the
WebviewWindow), ensuring each new WebviewWindow gets a unique label across rapid
invocations.
- Around line 73-93: Replace the Tauri WebviewWindow usage with the opener
plugin and make the call resilient: instead of importing and constructing
WebviewWindow, import the opener binding (use the openUrl/open function from
`@tauri-apps/plugin-opener`) and await it; ensure the await is wrapped in
try-catch so any async failure falls back to window.open(url, '_blank') (do not
return before fallback). Update the code paths around WebviewWindow, the
try-catch block that currently surrounds the import/constructor, and ensure the
else branch still calls logixFunction[listItem.itemid]() unchanged.
- Around line 73-93: Replace the WebviewWindow flow in the click handler (the
block that imports '@tauri-apps/api/core' and uses WebviewWindow) with the Tauri
opener plugin: import and await openUrl(url) from '@tauri-apps/plugin-opener'
when isTauri() is true, call openUrl(url) and only fall back to window.open(url,
'_blank') on error; remove the synchronous WebviewWindow constructor and its
early return so async failures don't silently drop navigation, and ensure errors
are caught/logged; also add the JS dependency '@tauri-apps/plugin-opener' and
enable the corresponding Rust plugin capability (opener:allow-open-url or
opener:default) in the Tauri config so openUrl will work.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src-tauri/capabilities/default.jsonsrc/components/Navbar/NavbarLinks/NavbarLink/NavbarLink2.vue
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src-tauri/src/lib.rs (1)
160-176:⚠️ Potential issue | 🔴 CriticalFix event name mismatch: backend emits "learn-digital-logic" but frontend listens for "learn-digital-circuit".
The native Help menu items emit events that listeners.js handles. Verification found that three of four are correctly named (
user-manual,discussion-forum,tutorial), but there is a critical mismatch: the backend emits"learn-digital-logic"(line 170, src-tauri/src/lib.rs) while the frontend listener is registered for"learn-digital-circuit"(src/simulator/src/listeners.js). This breaks the "Learn Digital Logic" native menu item.Align the event names between backend and frontend, or update the listener in listeners.js to match the backend's emitted event name.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src-tauri/src/lib.rs` around lines 160 - 176, The backend emits the native Help menu event as "learn-digital-logic" but the frontend listener in listeners.js is registered for "learn-digital-circuit", causing the menu item to not work; fix by making the names identical—either change the emitter in src-tauri/src/lib.rs (the branch checking event.id() == "learn-digital-logic" and calling app.emit(...)) to emit "learn-digital-circuit", or update the frontend listener in listeners.js to listen for "learn-digital-logic" so the event name used by app.emit and the listener match exactly.
🧹 Nitpick comments (1)
src-tauri/Cargo.toml (1)
28-28: Consider pinning to an explicit version for consistency.The file uses explicit versions for some plugins (
tauri-plugin-fs = "2.3.0") and loose major versions for others (tauri-plugin-http = "2"). WhileCargo.lockensures reproducibility regardless, aligning on a pinning strategy within the file improves clarity about the intended minimum version.♻️ Proposed change
-tauri-plugin-opener = "2" +tauri-plugin-opener = "2.0.0"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src-tauri/Cargo.toml` at line 28, The dependency declaration tauri-plugin-opener = "2" is using a loose major-only constraint; update the Cargo.toml entry for tauri-plugin-opener to an explicit pinned version (matching your project's pinning style, e.g., the same form as tauri-plugin-fs = "2.3.0") so the manifest clearly documents the intended minimum version; edit the tauri-plugin-opener line to the chosen exact version string and run cargo update or cargo generate-lockfile to refresh Cargo.lock if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src-tauri/src/lib.rs`:
- Around line 160-176: The backend emits the native Help menu event as
"learn-digital-logic" but the frontend listener in listeners.js is registered
for "learn-digital-circuit", causing the menu item to not work; fix by making
the names identical—either change the emitter in src-tauri/src/lib.rs (the
branch checking event.id() == "learn-digital-logic" and calling app.emit(...))
to emit "learn-digital-circuit", or update the frontend listener in listeners.js
to listen for "learn-digital-logic" so the event name used by app.emit and the
listener match exactly.
---
Nitpick comments:
In `@src-tauri/Cargo.toml`:
- Line 28: The dependency declaration tauri-plugin-opener = "2" is using a loose
major-only constraint; update the Cargo.toml entry for tauri-plugin-opener to an
explicit pinned version (matching your project's pinning style, e.g., the same
form as tauri-plugin-fs = "2.3.0") so the manifest clearly documents the
intended minimum version; edit the tauri-plugin-opener line to the chosen exact
version string and run cargo update or cargo generate-lockfile to refresh
Cargo.lock if needed.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
package-lock.jsonis excluded by!**/package-lock.jsonsrc-tauri/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
package.jsonsrc-tauri/Cargo.tomlsrc-tauri/capabilities/default.jsonsrc-tauri/src/lib.rssrc/components/Navbar/NavbarLinks/NavbarLink/NavbarLink2.vue
✅ Files skipped from review due to trivial changes (1)
- package.json
🚧 Files skipped from review as they are similar to previous changes (2)
- src-tauri/capabilities/default.json
- src/components/Navbar/NavbarLinks/NavbarLink/NavbarLink2.vue
|
@naman79820 I have updated my approach by using @tauri-apps/plugin-opener instead of WebviewWindow |
|
I am not the one who review the code, Other than that Ci is failing right now and also resolve the CodeRabbit suggestions so that the maintainer can review it. @abhiraj75 |
1c585cb to
b759439
Compare
|
Two small fixes: |
|
@Nihal4777 Let me know if you have any suggestions! Thanks! |

Fixes #949
Describe the changes you have made in this PR -
The navbar Help menu items (User Manual, Learn Digital Logic, Discussion Forum) were not opening when clicked in the desktop app.
Added a [handleItemClick()] function in (cv-frontend-vue/src/components/Navbar/NavbarLinks/NavbarLink/NavbarLink2.vue) that detects external link items (those with
hrefattributes) and opens them using Tauri'sWebviewWindowAPI in the desktop app, withwindow.open()fallback for web builds. Non-link items (e.g., Tutorial Guide) continue usinglogixFunctionas before. Also addedcore:webview:allow-create-webview-windowcapability permission .Code Understanding and AI Usage
Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?
If you used AI assistance:
Explain your implementation approach:
Navbar Help dropdown items with external URLs (User Manual, Learn Digital Logic, Discussion Forum) had empty
itemid, sologixFunction[""]()was called silently failing on click.Checklist before requesting a review
Note: Please check Allow edits from maintainers if you would like us to assist in the PR.
Summary by CodeRabbit
New Features
Improvements
Bug Fixes