The open source coding agent.
TypeScript
fix(desktop): complete symlink support implementation and enable CI for PRs (#7113)
Jérôme Benoitb1e381cff796
diff --git a/.github/workflows/nix-desktop.yml b/.github/workflows/nix-desktop.ymlindex 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.rsindex 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<std::path::PathBuf> {})}-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<String, String> {+pub fn install_cli(app: tauri::AppHandle) -> Result<String, String> {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.rsindex cb937401dd7..bdff738207b 100644--- a/packages/desktop/src-tauri/src/lib.rs+++ b/packages/desktop/src-tauri/src/lib.rs@@ -129,7 +129,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)