Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_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};
9
10use crate::{
11	RPC::CocoonService::CocoonServiceImpl,
12	Vine::Generated::{Empty, TerminalOpenedNotification},
13	dev_log,
14};
15
16pub async fn Fn(Service:&CocoonServiceImpl, Request:TerminalOpenedNotification) -> Result<Response<Empty>, Status> {
17	dev_log!(
18		"cocoon",
19		"[CocoonService] Terminal opened notification: {} (ID: {})",
20		Request.name,
21		Request.terminal_id
22	);
23
24	let _ = Service.environment.ApplicationHandle.emit(
25		"sky://terminal/create",
26		json!({ "id": Request.terminal_id, "name": Request.name, "pid": 0 }),
27	);
28
29	Ok(Response::new(Empty {}))
30}