DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/Terminal/DetachFromProcess.rs
1//! `localPty:detachFromProcess` - signal that the workbench is detaching
2//! from a live PTY (e.g. on window close while keeping the process alive).
3//!
4//! Mountain keeps the PTY running. The PTY output buffer continues to
5//! accumulate so that `sky:replay-events` can replay missed data when the
6//! window reattaches. Returns `null` unconditionally - the workbench treats
7//! any truthy resolve as "detach acknowledged".
8//!
9//! Wire shape: `Arguments[0]` = id (u64)
10
11use std::sync::Arc;
12
13use serde_json::Value;
14
15use crate::{RunTime::ApplicationRunTime::ApplicationRunTime, dev_log};
16
17pub async fn Fn(_RunTime:Arc<ApplicationRunTime>, Arguments:Vec<Value>) -> Result<Value, String> {
18 let TerminalId = match Arguments.first() {
19 Some(Value::Number(N)) => N.as_u64().unwrap_or(0),
20
21 Some(Value::Object(Obj)) => Obj.get("id").and_then(Value::as_u64).unwrap_or(0),
22
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}