Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/nix-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 9 additions & 6 deletions packages/desktop/src-tauri/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use tauri::Manager;

const CLI_INSTALL_DIR: &str = ".opencode/bin";
const CLI_BINARY_NAME: &str = "opencode";

Expand All @@ -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")
Expand All @@ -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());
}
Expand Down Expand Up @@ -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");

Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading