Skip to main content

Mountain/RPC/CocoonService/Terminal/
AcceptTerminalOpened.rs

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