Skip to main content

Mountain/RPC/CocoonService/Terminal/
AcceptTerminalProcessId.rs

1#![allow(non_snake_case)]
2
3//! Forward the resolved PID for a terminal to Sky on
4//! `sky://terminal/processId`.
5
6use serde_json::json;
7use tauri::Emitter;
8use tonic::{Response, Status};
9
10use crate::{
11	RPC::CocoonService::CocoonServiceImpl,
12	Vine::Generated::{Empty, TerminalProcessIdNotification},
13	dev_log,
14};
15
16pub async fn Fn(Service:&CocoonServiceImpl, Request:TerminalProcessIdNotification) -> Result<Response<Empty>, Status> {
17	dev_log!(
18		"cocoon",
19		"[CocoonService] Terminal PID: {} for terminal {}",
20		Request.process_id,
21		Request.terminal_id
22	);
23
24	let _ = Service.environment.ApplicationHandle.emit(
25		"sky://terminal/processId",
26		json!({ "id": Request.terminal_id, "pid": Request.process_id }),
27	);
28
29	Ok(Response::new(Empty {}))
30}