use crate::runtime::config::AgentLoopConfig;
use bamboo_agent_core::Session;
#[cfg(windows)]
use super::super::super::image_fallback::ensure_session_image_ocr_cached;
pub(super) async fn maybe_cache_ocr_results(
session: &mut Session,
config: &AgentLoopConfig,
session_id: &str,
) {
#[cfg(not(windows))]
let _ = (session, config, session_id);
#[cfg(windows)]
if matches!(
config.image_fallback,
Some(ref cfg) if cfg.mode == crate::runtime::config::ImageFallbackMode::Ocr
) {
let changed =
ensure_session_image_ocr_cached(session, config.attachment_reader.as_deref()).await;
if changed {
if let Some(ref storage) = config.storage {
if let Err(error) = storage.save_session(session).await {
tracing::warn!(
"[{}] Failed to save session after OCR caching: {}",
session_id,
error
);
}
}
}
}
}