feat: add proxy configuration support

- Add proxy settings UI component with enable/disable toggle
  - Support HTTP, HTTPS, NO_PROXY, and ALL_PROXY environment variables
  - Store proxy settings in app database for persistence
  - Apply proxy settings on app startup and when saved
  - Pass proxy environment variables to Claude command execution
  - Integrate proxy settings into main Settings page with unified save
  - Add proxy support for both system binary and sidecar execution

  This allows users to configure proxy settings for Claude API requests,
  which is essential for users behind corporate firewalls or in regions
  requiring proxy access.

  Fixes network connectivity issues in restricted environments.
This commit is contained in:
Catherine
2025-07-11 13:23:33 +08:00
committed by Vivek R
parent 67800087e9
commit 32a197100a
9 changed files with 715 additions and 3 deletions

View File

@@ -451,6 +451,8 @@ fn compare_versions(a: &str, b: &str) -> Ordering {
/// This ensures commands like Claude can find Node.js and other dependencies
pub fn create_command_with_env(program: &str) -> Command {
let mut cmd = Command::new(program);
info!("Creating command for: {}", program);
// Inherit essential environment variables from parent process
for (key, value) in std::env::vars() {
@@ -467,11 +469,25 @@ pub fn create_command_with_env(program: &str) -> Command {
|| key == "NVM_BIN"
|| key == "HOMEBREW_PREFIX"
|| key == "HOMEBREW_CELLAR"
// Add proxy environment variables (only uppercase)
|| key == "HTTP_PROXY"
|| key == "HTTPS_PROXY"
|| key == "NO_PROXY"
|| key == "ALL_PROXY"
{
debug!("Inheriting env var: {}={}", key, value);
cmd.env(&key, &value);
}
}
// Log proxy-related environment variables for debugging
info!("Command will use proxy settings:");
if let Ok(http_proxy) = std::env::var("HTTP_PROXY") {
info!(" HTTP_PROXY={}", http_proxy);
}
if let Ok(https_proxy) = std::env::var("HTTPS_PROXY") {
info!(" HTTPS_PROXY={}", https_proxy);
}
// Add NVM support if the program is in an NVM directory
if program.contains("/.nvm/versions/node/") {