Skip to content

Commit b1e381c

Browse files
fix(desktop): complete symlink support implementation and enable CI for PRs (anomalyco#7113)
1 parent 0433d4d commit b1e381c

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

.github/workflows/nix-desktop.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ on:
99
- "nix/**"
1010
- "packages/app/**"
1111
- "packages/desktop/**"
12+
pull_request:
13+
paths:
14+
- "flake.nix"
15+
- "flake.lock"
16+
- "nix/**"
17+
- "packages/app/**"
18+
- "packages/desktop/**"
1219
workflow_dispatch:
1320

1421
jobs:

packages/desktop/src-tauri/src/cli.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use tauri::Manager;
2+
13
const CLI_INSTALL_DIR: &str = ".opencode/bin";
24
const CLI_BINARY_NAME: &str = "opencode";
35

@@ -9,9 +11,10 @@ fn get_cli_install_path() -> Option<std::path::PathBuf> {
911
})
1012
}
1113

12-
pub fn get_sidecar_path() -> std::path::PathBuf {
13-
tauri::utils::platform::current_exe()
14-
.expect("Failed to get current exe")
14+
pub fn get_sidecar_path(app: &tauri::AppHandle) -> std::path::PathBuf {
15+
// Get binary with symlinks support
16+
tauri::process::current_binary(&app.env())
17+
.expect("Failed to get current binary")
1518
.parent()
1619
.expect("Failed to get parent dir")
1720
.join("opencode-cli")
@@ -26,12 +29,12 @@ fn is_cli_installed() -> bool {
2629
const INSTALL_SCRIPT: &str = include_str!("../../../../install");
2730

2831
#[tauri::command]
29-
pub fn install_cli() -> Result<String, String> {
32+
pub fn install_cli(app: tauri::AppHandle) -> Result<String, String> {
3033
if cfg!(not(unix)) {
3134
return Err("CLI installation is only supported on macOS & Linux".to_string());
3235
}
3336

34-
let sidecar = get_sidecar_path();
37+
let sidecar = get_sidecar_path(&app);
3538
if !sidecar.exists() {
3639
return Err("Sidecar binary not found".to_string());
3740
}
@@ -108,7 +111,7 @@ pub fn sync_cli(app: tauri::AppHandle) -> Result<(), String> {
108111
cli_version, app_version
109112
);
110113

111-
install_cli()?;
114+
install_cli(app)?;
112115

113116
println!("Synced installed CLI");
114117

packages/desktop/src-tauri/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn spawn_sidecar(app: &AppHandle, port: u32) -> CommandChild {
129129

130130
#[cfg(not(target_os = "windows"))]
131131
let (mut rx, child) = {
132-
let sidecar = get_sidecar_path();
132+
let sidecar = get_sidecar_path(app);
133133
let shell = get_user_shell();
134134
app.shell()
135135
.command(&shell)

0 commit comments

Comments
 (0)