feat: implement sidecar binary support and enhance Claude execution system

- **Enhanced Claude Binary Management**: Added support for sidecar binary execution alongside system binaries
- **Improved Command Creation**: Refactored command creation logic with separate functions for sidecar and system binaries
- **Enhanced Process Management**: Better process lifecycle management with improved error handling
- **Updated Tauri Configuration**: Added shell plugin configuration and expanded security policies
- **Agent Commands**: Enhanced agent management with improved error handling and validation

- **Redesigned Claude Version Selector**: Complete UI overhaul with modern select component and better UX
- **Enhanced Settings Integration**: Improved settings page integration with new selector component
- **API Layer Updates**: Updated API calls to support new binary execution modes
- **UI Component Improvements**: Better visual feedback and loading states

- **Updated Capabilities**: Enhanced Tauri capabilities for better security and functionality
- **Documentation Updates**: Updated scripts README with new build instructions
- **Security Enhancements**: Improved CSP policies and asset protocol configuration

- Added  function to determine execution mode
- Implemented  for sidecar binary execution
- Implemented  for system binary execution
- Enhanced process management with better error handling

- Replaced radio group with modern select component
- Added visual indicators for different installation types
- Improved loading states and error feedback
- Better responsive design and accessibility

- Enhanced CSP policies for better security
- Improved asset protocol configuration
- Better error handling and validation throughout
- Optimized process management and resource usage

- 10 files modified with 647 additions and 208 deletions
- Major changes in Claude execution system and UI components
- Configuration updates for enhanced security and functionality

- All existing functionality preserved
- New sidecar binary support tested
- UI components thoroughly tested for accessibility and responsiveness
This commit is contained in:
Vivek R
2025-07-04 03:27:54 +05:30
parent 91151530a5
commit f5cefb97ba
10 changed files with 648 additions and 209 deletions

View File

@@ -1392,7 +1392,20 @@ pub async fn get_claude_binary_path(db: State<'_, AgentDb>) -> Result<Option<Str
pub async fn set_claude_binary_path(db: State<'_, AgentDb>, path: String) -> Result<(), String> {
let conn = db.0.lock().map_err(|e| e.to_string())?;
// Validate that the path exists and is executable
// Special handling for bundled sidecar reference
if path == "claude-code" {
// For bundled sidecar, we don't need to validate file existence
// as it's handled by Tauri's sidecar system
conn.execute(
"INSERT INTO app_settings (key, value) VALUES ('claude_binary_path', ?1)
ON CONFLICT(key) DO UPDATE SET value = ?1",
params![path],
)
.map_err(|e| format!("Failed to save Claude binary path: {}", e))?;
return Ok(());
}
// Validate that the path exists and is executable for system installations
let path_buf = std::path::PathBuf::from(&path);
if !path_buf.exists() {
return Err(format!("File does not exist: {}", path));
@@ -1489,6 +1502,26 @@ fn create_command_with_env(program: &str) -> Command {
tokio_cmd.env("PATH", "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin");
}
// BEGIN PATCH: Ensure bundled sidecar directory is in PATH when using the "claude-code" placeholder
if program == "claude-code" {
// Attempt to locate the sidecar binaries directory that Tauri uses during development
// At compile-time, CARGO_MANIFEST_DIR resolves to the absolute path of the src-tauri crate.
// The sidecar binaries live in <src-tauri>/binaries.
#[allow(clippy::redundant_clone)]
let sidecar_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("binaries");
if sidecar_dir.exists() {
if let Some(sidecar_dir_str) = sidecar_dir.to_str() {
let current_path = std::env::var("PATH").unwrap_or_default();
let separator = if cfg!(target_os = "windows") { ";" } else { ":" };
if !current_path.split(separator).any(|p| p == sidecar_dir_str) {
let new_path = format!("{}{}{}", sidecar_dir_str, separator, current_path);
tokio_cmd.env("PATH", new_path);
}
}
}
}
// END PATCH
tokio_cmd
}