|
1 | 1 | use std::path::Path; |
2 | 2 |
|
3 | 3 | use tauri::async_runtime::Receiver; |
4 | | -use tauri::AppHandle; |
| 4 | +use tauri::{AppHandle, Manager}; |
5 | 5 | use tauri_plugin_shell::process::{CommandChild, CommandEvent}; |
6 | 6 | use tauri_plugin_shell::ShellExt; |
7 | 7 |
|
8 | 8 | use crate::paths::{candidate_xdg_config_dirs, candidate_xdg_data_dirs, maybe_infer_xdg_home}; |
| 9 | +use crate::paths::{prepended_path_env, sidecar_path_candidates}; |
9 | 10 |
|
10 | 11 | pub fn find_free_port() -> Result<u16, String> { |
11 | 12 | let listener = std::net::TcpListener::bind(("127.0.0.1", 0)).map_err(|e| e.to_string())?; |
@@ -77,6 +78,16 @@ pub fn spawn_engine( |
77 | 78 | command = command.env("OPENCODE_CLIENT", "openwork"); |
78 | 79 | command = command.env("OPENWORK", "1"); |
79 | 80 |
|
| 81 | + let resource_dir = app.path().resource_dir().ok(); |
| 82 | + let current_bin_dir = tauri::process::current_binary(&app.env()) |
| 83 | + .ok() |
| 84 | + .and_then(|path| path.parent().map(|parent| parent.to_path_buf())); |
| 85 | + let sidecar_paths = |
| 86 | + sidecar_path_candidates(resource_dir.as_deref(), current_bin_dir.as_deref()); |
| 87 | + if let Some(path_env) = prepended_path_env(&sidecar_paths) { |
| 88 | + command = command.env("PATH", path_env); |
| 89 | + } |
| 90 | + |
80 | 91 | if let Some(username) = opencode_username { |
81 | 92 | if !username.trim().is_empty() { |
82 | 93 | command = command.env("OPENCODE_SERVER_USERNAME", username); |
|
0 commit comments