mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
fix: remove unused capture_screenshot_background_strategy method
Removed dead code that was causing compilation warnings. The background strategy was replaced by the regular strategy as noted in comments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
This commit is contained in:
@@ -880,77 +880,6 @@ impl BrowserManager {
|
||||
self.capture_screenshot_regular().await
|
||||
}
|
||||
|
||||
/// Capture screenshot using background tab strategy (external Chrome)
|
||||
async fn capture_screenshot_background_strategy(&self) -> Result<(Vec<std::path::PathBuf>, String)> {
|
||||
// First get the main page to capture the current URL (no interaction)
|
||||
let main_page = self.get_or_create_page().await?;
|
||||
// Then use background page for the actual screenshot to avoid focus issues
|
||||
let screenshot_page = self.get_or_create_background_page().await?;
|
||||
|
||||
// Note: Focus preservation is handled at the Chrome flag and JavaScript level
|
||||
|
||||
// Initialize assets manager if needed
|
||||
let mut assets_guard = self.assets.lock().await;
|
||||
if assets_guard.is_none() {
|
||||
*assets_guard = Some(Arc::new(crate::assets::AssetManager::new().await?));
|
||||
}
|
||||
let assets = assets_guard.as_ref().unwrap().clone();
|
||||
drop(assets_guard);
|
||||
|
||||
// Get current config
|
||||
let config = self.config.read().await;
|
||||
|
||||
// Determine screenshot mode
|
||||
let mode = if config.fullpage {
|
||||
crate::page::ScreenshotMode::FullPage {
|
||||
segments_max: Some(config.segments_max),
|
||||
}
|
||||
} else {
|
||||
crate::page::ScreenshotMode::Viewport
|
||||
};
|
||||
|
||||
// Get current URL from the main page (user's active tab)
|
||||
let current_url = main_page
|
||||
.get_current_url()
|
||||
.await
|
||||
.unwrap_or_else(|_| "about:blank".to_string());
|
||||
|
||||
// Navigate background page to the same URL if it's not about:blank
|
||||
if current_url != "about:blank" && !current_url.is_empty() {
|
||||
info!("Navigating background tab to {} for screenshot", current_url);
|
||||
// Use a shorter wait strategy for background navigation to reduce delay
|
||||
let quick_wait = crate::config::WaitStrategy::Delay { delay_ms: 1000 };
|
||||
screenshot_page.goto(¤t_url, Some(quick_wait)).await?;
|
||||
|
||||
// Give the page a moment to settle
|
||||
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
|
||||
}
|
||||
|
||||
// Capture screenshots from the background page (no focus stealing!)
|
||||
info!("Taking screenshot from background tab to preserve focus");
|
||||
let screenshots = screenshot_page.screenshot(mode).await?;
|
||||
|
||||
// Store screenshots and get paths
|
||||
let mut paths = Vec::new();
|
||||
for screenshot in screenshots {
|
||||
let image_ref = assets
|
||||
.store_screenshot(
|
||||
&screenshot.data,
|
||||
screenshot.format,
|
||||
screenshot.width,
|
||||
screenshot.height,
|
||||
300000, // 5 minute TTL
|
||||
)
|
||||
.await?;
|
||||
paths.push(std::path::PathBuf::from(image_ref.path));
|
||||
}
|
||||
|
||||
// Focus preservation is handled by the background tab strategy and Chrome flags
|
||||
|
||||
self.update_activity().await;
|
||||
Ok((paths, current_url))
|
||||
}
|
||||
|
||||
/// Capture screenshot using regular strategy (launched Chrome)
|
||||
async fn capture_screenshot_regular(&self) -> Result<(Vec<std::path::PathBuf>, String)> {
|
||||
// For launched Chrome, use the regular approach since it's already isolated
|
||||
|
||||
Reference in New Issue
Block a user