Skip to main content

Mountain/RPC/CocoonService/Terminal/
AcceptTerminalOpened.rs

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