Skip to content

Commit

Permalink
Skip serializing our internal language kernel terminal processes on s…
Browse files Browse the repository at this point in the history
…hutdown

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
  • Loading branch information
petetronic committed Feb 28, 2023
1 parent 365e18f commit c7b1ea6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion extensions/jupyter-adapter/src/JupyterKernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/vs/platform/terminal/node/ptyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ export class PtyService extends Disposable implements IPtyService {
async serializeTerminalState(ids: number[]): Promise<string> {
const promises: Promise<ISerializedTerminalState>[] = [];
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<ISerializedTerminalState>(async r => {
Expand Down

0 comments on commit c7b1ea6

Please sign in to comment.