From bc7f679970bc3a7102c5c106ad184a8f52b9a9e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 6 Jan 2026 20:05:12 +0100 Subject: [PATCH] fix(desktop): complete symlink support implementation and enable CI for PRs - Fix get_sidecar_path() to use tauri::process::current_binary(&app.env()) - Pass AppHandle through the call chain to support the new API - Add Manager trait import for app.env() access - Enable pull_request trigger in nix-desktop workflow for CI on PRs This completes the fix from PR #7102 which was merged with compilation errors. --- .github/workflows/nix-desktop.yml | 7 +++++++ packages/desktop/src-tauri/src/cli.rs | 15 +++++++++------ packages/desktop/src-tauri/src/lib.rs | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/nix-desktop.yml b/.github/workflows/nix-desktop.yml index 54ce55be069..b7919c062cc 100644 --- a/.github/workflows/nix-desktop.yml +++ b/.github/workflows/nix-desktop.yml @@ -9,6 +9,13 @@ on: - "nix/**" - "packages/app/**" - "packages/desktop/**" + pull_request: + paths: + - "flake.nix" + - "flake.lock" + - "nix/**" + - "packages/app/**" + - "packages/desktop/**" workflow_dispatch: jobs: diff --git a/packages/desktop/src-tauri/src/cli.rs b/packages/desktop/src-tauri/src/cli.rs index 6b86cbcd2c3..8b76d1a7f8a 100644 --- a/packages/desktop/src-tauri/src/cli.rs +++ b/packages/desktop/src-tauri/src/cli.rs @@ -1,3 +1,5 @@ +use tauri::Manager; + const CLI_INSTALL_DIR: &str = ".opencode/bin"; const CLI_BINARY_NAME: &str = "opencode"; @@ -9,9 +11,10 @@ fn get_cli_install_path() -> Option { }) } -pub fn get_sidecar_path() -> std::path::PathBuf { - tauri::utils::platform::current_exe() - .expect("Failed to get current exe") +pub fn get_sidecar_path(app: &tauri::AppHandle) -> std::path::PathBuf { + // Get binary with symlinks support + tauri::process::current_binary(&app.env()) + .expect("Failed to get current binary") .parent() .expect("Failed to get parent dir") .join("opencode-cli") @@ -26,12 +29,12 @@ fn is_cli_installed() -> bool { const INSTALL_SCRIPT: &str = include_str!("../../../../install"); #[tauri::command] -pub fn install_cli() -> Result { +pub fn install_cli(app: tauri::AppHandle) -> Result { if cfg!(not(unix)) { return Err("CLI installation is only supported on macOS & Linux".to_string()); } - let sidecar = get_sidecar_path(); + let sidecar = get_sidecar_path(&app); if !sidecar.exists() { return Err("Sidecar binary not found".to_string()); } @@ -108,7 +111,7 @@ pub fn sync_cli(app: tauri::AppHandle) -> Result<(), String> { cli_version, app_version ); - install_cli()?; + install_cli(app)?; println!("Synced installed CLI"); diff --git a/packages/desktop/src-tauri/src/lib.rs b/packages/desktop/src-tauri/src/lib.rs index 5d1610fa3e6..612797fd099 100644 --- a/packages/desktop/src-tauri/src/lib.rs +++ b/packages/desktop/src-tauri/src/lib.rs @@ -120,7 +120,7 @@ fn spawn_sidecar(app: &AppHandle, port: u32) -> CommandChild { #[cfg(not(target_os = "windows"))] let (mut rx, child) = { - let sidecar = get_sidecar_path(); + let sidecar = get_sidecar_path(app); let shell = get_user_shell(); app.shell() .command(&shell)