Skip to content

Commit

Permalink
Remove kernel change on the Interactive Window (microsoft#12439)
Browse files Browse the repository at this point in the history
* add 'select kernel' handle message on the
interactive window

* remove kernel toolbar from the interactive
window if th user uses a local jupyter server

* add setting to enable it back

* add news file

* oops

* Add the experiment, as well as IExperimentService
on everything that extends WebViewHost

* removed setting

* add setting back
  • Loading branch information
David Kutugata committed Jun 23, 2020
1 parent 53c3fc6 commit 88f3b43
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 19 deletions.
2 changes: 2 additions & 0 deletions news/2 Fixes/11347.md
@@ -0,0 +1,2 @@
Removed the Kernel Selection toolbar from the Interactive Window when using a local Jupyter Server.
To show it again, set the setting 'Python > Data Science > Show Kernel Selection On Interactive Window'.
6 changes: 6 additions & 0 deletions package.json
Expand Up @@ -1925,6 +1925,12 @@
"description": "Automatically scroll the interactive window to show the output of the last statement executed. If false, the interactive window will only automatically scroll if the bottom of the prior cell is visible.",
"scope": "resource"
},
"python.dataScience.showKernelSelectionOnInteractiveWindow": {
"type": "boolean",
"default": false,
"description": "When set to true, enables the kernel selector in the Interactive Window. By default, the Interactive Window will use your Python Interpreters kernel.",
"scope": "resource"
},
"python.dataScience.enableScrollingForCellOutputs": {
"type": "boolean",
"default": true,
Expand Down
7 changes: 7 additions & 0 deletions src/client/common/experiments/groups.ts
Expand Up @@ -87,3 +87,10 @@ export enum NotebookEditorSupport {
export enum EnableStartPage {
experiment = 'EnableStartPage'
}

// Experiment to remove the Kernel/Server Tooblar in the Interactive Window when running a local Jupyter Server.
// It doesn't make sense to have it there, the user can already change the kernel
// by changing the python interpreter on the status bar.
export enum RemoveKernelToolbarInInteractiveWindow {
experiment = 'RemoveKernelToolbarInInteractiveWindow'
}
3 changes: 2 additions & 1 deletion src/client/common/startPage/startPage.ts
Expand Up @@ -66,7 +66,8 @@ export class StartPage extends WebViewHost<IStartPageMapping> implements IStartP
localize.StartPage.getStarted(),
ViewColumn.One,
false,
false
false,
Promise.resolve(false)
);
this.timer = new StopWatch();
}
Expand Down
1 change: 1 addition & 0 deletions src/client/common/types.ts
Expand Up @@ -399,6 +399,7 @@ export interface IDataScienceSettings {
jupyterCommandLineArguments: string[];
widgetScriptSources: WidgetCDNs[];
alwaysScrollOnNewCell?: boolean;
showKernelSelectionOnInteractiveWindow?: boolean;
}

export type WidgetCDNs = 'unpkg.com' | 'jsdelivr.com';
Expand Down
3 changes: 2 additions & 1 deletion src/client/datascience/data-viewing/dataViewer.ts
Expand Up @@ -58,7 +58,8 @@ export class DataViewer extends WebViewHost<IDataViewerMapping> implements IData
localize.DataScience.dataExplorerTitle(),
ViewColumn.One,
useCustomEditorApi,
false
false,
Promise.resolve(false)
);
}

Expand Down
15 changes: 11 additions & 4 deletions src/client/datascience/interactive-common/interactiveBase.ts
Expand Up @@ -35,10 +35,15 @@ import {
} from '../../common/application/types';
import { CancellationError } from '../../common/cancellation';
import { EXTENSION_ROOT_DIR, isTestExecution, PYTHON_LANGUAGE } from '../../common/constants';
import { RunByLine } from '../../common/experiments/groups';
import { RemoveKernelToolbarInInteractiveWindow, RunByLine } from '../../common/experiments/groups';
import { traceError, traceInfo, traceWarning } from '../../common/logger';
import { IFileSystem } from '../../common/platform/types';
import { IConfigurationService, IDisposableRegistry, IExperimentsManager } from '../../common/types';
import {
IConfigurationService,
IDisposableRegistry,
IExperimentService,
IExperimentsManager
} from '../../common/types';
import { createDeferred, Deferred } from '../../common/utils/async';
import * as localize from '../../common/utils/localize';
import { isUntitledFile, noop } from '../../common/utils/misc';
Expand Down Expand Up @@ -153,7 +158,8 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
@unmanaged() experimentsManager: IExperimentsManager,
@unmanaged() private switcher: KernelSwitcher,
@unmanaged() private readonly notebookProvider: INotebookProvider,
@unmanaged() useCustomEditorApi: boolean
@unmanaged() useCustomEditorApi: boolean,
@unmanaged() expService: IExperimentService
) {
super(
configuration,
Expand All @@ -167,7 +173,8 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
title,
viewColumn,
useCustomEditorApi,
experimentsManager.inExperiment(RunByLine.experiment)
experimentsManager.inExperiment(RunByLine.experiment),
expService.inExperiment(RemoveKernelToolbarInInteractiveWindow.experiment)
);

// Create our unique id. We use this to skip messages we send to other interactive windows
Expand Down
7 changes: 5 additions & 2 deletions src/client/datascience/interactive-ipynb/nativeEditor.ts
Expand Up @@ -34,6 +34,7 @@ import {
IAsyncDisposableRegistry,
IConfigurationService,
IDisposableRegistry,
IExperimentService,
IExperimentsManager,
IMemento,
Resource,
Expand Down Expand Up @@ -179,7 +180,8 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
@inject(IAsyncDisposableRegistry) asyncRegistry: IAsyncDisposableRegistry,
@inject(KernelSwitcher) switcher: KernelSwitcher,
@inject(INotebookProvider) notebookProvider: INotebookProvider,
@inject(UseCustomEditorApi) useCustomEditorApi: boolean
@inject(UseCustomEditorApi) useCustomEditorApi: boolean,
@inject(IExperimentService) expService: IExperimentService
) {
super(
listeners,
Expand Down Expand Up @@ -216,7 +218,8 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
experimentsManager,
switcher,
notebookProvider,
useCustomEditorApi
useCustomEditorApi,
expService
);
asyncRegistry.push(this);

Expand Down
Expand Up @@ -23,6 +23,7 @@ import {
IAsyncDisposableRegistry,
IConfigurationService,
IDisposableRegistry,
IExperimentService,
IExperimentsManager,
IMemento,
WORKSPACE_MEMENTO
Expand Down Expand Up @@ -101,7 +102,8 @@ export class NativeEditorOldWebView extends NativeEditor {
@inject(KernelSwitcher) switcher: KernelSwitcher,
@inject(INotebookProvider) notebookProvider: INotebookProvider,
@inject(UseCustomEditorApi) useCustomEditorApi: boolean,
@inject(INotebookStorageProvider) private readonly storage: INotebookStorageProvider
@inject(INotebookStorageProvider) private readonly storage: INotebookStorageProvider,
@inject(IExperimentService) expService: IExperimentService
) {
super(
listeners,
Expand Down Expand Up @@ -132,7 +134,8 @@ export class NativeEditorOldWebView extends NativeEditor {
asyncRegistry,
switcher,
notebookProvider,
useCustomEditorApi
useCustomEditorApi,
expService
);
asyncRegistry.push(this);
// No ui syncing in old notebooks.
Expand Down
Expand Up @@ -22,6 +22,7 @@ import {
GLOBAL_MEMENTO,
IConfigurationService,
IDisposableRegistry,
IExperimentService,
IExperimentsManager,
IMemento,
IPersistentStateFactory,
Expand Down Expand Up @@ -113,7 +114,8 @@ export class InteractiveWindow extends InteractiveBase implements IInteractiveWi
@inject(IExperimentsManager) experimentsManager: IExperimentsManager,
@inject(KernelSwitcher) switcher: KernelSwitcher,
@inject(INotebookProvider) notebookProvider: INotebookProvider,
@inject(UseCustomEditorApi) useCustomEditorApi: boolean
@inject(UseCustomEditorApi) useCustomEditorApi: boolean,
@inject(IExperimentService) expService: IExperimentService
) {
super(
listeners,
Expand Down Expand Up @@ -150,7 +152,8 @@ export class InteractiveWindow extends InteractiveBase implements IInteractiveWi
experimentsManager,
switcher,
notebookProvider,
useCustomEditorApi
useCustomEditorApi,
expService
);

// Send a telemetry event to indicate window is opening
Expand Down
3 changes: 2 additions & 1 deletion src/client/datascience/plotting/plotViewer.ts
Expand Up @@ -48,7 +48,8 @@ export class PlotViewer extends WebViewHost<IPlotViewerMapping> implements IPlot
localize.DataScience.plotViewerTitle(),
ViewColumn.One,
useCustomEditorApi,
false
false,
Promise.resolve(false)
);
// Load the web panel using our current directory as we don't expect to load any other files
super.loadWebPanel(process.cwd()).catch(traceError);
Expand Down
4 changes: 4 additions & 0 deletions src/client/datascience/types.ts
Expand Up @@ -764,6 +764,10 @@ export interface IDataScienceExtraSettings extends IDataScienceSettings {
variableOptions: {
enableDuringDebugger: boolean;
};

webviewExperiments: {
removeKernelToolbarInInteractiveWindow: boolean;
};
}

// Get variables from the currently running active Jupyter server
Expand Down
6 changes: 5 additions & 1 deletion src/client/datascience/webViewHost.ts
Expand Up @@ -51,7 +51,8 @@ export abstract class WebViewHost<IMapping> implements IDisposable {
@unmanaged() private title: string,
@unmanaged() private viewColumn: ViewColumn,
@unmanaged() protected readonly useCustomEditorApi: boolean,
@unmanaged() private readonly enableVariablesDuringDebugging: boolean
@unmanaged() private readonly enableVariablesDuringDebugging: boolean,
@unmanaged() private readonly hideKernelToolbarInInteractiveWindow: Promise<boolean>
) {
// Create our message listener for our web panel.
this.messageListener = messageListenerCtor(
Expand Down Expand Up @@ -214,6 +215,9 @@ export abstract class WebViewHost<IMapping> implements IDisposable {
},
variableOptions: {
enableDuringDebugger: this.enableVariablesDuringDebugging
},
webviewExperiments: {
removeKernelToolbarInInteractiveWindow: await this.hideKernelToolbarInInteractiveWindow
}
};
}
Expand Down
30 changes: 28 additions & 2 deletions src/datascience-ui/history-react/interactivePanel.tsx
Expand Up @@ -203,15 +203,41 @@ ${buildSettingsCss(this.props.settings)}`}</style>
/>
</ImageButton>
</div>
{this.renderKernelSelection()}
</div>
</div>
);
}

private renderKernelSelection() {
if (
this.props.settings &&
this.props.settings.webviewExperiments &&
this.props.settings.webviewExperiments.removeKernelToolbarInInteractiveWindow
) {
if (this.props.settings.showKernelSelectionOnInteractiveWindow) {
return (
<KernelSelection
baseTheme={this.props.baseTheme}
font={this.props.font}
kernel={this.props.kernel}
selectServer={this.props.selectServer}
selectKernel={this.props.selectKernel}
/>
</div>
</div>
);
} else if (this.props.kernel.localizedUri === getLocString('DataScience.localJupyterServer', 'local')) {
return;
}
}

return (
<KernelSelection
baseTheme={this.props.baseTheme}
font={this.props.font}
kernel={this.props.kernel}
selectServer={this.props.selectServer}
selectKernel={this.props.selectKernel}
/>
);
}

Expand Down
4 changes: 1 addition & 3 deletions src/datascience-ui/interactive-common/kernelSelection.tsx
Expand Up @@ -85,9 +85,7 @@ export class KernelSelection extends React.Component<IKernelSelectionProps> {
}

private selectKernel() {
if (this.isKernelSelectionAllowed) {
this.props.selectKernel();
}
this.props.selectKernel();
}
private getIcon(): ImageName {
return this.props.kernel.jupyterServerStatus === ServerStatus.NotStarted
Expand Down
3 changes: 3 additions & 0 deletions src/datascience-ui/react-common/settingsReactSide.ts
Expand Up @@ -68,6 +68,9 @@ export function getDefaultSettings() {
variableOptions: {
enableDuringDebugger: false
},
webviewExperiments: {
removeKernelToolbarInInteractiveWindow: false
},
runStartupCommands: '',
debugJustMyCode: true,
variableQueries: [],
Expand Down

0 comments on commit 88f3b43

Please sign in to comment.