Mountain/RPC/CocoonService/Debug/
StartDebugging.rs1use std::time::{SystemTime, UNIX_EPOCH};
5
6use serde_json::json;
7use tauri::Emitter;
8use tonic::{Response, Status};
9use ::Vine::Generated::{StartDebuggingRequest, StartDebuggingResponse};
10
11use crate::{RPC::CocoonService::CocoonServiceImpl, dev_log};
12
13pub async fn Fn(
14 Service:&CocoonServiceImpl,
15
16 Request:StartDebuggingRequest,
17) -> Result<Response<StartDebuggingResponse>, Status> {
18 dev_log!("cocoon", "[CocoonService] start_debugging: type={}", Request.debug_type);
19
20 let SessionIdentifier = format!(
21 "debug-{}",
22 SystemTime::now().duration_since(UNIX_EPOCH).map(|D| D.as_millis()).unwrap_or(0)
23 );
24
25 let _ = Service.environment.ApplicationHandle.emit(
26 "sky://debug/start",
27 json!({
28 "sessionId": SessionIdentifier,
29 "debugType": Request.debug_type,
30 "configuration": Request.configuration.as_ref().map(|C| json!({
31 "name": C.name,
32 "type": C.r#type,
33 "request": C.request,
34 })),
35 }),
36 );
37
38 Ok(Response::new(StartDebuggingResponse { success:true }))
39}