Fix Tauri v2.0 GUI compatibility and message sending functionality - #77
Conversation
WalkthroughUpdates 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
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)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests
Comment |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (4)
quietdrop-tauri/dist/index.htmlis excluded by!**/dist/**quietdrop-tauri/dist/quietdrop-tauri-16af60ac76bb525f_bg.wasmis excluded by!**/dist/**,!**/*.wasmquietdrop-tauri/dist/quietdrop-tauri-397bf89391b20bba.jsis excluded by!**/dist/**quietdrop-tauri/dist/quietdrop-tauri-397bf89391b20bba_bg.wasmis 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.
| #[wasm_bindgen(js_namespace = ["window", "__TAURI__", "core"])] | ||
| async fn invoke(cmd: &str, args: JsValue) -> JsValue; | ||
| } |
There was a problem hiding this comment.
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).
| let window = web_sys::window().unwrap(); | ||
| let tauri = js_sys::Reflect::get(&window, &"__TAURI__".into()); | ||
|
|
There was a problem hiding this comment.
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.
| 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.
There was a problem hiding this comment.
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.
| 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(), | ||
| ); |
There was a problem hiding this comment.
[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.
| #[tauri::command] | ||
| fn test_command() { | ||
| println!("=== TEST COMMAND CALLED ==="); | ||
| } |
There was a problem hiding this comment.
The test_command function appears to be debug code and should be removed from production or properly documented if it serves a specific purpose.
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
MessageRequestobject to individual parameters (name,content,recipient)window.__TAURI__.tauri.invoke) to Tauri v2.0 (window.__TAURI__.core.invoke)"withGlobalTauri": trueto enable window.TAURI API accessaddressfield toaddressesarray in Trunk.tomlSummary by CodeRabbit
New Features
Documentation
Chores