Skip to main content

Mountain/Binary/Service/
CocoonStart.rs

1//! # Cocoon Start Module
2//!
3//! Initializes and starts the Cocoon sidecar process.
4
5use crate::{
6	Environment::MountainEnvironment::MountainEnvironment,
7	ProcessManagement::CocoonManagement::InitializeCocoon,
8	dev_log,
9};
10
11/// Starts the Cocoon sidecar process for build tool support.
12///
13/// # Arguments
14///
15/// * `ApplicationHandle` - The Tauri application handle
16/// * `Environment` - The Mountain environment instance
17///
18/// # Returns
19///
20/// A `Result` indicating success or failure.
21///
22/// # Cocoon Sidecar Functionality
23///
24/// The Cocoon sidecar provides:
25/// - Build tool integration
26/// - Process management for external tools
27/// - Communication bridge with external build processes
28///
29/// # Errors
30///
31/// Returns an error if Cocoon initialization fails.
32pub async fn CocoonStart(
33	ApplicationHandle:&tauri::AppHandle,
34	Environment:&std::sync::Arc<MountainEnvironment>,
35) -> Result<(), String> {
36	match InitializeCocoon(ApplicationHandle, Environment).await {
37		Ok(()) => {
38			dev_log!("cocoon", "[Cocoon] [Start] Cocoon sidecar started successfully.");
39			Ok(())
40		},
41		Err(e) => {
42			dev_log!("cocoon", "warn: [Cocoon] [Start] Cocoon unavailable (degraded mode): {}", e);
43			Ok(()) // Graceful degradation — workbench works without Cocoon
44		},
45	}
46}