Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/Terminal/
DetachFromProcess.rs

1#![allow(non_snake_case)]
2
3//! `localPty:detachFromProcess` - signal that the workbench is detaching
4//! from a live PTY (e.g. on window close while keeping the process alive).
5//!
6//! Mountain keeps the PTY running. The PTY output buffer continues to
7//! accumulate so that `sky:replay-events` can replay missed data when the
8//! window reattaches. Returns `null` unconditionally - the workbench treats
9//! any truthy resolve as "detach acknowledged".
10//!
11//! Wire shape: `Arguments[0]` = id (u64)
12
13use std::sync::Arc;
14
15use serde_json::Value;
16
17use crate::{RunTime::ApplicationRunTime::ApplicationRunTime, dev_log};
18
19pub async fn DetachFromProcess(_RunTime:Arc<ApplicationRunTime>, Arguments:Vec<Value>) -> Result<Value, String> {
20	let TerminalId = match Arguments.first() {
21		Some(Value::Number(N)) => N.as_u64().unwrap_or(0),
22		Some(Value::Object(Obj)) => Obj.get("id").and_then(Value::as_u64).unwrap_or(0),
23		_ => 0,
24	};
25
26	dev_log!(
27		"terminal",
28		"[DetachFromProcess] id={} (PTY kept alive; output buffer accumulating for next attach)",
29		TerminalId
30	);
31
32	// Mountain intentionally keeps the PTY alive - no action needed.
33	// The next `localPty:attachToProcess` or `sky:replay-events` will
34	// drain the output buffer back to the renderer.
35	Ok(Value::Null)
36}