From c7b1ea61a19f9d8861f36c53225b5370dd553f94 Mon Sep 17 00:00:00 2001 From: petetronic <1178561+petetronic@users.noreply.github.com> Date: Tue, 28 Feb 2023 15:30:12 -0500 Subject: [PATCH] Skip serializing our internal language kernel terminal processes on shutdown When we quit Positron, we tear down any language runtime kernel processes (which are now managed by the terminal service host). These internal terminal processes should not be serialized/replayed on restarting Positron. This change attempts to detect those internal positron kernel terminal processes without changing the terminal service API. Issue: #213 --- .vscode/launch.json | 1 + extensions/jupyter-adapter/src/JupyterKernel.ts | 2 +- src/vs/platform/terminal/node/ptyService.ts | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 80c053af5b8..8660dc21bb4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -549,6 +549,7 @@ "Attach to Main Process", "Attach to Extension Host", "Attach to Shared Process", + "Attach to Pty Host Process" ], "preLaunchTask": "Ensure Prelaunch Dependencies", "presentation": { diff --git a/extensions/jupyter-adapter/src/JupyterKernel.ts b/extensions/jupyter-adapter/src/JupyterKernel.ts index 07e4ee7855c..76ffdf0684a 100644 --- a/extensions/jupyter-adapter/src/JupyterKernel.ts +++ b/extensions/jupyter-adapter/src/JupyterKernel.ts @@ -409,7 +409,7 @@ export class JupyterKernel extends EventEmitter implements vscode.Disposable { const command = args.join(' '); // Create environment. - const env = {}; + const env = { POSITRON_LANGUAGE: this._spec.language }; Object.assign(env, process.env, this._spec.env); // We are now starting the kernel diff --git a/src/vs/platform/terminal/node/ptyService.ts b/src/vs/platform/terminal/node/ptyService.ts index a116038d6f2..06038e3a24f 100644 --- a/src/vs/platform/terminal/node/ptyService.ts +++ b/src/vs/platform/terminal/node/ptyService.ts @@ -134,6 +134,15 @@ export class PtyService extends Disposable implements IPtyService { async serializeTerminalState(ids: number[]): Promise { const promises: Promise[] = []; for (const [persistentProcessId, persistentProcess] of this._ptys.entries()) { + + // --- Start Positron --- + // Skip serializing Positron language runtime kernel processes + const positronLanguage = persistentProcess.shellLaunchConfig.env?.POSITRON_LANGUAGE; + if (positronLanguage) { + continue; + } + // --- End Positron --- + // Only serialize persistent processes that have had data written or performed a replay if (persistentProcess.hasWrittenData && ids.indexOf(persistentProcessId) !== -1) { promises.push(Promises.withAsyncBody(async r => {