Skip to main content

Mountain/RPC/CocoonService/Terminal/
AcceptTerminalOpened.rs

1
2//! Forward a terminal-opened notification to Sky on
3//! `sky://terminal/create` (NOT `/opened` - `SkyBridge.ts:1736` listens on
4//! `create` and destructures `{ id, name, pid }`; the `pid` is best-effort
5//! 0 here until the real one lands via `AcceptTerminalProcessId`).
6
7use serde_json::json;
8use tauri::Emitter;
9use tonic::{Response, Status};
10
11use crate::{
12	RPC::CocoonService::CocoonServiceImpl,
13	Vine::Generated::{Empty, TerminalOpenedNotification},
14	dev_log,
15};
16
17pub async fn Fn(Service:&CocoonServiceImpl, Request:TerminalOpenedNotification) -> Result<Response<Empty>, Status> {
18	dev_log!(
19		"cocoon",
20		"[CocoonService] Terminal opened notification: {} (ID: {})",
21		Request.name,
22		Request.terminal_id
23	);
24
25	let _ = Service.environment.ApplicationHandle.emit(
26		"sky://terminal/create",
27		json!({ "id": Request.terminal_id, "name": Request.name, "pid": 0 }),
28	);
29
30	Ok(Response::new(Empty {}))
31}