diff --git a/config.example.toml b/config.example.toml index 8845749..49e3551 100644 --- a/config.example.toml +++ b/config.example.toml @@ -80,4 +80,3 @@ model = "claude-sonnet-4-5" # browser = "chrome-headless" # Default. Alternative: "safari" # chrome_binary = "/path/to/chrome" # Optional: custom Chrome path # chromedriver_binary = "/path/to/driver" # Optional: custom ChromeDriver path -# persistent_chrome = true # Keep chromedriver running between sessions for faster startup diff --git a/crates/g3-config/src/lib.rs b/crates/g3-config/src/lib.rs index adcad7d..c57e727 100644 --- a/crates/g3-config/src/lib.rs +++ b/crates/g3-config/src/lib.rs @@ -179,10 +179,6 @@ pub struct WebDriverConfig { pub chromedriver_binary: Option, #[serde(default)] pub browser: WebDriverBrowser, - #[serde(default)] - /// Keep chromedriver running after session ends for faster subsequent startups - /// When true, chromedriver process is not killed on webdriver_quit - pub persistent_chrome: bool, } impl Default for AgentConfig { diff --git a/crates/g3-core/src/tools/webdriver.rs b/crates/g3-core/src/tools/webdriver.rs index 4fa7bc5..029d819 100644 --- a/crates/g3-core/src/tools/webdriver.rs +++ b/crates/g3-core/src/tools/webdriver.rs @@ -644,13 +644,13 @@ pub async fn execute_webdriver_quit( Ok(_) => { debug!("WebDriver session closed successfully"); - // Kill the driver process (unless persistent_chrome is enabled for Chrome) + // For Chrome, always keep chromedriver running for faster subsequent startups + // For Safari, kill safaridriver as it doesn't benefit from persistence use g3_config::WebDriverBrowser; let is_chrome = matches!(&ctx.config.webdriver.browser, WebDriverBrowser::ChromeHeadless); - let keep_running = is_chrome && ctx.config.webdriver.persistent_chrome; - if keep_running { - debug!("Keeping chromedriver running (persistent_chrome enabled)"); + if is_chrome { + debug!("Keeping chromedriver running for reuse"); // Still take the process handle but don't kill it let _ = ctx.webdriver_process.write().await.take(); } else if let Some(mut process) = ctx.webdriver_process.write().await.take() { @@ -659,17 +659,13 @@ pub async fn execute_webdriver_quit( } else { debug!("Driver process terminated"); } - } + } // Return appropriate message based on browser type - let driver_name = match &ctx.config.webdriver.browser { - WebDriverBrowser::Safari => "safaridriver", - WebDriverBrowser::ChromeHeadless => "chromedriver", - }; - if keep_running { - Ok(format!("✅ WebDriver session closed ({} still running for reuse)", driver_name)) + if is_chrome { + Ok("✅ WebDriver session closed (chromedriver still running for reuse)".to_string()) } else { - Ok(format!("✅ WebDriver session closed and {} stopped", driver_name)) + Ok("✅ WebDriver session closed and safaridriver stopped".to_string()) } } Err(e) => Ok(format!("❌ Failed to quit WebDriver: {}", e)),