Skip to content

Fix Tauri v2.0 GUI compatibility and message sending functionality - #77

Merged
chizy7 merged 2 commits into
masterfrom
fix/tauri-issue
Sep 24, 2025
Merged

chizy7 merged 2 commits into
masterfrom
fix/tauri-issue

Conversation

@chizy7

@chizy7 chizy7 commented Sep 24, 2025

Copy link
Copy Markdown
Owner

Description

Fixed multiple Tauri v2.0 compatibility issues preventing the GUI from sending encrypted messages. The Tauri GUI now has full end-to-end encrypted messaging functionality matching the CLI implementation.

Related Issue

Fixes #76

Type of Change

  • WASM Runtime Error: Fixed "Unreachable code should not be executed" error in WebAssembly by using proper async Tauri commands instead of synchronous with tokio blocking
  • Parameter Binding: Fixed Tauri v2.0 parameter structure mismatch - changed from single MessageRequest object to individual parameters (name, content, recipient)
  • API Compatibility: Updated JavaScript API calls from Tauri v1 (window.__TAURI__.tauri.invoke) to Tauri v2.0 (window.__TAURI__.core.invoke)
  • Configuration: Added "withGlobalTauri": true to enable window.TAURI API access
  • Trunk Config: Updated deprecated address field to addresses array in Trunk.toml

Summary by CodeRabbit

  • New Features

    • Improved desktop app diagnostics with runtime readiness checks and enhanced logging for easier troubleshooting.
  • Documentation

    • Expanded setup guide with detailed build steps and a 3-terminal workflow to run server, frontend, and desktop app.
  • Chores

    • Added Trunk configuration for build/watch/serve.
    • Enabled global Tauri API access in app configuration.
    • Updated dependencies and removed unused desktop plugins.

@coderabbitai

coderabbitai Bot commented Sep 24, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Updates Tauri v2 integration across the app: adjusts frontend invocation to use window.TAURI.core, changes the send_message command signature to discrete params, adds a new test_command, removes log/shell plugins, adds Trunk config, updates tauri.conf.json, and expands README with multi-terminal build/run steps.

Changes

Cohort / File(s) Summary of Changes
Docs and run workflow
README.md
Replaced single-step run with a 3-terminal workflow; added CLI build, Tauri desktop build, and run instructions.
Tauri project configuration
quietdrop-tauri/Trunk.toml, quietdrop-tauri/src-tauri/tauri.conf.json, quietdrop-tauri/test.html
Added Trunk config (build/watch/serve). Added app.withGlobalTauri=true in Tauri config. Added placeholder test.html.
Tauri app dependencies
quietdrop-tauri/Cargo.toml
Added js-sys = "0.3".
Tauri backend (src-tauri) – plugins and setup
quietdrop-tauri/src-tauri/Cargo.toml, quietdrop-tauri/src-tauri/src/lib.rs
Removed tauri-plugin-log and tauri-plugin-shell deps; removed debug-time log plugin setup in builder.
Tauri backend (src-tauri) – commands and logging
quietdrop-tauri/src-tauri/src/main.rs
Changed send_message signature to (name, content, recipient); updated usage and logging; added #[tauri::command] fn test_command(); registered new command; added extensive runtime logs.
WASM frontend bridge
quietdrop-tauri/src/main.rs
Switched JS namespace from __TAURI__.tauri to __TAURI__.core::invoke; added readiness checks and detailed logs; derived Debug for request/response; serialized request for invoke and enhanced response handling.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant F as Frontend (WASM)
  participant T as Tauri Core (__TAURI__.core)
  participant B as Backend Cmd (send_message)
  participant C as Crypto
  participant S as Server

  U->>F: Click "Send"
  F->>F: Validate & serialize {name, content, recipient}
  F->>T: core.invoke("send_message", args)
  Note over F,T: Namespace changed from tauri→core

  T->>B: Dispatch command with discrete params
  B->>B: Load keys / generate keypair
  B->>C: Encrypt(content)
  C-->>B: Ciphertext
  B->>S: Send encrypted message
  S-->>B: Response
  B-->>T: MessageResponse
  T-->>F: Response
  F-->>U: Show result (with logging)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

I thump my paw: “core.invoke, ho!”
Three terms awake, the logs now flow.
Keys twirl, ciphers hop in line,
Packets leap like springtime vine.
Plugins shed, the path made new—
Carrot-ready, messages flew! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The changes include several items not explicitly requested by issue #76 and that need justification: removal of tauri-plugin-log and tauri-plugin-shell from src-tauri/Cargo.toml and deletion of the debug setup hook, addition of a new test_command, addition of js-sys and a minimal test.html file, and README run-instruction edits; these alterations may affect logging/diagnostics or introduce test artifacts and should be documented. While configuration updates (tauri.conf.json, Trunk.toml) and invoke/signature changes are in-scope, the plugin removals and test artifacts are out-of-scope unless the author documents why they were necessary for the v2 migration. Ask the author to either document the rationale for plugin removals and added test artifacts in the PR description or move those changes into a separate follow-up PR; confirm logging behavior remains acceptable and re-run tests after separating or justifying these changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Fix Tauri v2.0 GUI compatibility and message sending functionality" is concise, single-sentence, and directly summarizes the primary changes (Tauri v2 compatibility updates and message-sending API fixes) without noise, so it clearly communicates the main intent of the changeset.
Linked Issues Check ✅ Passed The PR implements the key objectives from linked issue [#76]: the backend command signature was changed to separate parameters (name, content, recipient), the frontend/wasm invoke path was updated to window.TAURI.core.invoke with withGlobalTauri set in tauri.conf.json, and a Trunk.toml was added/updated; these edits appear in src-tauri/src/main.rs, quietdrop-tauri/src/main.rs, and tauri.conf.json and align with resolving parameter binding and Tauri v2 API mismatches. The PR description and code indicate async-compatible command handling was applied to address the WASM runtime error, matching the issue goals. Run an end-to-end GUI message-send test to confirm the original "Unreachable code" runtime error is resolved before final merge.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/tauri-issue

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

@chizy7
chizy7 requested a review from Copilot September 24, 2025 02:42

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (5)
quietdrop-tauri/test.html (1)

1-1: Remove unused empty test.html or add meaningful content.

An empty file adds watcher/bundler noise. Prefer deleting it unless it serves a documented purpose.

quietdrop-tauri/src-tauri/tauri.conf.json (1)

21-23: Consider tightening CSP for production builds.

csp: null is fine for dev, but add a restrictive CSP in release to improve security.

quietdrop-tauri/src/main.rs (1)

86-89: Optional: reduce noisy logs or gate them behind debug.

Consider wrapping console logs with cfg(debug_assertions) to keep production output clean.

quietdrop-tauri/src-tauri/src/main.rs (2)

62-71: Key file handling is pragmatic; consider app data dir in future.

Using a few relative fallbacks is okay short-term; longer-term, prefer tauri::api::path to read from a stable app data location.


24-29: Remove unused MessageRequest in backend.

Struct isn’t used after switching to discrete params.

Apply this diff:

-#[derive(Deserialize)]
-struct MessageRequest {
-    name: String,
-    content: String,
-    recipient: String,
-}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd0b1a4 and 1a124ab.

⛔ Files ignored due to path filters (4)
  • quietdrop-tauri/dist/index.html is excluded by !**/dist/**
  • quietdrop-tauri/dist/quietdrop-tauri-16af60ac76bb525f_bg.wasm is excluded by !**/dist/**, !**/*.wasm
  • quietdrop-tauri/dist/quietdrop-tauri-397bf89391b20bba.js is excluded by !**/dist/**
  • quietdrop-tauri/dist/quietdrop-tauri-397bf89391b20bba_bg.wasm is excluded by !**/dist/**, !**/*.wasm
📒 Files selected for processing (9)
  • README.md (1 hunks)
  • quietdrop-tauri/Cargo.toml (1 hunks)
  • quietdrop-tauri/Trunk.toml (1 hunks)
  • quietdrop-tauri/src-tauri/Cargo.toml (0 hunks)
  • quietdrop-tauri/src-tauri/src/lib.rs (0 hunks)
  • quietdrop-tauri/src-tauri/src/main.rs (3 hunks)
  • quietdrop-tauri/src-tauri/tauri.conf.json (1 hunks)
  • quietdrop-tauri/src/main.rs (2 hunks)
  • quietdrop-tauri/test.html (1 hunks)
💤 Files with no reviewable changes (2)
  • quietdrop-tauri/src-tauri/src/lib.rs
  • quietdrop-tauri/src-tauri/Cargo.toml
🧰 Additional context used
🧬 Code graph analysis (1)
quietdrop-tauri/src-tauri/src/main.rs (2)
quietdrop-core/src/encryption.rs (1)
  • generate_keypair (8-10)
quietdrop-core/src/client.rs (1)
  • send_message (6-25)
🔇 Additional comments (7)
quietdrop-tauri/Cargo.toml (1)

11-11: js-sys addition looks correct (version alignment).

Matches web-sys 0.3 and wasm-bindgen 0.2 series. No action needed.

quietdrop-tauri/src-tauri/tauri.conf.json (1)

11-11: withGlobalTauri is appropriate for accessing window.TAURI in v2.

Change aligns with the new frontend invocation path.

quietdrop-tauri/Trunk.toml (1)

1-10: Trunk config LGTM.

addresses array and port 1420 align with tauri.conf.json devUrl.

README.md (2)

58-60: Build steps for CLI look good.

Consistent with later run commands.


67-79: Three-terminal workflow is clear.

Matches Trunk serve and Tauri dev configuration.

quietdrop-tauri/src-tauri/src/main.rs (2)

31-37: Signature change to discrete params matches Tauri v2 invoke args.

Good move; front-end now needs to pass { name, content, recipient } which it does.

Ensure the frontend fix to handle rejected invocations is applied (see src/main.rs suggestions) so backend Err(String) doesn’t crash the WASM side.


149-152: test_command registration is fine.

Handy for plumbing verification.

Comment on lines +10 to 12
#[wasm_bindgen(js_namespace = ["window", "__TAURI__", "core"])]
async fn invoke(cmd: &str, args: JsValue) -> JsValue;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix JS import: imported async functions aren’t supported; import Promise and await via JsFuture.

Imported JS functions should return js_sys::Promise (optionally with catch), then await with JsFuture.

Apply this diff:

-    #[wasm_bindgen(js_namespace = ["window", "__TAURI__", "core"])]
-    async fn invoke(cmd: &str, args: JsValue) -> JsValue;
+    #[wasm_bindgen(catch, js_namespace = ["window", "__TAURI__", "core"])]
+    fn invoke(cmd: &str, args: JsValue) -> Result<js_sys::Promise, JsValue>;

Also add this import (outside the selected range):

use wasm_bindgen_futures::JsFuture;
🤖 Prompt for AI Agents
In quietdrop-tauri/src/main.rs around lines 10 to 12, the #[wasm_bindgen] import
declares an async fn which is invalid; change the imported signature to return
js_sys::Promise instead of async, add the missing use
wasm_bindgen_futures::JsFuture at the top of the file, and update call sites to
convert the returned Promise into a Rust Future by using
JsFuture::from(promise).await (and handle errors via .catch or Result as
appropriate).

Comment on lines +91 to +93
let window = web_sys::window().unwrap();
let tauri = js_sys::Reflect::get(&window, &"__TAURI__".into());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Pass a JsValue to Reflect::get to avoid type mismatch.

Window must be converted to &JsValue.

Apply this diff:

-                let window = web_sys::window().unwrap();
-                let tauri = js_sys::Reflect::get(&window, &"__TAURI__".into());
+                let window = web_sys::window().unwrap();
+                let tauri = js_sys::Reflect::get(window.as_ref(), &"__TAURI__".into());
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let window = web_sys::window().unwrap();
let tauri = js_sys::Reflect::get(&window, &"__TAURI__".into());
let window = web_sys::window().unwrap();
let tauri = js_sys::Reflect::get(window.as_ref(), &"__TAURI__".into());
🤖 Prompt for AI Agents
In quietdrop-tauri/src/main.rs around lines 91 to 93, the call to
js_sys::Reflect::get uses a web_sys::Window directly which causes a type
mismatch; convert the Window to a JsValue and pass a reference to that JsValue
(e.g. let window = web_sys::window().unwrap(); let window_js =
wasm_bindgen::JsValue::from(window); let tauri =
js_sys::Reflect::get(&window_js, &wasm_bindgen::JsValue::from_str("__TAURI__"))
) so Reflect::get receives &JsValue for the target and &JsValue for the
property.

Comment thread quietdrop-tauri/src/main.rs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes Tauri v2.0 compatibility issues that were preventing the GUI from sending encrypted messages. The changes address WASM runtime errors and update the application to use Tauri v2.0 APIs.

  • Updated Tauri command parameter binding from single object to individual parameters
  • Migrated JavaScript API calls from Tauri v1 to v2.0 format
  • Added extensive diagnostics and logging for troubleshooting
  • Updated configuration for Tauri v2.0 compatibility

Reviewed Changes

Copilot reviewed 9 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
quietdrop-tauri/src/main.rs Updated JS bindings to use Tauri v2.0 core API and added comprehensive runtime diagnostics
quietdrop-tauri/src-tauri/src/main.rs Changed command signature from single object to individual parameters and added detailed logging
quietdrop-tauri/src-tauri/tauri.conf.json Enabled global Tauri API access for v2.0 compatibility
quietdrop-tauri/src-tauri/Cargo.toml Removed unused desktop plugins to reduce dependencies
quietdrop-tauri/Trunk.toml Added build configuration with updated serve addresses format
README.md Updated setup instructions with 3-terminal workflow for complete system setup

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread quietdrop-tauri/src/main.rs
Comment on lines +86 to +103
console::log_1(&"Frontend: About to send message request".into());
status.set("Sending message...".to_string());
console::log_1(&"Frontend: Status set to 'Sending message...'".into());

let result = invoke("send_message", JsValue::from_serde(&request).unwrap()).await;
// Check if Tauri is ready
let window = web_sys::window().unwrap();
let tauri = js_sys::Reflect::get(&window, &"__TAURI__".into());

if tauri.is_err() {
console::log_1(&"Frontend: Tauri not ready yet, waiting...".into());
status.set("Tauri not ready, please wait...".to_string());
return;
}

let tauri_obj = tauri.unwrap();
console::log_1(
&format!("Frontend: Tauri object available: {:?}", tauri_obj).into(),
);

Copilot AI Sep 24, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The numerous console::log_1 calls throughout the function create excessive logging. Consider using a more structured logging approach or reducing the verbosity for production code.

Copilot uses AI. Check for mistakes.
Comment on lines +149 to +152
#[tauri::command]
fn test_command() {
println!("=== TEST COMMAND CALLED ===");
}

Copilot AI Sep 24, 2025

Copy link

Choose a reason for hiding this comment

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

The test_command function appears to be debug code and should be removed from production or properly documented if it serves a specific purpose.

Copilot uses AI. Check for mistakes.
@chizy7
chizy7 merged commit 33212b9 into master Sep 24, 2025
3 checks passed
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.

Fix Tauri v2.0 GUI message sending - WASM runtime errors and parameter binding issues

2 participants