11import {
2+ ILabShell ,
23 JupyterFrontEnd ,
34 JupyterFrontEndPlugin ,
45} from '@jupyterlab/application' ;
56import { INotebookTracker } from '@jupyterlab/notebook' ;
67import { LabIcon } from '@jupyterlab/ui-components' ;
78import { ICommandPalette } from '@jupyterlab/apputils' ;
9+ import { IConsoleTracker } from '@jupyterlab/console' ;
810import { KernelUsagePanel } from './panel' ;
911import tachometer from '../style/tachometer.svg' ;
1012
@@ -13,6 +15,7 @@ import { IStatusBar } from '@jupyterlab/statusbar';
1315import { ITranslator } from '@jupyterlab/translation' ;
1416
1517import { MemoryUsage } from './memoryUsage' ;
18+ import { KernelWidgetTracker } from './tracker' ;
1619
1720namespace CommandIDs {
1821 export const getKernelUsage = 'kernel-usage:get' ;
@@ -46,13 +49,15 @@ const memoryStatusPlugin: JupyterFrontEndPlugin<void> = {
4649const kernelUsagePlugin : JupyterFrontEndPlugin < void > = {
4750 id : '@jupyter-server/resource-usage:kernel-panel-item' ,
4851 autoStart : true ,
49- optional : [ ICommandPalette ] ,
52+ optional : [ ICommandPalette , ILabShell , IConsoleTracker ] ,
5053 requires : [ ITranslator , INotebookTracker ] ,
5154 activate : (
5255 app : JupyterFrontEnd ,
5356 translator : ITranslator ,
5457 notebookTracker : INotebookTracker ,
55- palette : ICommandPalette | null
58+ palette : ICommandPalette | null ,
59+ labShell : ILabShell | null ,
60+ consoleTracker : IConsoleTracker | null
5661 ) => {
5762 const trans = translator . load ( 'jupyter-resource-usage' ) ;
5863
@@ -62,10 +67,15 @@ const kernelUsagePlugin: JupyterFrontEndPlugin<void> = {
6267 let panel : KernelUsagePanel | null = null ;
6368
6469 function createPanel ( ) {
65- if ( ( ! panel || panel . isDisposed ) && notebookTracker ) {
70+ if ( ! panel || panel . isDisposed ) {
71+ const tracker = new KernelWidgetTracker ( {
72+ notebookTracker,
73+ labShell,
74+ consoleTracker,
75+ } ) ;
76+
6677 panel = new KernelUsagePanel ( {
67- widgetAdded : notebookTracker . widgetAdded ,
68- currentNotebookChanged : notebookTracker . currentChanged ,
78+ currentChanged : tracker . currentChanged ,
6979 trans : trans ,
7080 } ) ;
7181 shell . add ( panel , 'right' , { rank : 200 } ) ;
0 commit comments