use crate::app::{config::AppConfig, logging::init_logging};
use anyhow::Result;
use tracing::{debug, error};
pub async fn initialize_app(config: AppConfig) -> Result<()> {
init_logging(&config);
if let Err(e) = check_and_migrate_storage().await {
error!("Storage migration failed: {}", e);
}
Ok(())
}
pub async fn check_and_migrate_storage() -> Result<()> {
use crate::storage::GlobalStorage;
use crate::unified_session::{migration::auto_migrate, SessionManager};
use std::env;
let project_path = env::current_dir()?;
let storage = GlobalStorage::new()?;
let manager = SessionManager::new(storage).await?;
if let Some(report) = auto_migrate(manager, project_path).await? {
debug!("Migration completed: {}", report.summary());
}
Ok(())
}