Skip to content

Commit

Permalink
Never autostart runtimes that have Manual startup behavior. (#5016)
Browse files Browse the repository at this point in the history
Addresses #4870 by adding a
new `Manual` startup behavior, that never automatically starts.
  • Loading branch information
dfalbel authored Oct 16, 2024
1 parent e95dbf3 commit 25b4e69
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion extensions/positron-reticulate/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ class ReticulateRuntimeMetadata implements positron.LanguageRuntimeMetadata {
runtimeVersion: string = '1.0';
runtimeSource: string = 'reticulate';
languageVersion = '1.0';
startupBehavior: positron.LanguageRuntimeStartupBehavior = positron.LanguageRuntimeStartupBehavior.Immediate;
startupBehavior: positron.LanguageRuntimeStartupBehavior = positron.LanguageRuntimeStartupBehavior.Manual;
sessionLocation: positron.LanguageRuntimeSessionLocation = positron.LanguageRuntimeSessionLocation.Workspace;
}

Expand Down
8 changes: 8 additions & 0 deletions src/positron-dts/positron.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,14 @@ declare module 'positron' {
* usually used for runtimes that only provide REPLs
*/
Explicit = 'explicit',

/**
* The runtime only starts up if manually requested by the user.
* The difference from Explicit, is that Manual startup never
* starts automatically, even if the run time is affiliated to the
* workspace.
*/
Manual = 'manual'
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/vs/workbench/api/common/positron/extHostTypes.positron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@ export enum LanguageRuntimeStartupBehavior {
* usually used for runtimes that only provide REPLs
*/
Explicit = 'explicit',

/**
* The runtime only starts up if manually requested by the user.
* The difference from Explicit, is that Manual startup never
* starts automatically, even if the run time is affiliated to the
* workspace.
*/
Manual = 'manual'
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,14 @@ export enum LanguageRuntimeStartupBehavior {
* usually used for runtimes that only provide REPLs
*/
Explicit = 'explicit',

/**
* The runtime only starts up if manually requested by the user.
* The difference from Explicit, is that Manual startup never
* starts automatically, even if the run time is affiliated to the
* workspace.
*/
Manual = 'manual'
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ export class RuntimeStartupService extends Disposable implements IRuntimeStartup
return;
}

if (session.runtimeMetadata.startupBehavior === LanguageRuntimeStartupBehavior.Manual) {
return;
}

// Save this runtime as the affiliated runtime for the current workspace.
this._storageService.store(this.storageKeyForRuntime(session.runtimeMetadata),
JSON.stringify(session.runtimeMetadata),
Expand Down Expand Up @@ -463,6 +467,14 @@ export class RuntimeStartupService extends Disposable implements IRuntimeStartup
return;
}

if (metadata.startupBehavior === LanguageRuntimeStartupBehavior.Manual) {
this._logService.info(`Language runtime ` +
`${formatLanguageRuntimeMetadata(affiliatedRuntimeMetadata)} ` +
`is affiliated with this workspace, but won't be started because its ` +
`startup behavior is manual.`);
return;
}

this._runtimeSessionService.startNewRuntimeSession(metadata.runtimeId,
metadata.runtimeName,
LanguageRuntimeSessionMode.Console,
Expand Down Expand Up @@ -655,7 +667,17 @@ export class RuntimeStartupService extends Disposable implements IRuntimeStartup
// Check the setting to see if we should be auto-starting.
const autoStart = this._configurationService.getValue<boolean>(
'positron.interpreters.automaticStartup');

if (autoStart) {

if (affiliatedRuntimeMetadata.startupBehavior === LanguageRuntimeStartupBehavior.Manual) {
this._logService.info(`Language runtime ` +
`${formatLanguageRuntimeMetadata(affiliatedRuntimeMetadata)} ` +
`is affiliated with this workspace, but won't be started because it's startup ` +
`behavior is manual.`);
return;
}

this._runtimeSessionService.autoStartRuntime(affiliatedRuntimeMetadata,
`Affiliated ${languageId} runtime for workspace`);
} else {
Expand Down Expand Up @@ -755,7 +777,8 @@ export class RuntimeStartupService extends Disposable implements IRuntimeStartup
session.getRuntimeState() !== RuntimeState.Uninitialized &&
session.getRuntimeState() !== RuntimeState.Initializing &&
session.getRuntimeState() !== RuntimeState.Exited &&
session.runtimeMetadata.sessionLocation === LanguageRuntimeSessionLocation.Workspace)
session.runtimeMetadata.sessionLocation === LanguageRuntimeSessionLocation.Workspace
)
.map(session => {
const metadata: SerializedSessionMetadata = {
metadata: session.metadata,
Expand Down

0 comments on commit 25b4e69

Please sign in to comment.