Skip to content

Commit 77b4184

Browse files
committed
fix(tauri): use nvm current bin in PATH; avoid double browser navigate
Replace hardcoded nvm version path with ~/.nvm/current/bin so PATH augmentation follows the active nvm default. Have ensure_browser return whether it created the webview and skip navigate() when it did, since WebviewUrl::External already loads the initial URL once.
1 parent b6be414 commit 77b4184

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

  • native/macos/comux-tauri/src-tauri/src

native/macos/comux-tauri/src-tauri/src/lib.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ fn ensure_browser(
246246
w: f64,
247247
h: f64,
248248
url: &str,
249-
) -> Result<(), String> {
249+
) -> Result<bool, String> {
250250
if app.webviews().keys().any(|existing| existing == label) {
251-
return Ok(());
251+
return Ok(false);
252252
}
253253

254254
let main = app
@@ -318,7 +318,7 @@ fn ensure_browser(
318318
)
319319
.map_err(|e| e.to_string())?;
320320

321-
Ok(())
321+
Ok(true)
322322
}
323323

324324
fn hide_webview(webview: &tauri::Webview) -> Result<(), String> {
@@ -342,12 +342,14 @@ fn browser_navigate(
342342
h: f64,
343343
) -> Result<(), String> {
344344
let label = safe_browser_label(label);
345-
ensure_browser(&app, &label, x, y, w, h, &url)?;
346-
let webview = app
347-
.get_webview(&label)
348-
.ok_or_else(|| "browser webview missing".to_string())?;
349-
let parsed_url = Url::parse(&url).map_err(|e| e.to_string())?;
350-
webview.navigate(parsed_url).map_err(|e| e.to_string())?;
345+
let created = ensure_browser(&app, &label, x, y, w, h, &url)?;
346+
if !created {
347+
let webview = app
348+
.get_webview(&label)
349+
.ok_or_else(|| "browser webview missing".to_string())?;
350+
let parsed_url = Url::parse(&url).map_err(|e| e.to_string())?;
351+
webview.navigate(parsed_url).map_err(|e| e.to_string())?;
352+
}
351353
Ok(())
352354
}
353355

@@ -734,7 +736,7 @@ fn augmented_path() -> String {
734736
for suffix in [
735737
".cargo/bin",
736738
".local/bin",
737-
".nvm/versions/node/v24.13.0/bin",
739+
".nvm/current/bin",
738740
".volta/bin",
739741
".bun/bin",
740742
".rbenv/shims",

0 commit comments

Comments
 (0)